CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate: Re: [stuckinarut] HASH-O-RAMA Data Processing Problem: Edit Log



FishMonger
Veteran / Moderator

Feb 23, 2015, 9:03 AM


Views: 16792
Re: [stuckinarut] HASH-O-RAMA Data Processing Problem

I don't have time right now to work up a full solution, but as a starting point, I'd drop that regex and instead use a simple split statement to extract your fields.

Example:

Code
while (my $line = <$Q_list>) { 
chomp $line;
if ( $line =~ m/^QSO.\s+([0-9]+).*\s+([\w]{4})\s+([\w]+)\s+([\w]+)\s+([\w]+)\s+([\w]+)\s+([\w]+)\s+([\w]+)/ ) {
print Dumper($1,$2,$3,$4,$5,$6,$7,$8);

my @fields = (split(/\s+/, $line))[1,4..10];
print Dumper \@fields;
last;
}
}


Outputs:

Code
$VAR1 = '7040'; 
$VAR2 = '0200';
$VAR3 = 'W7WHY';
$VAR4 = 'Tom';
$VAR5 = 'OR';
$VAR6 = 'N6ZFO';
$VAR7 = 'BILL';
$VAR8 = 'CA';
$VAR1 = [
'7040',
'0200',
'W7WHY',
'Tom',
'OR',
'N6ZFO',
'BILL',
'CA'
];



(This post was edited by FishMonger on Feb 23, 2015, 9:04 AM)


Edit Log:
Post edited by FishMonger (Veteran) on Feb 23, 2015, 9:03 AM
Post edited by FishMonger (Veteran) on Feb 23, 2015, 9:04 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives