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 fine for me:

$ perl -lne'eval; print $@ if $@'
$a = 1;
print $a;
1



John
-- 
use Perl;
program
fulfillment

-- 
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