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
Roy,
I am a beginner and this code is kludgy but it works. I am sure there are other more
simple ways to do this.
#!/usr/bin/perl -w
$str="X1=1,Y1=2,Z1=3";
($X1A,$Y1A,$Z1A) = split (/,/, $str);
$a = (split (/=/,$X1A))[1];
$b = (split (/=/,$Y1A))[1];
$c = (split (/=/,$Z1A))[1];
print "$a\n"
try this:
my($a, $b, $c) = $str =~ /\=(\d+)\,?/g;
Nikola Janceski
Science without religion is lame, religion without science is blind.
-- Albert Einstein (1879-1955)
> -Original Message-
> From: Roy Peters [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, April 02, 2002 3:43 PM
> To: [EMAI
On Tue, 2002-04-02 at 15:42, Roy Peters wrote:
> gurus,
>
> OK, shoot me for asking a dumb question.
>
> 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=