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

Using strict and getting return values

Thread Next
From:
Dermot Paikkos
Date:
March 4, 2002 09:07
Subject:
Using strict and getting return values
Message ID:
3C83A997.9349.15A9578@localhost
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>)) {
    chomp($i);
    my @a = split(/|/,$i);
    my $last = $a[1];
    my $first = $a[0];
    if ( $name =~ /$last/i ) {
          return($first,$last);
    }
 and get the error:
Global symbol "$last" requires explicit package name at 
/var/www/perl/reply.pl 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??
Dp.
 

 
~~
Dermot Paikkos * dermot@sciencephoto.com
Network Administrator @ Science Photo Library
Phone: 0207 432 1100 * Fax: 0207 286 8668


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About