use strict; my $lsdata; while (<>) { $lsdata .= $_; } # Add the /s option to make this work my @table = $lsdata =~ m/()/g; print $#table;