#!/usr/bin/perl use warnings; my $s='the quick red fox'; print $s, "\n"; my $s='Foo'; print $s, "\n"; { my $s="Bar"; print $s, "\n"; my $s; print $s, "\n"; } print $s, "\n"; #### $ perl t.pl "my" variable $s masks earlier declaration in same scope at t.pl line 5. "my" variable $s masks earlier declaration in same scope at t.pl line 10. the quick red fox Foo Bar Use of uninitialized value $s in print at t.pl line 11. Foo #### #!/tools/packarch/public/perl/5.8.8/bin/perl use strict; use warnings; open(my $file, "<", "input.txt") or die "Can't open input.txt: $!"; my $string = "icecream"; my $notfound = ""; while (<$file>) { if (/$string/) { print "found string $string\n"; } else { $notfound = "not found"; } } if ($notfound eq "not found") { print "string not found\n"; }