In the book "elements of programming perl", below program is presented.
I don't really understand these 2 lines. can someone break it down for me please?
$pattern = '.*(?:' . join('|', @ARGV) . ')'; $pattern = join('', map{"(?=.*$_)"} @ARGV); #!/usr/bin/perl use strict; use warnings; my $faqdir = '/usr/lib/perl5/5.10.0/pod/'; my($opt_f,$opt_or,$pattern); die "no keywords specified\n" unless @ARGV; while ( $ARGV[0] =~ /^-/ ) { $_ = $ARGV[0]; if ( /^-or$/ ) { $opt_or = 1; shift @ARGV; next } if ( /^-f$/ ) { $opt_f = 1; shift @ARGV; next } die<<HERE; illegal option: $_ usage: faqgrep [-f] [-or] [keywords...] HERE } if ( $opt_or) { $pattern = '.*(?:' . join('|', @ARGV) . ')'; } else { $pattern = join('', map{"(?=.*$_)"} @ARGV); } opendir(FAQDIR,$faqdir) or die "can't open $faqdir $!"; my @faqs = grep /faq/, readdir FAQDIR; closedir FAQDIR; foreach my $faq ( @faqs ) { open ( FAQ, "$faqdir/$faq" ) or die "can't $!"; while ( <FAQ> ) { if (s/^=head2($pattern)/$1/io) { print "$faq:$_"; if ( $opt_f ) { while ( <FAQ> ) { last if m/^=head(?!$pattern)/io; print; } } } } } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/