Front page | perl.beginners |
Postings from April 2002
Re: simple assignment
Thread Previous
|
Thread Next
From:
John W. Krahn
Date:
April 2, 2002 13:01
Subject:
Re: simple assignment
Message ID:
3CAA1BA8.58DCB5A6@acm.org
Roy Peters wrote:
>
> I have a string of the following
>
> $str = "X1=1,Y1=2,Z1=3";
>
> I want to assign the values to the right hand side of the "=" to 3 new
> variables so the final result is
>
> $a=1
> $b=2
> $c=3
>
> How do I get those values assigned to $a, $b, $c
$ perl -le'
$str = "X1=1,Y1=2,Z1=3";
( $a, $b, $c ) = $str =~ /=(\d+)/g;
print "$a $b $c"
'
1 2 3
John
--
use Perl;
program
fulfillment
Thread Previous
|
Thread Next