Give the names of the two files as arguments. And if there's a lot of data, you may want to turn the sort into a GRT.#!/usr/bin/perl use 5.8.0; use strict; use warnings 'all'; use sort 'stable'; my ($first, $second) = @ARGV; open my $fh => $first or die "open first: $!\n"; chomp (my @words = <$fh>); close $fh; my $c = 0; my %words = map {$_ => ++ $c} @words; open my $sh => $second or die "open second: $!\n"; my @info; while (<$sh>) { chomp; push @info => [split /\|/]; } close $sh; @info = sort {$words {$a -> [0]} <=> $words {$b -> [0]}} @info; print "@$_\n" for @info; __END__
Abigail
In reply to Re: Sorting with perl
by Abigail-II
in thread Sorting with perl
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |