[26325] in Perl-Users-Digest
Perl-Users Digest, Issue: 8500 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Oct 8 18:05:36 2005
Date: Sat, 8 Oct 2005 15:05:05 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 8 Oct 2005 Volume: 10 Number: 8500
Today's topics:
[Newbie] Running a Perl script on Windows <jfenn@gmx.net>
Recursive directory listing <waldbrunner_bernhard@hotmail.com>
Re: Recursive directory listing <1usa@llenroc.ude.invalid>
Re: Recursive directory listing <1usa@llenroc.ude.invalid>
Re: Recursive directory listing <rvtol+news@isolution.nl>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 08 Oct 2005 20:48:22 +0200
From: Juergen Fenn <jfenn@gmx.net>
Subject: [Newbie] Running a Perl script on Windows
Message-Id: <wk4q7rc0ax.fsf@juergenfenn.de>
Hello,
I am new to Perl so would you please apologise if this is an FAQ I
didn't read about earlier. I have the Lama Book here and I have had a
look into the ActivePerl FAQs, but I can't find anything about it. I
probably don't know the correct term to search for.
This is my question:
I have tried to use html2latex with ActivePerl 5.8.0 on my Windows 98
system recently. It works well when I put the script in the same
directory as the HTML file to be processed by the script. I call the
script using "perl html2latex myfile.html" from that same directory.
Now I put it in a directory that is in my PATH for further usage. It
doesn't work.
Perl does not find the script.
However, _I_ can find the script when I enter "which html2latex".
But where exactly does Perl look for scripts?
I tried to put the file in one of the directories other than "." that
are in @INC, but this didn't work either...
Do I have to write a DOS batch file for running Perl scripts that are
in my PATH?
Thanks in advance!
Juergen.
------------------------------
Date: Sat, 08 Oct 2005 19:32:56 +0200
From: Bernhard Waldbrunner <waldbrunner_bernhard@hotmail.com>
Subject: Recursive directory listing
Message-Id: <pi0gk15hs5mu76fjng31gthacps69834i7@4ax.com>
**** Post for FREE via your newsreader at post.usenet.com ****
I'm trying to print a directory listing recursively, in order
to synchronize directories later with Perl. The problem is that
only directories in root '/' are handled. Sub-directories are
printed (1 level) but the script doesn't list files in those
directories. Here is the source:
# BEGIN dirrec.pl
use strict;
# main
if (!defined($ARGV[0])) { $ARGV[0] = '.'; }
print "Recursive directory listing of `".$ARGV[0]."'\n\n";
list_dir($ARGV[0]);
sub list_dir {
#chdir($_[0]);
opendir(DIR, $_[0]);
if ($_[0] eq '/') {
$_[0] = '';
}
#foreach my $file (<*>) {
while (my $file = readdir(DIR)) {
print $file;
if (-d $file && $file ne "." && $file ne "..") {
print "/\n"; list_dir($_[0]."/".$file);
}
print "\n";
}
closedir(DIR);
} # end of list_dir
# END dirrec.pl
As you can see I've already tried other variations with
globals like <* */*>, neither worked.
Am I missing anything? I'd appreciate any help.
Thank you in advance.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
*** Usenet.com - The #1 Usenet Newsgroup Service on The Planet! ***
http://www.usenet.com
Unlimited Download - 19 Seperate Servers - 90,000 groups - Uncensored
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
------------------------------
Date: Sat, 08 Oct 2005 17:51:07 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Recursive directory listing
Message-Id: <Xns96E98CEB8B005asu1cornelledu@127.0.0.1>
Bernhard Waldbrunner <waldbrunner_bernhard@hotmail.com> wrote in
news:pi0gk15hs5mu76fjng31gthacps69834i7@4ax.com:
> **** Post for FREE via your newsreader at post.usenet.com ****
>
> I'm trying to print a directory listing recursively, in order
> to synchronize directories later with Perl.
...
> # BEGIN dirrec.pl
> use strict;
>
> # main
> if (!defined($ARGV[0])) { $ARGV[0] = '.'; }
> print "Recursive directory listing of `".$ARGV[0]."'\n\n";
> list_dir($ARGV[0]);
>
> sub list_dir {
> #chdir($_[0]);
> opendir(DIR, $_[0]);
> if ($_[0] eq '/') {
> $_[0] = '';
> }
Why re-invent the wheel? You could use File::Find if you are restricted
to using standard modules. On the other hand, I *really* like
File::Finder (http://search.cpan.org/~merlyn/File-Finder-0.53/). Here is
the File::Find version:
#!/usr/bin/perl
use strict;
use warnings;
use File::Find;
use File::Spec::Functions qw(canonpath rootdir);
push @ARGV, rootdir() unless @ARGV;
find(\&wanted, @ARGV);
sub wanted {
my $f = $File::Find::name;
unless ($f eq '.' or $f eq '..') {
print canonpath($f), "\n";
}
}
__END__
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: Sat, 08 Oct 2005 18:01:24 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Recursive directory listing
Message-Id: <Xns96E98EA9A742Aasu1cornelledu@127.0.0.1>
"A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in
news:Xns96E98CEB8B005asu1cornelledu@127.0.0.1:
> sub wanted {
> my $f = $File::Find::name;
> unless ($f eq '.' or $f eq '..') {
> print canonpath($f), "\n";
> }
> }
And, of course, this should have been:
sub wanted {
unless ($_ eq '.' or $_ eq '..') {
print canonpath($File::Find::name), "\n";
}
}
*Sigh* .. sorry about that.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: Sat, 8 Oct 2005 21:40:37 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Recursive directory listing
Message-Id: <di9elo.p4.1@news.isolution.nl>
A. Sinan Unur:
> I *really* like File::Finder
I am a great fan of IO::All:
http://search.cpan.org/dist/IO-All/lib/IO/All.pod
It is a very nice code shrinker:
my @io_files
= io($dir)->filter(sub {/\.jpe?g/i})->All_Files();
print "\t$_\n" for @io_files;
--
Affijn, Ruud <http://www.pandora.com/?sc=sh770781&cmd=tunermini>
"Gewoon is een tijger."
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 8500
***************************************