On 9/20/07, Dr.Ruud <[EMAIL PROTECTED]> wrote:
> Andrew Curry schreef:
>
> > (split/\s+/,$cmd)
>
> Very often, (split ' ', $cmd) is the better alternative.
snip

For the uninitiated: split ' ', $string does what split /\s+/, $string
does, but also removes leading whitespace.

The following code prints
||foo||bar||baz
foo||bar||baz

#!/usr/bin/perl

use strict;
use warnings;

print join('||', split /\s+/, "  foo bar baz"), "\n",
        join('||', split ' ', "  foo bar baz"), "\n";

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to