Eric said:
Hi,
Is there someone who knows how to execute a command line (such a simple echo
cmd) in PerlScript.
I hve tryed '' or system() but the result is the same: no result but no error
!
This syntax works fine in a perl program but not in PerlScript
An idea ?
Well, to answer your question successfully, I'll have to make some
assumptions. Some people, when they say "PerlScript," they really mean
"Perl script." But since there IS a product called "PerlScript," I'll
answer in that context. And even within THAT, there are two ways this
could be viewed: PerlScript under ASP and PerlScript under Windows
Scripting Host. I'll assume the later, but answer both.
PerlScript ASP cannot use 'print' or 'echo' to write to the end client
browser. You have to use $Response->Write(). Assuming you know that
already...
....the answer when running PerlScript in a WSH context is:
$WScript->Echo( "This is how to print in PerlScript\n" );
A tip: I personally like Ruby's use of a call named puts() which, named
in C-style convention, out Puts a string. I've adopted THAT as my
standard "outputing call" and I write wrappers in each environment I'm
in to handle it the right way (so I don't have to remember any more how
to write a string; it gets ridiculously out of hand esp. in the Windows
world where Microsoft can't get it together and each side of their house
invents a new standard for something so simple -- in ASP it's
Response.Write in WSH it's WScript.Echo, in Access it's print.debug or
whatever...)
So... I recommend this approach and then you never have to remember any
more:
ASP: sub puts { for (@_) { $Response->Write( "$_\n" ) } }
WSH: sub puts { for (@_) { $WScript->Echo( "$_\n" ) } }
Chris