while ($line = ) { # or where ever you get your input from @temp = split()/,+/, $line); if ($temp[0] eq '--' && $temp[3] eq '--' && $temp[4] eq '--' && $temp[5] eq '--') { # then do whatever you want } } #### while ($line = ) { /([e\d+.]+),[the same],[the same],([the same]),([the same]),([the same])/; if ($1 eq '--' || $2 eq '--' || $3 eq '--' && $4 eq '--') { # do your ting } }