in reply to Re: Newbie Trying to Read and Reformat File
in thread Newbie Trying to Read and Reformat File
That's my favorite... anyway here is my belated version
of the same thing--
Just watch out for people with pipes in their names... :)#!/usr/bin/perl -w use strict; my @fields = qw[Company Contact Title Phone]; for my $file (@ARGV) { open TEXT, "< $file" or die "Couldn't open $file: $!\n"; my %contact; while(<TEXT>) { chomp; my ($k, $v) = split ": " or next; $contact{$k} = $v; } # hashslice print join("|", @contact{ @fields }), "\n"; }
|
|---|