in reply to Re: another way to split with limit
in thread another way to split with limit

# give stdin a:b or hello:world or etc:etc while (<STDIN>){ ($a,$b) = split(/:/,$_,2); print "$a$b\n"; }
I want to get those two values, how else can I do that with or without using split :) can I do
(split(/:/)[0..1]? (split(/:/)[0,1]?

Replies are listed 'Best First'.
Re: Re: Re: another way to split with limit
by guillaume (Pilgrim) on Aug 20, 2001 at 00:34 UTC
    Ok so I guess your print statement here isn't related to your question and that you only want to match both side of `:'
    You could do so like that:
    ($a, $b) = /(\w+):(\w+)/;
    The regex at the right remembers the matches due to the parenthesis, and $a get the first value and $b the second.
    Guillaume