On Fri, 2006-05-05 at 11:29 +0100, Steve Swift wrote: > I've written a tiny program to make it easy to test the syntax and > effects of a Perl statement. My program is called "perltry" and here it > is in its full gory (pun intended) > > #!/usr/bin/perl > use strict; > use warnings; > system('clear'); > system('perl -v'); > print "Go on - try a few... Enter 'exit' to end.\n"; > while (<>) { > eval $_; > if ($@) {print "[EMAIL PROTECTED]";} > print ' ','.'x50," perltry on $^O\n" > }; > > If I enter a statement, such as "$a=1;" (without the quotes) then I > would expect that scalar $a would get the value 1. If I then enter the > statement "print $a" I expected to see "1". What I saw was: > Use of uninitialized value in string at (eval 2) line 1, <> line 2. > > Could someone tell me why this happened, please? > Is it possible to change this so that the variable $a would get set?
It works on my machine. You could try my favourite Perl one-liner, the Perl calculator: perl -ple '$_=eval' or on DOS: perl -ple "$_=eval" See `perldoc perlrun` and `perldoc -f eval` for details. -- __END__ Just my 0.00000002 million dollars worth, --- Shawn "For the things we have to learn before we can do them, we learn by doing them." Aristotle * Perl tutorials at http://perlmonks.org/?node=Tutorials * A searchable perldoc is at http://perldoc.perl.org/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>