passing "%20" in a url to Perl via CGI

Scott Elcomb Scott.Elcomb-iRg7kjdsKiH3fQ9qLvQP4Q at public.gmane.org
Fri Aug 6 13:23:16 UTC 2004


> > That may be so, but I know I'd much rather use someone else's tested, 
> > maintained code than have to write my own. In Perl, laziness is a virtue.

I am totally in line with the laziness thing.  :D

> - I use 'ls' to pass the file names in a directory to perl
> - perl then pushes that file name to a postres db

You can get a list of files without shelling to ls with readdir like:

opendir(DIR, "/home/selcomb") || die("Couldn't read dir: $!");
my @file_list = readdir(DIR);
closedir(DIR); 
foreach my $file (@file_list) {
	if ($file !~ /^\./) {      # ignore hidden files
		print "$file\n";   # push to database here
	}			   
}

(Incidentally, this would probably make a handy library routine, by
replacing the directory path with a variable and using a callback in
place of the print statement.)

>    I am not too familiar with 'pm' modules I'm afraid I'm not to sure 
> how to use them properly yet. Also, would one of these modules help 
> ensure that other special characters and possibly unicode characters in 
> file names where properly handled, too? Thanks!

There are perl modules for just about everything, and much of the time
they're not terribly difficult to work with.  It can take a while to
read some of the documentation, but the synopsis from most module POD's
make pretty good quick-starts.

http://search.cpan.org/ and the man pages for perltoot, perlboot,
perltooc, perlobj, and perlmod will help in learning about using perl
objects/modules.

- Scott.

-- 
https://sourceforge.net/projects/avalonweb/

PGP Public Key:
1024D/98125E76 2004-03-21 Scott Elcomb (dL33T) <Scott.Elcomb-iRg7kjdsKiH3fQ9qLvQP4Q at public.gmane.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://gtalug.org/pipermail/legacy/attachments/20040806/e72d7687/attachment.sig>


More information about the Legacy mailing list