The Range Operators
#!/usr/bin/perl -w
############### The Range Operators and the $. Special Variable ##############
open(F, "$ARGV[0]") or die "Cannot open $ARGV[0]!\n";
while (<F>)
{
print if /#/../#/; ##### Won't be what you want in all likelihood!
}
open(F, "$ARGV[0]") or die "Cannot open $ARGV[0]!\n";
print "*" x 50, "\n"; #### Divider line between output of 1st and 2nd loops!
while (<F>)
{
print if /#/.../#/; ##### This ** is ** what you want in all likelihood!
}
############################ Program Output #################################
$ dot.pl x ##### Program invocation.
Contents of input file (x)
--------------------------
this is junk.
this is more junk.
# abc #
123
456
# xyz #
hi there
# testing, testing!
inside
outside
USA
#end of test
more garbage.
Screen Output
-------------
# abc #
# xyz #
# testing, testing!
#end of test
**************************************************
# abc
123
456
# xyz
# testing, testing!
inside
outside
USA
#end of test
######## The moral of this story? If you're using /regexp/ then use ...
######## and not ..