if ($fileName =~ /\.bz2$/) { $isBz2 = 1 ; } else { $isBz2 = 0 ; } ... while ($line =~ /node/) { ...