View Single Post
Old 05-23-2008, 07:59 AM  
Mr Pheer
Too lazy to set a custom title
 
Mr Pheer's Avatar
 
Industry Role:
Join Date: Dec 2002
Posts: 21,471
someone help me out with the syntax error on line 18 please?

Code:
#!/usr/bin/perl
use strict;

my $FileName = 'file.txt'; # Modify file name as needed.

my(@List,%List,@NewList)= ();

sub Abandon
{
print join '
',@_;
exit;
} # sub Abandon

print "Content-type: text/plain\n\n";

Abandon("Unable to read file $FileName") unless open R,"<$FileName";
@List = ;
close R;

Abandon("Unable to create temporary file ${FileName}.tmp.txt") unless open W,">${FileName}.tmp.txt";
for(@List) { print W $_; }
close W;

for(@List)
{
next if $List{$_};
$List{$_}++;
push @NewList,$_;
}

Abandon('Something wrong.',"Backup file is ${FileName}.tmp.txt") unless open W,">$FileName";
for(@NewList) { print W $_; }
close W;

unlink "${FileName}.tmp.txt";

print 'D O N E';
Mr Pheer is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote