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: HELP!!Regex to match boundary from a range and substitute characters: Edit Log



akshay34
New User

Sep 17, 2012, 10:05 AM


Views: 4310
HELP!!Regex to match boundary from a range and substitute characters

Hi guys I am a beginner and I need help with this problem.

I am trying to this question.

Search for all names which second character of their first name is in the range of a-i. And it will substitute all beginning Lís with Zís.

The file is entered into an empty array from the command line. My problem is that I cant seem to devise a way to get the proper regex into the if statement.

Here is the code i have so far.

Here is the file containing text that is read into the empty array.

Joshua Smith
John Jenkins
Larry Roberts
Bob Jones
Linda Green
Tim Anderson
Adam Jackson


Code
#!/usr/bin/perl 

@phone = (<>);

foreach $item (@phone)
{
if ($item =~ /([a-i])\b/)
{
print $item;
}
}


Thanks for any help in advance =)


(This post was edited by akshay34 on Sep 17, 2012, 10:06 AM)


Edit Log:
Post edited by akshay34 (New User) on Sep 17, 2012, 10:06 AM
Post edited by akshay34 (New User) on Sep 17, 2012, 10:06 AM


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

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