Extract Parren matched values

Discussion in 'Perl Misc' started by ansher, Mar 23, 2009.

  1. ansher

    ansher Guest

    Hello

    I have a file which looks something like this...

    l axn1;c=c(&dat)'&lnk';nz
    *include &tt.qin;tt=WEB
    *include &base.qin;
    *include q6.qin;
    *include q7.qin; axn=q7;col(b)=&kod;pun=&p;fil=&fb
    *include q8.qin; axn=q8;col(b)=&qod;pun=&p;fil=&fb
    n01&txt ;c=gkeeper.eq.1
    n01Not &txt ;c=gkeeper.eq.2

    I want a list of values which qualifies the condition m/\&[a-z]+/.

    It will be great if you can help me in how to get the exact pattern
    match values to an array.


    &dat
    &lnk
    &tt
    &base
    &kod
    &p
    &fb
    &qod
    &txt
     
    ansher, Mar 23, 2009
    #1
    1. Advertising

  2. ansher <> wrote:


    > I have a file which looks something like this...


    [snip]

    > I want a list of values which qualifies the condition m/\&[a-z]+/.
    >
    > It will be great if you can help me in how to get the exact pattern
    > match values to an array.



    ----------------
    #!/usr/bin/perl
    use warnings;
    use strict;

    my @ampersands;
    while ( <DATA> ) {
    push @ampersands, /(&[a-z]+)/g;
    }
    print "$_\n" for @ampersands;


    __DATA__
    l axn1;c=c(&dat)'&lnk';nz
    *include &tt.qin;tt=WEB
    *include &base.qin;
    *include q6.qin;
    *include q7.qin; axn=q7;col(b)=&kod;pun=&p;fil=&fb
    *include q8.qin; axn=q8;col(b)=&qod;pun=&p;fil=&fb
    n01&txt ;c=gkeeper.eq.1
    n01Not &txt ;c=gkeeper.eq.2
    ----------------


    --
    Tad McClellan
    email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
     
    Tad J McClellan, Mar 23, 2009
    #2
    1. Advertising

  3. ansher

    Guest

    On Mon, 23 Mar 2009 08:37:47 -0700 (PDT), ansher <> wrote:

    >Hello
    >
    >I have a file which looks something like this...
    >
    >l axn1;c=c(&dat)'&lnk';nz
    >*include &tt.qin;tt=WEB
    >*include &base.qin;
    >*include q6.qin;
    >*include q7.qin; axn=q7;col(b)=&kod;pun=&p;fil=&fb
    >*include q8.qin; axn=q8;col(b)=&qod;pun=&p;fil=&fb
    >n01&txt ;c=gkeeper.eq.1
    >n01Not &txt ;c=gkeeper.eq.2
    >
    >I want a list of values which qualifies the condition m/\&[a-z]+/.
    >
    >It will be great if you can help me in how to get the exact pattern
    >match values to an array.
    >
    >
    >&dat
    >&lnk
    >&tt
    >&base
    >&kod
    >&p
    >&fb
    >&qod
    >&txt
    >


    -sln

    use strict;
    use warnings;

    my @vals = join('', <DATA>) =~ /\&[a-z]+/g;
    print "@vals\n";
     
    , Mar 23, 2009
    #3
  4. ansher

    ansher Guest

    On Mar 23, 11:08 pm, Tad J McClellan <> wrote:
    > ansher <> wrote:
    > > I have a file which looks something like this...

    >
    > [snip]
    >
    > > I want a list of values which qualifies the condition m/\&[a-z]+/.

    >
    > > It will be great if you can help me in how to get the exact pattern
    > > match values to an array.

    >
    > ----------------
    > #!/usr/bin/perl
    > use warnings;
    > use strict;
    >
    > my @ampersands;
    > while ( <DATA> ) {
    >     push @ampersands, /(&[a-z]+)/g;}
    >
    > print "$_\n" for @ampersands;
    >
    > __DATA__
    > l axn1;c=c(&dat)'&lnk';nz
    > *include &tt.qin;tt=WEB
    > *include &base.qin;
    > *include q6.qin;
    > *include q7.qin; axn=q7;col(b)=&kod;pun=&p;fil=&fb
    > *include q8.qin; axn=q8;col(b)=&qod;pun=&p;fil=&fb
    > n01&txt                                              ;c=gkeeper.eq.1
    > n01Not &txt                                      ;c=gkeeper.eq.2
    > ----------------
    >
    > --
    > Tad McClellan
    > email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


    Thanks a lot :)
     
    ansher, Mar 23, 2009
    #4
  5. ansher

    ansher Guest

    On Mar 23, 11:32 pm, wrote:
    > On Mon, 23 Mar 2009 08:37:47 -0700 (PDT), ansher <> wrote:
    > >Hello

    >
    > >I have a file which looks something like this...

    >
    > >l axn1;c=c(&dat)'&lnk';nz
    > >*include &tt.qin;tt=WEB
    > >*include &base.qin;
    > >*include q6.qin;
    > >*include q7.qin; axn=q7;col(b)=&kod;pun=&p;fil=&fb
    > >*include q8.qin; axn=q8;col(b)=&qod;pun=&p;fil=&fb
    > >n01&txt                                              ;c=gkeeper.eq.1
    > >n01Not &txt                                      ;c=gkeeper.eq.2

    >
    > >I want a list of values which qualifies the condition m/\&[a-z]+/.

    >
    > >It will be great if you can help me in how to get the exact pattern
    > >match values to an array.

    >
    > >&dat
    > >&lnk
    > >&tt
    > >&base
    > >&kod
    > >&p
    > >&fb
    > >&qod
    > >&txt

    >
    > -sln
    >
    > use strict;
    > use warnings;
    >
    > my @vals = join('', <DATA>) =~ /\&[a-z]+/g;
    > print "@vals\n";- Hide quoted text -
    >
    > - Show quoted text -


    Thanks a lot :)
     
    ansher, Mar 23, 2009
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Patrick

    VHDL Matched Filter

    Patrick, Jul 2, 2004, in forum: VHDL
    Replies:
    1
    Views:
    1,839
    Jerzy
    Jul 6, 2004
  2. David Tweed

    matched delays in Xilinx ISE?

    David Tweed, May 26, 2005, in forum: VHDL
    Replies:
    0
    Views:
    558
    David Tweed
    May 26, 2005
  3. Replies:
    0
    Views:
    1,576
  4. Remembering Matched Values

    , Aug 5, 2005, in forum: Perl Misc
    Replies:
    2
    Views:
    107
    Paul Lalli
    Aug 5, 2005
  5. shree
    Replies:
    5
    Views:
    153
    shree
    Dec 29, 2007
Loading...

Share This Page