macromedia wrote: > Hi, Hello,
> I have a file that I would like to read in then do the following: > > - Read in each line and remove any duplicate text with tags > - Sort the file so all tag IDs are in sequential order > - Save the results to a different file name. > > Can this be done easily? If so, how? I'm really a newbie at this > stuff. Any help would be greatly appreciated. #!/usr/bin/perl use warnings; use strict; my $file_in = 'somefile'; my $file_out = 'differentfile'; open my $in, '<', $file_in or die "Cannot open $file_in: $!"; open my $out, '>', $file_out or die "Cannot open $file_out: $!"; my %seen; print $out map $_->[ 1 ], sort { $a->[ 0 ] <=> $b->[ 0 ] } map [ /<tag id=(\d+)>/, $_ ], grep />([^<]+)</ && !$seen{ $1 }++, <$in>; __END__ John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>