in reply to Breaking out of a loop
#!/usr/bin/perl use warnings; use strict; my $git_dir = "/tmp/yum_sorted.log"; open(DIR,$git_dir) or die "Really bad!$!"; my @yum = <DIR>; my $hit; # <--- Inserted lines foreach my $line ( @yum ) { open(IN_GIT, "/tmp/git_sorted.log") or die "Really, re +ally bad $!"; my @in_git = <IN_GIT>; foreach my $x ( @in_git ) { if ( $line =~ $x ) { print "We found a match: $line\n"; $hit = $line; # <--- Inserted lines last; # <--- Inserted lines } } if (defined $hit) { # <--- And final inserted conditional # Do something } else { # Do something else }
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
|
|---|