in reply to Embed empty value using qw()

Well it doesn't use qw and one would need a comment but.

my $stuff='one, two, , three, four'; #empty element between two and th +ree my @arr=split(/, /, $stuff); #split on space comma

Since its in single quotes it will quote sort of like qw. Optionally one could split on \s (no plus) which would mean any series of 2 spaces would be an empty value from split. And you could combine the two statements.

my @arr=split(/\s/, 'one two three four'); #same effect as above

Of course the empty word is really subtle in the second example.

Update: Fixed the first RE typo as suggested.

Replies are listed 'Best First'.
Re: Re: Embed empty value using qw()
by BrentDax (Hermit) on Sep 04, 2001 at 00:07 UTC
    Er, shouldn't the regular expression for the split in the first example be /, /?

    =cut
    --Brent Dax
    There is no sig.