"R. Joseph Newton" wrote:
> 
> "John W. Krahn" wrote:
> >
> > Try it like this:
> >
> > perl -le 'print eval "@ARGV"'
> 
> Good on 'nix/'nux, I guess.  On Windows, It takes a little different quoting:

You mean like:

perl -le "print eval [EMAIL PROTECTED]"


> Greetings! E:\d_drive\perlStuff>perl -le "print eval $ARGV[0]" "2 + 3"
> 5

No, I guess you didn't.


> What happens is simply that the eval @ARGV statement calls the count of elements,

Are you implying that an array in a double quoted string is in scalar
context?  (To the beginners out there, an array in a double quoted
string expands to all the elements of the array separated by the
contents of the $" variable.)


> probably not what the OP had in mind.  Hmmm, lets see how join handles the original
> formulation--still needs double-quotes on Win, though
> 
> Greetings! E:\d_drive\perlStuff>perl -le "print eval join / /, @ARGV" 2 + 3
> 5

$ perl -wle 'print eval join / /, @ARGV' 5 + 5
/ / should probably be written as " " at -e line 1.
Use of uninitialized value in pattern match (m//) at -e line 1.
10

Your perl statement is equivalent to:

print eval join $_ =~ / /, @ARGV

And it only works because "$_ =~ / /" evaluates to '' and '2+3' gives
the same answer as '2 + 3'.


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to