pimplepoppereater has asked for the wisdom of the Perl Monks concerning the following question:

How can I search a site for any occurence before and after a variable? I'm trying to find every line that contains ~:~ where ~ would be any text or characters before a colon and then anything it finds after it.

Replies are listed 'Best First'.
Re: (nrd) Finding occurences
by newrisedesigns (Curate) on Feb 28, 2003 at 19:11 UTC
    @lines = grep(/(.+)\:(.+)/, @lines); # for the whole line from an arra +y #for the parts out of lines from a file. while(<$fh>){ if(/(.+)\:(.+)/){ $before = $1; $after = $2; } }

    How are you applying this? There may be a module to help you.

    Also, this is sort of an RTFM... see grep, perlre, and perlretut.

    Update: I just noticed that you want to search a site. What site? You'll have to use LWP to get the pages you want to search, then use HTML::TokeParser to pull out relevant text and process it.

    John J Reiser
    newrisedesigns.com