Extract Parren matched values

A

ansher

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
 
T

Tad J McClellan

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
 
S

sln

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";
 
A

ansher

ansher said:
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

Thanks a lot :)
 
A

ansher

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 :)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,052
Latest member
KetoBeez

Latest Threads

Top