develooper Front page | perl.beginners | Postings from March 2002

Using strict and getting return values

Thread Next
Dermot Paikkos
March 4, 2002 09:07
Using strict and getting return values
Message ID:
Hi Gurus,

I am trying to get tidy with my scripts and want to use Strict but am 
having difficulty with return values from subroutines. I have the 
following snippet:

  while (defined(my $i =<$fh>)) {
    my @a = split(/|/,$i);
    my $last = $a[1];
    my $first = $a[0];
    if ( $name =~ /$last/i ) {
 and get the error:
Global symbol "$last" requires explicit package name at 
/var/www/perl/ line 16.

When I later:  print "Hello $first $last\n";

I know it is out of the scope but I thought I could pass the results of 
a sub to main.

What am I doing wrong??

Dermot Paikkos *
Network Administrator @ Science Photo Library
Phone: 0207 432 1100 * Fax: 0207 286 8668

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About