CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
Quick one

 



kencl
User

Mar 20, 2001, 3:37 PM

Post #1 of 2 (1495 views)
Quick one Can't Post

I don't use regular expressions much, so I just need someone to verify that this will work. It's supposed to create an array called @Matches which contain all the keys from a hash (%hash) where the lowercase letter "p" is the second last character of the hash key.

Here's an example:

Code
$hash{'44x5'} = "no match"; 
$hash{'3p3'} = "should match";
$hash{'789p'} = "no match";
$hash{'4P1'} = "no match";
$hash{'p1'} = "should match";
@Matches = grep { /p.$/ } keys(%hash);

Thanks.

>> If you can't control it, improve it, correlate it or disseminate it with PERL, it doesn't exist!


Jasmine
Administrator

Mar 21, 2001, 5:45 AM

Post #2 of 2 (1491 views)
Re: Quick one [In reply to] Can't Post

That'll do it Smile


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives