[25957] in Perl-Users-Digest
Perl-Users Digest, Issue: 8176 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 16 09:05:31 2005
Date: Thu, 16 Jun 2005 06:05:09 -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 Thu, 16 Jun 2005 Volume: 10 Number: 8176
Today's topics:
Re: "END failed" -- but why? (Anno Siegel)
Re: Decorator pattern - IO::file <bugbear@trim_papermule.co.uk_trim>
Re: Decorator pattern - IO::file (Anno Siegel)
Re: Decorator pattern - IO::file <bugbear@trim_papermule.co.uk_trim>
is there a useful book? <black_dream@web.de>
Re: is there a useful book? <mark.clementsREMOVETHIS@wanadoo.fr>
Re: Mac Users cannot access perl CGI <tintin@invalid.invalid>
Re: Mac Users cannot access perl CGI <sherm@dot-app.org>
Re: Module to match file names against a wildcard spec? <lawshouse.public@btconnect.com>
Re: Module to match file names against a wildcard spec? (Anno Siegel)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 16 Jun 2005 08:46:00 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: "END failed" -- but why?
Message-Id: <d8re88$kqt$2@mamenchi.zrz.TU-Berlin.DE>
Chris <chriss@activestate.com> wrote in comp.lang.perl.misc:
> Matthias Urlichs wrote:
> > One of my programs exits with these lines, after its last line has
> > executed:
> >
> > Use of uninitialized value in null operation, <F> line 1796.
> > Undefined subroutine &main:: called, <F> line 1796.
> > END failed--call queue aborted at tools/mig.strings line 1, <F> line 1796.
> >
> > Well, that's helpful. :-/
> > Any ideas on how to figure out *where* and *why* that happens would be
> > greatly appreciated.
> >
>
> Are you able to reproduce it in a smaller script (less than 1800 lines)?
> If not, can you post your END block(s)?
"<F> line 1796" refers to a file opened by the program. The only
source line referenced is line 1, but I would take that with a grain
of salt.
Anno
------------------------------
Date: Thu, 16 Jun 2005 09:41:14 +0100
From: bugbear <bugbear@trim_papermule.co.uk_trim>
Subject: Re: Decorator pattern - IO::file
Message-Id: <42b13b2b$0$2039$ed2e19e4@ptn-nntp-reader04.plus.net>
Brian McCauley wrote:
> bugbear wrote:
>
>> I would (greatly) like to be able to do something a LOT
>> like pipes, without using (well...) pipes.
>>
>> I simple want to be able to build sequence
>> of filters (at least if they were on Unix
>> they would be called filters)
>
>
> Perl calls them IO layers.
>
>> It appears that I can achive this by embodying
>> my filter code in the read() method of IO::file
>> (actually, IO;:handle withing IO::file).
>
>
> You could do that - but you'd be better off using tied filehandles (if
> you need pre-5.8.x compatibility) or PerlIO layers otherwise.
>
Thanks for the pointer.
As far as I (and google ...) can find,
Perl layers appear to be a 'C' thing.
http://www.faqs.org/docs/perl5int/x197.html
I was think of something much simpler - e.g.
a comment filtering "layer", which should be
a 1 liner regex (in the right place...) in perl.
Obviously the "1 liner" needs to be wrapped
in the right way...
Do you have any more help for me?
BugBear
------------------------------
Date: 16 Jun 2005 10:48:28 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Decorator pattern - IO::file
Message-Id: <d8rlds$pu5$1@mamenchi.zrz.TU-Berlin.DE>
bugbear <bugbear@trim_papermule.co.uk_trim> wrote in comp.lang.perl.misc:
> Brian McCauley wrote:
> > bugbear wrote:
> >
> >> I would (greatly) like to be able to do something a LOT
> >> like pipes, without using (well...) pipes.
> >>
> >> I simple want to be able to build sequence
> >> of filters (at least if they were on Unix
> >> they would be called filters)
> >
> >
> > Perl calls them IO layers.
> >
> >> It appears that I can achive this by embodying
> >> my filter code in the read() method of IO::file
> >> (actually, IO;:handle withing IO::file).
> >
> >
> > You could do that - but you'd be better off using tied filehandles (if
> > you need pre-5.8.x compatibility) or PerlIO layers otherwise.
> >
>
> Thanks for the pointer.
> As far as I (and google ...) can find,
> Perl layers appear to be a 'C' thing.
> http://www.faqs.org/docs/perl5int/x197.html
>
> I was think of something much simpler - e.g.
> a comment filtering "layer", which should be
> a 1 liner regex (in the right place...) in perl.
Comments of what language? Only the most simple-minded comment parsers
are one-liners. Usually, comment parsing and string (quote) parsing
must be done in conjunction. That's more than one line for most target
languages.
> Obviously the "1 liner" needs to be wrapped
> in the right way...
Okay, here is a tie() example (I haven't played with IO layers yet).
#!/usr/bin/perl
use strict; use warnings; $| = 1;
tie *FH, 'Filter', "/tmp/x";
print while <FH>;
exit;
######################################################################
package Filter;
use Tie::Handle;
use base 'Tie::StdHandle';
sub READLINE {
my $fh = shift;
my $l = $fh->SUPER::READLINE or return;
$l =~ s/#.*//; # strip comments (or non-comments, see above)
$l;
}
__END__
Anno
------------------------------
Date: Thu, 16 Jun 2005 12:40:19 +0100
From: bugbear <bugbear@trim_papermule.co.uk_trim>
Subject: Re: Decorator pattern - IO::file
Message-Id: <42b16524$0$41904$ed2619ec@ptn-nntp-reader03.plus.net>
Anno Siegel wrote:
>>
>>Thanks for the pointer.
>>As far as I (and google ...) can find,
>>Perl layers appear to be a 'C' thing.
>>http://www.faqs.org/docs/perl5int/x197.html
>>
>>I was think of something much simpler - e.g.
>>a comment filtering "layer", which should be
>>a 1 liner regex (in the right place...) in perl.
>
>
> Comments of what language? Only the most simple-minded comment parsers
> are one-liners. Usually, comment parsing and string (quote) parsing
> must be done in conjunction. That's more than one line for most target
> languages.
Agreed. Comment stripping was an arbitrary example;
I was thinking of assembler/postscript/Perl comments
which (unusually, as you point out) are detectable by
a trivial regexp.
>>Obviously the "1 liner" needs to be wrapped
>>in the right way...
>
>
> Okay, here is a tie() example (I haven't played with IO layers yet).
>
> #!/usr/bin/perl
> use strict; use warnings; $| = 1;
>
> tie *FH, 'Filter', "/tmp/x";
>
> print while <FH>;
> exit;
> ######################################################################
>
> package Filter;
> use Tie::Handle;
> use base 'Tie::StdHandle';
>
> sub READLINE {
> my $fh = shift;
> my $l = $fh->SUPER::READLINE or return;
> $l =~ s/#.*//; # strip comments (or non-comments, see above)
> $l;
> }
> __END__
>
> Anno
Thank you *very* much. I'll start from here. Can I assume that If I
overdefine read() (in StdHandle) the other methods (e.g. readline)
are defined in terms of read() - or am I being optimistic?
BugBear
------------------------------
Date: Thu, 16 Jun 2005 11:20:18 +0200
From: Alexander Teves <black_dream@web.de>
Subject: is there a useful book?
Message-Id: <d8rg6k$vv9$03$1@news.t-online.com>
hi there,
i used to code in ruby and purebasic, and i want to take a look at perl. so,
is there any nice tutorial / book / website or something? e.g. for ruby
there is the programming guide which is for free.
best regards
------------------------------
Date: Thu, 16 Jun 2005 12:44:02 +0200
From: Mark Clements <mark.clementsREMOVETHIS@wanadoo.fr>
Subject: Re: is there a useful book?
Message-Id: <7vfqptx7u0ok$.1v77zlh532fsq$.dlg@40tude.net>
On Thu, 16 Jun 2005 11:20:18 +0200, Alexander Teves wrote:
> hi there,
>
> i used to code in ruby and purebasic, and i want to take a look at perl. so,
> is there any nice tutorial / book / website or something? e.g. for ruby
> there is the programming guide which is for free.
>
> best regards
http://learn.perl.org
but more generally, it wouldn't have hurt you to Google for this.
Mark
------------------------------
Date: Thu, 16 Jun 2005 19:17:02 +1200
From: "Tintin" <tintin@invalid.invalid>
Subject: Re: Mac Users cannot access perl CGI
Message-Id: <LH9se.7932$U4.1091386@news.xtra.co.nz>
"GMI" <Admin@GoMonitor.com> wrote in message
news:11b1jnehnu8a963@corp.supernews.com...
>I am devaloping a web site on IIS on a Win2K sysem. the system works fine
> when using IE on Windows but Mac users get an error message that say it
> does
> not recognize ".PL"
>
> Also when I am using FireFox as a browsed it starts to download the HTML
> contents as a file!!
> Any help is appreciated.
Your question is off topic, but I'll bet you that the Mac Browser (Safari?)
and Firefox are both doing the correct things, whereas IE is only working
due to its inability to conform to standards.
------------------------------
Date: Thu, 16 Jun 2005 06:11:06 -0400
From: Sherm Pendley <sherm@dot-app.org>
Subject: Re: Mac Users cannot access perl CGI
Message-Id: <87ll5alih1.fsf@dot-app.org>
"GMI" <Admin@GoMonitor.com> writes:
> I am devaloping a web site on IIS on a Win2K sysem. the system works fine
> when using IE on Windows but Mac users get an error message that say it does
> not recognize ".PL"
>
> Also when I am using FireFox as a browsed it starts to download the HTML
> contents as a file!!
You are not returning the correct MIME type from your CGI.
sherm--
------------------------------
Date: Thu, 16 Jun 2005 09:47:17 +0100
From: Henry Law <lawshouse.public@btconnect.com>
Subject: Re: Module to match file names against a wildcard spec?
Message-Id: <jpe2b1lkj7jm1ct5u82pp0r045eak6af99@4ax.com>
On Wed, 15 Jun 2005 23:10:03 -0700, Chris <chriss@activestate.com>
wrote:
>Henry Law wrote:
>> Yes, I'm familiar with File::Find and there are two reasons why I'm
>> not using it. Firstly I can't prevent it from scanning sub-trees
>>
>> include C:\some\path
>> exclude C:\some\path\huge\subdirectory
>
>File::Find has a "preprocess" option that may help here. From the
>documentation:
Ah, I'd looked at this but not in the right way; I see what you mean.
If I want to exclude certain subdirectories from being processed I can
drop them out of the list that the "preprocess" subroutine returns.
Neat; thank you.
>It looks like the problem is in your regex. You put:
>
> my $excl_spec = "F:/NOTES/DATA/.*\.NSF";
>
>which matched "F:/NOTES/DATA/ABBC2.NSF" and
>"F:/NOTES/DATA/FURBLE/ABBC2.NSF". The reason it matched the second
>string is because of the ".*" - you probably don't want to match ANY
>character. For instance, you probably don't want to match the directory
>separator "/". Try it with:
>
> my $excl_spec = "F:/NOTES/DATA/[^/]*\.NSF";
Yes, I can see that now. I'm re-casting the exclusion checking to
split the checked file name and the exclude specification into their
component parts (F:, NOTES, DATA, .*\.NSF) and then I can immediately
tell if the two aren't at the same depth in the tree, before doing
regex-type matches on the respective parts. I've not shot all the
bugs yet but it looks promising.
Thanks for all the help.
--
Henry Law <>< Manchester, England
------------------------------
Date: 16 Jun 2005 09:51:16 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Module to match file names against a wildcard spec?
Message-Id: <d8ri2k$nif$2@mamenchi.zrz.TU-Berlin.DE>
Henry Law <news@lawshouse.org> wrote in comp.lang.perl.misc:
> I've searched CPAN and the web for an answer to this without finding
> anything (but I confess I found it hard to structure a query so I may
> have missed something). Maybe someone can point me in the right
> direction.
>
> A Perl program I'm writing reads in file names from a specified
> directory amd then processes them (how doesn't matter). If
> subdirectories are found they are processed recursively.
>
> I need to be able to restrict its operation by specifying groups of
> files via a wild card; the control syntax looks a bit like this
>
> # Include contents of C:\foo and all its subdirectories
> include C:\foo
> # But don't do text files in the root of \foo
> exclude C:\foo\*.txt
> # Note that text files elsewhere in the \foo tree, such as
> # C:\foo\bar\bletch.txt should be processed.
>
> (The above is Windows, obviously, but I need to write this so it works
> on Unix too).
>
> I'm getting really tangled up trying to turn my exclude specifications
> into regexes which I can then use to exclude relevant files; not only
> am I not a very experienced Perl coder but the logic of the task turns
> out to be quite complicated. For example
Do you actually need that?
A glob-to-regex translator wouldn't be very hard to write (I think).
The hard part is getting the specification right for all kinds of
file system with so many variants of glob around. That is probably
why there isn't one in Regex::Common, where it would belong.
However, since everything you want to include or exclude are actual
files in a file system (right?), you don't have to do that, you can
use Perl's glob() function together with File::Find. Here's a sketch:
use File::Find;
my $dir = 'c:\foo';
my $exclude = 'C:\foo\*.txt'
my %exclude;
@exclude{ glob( $exclude)} = ();
find sub {
return if exists $exclude{ $File::Find::name};
# process file
}, $dir;
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.
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 8176
***************************************