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"
3 PM
> To: [EMAIL PROTECTED]
> Subject: simple assignment
>
>
> 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 &qu
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=
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=2
$c=3
How do I get those values assigned to $a, $b, $c
Thanks
=