in reply to <STDIN> always in string mode?

Further tests have shown that you can "anonymise"(sp?) the scalar with an eval:
perl -e '$foo=<STDIN>;$foo=eval($foo);print(($foo*2)."\n")'


-- Ian Stuart
A man depriving some poor village, somewhere, of a first-class idiot.

Replies are listed 'Best First'.
Re^2: <STDIN> always in string mode?
by salva (Canon) on Mar 27, 2006 at 12:08 UTC
    be aware that evaling something read from an external file or STDIN is highly insecure. In an untrusted environment, you should check the input (and use taint checking):
    $foo = <STDIN>; if ($foo =~ /^(\d*)$/) { $foo = eval $1; print "foo: $foo\n" } else { die "bad input" }