in reply to search/grep perl/*nix
To help you with improving your Perl technique, some minor Perl style advice on your originally posted code:
That is, I would write your originally posted code:
open my $fh1, "<:encoding(utf-8)","$tmpfile" or die "$tmpfile: $!"; while (<$fh1>) { chomp; push @names, split (/\n/); } $fh1->close;
as:
use strict; use warnings; my $tmpfile = 'f.tmp'; # test file used only for testing this script s +tandalone my @names; open my $fh1, "<:encoding(utf-8)", $tmpfile or die "$tmpfile: $!"; while (<$fh1>) { chomp; push @names, $_; } close $fh1;
That said, I strongly endorse the other comments exhorting you to write the whole thing in Perl
without using Unix shell at all.
As for why, see: Unix shell versus Perl
|
|---|