--- Dermot Paikkos <[EMAIL PROTECTED]> wrote: > Hi Gurus, > > I am trying to get tidy with my scripts and want to > use Strict
Use lowercase for strict! Anything else will cause havoc. > but am having difficulty with return values from > subroutines. I have the following snippet: > > while (defined(my $i =<$fh>)) { Don't bother with $i... lot neater if you use the implict $_ - hence your code: > chomp($i); > my @a = split(/|/,$i); > my $last = $a[1]; > my $first = $a[0]; > if ( $name =~ /$last/i ) { > return($first,$last); > } becomes: while (<$fh>) { chomp($_); my ($first, $last) = split /|/; return ($first, $last) if $name eq lc $last; } with the following benefits: 1. Shorter/cleaner. 2. Doesn't bother with an needless array 3. lc() and eq is better than using =~ and /i since $last might contain a dodgy regex that hacks your computer. 4. It looks more Perlish :) anyway, I haven't tested it so complain if something doesn't work - it'll be some minor syntax to fix. You can probably shorten chomp($_) - but strange things can happen that I'd rather test first. > 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"; my ($first, $last) = function(); Take care, Jonathan Paton __________________________________________________ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]