On Jun 30, Sanjeeb Basak said:
>I want to perform a simple split operation, but can't get the regular expr
>working. Can anybody help me on this?
>
>my $line from a file read is:
>xyz abc 12sd "pqr stz" dfg (delimited by blank char).
>
>I'm doing
>my ($par1, $par2, $par3, $par4, $par5) = split(/ /, $line);
Using split() isn't good enough here. You'll need to use a more involving
regex:
my @pieces;
push @pieces, $1 while
$line =~ /\G\s*"([^"]*)"/gc or
$line =~ /\G\s*(\S+)/gc;
That code matches either quoted strings, or groups of non-whitespace, and
puts them, one-at-a-time, into @pieces.
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk? http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
** Manning Publications, Co, is publishing my Perl Regex book **