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 } }