Hi all, I want to grap the: last first middle(if any) email from a text file
sometimes there is a middle intital, sometimes there isn't sample data: Smith, Mary [EMAIL PROTECTED] Jones, Tommy Lee [EMAIL PROTECTED] can someone suggest improvements to the code below? #!/usr/bin/perl -w my ($first, $last, $middle, @fields); open(IN, "text.txt") or die("nope: $!\n"); while($line = <IN>){ chomp($line); @fields=split(/ /, $line); #an array in scalar context returns number of elements $number = @fields; print("number: $number\n"); #if there is no remainder, there are 3 elements if($number % 3 == 0){ $first = $fields[0]; $last = $fields[1]; $email= $fields[2]; } #if there is no remainder, there are 4 elements elsif($number % 4 == 0){ $first = $fields[0]; $last = $fields[1]; $middle= $fields[2]; $email= $fields[3]; } print("first: $first\n"); print("last: $last\n"); print("middle: $middle\n"); print("email: $email\n"); } close(IN); thanks in advance, Pam -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]