Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Search And Replace

by emilford (Friar)
on Jul 01, 2002 at 03:04 UTC ( [id://178457]=note: print w/replies, xml ) Need Help??


in reply to Search And Replace

This should work:

#!/usr/bin/perl -w use strict; my @users = ("Andrew", "Andrews", "Eric", "Andy", "Test"); my $param = "AnDr"; # what to search for foreach (@users) { print "$_\n" if /$param/i; } __OUTPUT__ Andrew Andrews
Update: Check the references that were mentioned in the above post. You need to read up on the m// operator. Also check this post for a list of some of the modifiers.

Update2: Your thread title was "Search and Replace. After you match the username to the search pattern, if you are wanting to replace it, you should also look into the s/// operator.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-04-19 17:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found