[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] duh: A small puzzler



Jim Monty wrote:
> 
> By the way, the plus quantifier in this expression is superfluous:
> 
>     ($id) = split(/\s+/, $record);

Only if, as in this case, there are no runs of whitespace longer
than one.
But in general, you need /\s+/ if you want the same behavior as ' '.


$_ = "foo   bar";
@a = split ' ';
@b = split /\s/;
@c = split /\s+/;
$,=',';
$\="\n";
print @a;
print @b;
print @c;
foo,bar
foo,,,bar
foo,bar

John Porter


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe