Nigel Peck schreef:
> I'm trying to get the following to work and can't. It's the
> assignment to $val1 and $val2 that's causing me the problem.
>
> my ( $val1, $val2 ) = $data =~ /^([^:]+):([^:]+)$/
> || die 'Failed to parse data';
>
> What am I doing wrong?
See perlop. Change the "||" to "or".
> I can do it on multiple lines by assigning $1
> and $2 to the variables after the regex but I want
> to do it all on one line.
I tend to put () around the =~ expression too:
my ( $val1, $val2 ) = ($data =~ /^([^:]+):([^:]+)$/)
or die 'Failed to parse data';
Is that second "[^:]+" really what you mean? Change to ".*" for more
matches.
--
Affijn, Ruud
"Gewoon is een tijger."
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>