while ( my $line = ) { chomp $line; # backup of line, in case we need original version later my $line_copy = $line; # transliterate ',' into ';' remove '(', ')' and space(0x20) $line =~ tr/,() /;/d; # split at ';' my ( $first, $second, @rest ) = split /;/, $line; # do your work }