in reply to Re: How to differentiate an empty array from an unitialized one?
in thread How to differentiate an empty array from an unitialized one?

I congratulate you for posting some actual Perl code!
I do have some quibbles with it. For example, you are experienced enough to know never to use $a or $b as a user variable name since these variable names have special meaning within Perl.
I don't want to be overly critical lest I discourage you from posting code.

Update: Three examples should suffice. Ha!

You did not consider blank fields at the beginning of the line.
I don't think that any beginning Perl'er needs to know this, but:

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $str =" abc xyz \n"; my @tokens = split(/\s+/,$str); print Dumper \@tokens; =PRINTS: $VAR1 = [ '', 'abc', 'xyz' ]; =cut @tokens = split (' ',$str); print Dumper \@tokens; # note: leading blank field is not there! # no need to remove spaces at beginning or end of # line with this special situation. =PRINTS: $VAR1 = [ 'abc', 'xyz' ]; =cut
  • Comment on Re^2: How to differentiate an empty array from an unitialized one?
  • Download Code