Front page | perl.beginners |
Postings from April 2002
Re: simple assignment
Thread Previous
|
Thread Next
From:
Craig Sharp
Date:
April 2, 2002 12:58
Subject:
Re: simple assignment
Message ID:
sca9d44d.016@roushind.com
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";
print "$b\n";
print "$c\n";
Have fun!
Craig
>>> Roy Peters <epeters@tellabs.com> 04/02/02 03:42PM >>>
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
============================================================
The information contained in this message may be privileged
and confidential and protected from disclosure. If the
reader of this message is not the intended recipient, or an
employee or agent responsible for delivering this message to
the intended recipient, you are hereby notified that any
reproduction, dissemination or distribution of this
communication is strictly prohibited. If you have received
this communication in error, please notify us immediately by
replying to the message and deleting it from your computer.
Thank you.
Tellabs
============================================================
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
Thread Previous
|
Thread Next