in reply to Re: grep exact words
in thread grep exact words

I tried the code you posted..it doesnt seem to be working . What is this 1 in the code here:- my %seen = map { $_ => 1 } @serv;

Replies are listed 'Best First'.
Re^3: grep exact words
by Roy Johnson (Monsignor) on Jun 26, 2004 at 17:24 UTC
    %seen is a hash. map is constructing a list of key-value pairs to assign to it. Each element of @serv is a key, and 1 is the value for each. It's the same as saying
    my %seen; @seen{@serv} = (1) x @serv;
    Saying "doesn't seem to be working" is not useful. Providing your input, output, and what you expected to be different could help.

    Please do note the advice to chomp the lines you're reading from a file. "foo\n" will not be equal to "foo".


    We're not really tightening our belts, it just feels that way because we're getting fatter.