<snip>

> I don't like who look for a complete and correct script here, but I 
> cannot solve my problem: this is my input-type:
> 
> Dante  Alighieri 
> Cecco  Angiolieri 
> Brunetto       Latini 
> Eugenio        Montale 
> Giacomo        Leopardi 
> Niccolò        Tommaseo 
> Guido  Gozzano 
> (and so on...)
> 
> all I want in my output are two arrays: the first column of the input 
> (all the first names) in the first array and the second column (all the 
> surnames) in the second array.

Assuming an array of lines with the names in it:

@names

Then:

my (@firstnames,@secondnames,@badnames);
foreach my $name (@names) {
  if ($name =~ /(.*)\s+(.*)/) {
     push @firstnames, $1;
     push @secondnames, $2;
  }
  else {
     # Invalid formatted name
     push @badnames;
  }
}

Depending on what you are doing with the two arrays it might be easier/better to use 
an array of hashrefs, where you can store the names by key, something like:

foreach my $name (@names) {
  if ($name =~ /(.*)\s+(.*)/) {
     push @fullnames = { 'firstname'=>$1,'lastname'=>$2 };
  }
}

etc...

http://danconia.org

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

Reply via email to