macromedia wrote: > Hi, Hello,
> I added your changes to my script but now I get no output. See code below: > > Syntax: perl test.pl in.srt out.srt > > > #!/usr/local/bin/perl > > require 5.000; > > my %tags = (); > my %seen; > > my $input = $ARGV[0]; > my $output = $ARGV[1]; > > open (FILE, "< $input") or die "cannot open $input: $!\n"; > open (OUTPUTFILE, "> $output"); > chomp(my @lines = <FILE>); > > my @chars = grep !$seen{$_->[1]}++, > map { > my ($id) = m{<a id=(\w+)>}; > [ $_, $id, scalar $id =~ /^\d+$/ ]; > [EMAIL PROTECTED]; > > > map $_->[0], > sort { > $b->[2] <=> $a->[2] > or > ( $a->[2] ? $a->[1] <=> $b->[1] : $a->[1] cmp $b->[1] ) > or > $a->[0] cmp $b->[0] > > grep !$seen{$_->[1]}++, > map { > my ( $id ) = /<a id=(\w+)>/; > [ $_, $id, scalar $id =~ /^\d+$/ ]; > > > print OUTPUTFILE ; > close OUTPUTFILE; > close FILE; If you had made the changes I indicated then your program should look something like: #!/usr/local/bin/perl require 5.000; my %tags = (); my %seen; my $input = $ARGV[0]; my $output = $ARGV[1]; open (FILE, "< $input") or die "cannot open $input: $!\n"; open (OUTPUTFILE, "> $output") or die "cannot open $output: $!\n"; my @chars = grep !$seen{$_->[1]}++, map { my ($id) = m{<a id=(\w+)>}; [ $_, $id, scalar $id =~ /^\d+$/ ]; } @lines; my @sorted_chars = sort { $b->[2] <=> $a->[2] or ($a->[2] ? $a->[1] <=> $b->[1] : $a->[1] cmp $b->[1]) or $a->[0] cmp $b->[0] } @chars; my @result = map { $_->[0] } @sorted_chars; print OUTPUTFILE @result; close OUTPUTFILE; close FILE; 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>