"John W. Krahn" wrote:
> Stephen Gilbert wrote:
> >
> > I know I saw something like this in the past I just can't find it. Anyone got any
> > ideas?
> >
> > perl -e 'print eval { @ARGV }, "\n"' 5 + 5
> >
> > it should be able to take any perl arithmetic operator. so:
> >
> > perl -e 'print eval { @ARGV }, "\n"' 840928302840982 / 74098374
> >
> > or
> >
> > perl -e 'print eval { @ARGV }, "\n"' 79872593 * 67
> >
> > This code does not work, but I'm sure there is something simple, I know I've seen
> > it.
>
> Try it like this:
>
> perl -le 'print eval "@ARGV"'
>
> John
Good on 'nix/'nux, I guess. On Windows, It takes a little different quoting:
Greetings! E:\d_drive\perlStuff>perl -le "print eval $ARGV[0]" "2 + 3"
5
Greetings! E:\d_drive\perlStuff>
What happens is simply that the eval @ARGV statement calls the count of elements,
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
Greetings! E:\d_drive\perlStuff>
Yep, it works. Essentially gets the same place as the quoted expression.
Joseph
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]