Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: How to grep for a filename for each of the keys of a hash

by k_manimuthu (Monk)
on Dec 13, 2010 at 05:43 UTC ( [id://876794]=note: print w/replies, xml ) Need Help??


in reply to Re: How to grep for a filename for each of the keys of a hash
in thread How to grep for a filename for each of the keys of a hash

As per above comments you use the quotemeta function.
And
Insist of the below code

grep (/$filename/i, $key) foreach my $key (keys %path_versions)

You will try the below code. Here, you no need to use the foreach loop. You directly pass 'hash keys'.

@array = grep (/$filename/, keys %path_versions);

Replies are listed 'Best First'.
Re^3: How to grep for a filename for each of the keys of a hash
by perl_mystery (Beadle) on Dec 13, 2010 at 06:11 UTC
    push @array = grep (/\Q$file_name\E/i, keys %pathname_versions);

    I am getting the below error when the above piece of code is executed,what does it mean?

    Type of arg 1 to push must be array (not list assignment)

      my @array = grep (/\Q$file_name\E/i, keys %pathname_versions);

      That's the right thing.

      s/ =/,/ in that code.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://876794]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-25 22:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found