Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to parse out records that begin with "./"?

Status
Not open for further replies.

kre1973

IS-IT--Management
May 5, 2006
47
US
I'd like to parse out the records from the file below that begin with a: "./"


./ ADD NAME=AB00001
//AB00001 JOB (DAB,PROD), Y09/10/2004 AB00001
// CLASS=H AB00001
//*MAIN LINES=(2000,W,50) AB00001
//*FORMAT PR,DDNAME=COMOUT,PRTY=2 AB00001
//AB01PRC EXEC AB01PRC, AB00001
// REGION=8000K AB00001
./ ADD NAME=AB00002
//AB00002 JOB (DAB,PROD), Y09/10/2004 AB00002
// REGION=8000K AB00002
./ ADD NAME=AB00006
//AB00006 JOB (DAB,PROD), Y09/10/2004 AB00006
// CLASS=H AB00006
//ABCFIST EXEC ABCFIST, AB00006
// REGION=8000K AB00006
./ ADD NAME=AB00007
//AB00007 JOB (DAB,PROD), Y09/10/2004 AB00007
// AB00007
$DD=PAYLOUT
JDE=ABLEDG,JDL=SYSOT2
$DD=PRTJRNL
JDE=PDAILY,JDL=SYSOT2
//*ENDDATASET AB00007
//ABCLEDG EXEC ABCLEDG, AB00007
// REGION=8000K AB00007
./ ADD NAME=AB00016A
//AB00016A JOB (DAB,PROD), Y09/10/2004 AB00016A
// CLASS=H AB00016A
//ABMSUBS EXEC ABMSUBS, AB00016A
// #JI,ID=2 RUN IN FEB, MAR, MAY JUN, AUG, SEP, NOV & DEC AB00016A
//AB016A.OUTPTFL DD DSN=NML.AGYBOOKS.PRODDATA.STMTSMON(+1) AB00016A
//AB16PRC EXEC AB16PRC, AB00016A
// REGION=8000K AB00016A
#JEND ./ ADD NAME=AB00016B
//AB00016B JOB (DAB,PROD), Y09/10/2004 AB00016B
// CLASS=H AB00016B
//ABMSUBS EXEC ABMSUBS, AB00016B
// REGION=8000K AB00016B
//DAB33.FIELDFL DD SYSOUT=(E,,AB28),HOLD=YES, AB00016B
// DCB=(NML.DATAPROC.PRODDATA.NMLPRINT) AB00016B
//DAB33.HOMEFIL DD SYSOUT=(E,,AB29), AB00016B
// DCB=(NML.DATAPROC.PRODDATA.NMLPRINT) AB00016B
./ ADD NAME=AB00020
//AB00020 JOB (DAB,PROD), Y09/10/2004 AB00020
// CLASS=H AB00020
//ABREQFN EXEC ABREQFN, AB00020
// REGION=8000K AB00020
./ ADD NAME=AB00029A



And create a new file with the only third field from the record which would then look like this:

AB00001
AB00002
AB00007
AB00016A
AB00020
AB00029A



Thanks
 
Code:
use strict;
open (IN, "$file"); # The data file: replace $file with path to file
open (OUT, ">$new_file"); # Open a file to write to
while (<IN>) { # Read IN file line by line
    chomp;
    if (/^\.\//) { # Look for ./
        my ($junk,$string) = split(/=/); # Split on the = sign
        print OUT $string . "\n"; # Print out the value to the write file
    }
}

Cheers
 
Code:
use strict;
use warnings;

my %pdsmembers;

while (<>) {
    $pdsmembers{$1}++ if (/^\.\/\s+\w+\s+\w+=([A-Z]\w{0,7})/);
}

print join("\n", sort keys %pdsmembers);
Also sorts and de-dupes the member names and the regex handles IEBUPDTE syntax and PDS member name conventions.

Aargh! My roots are showing...

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top