[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl-AnyPerl] good idea or bad idea?



I have a couple of questions about the following code snippet:

my $story_time;
foreach my $line (split(/\015/,$sci_page_head)) {
	if ($line =~ /OriginalPublicationDate/) {
		($story_time) = ($line =~ /content=\"(.*)\"/);
	}
}
print $story_time;

First, is declaring the my $line in the foreach line a good idea/bad 
idea/doesn't matter?  I know if I declare the $story_time as my 
inside the loop it doesn't seem to exist outside the loop.  The code 
as written works fine (I don't need the $line variable outside the 
loop).

Second, is this a good way of doing this loop?  $sci_page_head is 
just the header info from a web page sucked in via LWP::Simple.  If 
it where a text file I'd probably just do a while <> {}.  I guess I'm 
asking if there is a way to get rid of the $line variable altogether.

Thanks - Kevin

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-anyperl-request@macperl.org