in reply to Help getting desired output

First off, choose better variables names. $goober may strike you as really funny right now, but in the long run you are going to come back to the code and either a) cringe or b) wonder what purpose it serves.

Even more insidious is the variable $flag. Okay, so it's a boolean. So what? What are you tracking with it... the fact that you have matched an URL? In that case, give it a better name, such as $seen_url. Get the name right, and you can get rid of the comment.

You are testing to see whether open works correctly or not, although you should add $! into the error string somewhere, so you have an idea of why it went wrong when it does go wrong.

A terribly common mistake made by beginners is to open a file, slurp the whole damned mess into an array, and then process the array. This consumes prolifligate amounts of memory, and when you hit gigabyte files you can bring you system to its knees. The canonical way to proceed is as follows:

open IN, $file or die "Cannot open $file for input: $!\n"; while( <IN> ) { # do your if-flag-two-step } close IN;

Finally, back to the beginning again, this is best written as

my $file = shift || 'rlf.txt';

That is, if you don't specify the name of a file, it will use rlf.txt by default, otherwise it will use whatever you specify on the command line. Much more flexible.

Hope this helps.

--
g r i n d e r