[EMAIL PROTECTED] wrote:
> Hi all,
>
> i have a set if keywords  which i have to search for in the lines
> beginning with character 'A' in the "file".
> snippet follows -
>
> #!/usr/bin/perl -w
> $keywords = "hello|world|all|chipset";
> open FH,"file";
> while(<FH>)
> {
> print if(/^A/ && /(?:$keyword)/g);

    print if /^A.*(?:$keyword)/
> }
> close FH;
>
> is that correct or any other shortcuts and corrections ?
> thanks in advance ,

You should use

    print if /^A.*\b(?:$keyword)\b/

if you want to make sure you don't match the line

A shallow existence

as well. Or

    print if /^A(?:.*\b)?(?:$keyword)\b/

if the 'A' at the start of the line may be followed immediately by a
keyword, like this

Aworld of difference

Cheers,

Rob




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to