How to determine of text matches?

From: nospam (no_at_spam.com)
Date: 08/22/04

  • Next message: Alan Connor: "[OT] Perl to C Converter?"
    Date: Sat, 21 Aug 2004 19:17:04 -0400
    
    

    In the code fragment below, I'm doing a substitution
    of the key/value pairs in a hash using s/$key/$value/g;.
    How can I determine if a match is found? I want to do
    something like:

    If (match found) {
      print "FOUND MATCH";
    }

    -Thanks

    #############################

      return unless -T;

      print "Processing==> $File::Find::name\n";

      my $obj = tie(my @array, 'Tie::File', $_) || die "$!\n";

      for (@array) {

        while ((my $key, my $value) = each %strings) {

          s/$key/$value/g;

        }

      }

       untie @array;


  • Next message: Alan Connor: "[OT] Perl to C Converter?"

    Relevant Pages

    • Hashes and scope
      ... I am trying to assign key/value pairs to a hash from a text input file. ... are evenly divided among new files glaa, glab, glac and glad.d. ...
      (perl.beginners)
    • Re: Breaking reference chians
      ... > I'm currently writing a script to read windows style config files. ... > know the sort of file ... The first line builds a hash whose keys are the section names and ... The second line transforms each set of key/value pairs into the equivalent ...
      (comp.lang.perl.misc)
    • Re: Creating a search
      ... only key/value pairs which have a value that's not empty should ... Conditions is actually a Hash, or expecting a Hash, and indeed, this syntax ... a bit more concise. ... This does what your loop was trying to do, ...
      (comp.lang.ruby)
    • Re: How to determine of text matches?
      ... > In the code fragment below, I'm doing a substitution ... This newsgroup does not exist (see FAQ). ...
      (comp.lang.perl)
    • Re: How to Iterate over nested Hashes ?
      ... What i was looking is, if the "value" is a hash, then i want to assign ... variable i should see the key/value pairs of this new value. ... In our case even though the "value" was a hash i think while iterating ... it gets converted to string and it is printing as "continious string". ...
      (comp.lang.ruby)