Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Re: Removing delimiters

by DaveH (Monk)
on Feb 04, 2003 at 08:28 UTC ( #232492=note: print w/replies, xml ) Need Help??


in reply to Re: Removing delimiters
in thread Removing delimiters

Hi.

Why do two splits, when one would do?

my ($first, $second) = split /::/, $readline, 3;
or more simply
my (@fields) = split /::/, $readline;

Cheers,

-- Dave :-)


$q=[split+qr,,,q,~swmi,.$,],+s.$.Em~w^,,.,s,.,$&&$$q[pos],eg,print

Replies are listed 'Best First'.
Re^3: Removing delimiters
by JaWi (Hermit) on Feb 04, 2003 at 08:35 UTC
    Agreed, but the original post asked for either the first or the second; so I assumed that was all he wanted... In fact, if you don't want to use the list assignment you could do it also like this:
    my $first = ( split /::/, $readline, 2 )[ 0 ];
    Many, many ways of doing the same... And how I love it ;-)

    -- JaWi

    "A chicken is an egg's way of producing more eggs."

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://232492]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (7)
As of 2022-09-27 10:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (119 votes). Check out past polls.

    Notices?