chop up code

if $test = "this is a test file"
(words seperated by spaces)
how do i make
$var1="this"
$var2="is"
$var3="a"
$var4="test"
$var5="file"
i tried
($var1,$rest)=split(" ",$test);
($var2,$rest1)=split(" ",$rest1);
etc....but it just works for the first two values....
boofullsAsked:
Who is Participating?
 
mjswartConnect With a Mentor Commented:
Try using
($var1, $var2, $var3, $var4, $var5) = split(" ",$test);

or better
@var = split(" ",$test)

after the second suggestion you would have to refer to your variables like: $var[0] $var[1] $var[2] etc...

0
All Courses

From novice to tech pro — start learning today.