Anidil Rajendran-Raj wrote:
> 
> Firstname Lastname 650 156 7190:somfield:somefield:somefield
> Firstname Lastname 408 256 7290:somfield:somefield:somefield
> Firstname Lastname 510 3456 7390:somfield:somefield:somefield
> 
> I have the above lines in a file and I am trying to create an array of =
> phone numbers
> 
> open (FILE,"thefile") or die;

You should include the file name and the $! variable in the error
message.

> @array =3D <FILE>;
         ^^^
This is not a valid operator

> my @phone;
> for each $string (@array) {
      ^^^^
each() works with hashes, not scalars, you want to use my() here

>   $phone[$i] =3D ($string =3D~ /\s\d+\s\d+\s\d+:/) ;
               ^^^          ^^^
Again, this is not a valid operator.

>   $i++;
> }
> 
> This  does not work, what am I doing wrong? or it there a better way?


open FILE, 'thefile' or die "Cannot open 'thefile': $!";
my @phone;
while ( <FILE> ) {
    push @phone, /\s(\d+\s\d+\s\d+):/;
    }



John
-- 
use Perl;
program
fulfillment

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

Reply via email to