Gossamer Forum
Home : General : Perl Programming :

Re: Script what shows an image and records data?

Quote Reply
Re: Script what shows an image and records data? In reply to
To check a URL:

unless ($url =~ /^http:\/\//) {
&error("Invalid URL");
}

That will just check that it starts with http:// - what did you want to check for exactly?

To stop duplicates....change:

open(FILE,">>$file") || die &error("Couldn't open file : $!");
print FILE "$username|$image";
close FILE;


to...

open(FILE,">>$file") || die &error("Couldn't open file : $!");
@data = <FILE>;
close FILE;

foreach (@data) {
chomp $_;
($user,$img) = split(/\|/, $_);
if (($username eq $user) or ($image eq $img)) {
&error("Duplicate entry.");
}
else {
open(FILE,">>$file") || die &error("Couldn't open file : $!");
print FILE "$username|$image";
close FILE;
}
}





Paul
Installations:http://wiredon.net/gt/
Support: http://wiredon.net/forum/

Subject Author Views Date
Thread Script what shows an image and records data? Chef 2561 May 25, 2001, 1:08 AM
Thread Re: Script what shows an image and records data?
Paul 2481 May 25, 2001, 2:47 AM
Post Re: Script what shows an image and records data?
Chef 2454 May 25, 2001, 3:23 AM
Thread Re: Script what shows an image and records data?
Chef 2469 May 25, 2001, 3:25 AM
Post Re: Script what shows an image and records data?
Paul 2504 May 25, 2001, 3:33 AM