[23641] in Perl-Users-Digest
Perl-Users Digest, Issue: 5848 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Nov 23 18:05:50 2003
Date: Sun, 23 Nov 2003 15:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 23 Nov 2003 Volume: 10 Number: 5848
Today's topics:
ActiveX component cannot create object <david@digiportal.com>
Re: Bit counting benchmarks Was: count of 1s in a binar (Anno Siegel)
Re: Capture external command output line by line on Win <jwillmore@remove.adelphia.net>
Re: Capture external command output line by line on Win <ben@liddicott.com>
Re: fork question (bruno)
from data file into hash slice <eddhig22@yahoo.com>
How to convert a date to Unix time (Francesco Moi)
Re: How to convert a date to Unix time <noreply@gunnar.cc>
how to find directory <aolblowz@yahoo.com>
Re: how to find directory <noreply@gunnar.cc>
Re: how to find directory <aolblowz@yahoo.com>
Re: how to find script directory <aolblowz@yahoo.com>
if action do same action plus... <eddhig22@yahoo.com>
Re: if action do same action plus... <asu1@c-o-r-n-e-l-l.edu>
Re: if action do same action plus... <eddhig22@yahoo.com>
Re: if action do same action plus... <trammell+usenet@hypersloth.invalid>
Re: Listing Functions Called In A Script <krahnj@acm.org>
Re: Newbie Question: Best way to Extract Post Hashes? <Juha.Laiho@iki.fi>
Re: Printing to one x-y co-ord <jurgenex@hotmail.com>
Re: Problem with nlink from stat(). <kalinaubears@iinet.net.au>
Re: Problem with nlink from stat(). <kuujinbo@hotmail.com>
Re: Problem with nlink from stat(). (DJ Austin)
push @arr, slice-of-href <eddhig22@yahoo.com>
Re: push @arr, slice-of-href <usenet@morrow.me.uk>
select sub directories / File::Find? <geoff.cox@blueyonder.co.uk>
Re: select sub directories / File::Find? (Tad McClellan)
Re: select sub directories / File::Find? <geoff.cox@blueyonder.co.uk>
Re: strange hash syntax <dmn@box43.pl>
Re: strange hash syntax (Tad McClellan)
Re: Top level blocks and indentation (Anno Siegel)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 23 Nov 2003 22:42:59 GMT
From: "David Jameson" <david@digiportal.com>
Subject: ActiveX component cannot create object
Message-Id: <TJawb.20026$Hb.7095181@news4.srv.hcvlny.cv.net>
I just moved to a new machine, now running XP. I have some MS Access code
that invokes PerlScript. However, whenever I try to run it, I get the error
message
Runtime error 429
ActiveX component cannot create object
I've looked around the web and seen this generic error which appears
whenever ANY activeX component cannot be instantiated but I have not been
able to find how to solve this for ActivePerl.
I did try manually registering every DLL/OCX that I could find in the Perl
folders but that didn't help.
Does anyone know how to fix this problem with ActivePerl? ActiveState has
not replied to my email messages for support.
Thanks,
David Jameson
--
______________________
Dr. David H. Jameson
DigiPortal Software Inc
Three quarters of the mail you receive on the internet
is spam, and that's on a good day!
Stop it all with ChoiceMail Enterprise
http://www.digiportal.com
------------------------------
Date: 23 Nov 2003 22:15:33 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Bit counting benchmarks Was: count of 1s in a binary number
Message-Id: <bprbi5$m3n$1@mamenchi.zrz.TU-Berlin.DE>
Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote in comp.lang.perl.misc:
> [A complimentary Cc of this posting was sent to
> Anno Siegel
> <anno4000@lublin.zrz.tu-berlin.de>], who wrote in article
> <bpnmtk$fja$1@mamenchi.zrz.TU-Berlin.DE>:
> > Not an attempt to revive this thread (it *was* a good one)
>
> Ok, so let *me* attempt to revive it. ;-)
>
> > I just want
> > to mention that I have code that compiles, in either Perl or C, the
> > mask/shift/add-method (thread-insiders know what I mean) according to
> > the current word length. By itself it doesn't quite make a CPAN module,
> > but if anyone wants to make use of it, it's at
> >
> > http://www.tu-berlin.de/zrz/mitarbeiter/anno4000/clpm/bench.bitcount
>
> I do not see the *other* optimization I (kinda ;-) mentioned used:
>
> "MASKING" is required only on steps when "the step number" is a
> power of 2 (so only with 1-bit, 2-bit, 4-bit, 16-bit, 256-bit etc
> "nibbles").
I think I see what you mean, overflow cannot occur on some steps, so
we don't care if spurious additions happen on the side as long as we
mask off the results eventually.
I don't quite see how you arrive at the particular step numbers that
require masking, and applied blindly to my code-generator they appear
to give the wrong result. That's very preliminary, I'll pursue it
further... or maybe not :)
Anno
------------------------------
Date: Sun, 23 Nov 2003 11:11:28 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Capture external command output line by line on Windows 98
Message-Id: <20031123061127.2ce9032e.jwillmore@remove.adelphia.net>
On Thu, 20 Nov 2003 16:24:35 +0200
"Dib Urim" <DibUrim@hotmail.com> wrote:
> I'm trying to Capture external command output and error line by
> line. I wrote this example witch work excellent on Windows 2000:
>
> open(PROC,"DIR 2>&1 |");
> while(<PROC>) {
> print ("LINE:$_");
> }
> close(PROC);
>
> But on Windows 98 it don't do nothing!
> I'm user perl 5.6.1 activestate 625.
> I need to display the output line by line and not all at once
> so I can't use system command.
> How can I implement it on windows 98 ?
For an idiomatic Perl solution, type:
perldoc -q "STDERR"
This will produce perlfaq8, which approaches the question ...
"How can I capture STDERR from an external command?"
You could also use Google, using the following keywords:
"comp.lang.perl.misc STDERR capture"
This query gives, again, idiomatic Perl solutions. For OS specific
solutions, use whatever command you execute at the command line in the
system call.
This question has been asked and answered before - so the solution is
available to you :-)
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
The right half of the brain controls the left half of the body.
This means that only left handed people are in their right mind.
------------------------------
Date: Sun, 23 Nov 2003 12:14:04 +0000 (UTC)
From: "Ben Liddicott" <ben@liddicott.com>
Subject: Re: Capture external command output line by line on Windows 98
Message-Id: <bpq8ac$dub$1@hercules.btinternet.com>
Hi Dib,
I really don't know whether you can do this in Win98. Sorry.
I suggest you try a Windows newsgroup.
--=20
Cheers,
Ben Liddicott
"Dib Urim" <DibUrim@hotmail.com> wrote in message =
news:bpq07c$dos$1@news2.netvision.net.il...
> Hello Ben,
>=20
> Thank for you quick replay.
> What abut command/utils that are not in the command interpreter.
> Specially I need to capture the output/error of utility called =
rsync.exe
------------------------------
Date: 23 Nov 2003 12:47:06 -0800
From: bskorepa@yahoo.com (bruno)
Subject: Re: fork question
Message-Id: <f542e1ac.0311231247.6c6219eb@posting.google.com>
> I have found fork() to be unreliable on ActivePerl, in the same way as
> you. Can I suggest you use system(1, $0, @some args)...
Thanks, I'll try that,
Bruno.
------------------------------
Date: Mon, 24 Nov 2003 08:26:19 +1100
From: Edo <eddhig22@yahoo.com>
Subject: from data file into hash slice
Message-Id: <3FC125FB.7030604@yahoo.com>
Hello
I need to grap a few lines of records from a comma delimited data file,
the second field is the key and the rest of the line to the right of the
key are the data associated with this key.
open FH, "/dir/.../file.txt" or die $!,"\n";
tie my (%all), 'Tie::IxHash';
put the file into %all;
tie my (%section), 'Tie::IxHash';
while (<FH>){
get the 20 records from %all starting from the 'n' record
or from key 'x' into a sorted hash %section
}
how can it be done?
thank you
------------------------------
Date: 23 Nov 2003 08:34:46 -0800
From: francescomoi@europe.com (Francesco Moi)
Subject: How to convert a date to Unix time
Message-Id: <5b829932.0311230834.1246f9d4@posting.google.com>
Hello.
I want to convert a date (e.g. '20 january 2001') to Unix
time.
Is there any function, or must I create my own one?
Thank you very much.
------------------------------
Date: Sun, 23 Nov 2003 17:48:18 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: How to convert a date to Unix time
Message-Id: <bpqolk$1qf7oj$1@ID-184292.news.uni-berlin.de>
Francesco Moi wrote:
> I want to convert a date (e.g. '20 january 2001') to Unix
> time.
>
> Is there any function, or must I create my own one?
There is a module:
use Date::Parse;
my $date = '20 january 2001';
my $unixtime = localtime str2time($date);
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sun, 23 Nov 2003 14:39:56 -0500
From: lucas <aolblowz@yahoo.com>
Subject: how to find directory
Message-Id: <faqdnf7mv6aWkFyi4p2dnA@golden.net>
I'm running my script from various places on the hard drive. How can I find
the directory that the script actually sits.
Say if my script is in /home/lucas/script
and I run it from /home/lucas/dl/temp
Is there a way to find the /home/lucas/script???
thx
--
lucas
-------------------------
Perl Coder since 2001
shift || die;
-------------------------
------------------------------
Date: Sun, 23 Nov 2003 20:46:28 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: how to find directory
Message-Id: <bpr34b$1rao22$1@ID-184292.news.uni-berlin.de>
lucas wrote:
> I'm running my script from various places on the hard drive. How
> can I find the directory that the script actually sits.
>
> Say if my script is in /home/lucas/script
> and I run it from /home/lucas/dl/temp
>
> Is there a way to find the /home/lucas/script???
You posted almost the same question a few hours ago, and you got
guidance. Why did you start this new thread??
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sun, 23 Nov 2003 17:58:39 -0500
From: lucas <aolblowz@yahoo.com>
Subject: Re: how to find directory
Message-Id: <LPydnRLCN_IDplyi4p2dnA@golden.net>
I appologized in the other thread. I was not sure it if it had posted,
because I couldn't find it, and it was not in my 'Outbox'
--
lucas
-------------------------
Perl Coder since 2001
shift || die;
-------------------------
------------------------------
Date: Sun, 23 Nov 2003 14:49:39 -0500
From: lucas <aolblowz@yahoo.com>
Subject: Re: how to find script directory
Message-Id: <faqdnfvmv6bPklyi4p2dnA@golden.net>
Thanks for both your reply's. And I appologize for posting this twice. I
thought this one didn't go through.
--
lucas
-------------------------
Perl Coder since 2001
shift || die;
-------------------------
------------------------------
Date: Mon, 24 Nov 2003 05:39:41 +1100
From: Edo <eddhig22@yahoo.com>
Subject: if action do same action plus...
Message-Id: <3FC0FEED.6020808@yahoo.com>
Hello
not sure if the title is correct but after some reading, I could not
find the answer
if ( check( \@arr1, \@arr2 ) > ( sort {$a <=> $b} @top3 )[0]){
push @top3, check (\@arr1, \@arr2);
}
sub check {
...
returns a number
}
thanks
------------------------------
Date: 23 Nov 2003 18:55:20 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: if action do same action plus...
Message-Id: <Xns943C8DA1E1417asu1cornelledu@132.236.56.8>
Edo <eddhig22@yahoo.com> wrote in news:3FC0FEED.6020808@yahoo.com:
> Hello
> not sure if the title is correct but after some reading, I could not
> find the answer
what is the question?
>
> if ( check( \@arr1, \@arr2 ) > ( sort {$a <=> $b} @top3 )[0]){
> push @top3, check (\@arr1, \@arr2);
> }
>
> sub check {
> ...
> returns a number
> }
>
> thanks
you are welcome.
Sinan.
--
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov
------------------------------
Date: Mon, 24 Nov 2003 06:35:56 +1100
From: Edo <eddhig22@yahoo.com>
Subject: Re: if action do same action plus...
Message-Id: <3FC10C1C.9090603@yahoo.com>
A. Sinan Unur wrote:
> Edo <eddhig22@yahoo.com> wrote in news:3FC0FEED.6020808@yahoo.com:
>
>
>>Hello
>>not sure if the title is correct but after some reading, I could not
>>find the answer
>
>
> what is the question?
>
>
>> if ( check( \@arr1, \@arr2 ) > ( sort {$a <=> $b} @top3 )[0]){
>> push @top3, check (\@arr1, \@arr2);
>> }
>>
>>sub check {
>> ...
>> returns a number
>>}
>>
>>thanks
>
>
> you are welcome.
>
> Sinan.
sorry, it is check( \@arr1, \@arr2 ) is calculated twice, how to make
the code more effecient.
sorry for deleting the original post after re-thinking a more complete
question in a different thread.
------------------------------
Date: Sun, 23 Nov 2003 19:34:24 +0000 (UTC)
From: "John J. Trammell" <trammell+usenet@hypersloth.invalid>
Subject: Re: if action do same action plus...
Message-Id: <slrnbs22u0.5lg.trammell+usenet@hypersloth.el-swifto.com.invalid>
On Mon, 24 Nov 2003 05:39:41 +1100, Edo <eddhig22@yahoo.com> wrote:
> not sure if the title is correct but after some reading, I could not
> find the answer
>
> if ( check( \@arr1, \@arr2 ) > ( sort {$a <=> $b} @top3 )[0]){
> push @top3, check (\@arr1, \@arr2);
> }
>
> sub check {
> ...
> returns a number
> }
Not sure what the question is, but here's my take on the code:
# if the value of check(@arr1,@arr2) is greater than the
# smallest value in @top3, push it onto @top3
if ( check( \@arr1, \@arr2 ) > ( sort {$a <=> $b} @top3 )[0]){
push @top3, check (\@arr1, \@arr2);
}
If check() is an expensive calculation, it may be worth it
to do something like (untested):
my $tmp = check(\@arr1, \@arr2);
my $min = (sort {$a <=> $b} @top3)[0];
push(@top3,$tmp) if $tmp > $min;
------------------------------
Date: Sun, 23 Nov 2003 18:13:18 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Listing Functions Called In A Script
Message-Id: <3FC0F8C1.ED5620AA@acm.org>
Hal Vaughan wrote:
>
> John W. Krahn wrote:
> >
> > perldoc B::Xref
>
> Thanks. I looked that up. But I couldn't find anything before 5.8.2 -- is
> there anything for earlier verisions?
I believe that the B::Xref module was added in Perl 5.005_03.
John
--
use Perl;
program
fulfillment
------------------------------
Date: Sun, 23 Nov 2003 19:17:00 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: Newbie Question: Best way to Extract Post Hashes?
Message-Id: <bpr0ri$k4v$1@ichaos.ichaos-int>
"Eric J. Roode" <REMOVEsdnCAPS@comcast.net> said:
>awilhite@cableone.net (Andrew) wrote in news:9b7dcecd.0311211429.3c7a7735@posting.google.com:
>> I am a Perl newbie and I was wondering if anyone could tell me the
>> best way to extract expected post keys and values from websites?
[...]
>I have been a web programmer for eight years, and I have no clue what you
>mean by "expected post keys and values". Can you give some more details
>about what you are trying to do?
For some reason his wording made slight problems for me as well, but
what he apparently wants to write is software that:
- downloads a HTML form
- parses the form to determine which fill-in elements it contains
- somehow generate data for those elements
- submits the filled-in form appropriately
Now, the hard parts here are
- to determine what data is requested by the form
- what are the allowable values for free-text fields
- what all can be filled in to the form, if it happens to be something
that is partially generated by client-side technologies while the user
is filling it
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)
------------------------------
Date: Sun, 23 Nov 2003 16:55:53 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Printing to one x-y co-ord
Message-Id: <tE5wb.8990$Cw.2797@nwrddc02.gnilink.net>
Default@IO_Error_1011101.xyz wrote:
[...]
>> I am guessing you are looking for Curses, but it is quite difficult
>> to tell because your description is somewhat lacking in clarity.
>
> Hmmm curses ok, never heard of it.. ill check that out thanks.
> See i just want to print something then run a time consuming function,
> then backspace over what was just printed, so that i can print
> something new in the same place on the screen as the previously
> printed char.
Yep, you are looking for the Curses module.
Keep in mind that many output devices don't support a backspace or the
backspace may have a totally different meaning on them (tapes, braile or
voice readers, TTYs, paper printers, sockets or pipes, ...).
Therefore you need to use the proper action for each device. The Curses
module provides an abstract interface for each action if supported by that
device.
jue
------------------------------
Date: Sun, 23 Nov 2003 22:06:43 +1100
From: Sisyphus <kalinaubears@iinet.net.au>
Subject: Re: Problem with nlink from stat().
Message-Id: <3fc0958a$0$1722$5a62ac22@freenews.iinet.net.au>
DJ Austin wrote:
>
> #!/usr/local/bin/perl
>
> ($dev, $ino, $mode, $nlink) = stat ('.') unless $nlink;
> print "nlnk = $nlink\n";
> print "dev = $dev\n";
> print "ino = $ino\n";
> print "mode = $mode\n";
>
Hmmm .... 'perldoc perlport' states that 'device' and 'inode' are
meaningless on Win32.
> The problem is: the nlink is always 1 no matter what directory/file I
> stat.
>
On my various builds (5.6 and 5.8) of perl on both my Win2k laptop
(NTFS) and Win2k desktop (FAT), I find that stat() seems to be always
returning a value of 1 for nlink.
Can't really help much ... I wondered whether different behaviour might
be explained in terms of different file systems - NTFS versus FAT, for
instance - but the fact that my laptop and my desktop are giving the
same results would suggest that isn't a factor.
I found in 'perlport', in the section headed 'link OLDFILE,NEWFILE', the
statement that "hard links are implemented on Win32 (Windows NT and
Windows 2000) under NTFS only."
But there's no specific mention of 'nlink' in the section of perlport
that deals with the stat function.
Anyway - just thought I'd mention all that in case it triggers something
for you.
Cheers,
Rob
--
To reply by email u have to take out the u in kalinaubears.
------------------------------
Date: Sun, 23 Nov 2003 21:40:00 +0900
From: ko <kuujinbo@hotmail.com>
Subject: Re: Problem with nlink from stat().
Message-Id: <bpqa1b$8jm$1@pin3.tky.plala.or.jp>
DJ Austin wrote:
> Hi All,
>
> I'm losing a lot of hair with this problem, and I hope some of you had
> bumped into this problem before and can help me out.
>
> I have 2 Windows XP machines. One desktop and one laptop. I installed
> both cygwin (www.cygwin.com) and perl (www.activestate.com) late last
> year (sometime in November 2002) on both computers, and everything
> works fine.
Are you sure that you didn't install Cygwin's Perl last year? Try a
'perl -v' on the desktop to verify. You'll get something like this:
This is perl, v5.8.0 built for cygwin-multi-64int
...
[snip code]
> The problem is: the nlink is always 1 no matter what directory/file I
> stat.
>
> Please note that the same test case above runs fine (as expected) on
> my desktop. I notice that I have perl 5.6.1, and my laptop has 5.8.1,
> so I uninstall 5.8.1 and install 5.6.1 thinking that it has conflict
> with cygwin. Problem still exists. So, next step is to remove cygwin
> and re-install it again thinking it was corrupted. No go.
>
> Please note that when I install cygwin, I did not include perl, so I
> know cygwin doesn't install perl, and my perl comes from
> activestate.com installation.
Created a test script and Cygwin Perl returned the link count.
To use ActiveState Perl, created a symlink:
$ ln -s c:/perl/bin/perl.exe /usr/local/bin/perl
$ perl -v
This is perl, v5.8.1 built for MSWin32-x86-multi-thread
...
Then the test script gave the same result you are getting - a link count
of one for everything.
HTH - keith
------------------------------
Date: 23 Nov 2003 11:58:12 -0800
From: djonli@yahoo.com (DJ Austin)
Subject: Re: Problem with nlink from stat().
Message-Id: <d2365135.0311231158.545e16f1@posting.google.com>
First of all, thanks for everybody who responded to my inquiry via
post or direct email. I appreciate it.
Keith is correct, the issue is with ActiveState perl installation.
Installing perl from cygwin.com solves my problem. Thanks, Keith!
------------------------------
Date: Mon, 24 Nov 2003 06:32:49 +1100
From: Edo <eddhig22@yahoo.com>
Subject: push @arr, slice-of-href
Message-Id: <3FC10B61.9040809@yahoo.com>
Hello
the code is part of a bigger code, I tried to do my best without asking
this question the code is trimed for readability.
I don't know how to push @arr, slice-of-href in the for loop in the sub
scan below.
sub scan (\@\%);
my @top3;
tie my %hash, 'Tie::IxHash';
my @arr = (01, 00, 11);
the %hash values are the same data type as the @arr values
sub scan (\@\%) {
my ($arr, $hash) = @_;
my @k = keys %$hash;
for( 0 .. keys(%$hash) - @$arr+0 ) {
my @v = @hash{ (keys %hash)[ $_ .. $_+2 ] };
if ( check( \@arr, \@v ) > ( sort {$a <=> $b} @top3 )[0]){
push @top3, href with the %$hash keys and values
}
}
}
print Dumper @top3;
sub check returns a number
thank you
------------------------------
Date: Sun, 23 Nov 2003 19:36:18 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: push @arr, slice-of-href
Message-Id: <bpr27i$mhn$1@wisteria.csv.warwick.ac.uk>
Edo <eddhig22@yahoo.com> wrote:
> I don't know how to push @arr, slice-of-href in the for loop in the sub
> scan below.
>
> sub scan (\@\%) {
> my ($arr, $hash) = @_;
> my @k = keys %$hash;
> for( 0 .. keys(%$hash) - @$arr+0 ) {
> my @v = @hash{ (keys %hash)[ $_ .. $_+2 ] };
> if ( check( \@arr, \@v ) > ( sort {$a <=> $b} @top3 )[0]){
> push @top3, href with the %$hash keys and values
push @top3, { @v };
> }
> }
> }
Ben
--
Like all men in Babylon I have been a proconsul; like all, a slave ... During
one lunar year, I have been declared invisible; I shrieked and was not heard,
I stole my bread and was not decapitated.
~ ben@morrow.me.uk ~ Jorge Luis Borges, 'The Babylon Lottery'
------------------------------
Date: Sun, 23 Nov 2003 14:36:30 GMT
From: Geoff Cox <geoff.cox@blueyonder.co.uk>
Subject: select sub directories / File::Find?
Message-Id: <uqg1svc2ndg75fbhkag6nmd99js0339l3v@4ax.com>
Hello,
The following code will put the addresses from the multiple versions
of the nominal_3.htm files in a series of sub directories of
d:/addresses into a file called addresses-file ...
but I cannot see how to create a different file for each sub
directory...How do I select each different sub directory using
File::Find? Ideas please?! I
Thanks
Geoff
use warnings;
use strict;
use File::Find;
my $dir = 'd:/addresses';
find ( sub {
if ($_ =~ /nomination_3.htm/) {
print ("$_ \n");
open (IN, $_) or die ("Cannot open file $_ \n");
my $line = <IN>;
while (defined($line = <IN>)) {
if ($line =~ /<TD>(.*?)<\/TD>/i) {
open (OUT, ">>d:/addresses/addresses-file");
print OUT ("$1 \n");
}
}
}
}, $dir);
close (OUT);
close (IN);
------------------------------
Date: Sun, 23 Nov 2003 10:38:27 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: select sub directories / File::Find?
Message-Id: <slrnbs1ok3.mfe.tadmc@magna.augustmail.com>
Geoff Cox <geoff.cox@blueyonder.co.uk> wrote:
> How do I select each different sub directory using
> File::Find? Ideas please?!
by examining the $File::Find::dir variable in the find subroutine,
or by using a relative rather than absolute filename in open().
> open (OUT, ">>d:/addresses/addresses-file");
open (OUT, ">>addresses-file") or
die "could not open addresses file in the $File::Find::dir directory $!";
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 23 Nov 2003 18:02:11 GMT
From: Geoff Cox <geoff.cox@blueyonder.co.uk>
Subject: Re: select sub directories / File::Find?
Message-Id: <1ft1svsriendbp9ftbbkvitk7mp89q950v@4ax.com>
On Sun, 23 Nov 2003 10:38:27 -0600, tadmc@augustmail.com (Tad
McClellan) wrote:
>Geoff Cox <geoff.cox@blueyonder.co.uk> wrote:
>
>> How do I select each different sub directory using
>> File::Find? Ideas please?!
>
>
>by examining the $File::Find::dir variable in the find subroutine,
>or by using a relative rather than absolute filename in open().
>
>
>> open (OUT, ">>d:/addresses/addresses-file");
>
>
> open (OUT, ">>addresses-file") or
> die "could not open addresses file in the $File::Find::dir directory $!";
Many thanks Tad
Geoff
------------------------------
Date: Sun, 23 Nov 2003 12:25:39 +0100
From: "Darek N" <dmn@box43.pl>
Subject: Re: strange hash syntax
Message-Id: <bpq5ef$o8g$1@nemesis.news.tpi.pl>
>> $somehash{$somekey} = [ @somearray];
>You can index it like this:
>
> # Third element of the stored array:
> my $e = $somehash{$somekey}[2]; ## need to derefernce !!
This is not quite right because of the dereferencing action:
my $e = $somehash{$somekey}->[2];
Darek
------------------------------
Date: Sun, 23 Nov 2003 08:43:32 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: strange hash syntax
Message-Id: <slrnbs1hsk.m47.tadmc@magna.augustmail.com>
Darek N <dmn@box43.pl> wrote:
>> # Third element of the stored array:
>> my $e = $somehash{$somekey}[2]; ## need to derefernce !!
>
> This is not quite right
Yes it is.
> because of the dereferencing action:
> my $e = $somehash{$somekey}->[2];
perldoc perlref
One more thing here. The arrow is optional _between_
brackets subscripts...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 23 Nov 2003 18:31:05 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Top level blocks and indentation
Message-Id: <bpqud9$dkh$1@mamenchi.zrz.TU-Berlin.DE>
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote in comp.lang.perl.misc:
[...]
> I have taken to using double braces, '{{' and '}}' to delimit top
> level blocks that aren't indented.
>
> ... I'd like to test the waters ...
Thanks to all who replied, and also to those who through not replying
expressed an indifference which I am free to interpret as a lack of
outrage. (Whee... what *have* I been reading lately?) Let me reply
summarily in my own followup.
First off, no one doubted that avoiding indentation is desirable under
some circumstances. Someone (sorry, lost attribution) objected that
indentation wouldn't hurt when the lines were short enough. But the
loss of line space isn't the only reason. You can usually (without
indentation) scan down the left margin of a Perl source to find sub
definitions (and run-time actions). I want to preserve that state
through some routine situations.
Also, there were no technical objections. I mean, those double braces
actually compile an extra block (it isn't optimized away). By all
accounts that should be equivalent to a single block, but this is
Perl, after all...
No-one really loved my tentative solution (I didn't expect that), and
some expressed outright queasiness. Not to be dismissive, but that was
also to be expected. After all, it goes against ingrained indentation
habits (that took some pain to learn). But so will anything that avoids
top-level indentation; short of a source filter there will be a visible
"{" with no indentation to follow. Using "{{" doubles the offence,
but that *can* be read as "this is deliberate".
Tad suggested using a standard comment instead of doubling the braces,
and Tassilo (whom I thank for his kind words), even suggested a source
filter to balance-check them. However, the room after the opening and
closing brace(s) of a block is sometimes used for source-related comments,
I don't want to occupy the place.
Tad'd personal comment
> I don't find it particularly annoying or distressing.
> _I_ wouldn't do it that way, but that probably just me.
also neatly summs up the general tenor.
I'll go on with the double braces for a while. For published code there
ought to (and will) be a comment near the first occurence that explains
the praxis.
Anno
------------------------------
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.
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 5848
***************************************