Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: find text in string

by chanakya (Friar)
on Sep 13, 2005 at 05:19 UTC ( [id://491475]=note: print w/replies, xml ) Need Help??


in reply to find text in string

I suggest using grep to search strings in array, or to find number of elements matching a criteria. The points are demonstrated in the code below:
use strict; use warnings; use Data::Dumper; my @GrepList = ("yesterday", "today", "tomorrow") ; # look for all elements with "to" in the string my @ElementList = grep(/to/i, @GrepList) ; print Dumper(@ElementList); ## In list context, returns the count of number of elements ## that meet the search criteria my $ElementsFound = grep(/to/i, @GrepList) ; print $ElementsFound;
Hope this helps
May the force be with you

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2024-04-20 03:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found