On 5/5/06, Steve Swift <[EMAIL PROTECTED]> 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?

This is my very first post to a Perl newsgroup, so treat me gently, please!

--
Steve Swift (aka "Swifty")

Odd, it works fine when I run it.  Could you post a test case that
always produces the warning message?  Also it would be helpful to have
some information on the version of Perl you are using and the OS the
script is running under.

By the way, $a and $b are special varaibles used by the sort function
and therefore do not need to be declared with "my", but it is bad form
to use them for anything but the sort function.  For short examples it
is best to use $x, $y, and $z or $i, $j, and $k.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to