David Samuelsson wrote:
> 
> I have gotten 2 values, they "belong" to eachother but i want
> to use them later. So i pushed em into an array for use later
> like this:
> 
>     $text = "$first $second\n";
>     push (@array,$text);
> 
> the array works and if i do an foreach loop inside the array
> later i get the 2 values.
> 
> saying "$first $second"
> 
> ok, now i want to split this value so i get the first value
> separeted from the second again, and into separet variables.
> All this due to i had to sort stuff first.
> 
> foreach $line (@array)
> {
>     print "$line\n"; # prints "$first $second";
>     $line =~ split(/\w/,$line);
>     print "seperated got $1 and $2\n";
> }
> 
> this was what i thought was going to work..apperently it doesnt.
> Cause the values are just blank, how do i get the 2 values as
> seperate variables again? i want em back as $first and $second
> again..should be easy enough? i just cant get it :)


You could use an array of arrays:

push @array, [ $first, $second ];

for my $line ( @array ) {
    print "@$line\n"; # prints "$first $second";
    my ( $first, $second ) = @$line;
    print "seperated got $first and $second\n";
    }



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to