Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2008
    Location
    India
    Posts
    3

    Unanswered: Regular Expressions, Help Me Pls

    hi
    I have small doubt. Hope u will clear that.
    Usually in perl to count the occurance of a specific variable in the input we will use "count".
    I want to know whether we can assign differnt variables and can be able to count the total no of that variables in the input...
    EXAMPLE::

    @m_sites = ( 'ggwxy', 'ggvtew', ' gyhtdj', hhhwqr' );

    IF THE GIVEN INPUT SEQUENCE IS:
    xxxxxxxggwxyxxxxxxxxxggwxyxxxxxxxxxxggvtewxxxxxxxxx

    The output should be 3. Because the given patterns occured 3 times in the sequence.
    i want to know what we can do to count the total no of m_sites in the input

    Thanks in advance.
    Last edited by srisha; 01-10-08 at 00:21.

  2. #2
    Join Date
    Oct 2002
    Location
    Baghdad, Iraq
    Posts
    697
    Since I can barely guess at what you're asking, I won't spend a lot of time explaining myself. Try this:

    Code:
    my $re = join('|', map(quotemeta, @m_sites));
    print scalar($input =~ /$re/g);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •