Assuming all of your data follows the same format, you could always do
something like this:
$_ =~ /\^([^\^]+)$/; #a ^ followed by one or more non-^ chars
@items = split /\s/,$1;
Disclaimer: I might have the character class part wrong. I can't test this
yet.
or option 2:
($record, $customer, $location, $plan, $items) = split(/\^/,$_);
@items = split /\s/,$items;
-----Original Message-----
From: Sudarsan Raghavan
To: Ho, Tony
Cc: '[EMAIL PROTECTED]'
Sent: 4/23/02 2:30 AM
Subject: Re: Assigning values from files into an aray
>
>
> 405^100^200^A^B C D E
>
> while (<FILE_OPENED>) {
> $number_of_elements= 0;
> chop;
> ($record, $customer, $location, $plan, @items) = split(/\^/,
$_);
> $number_of_elements= $#items + 1;
> print "number_of_elements: $number_of_elements\n";
> }
>
> At the moment, the program prints out the value of
"number_of_elements" to
> be 1.
> However "number_of_elements" should print out 4 because there are 4
values
> (i.e. B, C, D, E)
Your @items is an one item array containing the value 'B C D E'
The string B C D E is space separated not by '^' resulting in split
passing them back as one
element and not as separate elements.
>
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]