undef $/; while(<>){ while(/console(.*?)}/gs){ $_ =~ s/\s//g; printf ("String = $_\n"); } }