
Hellena
New User
Feb 19, 2013, 5:16 AM
Post #1 of 3
(98 views)
|
|
How to add each line into single line in txt file?
|
Can't Post
|
|
I have problem with my code cose of this part:
foreach my $line(keys %results){ print Dump($post) if $results{$line} == 1; } I need it to be only one time printed 'print Dump($post)' Here is all that part
my $f1 = "/home/hellena/Desktop/data.txt"; my $f2 = "/home/hellena/Desktop/ini.txt"; my %results = (); open FILE1, "$f1" or die "Could not open file: $! \n"; while(my $line = <FILE1>){$results{$line}=1; } close(FILE1); open FILE2, "$f2" or die "Could not open file: $! \n"; while(my $line =<FILE2>) { $results{$line}++; } close(FILE2); foreach my $line(keys %results){ print Dump($post) if $results{$line} == 1; } $post contains same like it lines but cose of hash I get randomed lines if i print line by line... If I run code it will repat printed post 4-5 times it depends how much lines have in it post(lines comes dinamicly) but I need post be printed just one time...
(This post was edited by Hellena on Feb 19, 2013, 5:32 AM)
|