Re: in the elemetns of programming perl , I need help with 2 lines that I don't understand
[email protected] (Richard Lee)
| Newsgroups | perl.beginners |
|---|---|
| Message-ID | <[email protected]> |
Dr.Ruud wrote:
> Richard Lee schreef:
>
>
>> $pattern = '.*(?:' . join('|', @ARGV) . ')';
>>
>
> Safer:
>
> $pattern = '.*(?:' . join('|', map quotemeta, @ARGV) . ')';
>
> And I would do a qr() on top of that.
>
>
} else {
$pattern = join('', map{"(?=.*$_)"} @ARGV);
}
print "\$pattern is $pattern\n";
[root@RLEE ~]# ./faqgrep -or list
$pattern is .*(?:list)
---------------------- breaking it down on my own------------------------
@_ = shift @ARGV ==> should be 'list'
map{"(?=.*$_)"} ==> positive look ahead on anything followed by
pattern 'list'
join() ==> shoudln't it be just 'list' ??
but when I print it, I get .*(?:list).... why???