Professional Web Applications Themes

Pattern Matching Operators - PERL Beginners

Is there a similar operator in Perl for ${variable##pattern} as there is in korn shell. Thanks for the help. Prasad __________________________________________________ ________________ McAfee VirusScan Online from the Netscape Network. Comprehensive protection for your entire computer. Get your free trial today! [url]http://channels.netscape.com/ns/computing/mcafee/index.jsp?promo=393397[/url] Get AOL Instant Messenger 5.1 free of charge. Download Now! [url]http://aim.aol.com/aimnew/Aim/register.adp?promo=380455[/url]...

  1. #1

    Default Pattern Matching Operators

    Is there a similar operator in Perl for ${variable##pattern} as there is in korn shell.

    Thanks for the help.

    Prasad

    __________________________________________________ ________________
    McAfee VirusScan Online from the Netscape Network.
    Comprehensive protection for your entire computer. Get your free trial today!
    [url]http://channels.netscape.com/ns/computing/mcafee/index.jsp?promo=393397[/url]

    Get AOL Instant Messenger 5.1 free of charge. Download Now!
    [url]http://aim.aol.com/aimnew/Aim/register.adp?promo=380455[/url]
    Prasad Karpur Guest

  2. #2

    Default Re: Pattern Matching Operators

    [email]pkarpurnetscape.net[/email] (Prasad Karpur) wrote:
    > Is there a similar operator in Perl for ${variable##pattern} as there
    > is in korn shell.
    Not knowing korn shell, i'm not sure if this is what you want, but there is
    a Pattern Matching Operator in perl, and it is the "m//" operator.

    Look at perldoc perlop and search for the section named "Regexp Quote-Like
    Operator".

    --
    Zanardi2k3
    Zanardi2k3 Guest

  3. #3

    Default RE: Pattern Matching Operators

    >Is there a similar operator in Perl for ${variable##pattern} as there
    is in korn shell.

    As far as I can tell, no.

    However, from
    [url]http://wwwcgi.rdg.ac.uk:8081/cgi-bin/cgiwrap/wsi14/poplog/man/1/ksh[/url] :

    ${parameter##word} Remove Largest Prefix Pattern. The word will
    be expanded to produce a pattern. The parameter expansion then will
    result in parameter, with the largest portion of the prefix matched by
    the pattern deleted.

    So

    $variable =~ s/^(pattern){1}//g;

    should be close in effect to the ksh

    $variable = ${variable##pattern};

    (see [url]http://www.perldoc.com/perl5.6/pod/perlre.html[/url])

    In any case, it apears that ksh offers a limited capability of substring
    processing through 4 varieties of parameter expansion ( (prefix,suffix)
    by (smallest,largest) ). The ksh doentation says "pattern matching
    notation (see patmat), rather than regular expression notation, will be
    used to evaluate the patterns" but I can't find any relevant
    doentation of "patmat" and doubt if it covers more than a small part
    of the functionality provided by perl's regular expression facility.

    -tristram

    Tn Guest

Similar Threads

  1. pattern matching
    By Tad McClellan in forum PERL Beginners
    Replies: 30
    Last Post: June 23rd, 07:42 PM
  2. Pattern matching username
    By perl@swanmail.com in forum PERL Beginners
    Replies: 1
    Last Post: September 30th, 05:37 PM
  3. matching the pattern (strings)
    By MJS in forum PERL Beginners
    Replies: 0
    Last Post: September 28th, 07:04 PM
  4. [PHP] mysql Pattern Matching
    By Cpt John W. Holmes in forum PHP Development
    Replies: 1
    Last Post: September 5th, 06:42 PM
  5. mysql Pattern Matching
    By Electroteque in forum PHP Development
    Replies: 3
    Last Post: September 4th, 03:30 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139