[10830] in Perl-Users-Digest
Perl-Users Digest, Issue: 4431 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 15 18:07:27 1998
Date: Tue, 15 Dec 98 15:00:18 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 15 Dec 1998 Volume: 8 Number: 4431
Today's topics:
Re: Complicated sorting problem (Larry Rosler)
Re: Complicated sorting problem (Tad McClellan)
Disk Free <pep_mico@hp.com>
Favourite Editor for NT Perl <kirby@jamesk.REMOVE.freeserve.co.uk>
Re: Favourite Editor for NT Perl <due@murray.fordham.edu>
Getting compiled /usr/include files for Digital Unix ftidev@fhb.clickcharge.com
how do I do this common text import task? <tharold@portal.ca>
Re: Need some speed tips on this script.. (Larry Rosler)
NEWBIE! - need help with sar output on UNIX and perl jdennis@alldata.net
nice(2)ing a script <doug@weboneinc.com>
Re: OLE referencing problem: PerlScript, ASP and CDONTS bdavis@mediaphex.com
Re: Origin of 'local'? <hansmu@xs4all.nl>
Passing hash to module written in C <beske@worldnet.att.net>
Re: Perl and reading from log files (Marc Haber)
Re: Perl newbie question.. (Larry Rosler)
Re: Perl2EXE <tchrist@mox.perl.com>
Pipe docs (basic) <dropzone@mail.utexas.edu>
question on perlshop (Tom)
Trying to get all directories recursively (Christopher Parent)
Re: Trying to get all directories recursively <kprice@cardinal.co.nz>
Re: uuencoded data in scripts failing to decode / unpac <jbattikha@highsynth.com>
Re: What is next book to read after Learning PERL ? birgitt@my-dejanews.com
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 15 Dec 1998 12:56:52 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Complicated sorting problem
Message-Id: <MPG.10e06cf3397064af9898c4@nntp.hpl.hp.com>
In article <m31zm1gnp1.fsf@localhost.localdomain> on 15 Dec 1998
15:22:34 -0500, Bruce Z. Lysik <eldrik@localhost.localdomain> says...
> aml@world.std.com (Andrew M. Langmead) writes:
>
> > A lot of time you see the spliting and sorting combined into this mess
> > of map functions and references called a "Schwartzian Transform",
> > named for (and developed by) a well known Perl obfusciator.
> >
> > @sorted = map { $_->[0] }
> > sort { $a->[1] cmp $b->[1] or $a->[2] <=> $b->[2] }
> > map { [ $_, /(\D+)(\d+)/ ] } @array;
There's Another (somewhat faster) Way To Do It. This very problem
(identical, except that the submitter wanted case-independence for the
letters) was discussed here over the weekend. See "Sorting problem: Is
there a better way?", http://x11.dejanews.com/getdoc.xp?AN=421986706
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 15 Dec 1998 14:57:13 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Complicated sorting problem
Message-Id: <9fi657.0bd.ln@magna.metronet.com>
Bruce Z. Lysik (eldrik@metronet.com.localdomain) wrote:
: (Each line being a member of the array). Now before I
: was happy sorting on the first field normally, even
: though the names wouldn't be in numerical order in the
: list, just alphabetical. (I actually used the unix
: 'sort' command to simplify this.)
^^^^^^^^
How does shelling out to Unix sort _simplify_ it?
Seems like native perl's sort() would be more simple...
: Unfortunately, now I have a picky person wanting them
: grouped alphabetically and /then/ in nice ascending
: numerical order. Does anyone have an idea on how to
: do this? I have no idea how to go about doing it.
------------------------------
#!/usr/bin/perl -w
@lines = <DATA>;
@sorted = map { $_->[0] } # Schwartzian Transform
sort {
$a->[1] cmp $b->[1] or # names
$a->[2] <=> $b->[2] # numbers
} map {
[$_, m/^(\D+)(\d+)/]
} @lines;
foreach (@sorted) {
print;
}
__DATA__
esub06,some text,some more text,misc text
gsun23,some text,some more text,misc text
gsun102,some text,some more text,misc text
gsun55,some text,some more text,misc text
esub04,some text,some more text,misc text
------------------------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 15 Dec 1998 23:06:30 +0100
From: Pep Mico <pep_mico@hp.com>
Subject: Disk Free
Message-Id: <3676DD66.B16BC896@hp.com>
How can I get how many disk free space is available in one volume disk?
I'm working in Windows NT environment.
Regards
pep_mico@hp.com
------------------------------
Date: Tue, 15 Dec 1998 19:56:05 -0000
From: "Kirby James" <kirby@jamesk.REMOVE.freeserve.co.uk>
Subject: Favourite Editor for NT Perl
Message-Id: <756ite$vr7$1@newsreader1.core.theplanet.net>
After using Notepad for some time I've decided to treat myself....
... Anyone like to suggest the 'best' editor for Perl under Windows NT.
I've tried MultiEdit which 'understands' Perl out-of-the box, takes you
to the lines with errors (if you make any), and shows you programme
output.
I've also tried CodeWright - this uses Perl as a macro language - but
doesn't seem to 'understand' Perl without some configuration.
Any recommendations from experienced users?
Thanks
Kirby
------------------------------
Date: 15 Dec 1998 22:33:53 GMT
From: "Allan M. Due" <due@murray.fordham.edu>
Subject: Re: Favourite Editor for NT Perl
Message-Id: <756o4h$gqr$0@206.165.165.152>
Kirby James wrote in message <756ite$vr7$1@newsreader1.core.theplanet.net>...
|After using Notepad for some time I've decided to treat myself....
|... Anyone like to suggest the 'best' editor for Perl under Windows NT.
|I've tried MultiEdit which 'understands' Perl out-of-the box, takes you
|to the lines with errors (if you make any), and shows you programme
|output.
|I've also tried CodeWright - this uses Perl as a macro language - but
|doesn't seem to 'understand' Perl without some configuration.
|Any recommendations from experienced users?
|Thanks
|Kirby
Man, I got to set up a macro for this. My favorite Windoze editor is
UltraEdit. Here is what I had to say about this last week.
-----
Well, I say this all the time but I quite like UltraEdit. Macros, column
mode, colored syntax, automatic indenting, match braces, view html your are
editing with your browser from within the editor, etc. Plus it is easy to set
up a tool that allows you to run Perl from within UltraEdit and then capture
the output to either a list box or a new file in the editor. You can also run
DOS commands from within the editor. It is shareware and times out after
something like 30-45 days, I forget which. For me, it is well worth the money.
Oh, new feature, it now has it's own FTP capability. Just my $.02.
AmD
------------------------------
Date: Tue, 15 Dec 1998 22:26:42 GMT
From: ftidev@fhb.clickcharge.com
Subject: Getting compiled /usr/include files for Digital Unix
Message-Id: <756nmt$1is$1@nnrp1.dejanews.com>
The compiler switches that Perl 5.005_02 picked for h2xs for Digital Unix cc
cc -c -std -fprm -d -ieee -D_INTRINSICS -O4
are generating many errors.
Rather than analyze without seeing if the problem was solved here, let me ask,
has anyone been down this road before with Digital Unix, and if so, what have
you changed?
Also, let me ask the general question. If I attempt to fix this problem,
and the solution is in a modification of some Perl-distributed software,
what is the Perl-approved method of getting my correction into the next
version of perl?
Pat Sweeney
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 15 Dec 1998 02:28:24 -0800
From: Terry Haroldson <tharold@portal.ca>
Subject: how do I do this common text import task?
Message-Id: <367639C8.672F5850@portal.ca>
I'm new at this and am sure this is a easy question. I have data in a
text file similar to the following (retrieved from a Informix d/b). I
would like to transpose it into a csv format, so I can stick it into
Excel. (I don't care about the field names.) This must be a common
task. Any ideas.
I would like to get this:
11,1,876,1,909576453,7,0,0,7
2,CT003A,76,1,912859221,0,0,0,0
2,CT003A,51,1,912859221,0,0,0,0
etc.
from the following:
wire_center_id 11
cable_name 1
first_pair 876
sequence_num 1
date_analyzed 909576453
all_fault_weight 7
weight_fault_count 0
all_fault_count 0
bad_pair_count 7
wire_center_id 2
cable_name CT003A
first_pair 76
sequence_num 1
date_analyzed 912859221
all_fault_weight 0
weight_fault_count 0
all_fault_count 0
bad_pair_count 0
wire_center_id 2
cable_name CT003A
first_pair 51
sequence_num 1
date_analyzed 912859221
all_fault_weight 0
weight_fault_count 0
all_fault_count 0
bad_pair_count 0
,etc.
Thanks in advance.
------------------------------
Date: Tue, 15 Dec 1998 13:49:27 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Need some speed tips on this script..
Message-Id: <MPG.10e07941e20f73279898c6@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and a copy mailed.]
In article <756g7i$gei$1@spider.ci.lubbock.tx.us> on Tue, 15 Dec 1998
14:14:08 -0600, Chris Beatson <cbeatson@mail.ci.lubbock.tx.us> says...
> This script works fine, but it runs a bit slow. Any advice to speed it up
> would be appreciated. Please explain any suggestions.
...
> open (file, "<$logfile") || die "can't open the logfile: $logfile\n";
Perl convention is to use upper-case for filehandles. This protects you
from conflict with function names, and makes it easier on the eyes of
other Perl programmers. Also, the diagnostic should include $! to
report the cause of the failure.
> OUTER: while (<file>) {
> chomp;
> if ($_=~ /(^\d+?\.\d+?\.\d+?\.\d+?)\,.*$/) {
> foreach $i (@ips)
> {
> if ($1 eq $i)
> {
> next OUTER;
> }
> }
> $ips[$count]="$1";
> $count++;
> }
> }
> open (results, ">ips");
Where is the test for failure here?
> foreach $i (sort(@ips))
> {
> $ipcount++;
> print results "$i\n";
> }
> close (results);
> close (file);
> print "there were $ipcount different ips\n";
This is an easy one. You are using a quadratic algorithm -- for every
line in the input, you are searching through an array whose size is
growing proportionately to the size of the input.
When the question you are asking is "Does the array *contain* a specific
item?", you should think 'hash'. Instead of adding them onto an array
(which you could have done more nicely using 'push', by the way), and
then searching through them, you should store them in a hash, and see if
they exist. perlfaq4: "How can I tell whether an array contains a
certain element?"
Now, as all you seem to want is a list of the *unique* items, you should
think 'hash' and read the preceding FAQ, "How can I extract just the
unique elements of an array?". When you are done, you end up with this
[leaving out the file closings]:
open (FILE, $logfile) ||
die "can't read the logfile: $logfile. $!\n";
my %ips;
@ips{ map /^(\d+\.\d+\.\d+\.\d+),/, <FILE> } = ();
open (RESULTS, ">ips") ||
die "can't write the results file: ips. $!\n";
print RESULTS map "$_\n", sort keys %ips;
print "there were ", scalar keys %ips, " different ips\n";
__END__
Search for 'hash slice' and do `perldoc -f map` to understand the magic
one-liner that gathers all the data.
I have simplified and probably speeded up your regex (which itself may
draw flak from others in this newsgroup, because it ignores certain
pathological IMO forms for ip addresses).
This should run blindingly fast compared to your original. Benchmarking
up to you...
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 15 Dec 1998 21:00:22 GMT
From: jdennis@alldata.net
Subject: NEWBIE! - need help with sar output on UNIX and perl
Message-Id: <756il5$ssm$1@nnrp1.dejanews.com>
Help!
I need to use perl (I think it is probably the BEST language to use)
to format the output of sar -d on an HPUX system.
sar -d gives output for each disk and tape device on a separate line, with
only the first line giving the timestamp.
I need to duplicate the timestamp for all disks in my output file.
For example, the original sar -d output is as follows:
00:10:01 c0t1d0 0.07 0.51 1 7 3.12 1.88
c0t1d3 0.04 0.50 0 1 3.42 2.07
00:20:01 c0t1d0 0.26 0.50 1 8 3.41 3.30
c2t0d0 0.00 0.50 0 0 4.76 0.79
c0t1d3 0.03 0.50 0 1 3.49 1.76
00:30:01 c0t1d0 0.22 0.50 1 5 3.23 3.91
c2t0d0 0.00 0.50 0 0 4.84 0.78
c0t1d3 0.03 0.50 0 2 3.32 1.71
I need the resulting file to look like this:
00:10:01 c0t1d0 0.07 0.51 1 7 3.12 1.88
00:10:01 c0t1d3 0.04 0.50 0 1 3.42 2.07
00:20:01 c0t1d0 0.26 0.50 1 8 3.41 3.30
00:20:01 c2t0d0 0.00 0.50 0 0 4.76 0.79
00:20:01 c0t1d3 0.03 0.50 0 1 3.49 1.76
00:30:01 c0t1d0 0.22 0.50 1 5 3.23 3.91
00:30:01 c2t0d0 0.00 0.50 0 0 4.84 0.78
00:30:01 c0t1d3 0.03 0.50 0 2 3.32 1.71
Maybe this is easier than I am assuming (probably) but I have been looking at
sed, awk, and other tools.
Any help appreciated
Jamie
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 15 Dec 1998 17:23:07 -0500
From: Douglas Clifton <doug@weboneinc.com>
Subject: nice(2)ing a script
Message-Id: <3676E14B.E38197ED@weboneinc.com>
I checked the FAQ for this question, no luck.
I have a long complex Perl script that has a tendency
to slow down my machine. Since the script is exec()ed
from a CGI script I was wondering if there was any way
to nice(2) a script from inside the script.
Would:
$nice = "nice";
$priority = 10;
syscall $nice, $priority;
work?
I am aware of efficiency issues and the use of sleep()
inside of loops.
Thanks,
--
Douglas Clifton
Unix/C/Perl/CGI/HTML Programmer
doug@weboneinc.com
------------------------------
Date: Tue, 15 Dec 1998 21:45:03 GMT
From: bdavis@mediaphex.com
To: jan.dubois@ibm.net
Subject: Re: OLE referencing problem: PerlScript, ASP and CDONTS.NewMail object
Message-Id: <756l8u$v7s$1@nnrp1.dejanews.com>
In article <367ca1a8.43126602@news3.ibm.net>,
jan.dubois@ibm.net (Jan Dubois) wrote:
> It's not only the signature, it's the concept of properties with
> parameters that makes me shudder.
Yeah, it took me quite a while to grasp what it was doing. It looks like
'Value' should be a dictionary object at first glance. I still don't
understand why it's not a dictionary. Did the OLE team give them a new toy to
play with so they decided to implement it?
> >> I think the following is more likely:
> >> $obj->SetProperty('Value', 'header', 'headervalue');
>
> Are you running your script with "perl -w"? This is necessary to get the
> full OLE error message. Alternatively, please display the value of
> Win32::OLE->LastError() after the SetProperty call to check if there was
> an error.
I don't know what changed, but I went back to the script I was working with
yesterday to add the LastError() call and everything "magically" worked. I
don't think that i had a typo which was corrected, because I had just
commented the code you had suggested out. But it is working now and I'm
happy.
Thanks for all of the trouble you went to to help me get this working. For
the benefit of anyone who's been following this thread and Jan and Matt for
figuring it out here's the final function:
sub sendmail {
# Send an email message using the IIS 4 mail service
# Mediaphex Production Co. 12/11/98
# $from : originating email address
# $to : destination email address
# $subject : message subject
# $body : message body
# $headers : reference to hash of "header" => "value" pairs
local($from, $to, $subject, $body, $headers) = @_;
use Win32::OLE;
my $MAIL = Win32::OLE->new('CDONTS.NewMail'); #IIS 4 Mail Object
$MAIL->{From} = $from;
$MAIL->{To} = $to;
$MAIL->{Subject} = $subject;
if($headers){
foreach $key (keys %$headers) {
## Sugested by Jan Dubois <jan.dubois@ibm.net>
$MAIL->SetProperty('Value', $key, $$headers{$key});
}
}
$MAIL->{Body} = $body;
$MAIL->Send; #send message
undef($MAIL); #drop object
}#end sendmail
Thanks again for the help.
Bryan
--
Bryan Davis -M E D I A P H E X- 815 Park Blvd, Ste 340
<bdavis@mediaphex.com> Technical Director Boise, ID 83712
http://www.mediaphex.com v:208.343.2868 f:208.343.1336
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 15 Dec 1998 22:38:51 GMT
From: Hans Mulder <hansmu@xs4all.nl>
Subject: Re: Origin of 'local'?
Message-Id: <756odr$2bos$1@beast.euro.net>
David L Nicol <david@kasey.umkc.edu> wrote:
>Steven Morlock wrote:
>>
>> I have had an opportunity to develop in several different
>> languages and I never encountered anything quite like 'local'.
>
>Really? Ever "develop" in Pascal? Local implements scoping so that
>references to non-declared variables in called routines get the variable
>with that name from the calling function rather than the global
>namespace, just like Pascal variables.
Errhm, no. That's what "my" does. "Local" does dynamic binding.
Dynamic binding is featured in some ancient Lisp dialects, but not
in modern language. To see the difference, consider:
$x = "hello\n";
sub print_x { print $x; }
sub call_it {
local $x = "goodbye\n";
&print_x;
}
&call_it;
This prints "goodbye", i.e. the value of $x at the time &print_x
is called. If you replace the "local" by a "my", you'd get "hello",
i.e. the value of the variable $x in scope at the point where
&print_x is defined.
If you translate the example to Pascal, you get "hello", since
Pascal does lexical scoping.
Hope this helps,
-- HansM
------------------------------
Date: 15 Dec 1998 21:48:37 GMT
From: Bryan Beske <beske@worldnet.att.net>
Subject: Passing hash to module written in C
Message-Id: <3676D8F1.7D0BDF83@worldnet.att.net>
I have been trying to get a simple call to a module written
in C to work when passing a hash array without luck.
In the perl program, I have:
my( %foo );
...
bbtest( \%foo );
...
In the Module I have:
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
MODULE = bbtest PACKAGE = bbtest
PROTOTYPES: ENABLED
void
bbecho( host )
HV * host
CODE:
When I build the module, All is fine. When I run the program, I get:
"host is not of type HVPtr at test.pl line 10."
What am I missing?
------------------------------
Date: Tue, 15 Dec 1998 22:55:55 GMT
From: Marc.Haber-usenet@gmx.de (Marc Haber)
Subject: Re: Perl and reading from log files
Message-Id: <756pdr$sci$3@news.rz.uni-karlsruhe.de>
Marc.Haber-usenet@gmx.de (Marc Haber) wrote:
>Good idea, however, to take a closer look at
>tail's source.
The relevant part of tail looks like:
|output:
| while ((bytes_read = safe_read (fd, buffer, BUFSIZ)) > 0)
| {
| XWRITE (STDOUT_FILENO, buffer, bytes_read);
| total += bytes_read;
| }
| if (bytes_read == -1)
| error (EXIT_FAILURE, errno, "%s", filename);
| if (forever)
| {
| fflush (stdout);
| sleep (1);
| goto output;
| }
So I reckon this may be the canonical way to do it.
Greetings
Marc
--
-------------------------------------- !! No courtesy copies, please !! -----
Marc Haber | " Questions are the | Mailadresse im Header
Karlsruhe, Germany | Beginning of Wisdom " | Fon: *49 721 966 32 15
Nordisch by Nature | Lt. Worf, TNG "Rightful Heir" | Fax: *49 721 966 31 29
------------------------------
Date: Tue, 15 Dec 1998 13:01:13 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl newbie question..
Message-Id: <MPG.10e06df188d46cd19898c5@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and a copy mailed.]
In article <x71zm1ql9k.fsf@sysarch.com> on 15 Dec 1998 14:04:55 -0500,
Uri Guttman <uri@sysarch.com> says...
...
> ... if he just wants to
> delete a true line then good ol' grep -v would be enough (unless he is a
> POB).
A POB who hasn't installed a set of useful tools. See my response to
TomC today. Don't jump gratuitously on the Bash Bill Bandwagon when
there are reasonable alternative approaches (some of which are free).
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 14 Dec 1998 18:16:09 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Perl2EXE
Message-Id: <753kl9$j4o$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, "Christian" <cb2001@hotmail.com> writes:
:i need this very much, cuz i have to write a perl script for school, but i
:don't want them to get the source, it was too much work!
So much for science and research and education.
"And just as you're under no obligation to publish your source code
to please me, I'm under no obligation to help you hide it."
--Russ Allbery (rra@cs.stanford.edu)
--tom
--
/* Force them to make up their mind on "@foo". */
--Larry Wall, from toke.c in the v5.0 perl distribution
------------------------------
Date: Tue, 15 Dec 1998 15:41:01 -0600
From: Forrest Reynolds <dropzone@mail.utexas.edu>
Subject: Pipe docs (basic)
Message-Id: <3676D76B.AB319846@mail.utexas.edu>
Hello,
I'm lookling for a place to read about pipes " from the beginning." The
Llama doesn't have it and the Camel assumes more than I know. I understand how
this statement works:
ls -l | more
but not much more.
Thanks, Forrest
------------------------------
Date: Tue, 15 Dec 1998 21:51:42 GMT
From: submit@tejasdesign.com (Tom)
Subject: question on perlshop
Message-Id: <3676d6af.35282861@news.ktc.com>
I also would like know if anybody has a problem installing the
"perlshop 3.1" on a unix/apache virtual server.???
The cgi is accessed through a form, but some parts of it does not
recognize certain paths to html's called by the <input TYPE=HIDDEN
NAME="THISPAGE" VALUE="page1.htm">. Keeps coming up with the error
"The page (catalog/page1.htm) you have requested is not available."
but the rest of the script comes up like the footer. The script does
not crash and burn, it just acts like it was not made for just any
server other than the one it designed on.
BTW, I have at least 50 other scripts installed on this same server.
------------------------------
Date: Tue, 15 Dec 1998 22:31:42 GMT
From: parenc@rpi.edu (Christopher Parent)
Subject: Trying to get all directories recursively
Message-Id: <3676e1f1.4497610@news.ntplx.net>
I'm trying to write a perl script that goes through each directory and
subdirectory, and returns all the files that match a mask that I set.
I can determine what's a directory, and what's not (duh), but I'm
having a problem with the recursion. Basically my script goes like
this:
findFile {
Get all files in directory
for each file
if file is a directory
change into that directory
list files based on mask
findFile(parameter)
}
}
}
*** Note the parameter passed is something like @allfiles = `ls -l`
I then parse through the array and find which elements are directories
(if file is a directory).
for some reason, i'm coming up short. After I change into the
directory, the script dies. If anyone has written something like this
and can help, I'd appreciate it.
Thanks,
Chris
------------------------------
Date: Wed, 16 Dec 1998 11:50:01 +1300
From: Kelvin Price <kprice@cardinal.co.nz>
Subject: Re: Trying to get all directories recursively
Message-Id: <3676E799.50ECEBC@cardinal.co.nz>
Christopher Parent wrote:
>
> I'm trying to write a perl script that goes through each directory and
> subdirectory, and returns all the files that match a mask that I set.
> I can determine what's a directory, and what's not (duh), but I'm
> having a problem with the recursion. Basically my script goes like
> this:
>
> findFile {
> Get all files in directory
> for each file
> if file is a directory
> change into that directory
> list files based on mask
> findFile(parameter)
> }
> }
> }
>
> *** Note the parameter passed is something like @allfiles = `ls -l`
> I then parse through the array and find which elements are directories
> (if file is a directory).
>
> for some reason, i'm coming up short. After I change into the
> directory, the script dies. If anyone has written something like this
> and can help, I'd appreciate it.
>
> Thanks,
> Chris
Unless you are using absolute path names in your chdir command, you need
to chdir back up a level before you can step down another level.
IE. You have dir1/subdir1 and dir1/subdir2 and you chdir to dir1 (all
okay so far) then you chdir to subdir1 (still okay). Now if you don't
chdir back up to dir1, you can't chdir to subdir2 because it is not a
sub-directory of subdir1 which is your currrent directory.
If you're going to recurse through a tree (EG. a hierarchical
filesystem) then you have to terminate at the 'leaves' and backtrack up
the 'branches' you tracked down.
HTH, Kelvin 8-D
------------------------------
Date: Tue, 15 Dec 1998 16:39:37 -0500
From: Jihad Battikha <jbattikha@highsynth.com>
Subject: Re: uuencoded data in scripts failing to decode / unpack ?
Message-Id: <3676D719.F422A184@highsynth.com>
RE: uuencode data in scripts
I always end up doing this:
Post a question, think deep thoughts, and finally figure out on my own
what I was doing wrong - which ends up being something boneheaded.
Apparently, when I was generating the uuencode ASCII in the first place
(which happened to be on a Windows system), I wasn't turning binmode on
for the file. It's always the little things that get ya...
Everything's working as expected now.
~jihad
--
<>>>===========================================================<<<>
Jihad Battikha <jbattikha@highsynth.com> http://www.highsynth.com
-=< graphics . 2d/3d animation . illustration . web authoring >=-
<>>>===========================================================<<<>
Before sending me commercial e-mail, the sender must first agree
to my LEGAL NOTICE located at: http://www.highsynth.com/sig.html.
<>>>===========================================================<<<>
------------------------------
Date: Tue, 15 Dec 1998 22:32:38 GMT
From: birgitt@my-dejanews.com
Subject: Re: What is next book to read after Learning PERL ?
Message-Id: <756o27$20e$1@nnrp1.dejanews.com>
In article <74vdts$vh5$1@nnrp1.dejanews.com>,
sofianb@my-dejanews.com wrote:
> Hello! My name is Budi Sofian. I've just finished reading "Learning PERL". I
> need recommendations for the next book to read. I have searched through the
> web and found "Programming PERL" and "CGI/PERL Cookbook" interesting, but I
> could not decide which one I should get. Or probably there are other books
> which are better than these two.
>
> By the way, my purpose of learning PERL is for CGI programming and I have
> programming experience previously (FORTRAN 77).
> Please send me your recommendation. Your help is highly appreciated.
>
If it is for CGI programming:
CGI Programming on the WWW, Gundavaram, O'Reilly
Web-Client Programming with Perl, Clinton Wong, O'Reilly
The Webmaster's Handbook, Perl Power for Your Web Server, Neuss, Vromans,
Int. Thompson Computer Press
If it's for learning Perl no matter what:
Programming Perl, Wall, Christiansen, Schwartz, O'Reilly
Advanced Perl Programming, Srinivasan, O'Reilly
Perl Cookbook, Christiansen, Torkington, O'Reilly
Mastering Regular Expressions, Friedl, O'Reilly
Learning Perl on Win32 Systems,Schwartz, Olson, Christiansen, O'Reilly
Perl 5 Interactive Course, Orwant, Waite Group
Perl 5 How-To, Asbury, Glover, Humphreys, Weiss, Mathews, SOL, Waite Group
What's the best for you ? Only you can know. Depends on your learning style.
None of the above are so bad, that you would waste money in buying them.
O'Reilly books are mostly more detail oriented in anything they do. The Waite
Group one's try to be a bit more tutorial-like. Some people like and need
that. I find that the devil is in the detail. You have to look at them in
your nearest bookstore on a long, rainy Saturday afternoon. Have fun. :-)
birgitt
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 4431
**************************************