in reply to Re: Re: Re: Help with null string behavior in regex?
in thread Help with null string behavior in regex?

It's definitely clear! But "grep length" and "map qr" haven't made it into my syntactical bag yet.

I get new stuff to read about every time I post code here.

BTW, I didn't know "chomp @array" was possible. I posted a question recently trying to "lc @array", which *isn't* possible, so I just figured the same rule applied.
  • Comment on Re: Re: Re: Re: Help with null string behavior in regex?

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Help with null string behavior in regex?
by diotalevi (Canon) on May 04, 2004 at 00:06 UTC

    Oh ok. This is easy enough.

    @foo = grep length(), @foo; # is equivalent to but faster and clearer than my @tmp; for my $element_of_foo ( @foo ) { if ( length( $element_of_foo ) > 0 ) { push @tmp, $element_of_foo; } } @foo = @tmp;

    The line @foo = map qr/$_/, @foo; could be omitted from your program with no effect except of being slower. You'll see notes on qr// in perlop. The entire point is to pre-compile each regular expression so that when you do tests against it later perl won't have to do everything on the fly (and everytime you test a new file).