in reply to Re: Copying files from one file to another file
in thread Copying files from one file to another file
What is the name of the files you want the values saved to ?
poj#!/usr/bin/perl use strict; use warnings; my %hash=(); # input my $inputfile = 'nv.txt'; open IN, '<',$inputfile or die "Could not open $inputfile : $!"; while (<IN>) { my ($key, $val) = split (/:/,$_,2); $hash{$key} .= $val; } # output for my $key (keys %hash){ my $outputfile = "output_$key"; $outputfile =~ s{/}{-}g; print "Writing to $outputfile\n"; open OUT,'>',$outputfile or die "Could not open $outputfile : $!"; print OUT $hash{$key}; close OUT; } __DATA__ test/right/case1:12: //comment test/right/case1:344: //comment test/wrong/case3:123: //comment
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Copying files from one file to another file
by harishnv (Sexton) on Feb 20, 2018 at 11:03 UTC | |
by poj (Abbot) on Feb 20, 2018 at 11:09 UTC | |
by harishnv (Sexton) on Feb 20, 2018 at 11:20 UTC | |
by harishnv (Sexton) on Feb 21, 2018 at 04:48 UTC |