
ozi
Novice
Dec 16, 2008, 11:11 AM
Post #10 of 18
(1147 views)
|
|
Re: [KevinR] Parsing Text File
[In reply to]
|
Can't Post
|
|
Ok, I'm stumped. I just can't seem to figure this out. It's probably due to that I'm trying to hurry as this needs to get done asap.... Here is the latest that I've tried to parse this information.
use strict; use warnings; use Data::Dumper; my %data = (); open (IN, 'clientname.txt') or die "$!"; LINE: while( my $line = <IN>) { if ($line =~ /\- (Note \d+):/) { my $note = $1; <IN>,<IN>,<IN>; while ($line = <IN>) { redo LINE if ($line =~ /\- Note \d+:/); push @{$data{$note}},$line; } } } print Dumper \%data; my (@data, $sample, %sample, $key); @data = (Dumper \%data); $sample{'key'} = \@data; foreach $key (sort keys %data) { print "1. $key: <br>2. $data{$key}<br />"; } Which returns the 1. clientname and 2. hash reference So then I tried this .....
#snipped out code ... my (@data, $sample, %sample, $key); @data = (Dumper \%data); $sample{'key'} = \@data; foreach $key (\%data) { if ($key =~ /<h1>Content Management System.*/){ print "1. $key: <br>2. $data{$key}<br />"; } } Which returns nothing. Please please help? I don't even know if I'm getting close or if i'm way off base here. Another question for you...and just a curious question right now. But if I were to ask you to do this and I pay you for it, how much would it cost and how long would it take? Thanks.
|