[17939] in Perl-Users-Digest
Perl-Users Digest, Issue: 99 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 19 14:05:37 2001
Date: Fri, 19 Jan 2001 11:05:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <979931113-v10-i99@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 19 Jan 2001 Volume: 10 Number: 99
Today's topics:
Re: $FindBin::Bin for modules nobull@mail.com
ANNOUNCE: Parse::RecDescent 1.80 (Damian Conway)
Re: Another newbie <ren.maddox@tivoli.com>
Re: Cache control: no Cache ?? for parts of a html file nobull@mail.com
Re: Call C function in XS from C function in the same X (Ilya Zakharevich)
CGI Timeout - Avoiding <tamer@nospam.yahoo.co.uk>
Re: Child processes don't clean up (defunct processes l (Villy Kruse)
Re: Hello. I'm back. (Abigail)
Re: help with 4-arg select <uri@sysarch.com>
How much time does a subroutine call take? tigra@sky.deep.ru
Re: how to match a space character vupt@yahoo.com
Re: How to number of directories and dates on NT <sumera.shaozab@lmco.com>
HTML::Form Examples adms1@cts.com
Re: HTML::TokeParser - Help please! <bart.lateur@skynet.be>
Just got mod_perl working: <a565a87@my-deja.com>
Re: List Current Processes in Win32 marc_w@my-deja.com
Re: lookbehind in s///g (Gary E. Ansok)
MIME Lite Problem (Rand Simberg)
MIME::Parser Finding decoded files <drewhead.nospam@drewhead.org>
Re: More questions about pattern matching <mischief@velma.motion.net>
My hash slice is yielding a syntax error.. please help <brannon@lnc.usc.edu>
Re: Newbie questions: variable scope (Tad McClellan)
Re: opening file into filter nobull@mail.com
Re: Pattern Matching Problem <mischief@velma.motion.net>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 19 Jan 2001 17:57:00 +0000
From: nobull@mail.com
Subject: Re: $FindBin::Bin for modules
Message-Id: <u9hf2vctn7.fsf@wcl-l.bham.ac.uk>
"John Lin" <johnlin@chttl.com.tw> writes:
> > "John Lin" writes:
> >
> > > My module needs to know where itself is stored because it wants
> > > to open a data file stored in the same directory.
>
> <nobull@mail.com> wrote:
> > A module can access its own filename using __FILE__.
>
> "Rafael Garcia-Suarez" wrote:
> > Use the %INC hash, described in perlvar.
> When main.pl is evoked in the same directory
>
> in A.pm: __FILE__ = A.pm
> in A.pm: $INC{'A.pm'} = A.pm
>
> When main.pl is evoked in different directory
>
> in A.pm: __FILE__ = /john/lib/A.pm
> in A.pm: $INC{'A.pm'} = /john/lib/A.pm
If __FILE__ is returning a relative filename then you must have
relative directory names in @INC. If you have realtive directory
names in @INC then you shouldn't ever do chdir(). If you never do
chdir() there's no problem using a relative path to find the data file.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 19 Jan 2001 18:05:05 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: ANNOUNCE: Parse::RecDescent 1.80
Message-Id: <t6h0jj9frk1p91@corp.supernews.com>
Keywords: perl, module, release
==============================================================================
Release of version 1.80 of Parse::RecDescent
==============================================================================
NAME
Parse::RecDescent - generate recursive-descent parsers
DESCRIPTION
RecDescent incrementally generates top-down recursive-descent text
parsers from simple yacc-like grammar specifications. It provides:
* Regular expressions or literal strings as terminals (tokens),
* Multiple (non-contiguous) productions for any rule,
* Repeated, optional and alternate subrules within productions,
* Late-bound (run-time dispatched) subrules
* Full access to Perl within actions specified as part of the grammar,
* Simple automated error reporting during parser generation and parsing,
* The ability to commit to, uncommit to, or reject particular
productions during a parse,
* Incremental extension of the parsing grammar (even during a parse),
* Precompilation of parser objects,
* User-definable reduce-reduce conflict resolution via
"scoring" of matching productions.
See the file "RecDescent.pod" for excruciating detail on all of this.
LIMITATIONS
* There's no support for parsing directly from an input stream.
* The generator doesn't handle left-recursion.
PREREQUISITES
Parse::RecDescent requires Text::Balanced, which is included in the
distribution.
INSTALLATION
It's all pure Perl, so just put the .pm files in their appropriate
local Perl subdirectories.
CHANGES AND FUTURE DEVELOPMENT
This readme refers to versions 1.XX.
For details of changes, refer to the file Changes.
Version 2.00 will provide a cleaner interface and better
parsing performance.
AUTHOR
Damian Conway (damian@csse.monash.edu.au)
COPYRIGHT
Copyright (c) 1997-2000, Damian Conway. All Rights Reserved.
This module is free software. It may be used, redistributed
and/or modified under the terms of the Perl Artistic License
(see http://www.perl.com/perl/misc/Artistic.html)
==============================================================================
CHANGES IN VERSION 1.80
- Fixed Save so that saved parsers can still be used after saving
(thanks Supun)
- Fixed bug in line number tracking (thanks Theo)
- Fixed bug in (s /pat/) shorthand (thanks Julien)
- Improved docs on <rulevar> (thanks Steve)
==============================================================================
AVAILABILITY
Parse::RecDescent has been uploaded to the CPAN
and is also available from:
http://www.csse.monash.edu.au/~damian/CPAN/Parse-RecDescent.tar.gz
==============================================================================
------------------------------
Date: 19 Jan 2001 11:08:21 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Another newbie
Message-Id: <m3ae8nlbay.fsf@dhcp11-177.support.tivoli.com>
bernard.el-hagin@lido-tech.net (Bernard El-Hagin) writes:
> On Fri, 19 Jan 2001 15:08:23 GMT, mattfenn@my-deja.com
> <mattfenn@my-deja.com> wrote:
>
> >I'm having trouble matching each word for only one vowel. Any
> >ideas?
>
> A rather simple, but ugly way of counting the number of vowels:
Here's a simple, less ugly way:
$_ = "abba";
my $vowels = tr/aeiou//; # I excluded "y" as the OP didn't mention it
print "Too many vowels in $_\n" if $vowels > 1;
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: 19 Jan 2001 18:12:13 +0000
From: nobull@mail.com
Subject: Re: Cache control: no Cache ?? for parts of a html file ?
Message-Id: <u9d7djctga.fsf@wcl-l.bham.ac.uk>
Seansan <comctl@yahoo.com> writes something totally unrealated to Perl:
> I have a page and when it loads. The contents of the page is not
> supposed to be cached at all. SO i use cache control and pragma is no
> cache
> But in the html page gif images are used. I DO want these to be cached,
> because the page is refreshed quite foten and this only makes the page
> slower.
HTTP headers effecting caching effect only the document they appear
in.
Can you explain the thought process that lead you to the conclusion
that this may be even remotely related to Perl?
> Any idea on how to solve this??
Whatever it was you did to configure your server to emit headers
preventing the HTML document from being cached, don't do it (or do the
opposite) for the others.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 19 Jan 2001 16:28:21 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Call C function in XS from C function in the same XS file
Message-Id: <949pv5$5p7$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to James Richardson
<time4tea@monmouth.com>],
who wrote in article <948jt4$6vj$1@slb7.atl.mindspring.net>:
> #include <perl.h>
> #include <XSUB.h>
> #include <stdio.h>
>
> void plusone( int i, int times ) {
> if ( times == 0 )
> return
> printf("%d",i);
> plusone(++i, --times);
> }
>
> MODULE = Rubbish PACKAGE = Rubbish
>
> void
> PlusOne(SV *i, SV *times)
> PPCODE:
> {
> plusone(SvIV(i), SvIV(times));
> /* But you can't call PlusOne(i,times), because its name is
> XS_Rubbish_PlusOne (check the output from nm) */
> XPUSHs(&PL_sv_undef);
> }
No need for all these complications. After you defined your C
function void plusone( int i, int times ), just ask XS to make the
Perl entry point for it:
MODULE = Rubbish PACKAGE = Rubbish
void plusone( int i, int times );
[Assuming that Perl supports ANSI declarations, as it does with 5.6.0.]
Hope this helps,
Ilya
------------------------------
Date: Fri, 19 Jan 2001 17:23:18 -0000
From: "Tamer" <tamer@nospam.yahoo.co.uk>
Subject: CGI Timeout - Avoiding
Message-Id: <lL_96.1035$vH6.18313@news6-win.server.ntlworld.com>
I have a script which keeps timing out with the following error:
CGI Timeout
The specified CGI application exceeded the allowed time for processing. The
server has deleted the process.
I wonder if the server has been set up with a very short timeout as this
occurs after 10 seconds or less.
Is there anyway I can avoid this error , increase the timeout setting , or
at least trap the error?
Many thanks
Ian
------------------------------
Date: 19 Jan 2001 16:29:28 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: Child processes don't clean up (defunct processes left) even though SIGCHLD does wait()
Message-Id: <slrn96gqr6.kq7.vek@pharmnl.ohout.pharmapartners.nl>
On Fri, 19 Jan 2001 03:37:27 -0000,
Chris Stith <mischief@velma.motion.net> wrote:
>
>There are ways to reap using Perl waitpid() without waitpid() being
>implemented on the system, such as keeping around an array of your child
>pids and looping through it with a blocking waitpid() for each child pid.
Once you run out of children to wait for the wait won't block anymore.
If a child is still running the wait will block until one of them
terminates. and if the main process has important thing to do then it
won't be able to.
A technique sometimes used is to double fork, that is fork a child and
let this child fork a grand child and immidiatly terminate. The
original process can then wait for the child without risk of the wait
blocking. The grandchild will now be orphaned, and won't therefore
become a zombie when it terminates. The init process will see to it
that this doesn't happen.
Following C code to illustrate. Perl should be similar.
if ( (pid = fork() == 0 ) {
/* Child process */
if ( fork() == 0 ) {
/* Grand child process */
childprocess();
_exit();
}
_exit();
} else if ( pid > 0 ) {
while ( wait(NULL) != pid ) continue;
}
/* Parent process continues here */
Villy
------------------------------
Date: 19 Jan 2001 16:46:27 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Hello. I'm back.
Message-Id: <slrn96grr2.inj.abigail@tsathoggua.rlyeh.net>
Tad McClellan (tadmc@augustmail.com) wrote on MMDCXCVIII September
MCMXCIII in <URL:news:slrn96gbgj.6rf.tadmc@tadmc26.august.net>:
..
.. I collect perl-related scorefiles (several have been posted here
.. in the past, some I requested in email), I wouldn't have thought
.. to look in an article with this Subject though...
The best addition I've made to my score file in a long, long time:
[*]
Score:: -9999
X-Newsreader: Microsoft Outlook Express
clpm becomes a lot more readable, and none of the other groups I frequent
is effected.
Abigail
--
perl -le 's[$,][join$,,(split$,,($!=85))[(q[0006143730380126152532042307].
q[41342211132019313505])=~m[..]g]]e and y[yIbp][HJkP] and print'
------------------------------
Date: Fri, 19 Jan 2001 16:54:42 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: help with 4-arg select
Message-Id: <x7r91zxz1p.fsf@home.sysarch.com>
>>>>> "RL" == Reuben Logsdon <rlogsdon@eris.io.com> writes:
RL> the socket/bind/connect sequence is okay, i'm worried about read and
RL> write. perl has the 4-part select for that, but the docs aren't really
RL> clear at all. has anyone got a 4-part select to work? are there code
RL> samples anywhere, docs, etc? or other approaches for safe network
RL> communications?
use IO::Select, Event.pm, or POE. using 4 arg select is a pain. and yes
it works fine.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Fri, 19 Jan 2001 18:48:28 GMT
From: tigra@sky.deep.ru
Subject: How much time does a subroutine call take?
Message-Id: <94a25p$sq7$1@nnrp1.deja.com>
Hi.
I've just got interested in benchmarking of sub calls in perl. To make
the affairs worse I put the sub's code into a separate package and then
eval it. So this is what I was going to test for my own purposes. The
code follows:
=cut ##################
#!/usr/bin/perl -w
use strict;
use Time::HiRes qw(gettimeofday);
use constant LOOPS => 1e6;
my ($before, $elapsed);
$before = gettimeofday;
for(1..LOOPS) {
}
$elapsed = gettimeofday - $before;
print "Empty loop elapsed $elapsed sec.\n";
eval 'package Foo; use strict; sub loop {}';
$before = gettimeofday;
for(1..LOOPS) {
Foo::loop();
}
$elapsed = gettimeofday - $before;
print "Loop with sub calls elapsed $elapsed sec.\n";
my $func = \&{Foo::loop};
$before = gettimeofday;
for(1..LOOPS) {
&$func;
}
$elapsed = gettimeofday - $before;
print "Loop with referenced sub calls elapsed $elapsed sec.\n";
=cut ##################
The result was amazing:
Empty loop elapsed 4.39593291282654 sec.
Loop with sub calls elapsed 9.86866104602814 sec.
Loop with referenced sub calls elapsed 8.85909807682037 sec.
Without "my $foo;" it produces:
Empty loop elapsed 2.15937805175781 sec.
Loop with sub calls elapsed 8.32374000549316 sec.
Loop with referenced sub calls elapsed 7.37839591503143 sec.
So the question is: Does this imply that calling subroutines in a loop
don't gobble much time in respect to doing everything in plain mode? And
does this mean that using
for(...) {&code_that_says_blah_blah}
instead of
for(...) {blah-blah}
is better if former is more convinient?
Regards,
Sergey
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 19 Jan 2001 17:43:09 GMT
From: vupt@yahoo.com
Subject: Re: how to match a space character
Message-Id: <949ubb$p1t$1@nnrp1.deja.com>
Hi Ren,
Thanks very much for your information.
I guess I just wanted a way to determine if a string contains a
nonblank character.
I fixed up my function and so $length = tr/a-zA-Z0-9//;
will return a nonzero for a string that contains a letter or number.
But I your $string =~/[^ ]/ is much better.
And so just to make things complete, here is the function.
#
#Return true if the string is empty or made of blanks
sub isEmptyString{
($string)=@_;
if($string =~/[^ ]/){
print "not empty";
return 0;
}else{
print "empty";
return 1;
}
}
>
>> $length = tr/a-zA-Z/0-9/;
>
> Not sure exactly what you think this does, but what it actually does
> is replace all the letters in the string with numbers (mostly 9s) and
> sets length to the number of such letters so changed. This does have
> the effect of returning a positive number for any string that has
> (had) letters in it. But try it with a string that only has numerals
> and see what you get.
>
> --
> Ren Maddox
> ren@tivoli.com
>
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 19 Jan 2001 16:47:27 GMT
From: smax <sumera.shaozab@lmco.com>
Subject: Re: How to number of directories and dates on NT
Message-Id: <949r2s$lml$1@nnrp1.deja.com>
Sorry, This message was sent to the wrong group.
SAS
In article <949mtl$hme$1@nnrp1.deja.com>,
smax <sumera.shaozab@lmco.com> wrote:
> Hi,
>
> I am tring to write a "C" program to run on an NT server. It has to
go
> through each directory and check its subdirectories. If there are 100
> subdirectories then move the entire directory to another location. If
> there are less than 100 then check the directory's modification date.
> If the date is greater than 2 days then move it to another location.
> Otherwise leave that directory where it is.
>
> How can I capture the number of each subdirectories and modification
> date of the parent directory using C programming?
>
> Any help is appreciated
>
> Thanks!
>
> SAS
>
> Sent via Deja.com
> http://www.deja.com/
>
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 19 Jan 2001 18:33:30 GMT
From: adms1@cts.com
Subject: HTML::Form Examples
Message-Id: <94a19q$s27$1@nnrp1.deja.com>
I am looking for example scripts using the HTML::Form module. Or, if
anyone could provide a example in a reply.
Thank You!
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 19 Jan 2001 18:03:33 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: HTML::TokeParser - Help please!
Message-Id: <o10h6tsql2l35jmh1co4btp5qoh9mou034@4ax.com>
badass101@my-deja.com wrote:
>I am currently doing this:
>
> my $parser = HTML::TokeParser->new(\$c);
> while (my $token = $parser->get_token) {
> next unless $token->[0] eq 'T';
> if (($token->[1] ne "")&&($token->[1] ne "\n")
>&&($token->[1] ne " ")){
>
> print $token->[1];
> }
> }
>
>but it returns very spaced out text.
It can. The text token it returns, needn't e just one character, or one
logical unit. It is not uncommon that a piece of html like
<H1>This is a number 1 header</H1>
to return a list of tokens (one at a time) like this:
S h1 {} <H1>
T This is a numb
T er 1 header
E h1 </H1>
So, in my example, the text is randomly split into two.
What can you do? Collect all text, by appending it to a string:
my $alltext = '';
while (my $token = $parser->get_token) {
$alltext .= $token->[1] if $token->[0] eq 'T';
}
Replace every " " with "\240"; or just a space for all I care.
Finally, do
tr/\240 \t\n\r/ /s;
on this string, and print it out.
--
Bart.
------------------------------
Date: Fri, 19 Jan 2001 17:43:13 GMT
From: Rob <a565a87@my-deja.com>
Subject: Just got mod_perl working:
Message-Id: <949ubf$p21$1@nnrp1.deja.com>
Exciting. The following is for anyone's information if wanted:
LoadModule perl_module modules/ApacheModulePerl.dll
works well if CPAN 5.6.0 source, and an Apache 1.3.14 binary installer
distribution, is used with mod_perl-1.24_01 source.
Thanks again, everyone.
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 19 Jan 2001 16:01:31 GMT
From: marc_w@my-deja.com
Subject: Re: List Current Processes in Win32
Message-Id: <949ocj$j87$1@nnrp1.deja.com>
This can be gotten via Win32::Perflib which is included as a part of
ActiveState's perl distribution. If you can, try to find a script that
does it, and borrow the code. I believe the ActivePerl docs actually
have a example to do exactly this in them..if not search on the web.
Win32::Perflib is rather deep/complex to understand, so you may want to
use what the other's mentioned in their reply's(Shelling out to some
sort of .exe and capturing the output).
Shelling out IMHO is generally cheating, but it is quick, crude, and
efficient(to make anyways).
marc
In article <9477qg$71l$1@whqnews01.infinium.com>,
"jg" <Jerry_Geist@infinium.com> wrote:
> Can someone point me in the direction of how to get the entire list of
> processes which are showing in the Windows NT Task Manager into a
list.
> After I close a program, it sometimes leaves child tasks running and
I need
> to check and see whether it exists or not.
>
> Thanks .
>
>
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 19 Jan 2001 17:19:52 GMT
From: ansok@alumni.caltech.edu (Gary E. Ansok)
Subject: Re: lookbehind in s///g
Message-Id: <949svo$q46@gap.cco.caltech.edu>
In article <slrn96f1dq.8jg.abigail@tsathoggua.rlyeh.net>,
Abigail <abigail@foad.org> wrote:
>Bart Lateur (bart.lateur@skynet.be) wrote on MMDCXCVII September MCMXCIII
>in <URL:news:7lue6tgb1rq25b92s8hhbhhtgtgol5k23l@4ax.com>:
>%% By comparison: a similar problem occurs when you test length of $` in
>%% each substitution. You'll see the old length, not the substituted one.
>
>Since $` is the part of the string before the match, and since s///
>replaces what matches, how could $` change, let alone its length change?
I found this one a while ago:
#! perl -w
$_ = '1x2x3';
s/x/foo()/eg;
print "foo: $_\n";
sub foo { # replace each 'x' with the number of digits before it
my $d = $`;
my $c = ($` =~ tr/0-9//);
return "<$c>";
}
You get an output of '1<1>2<2>3' -- $`, on the second substitution, is
set to '1x2' (part of the original string), rather than '1<1>2' (part
of the string as modified so far). Surprising at first, but one can
understand the logic behind it.
(By the way, if I don't assign $` to a variable, tr/// sees '1' on both
substitutions. This is definitely wrong, and I've perlbug'd it.
That's what I originally was testing with this code.)
-- Gary Ansok
------------------------------
Date: Fri, 19 Jan 2001 18:22:16 GMT
From: simberg.interglobal@trash.org (Rand Simberg)
Subject: MIME Lite Problem
Message-Id: <3a68847c.63263620@nntp.ix.netcom.com>
OK, I'm using MIME Lite, and am having a problem getting it to work.
I put in the following debug statement:
"About to set path to miguelruiz/dmrc_2001-01-18-131618.txt,
contained in $data_directory/$file"
just before setting
Path => $data_directory/$file,
There's another debug statement immediately following this one, but it
doesn't print--the script seems to die there. The path is valid,
because a different routine uses it successfully just before. Any
ideas what the problem is?
************************************************************************
simberg.interglobal.org * 310 372-7963 (CA) 307 739-1296 (Jackson Hole)
interglobal space lines * 307 733-1715 (Fax) http://www.interglobal.org
"Extraordinary launch vehicles require extraordinary markets..."
Replace first . with @ and throw out the "@trash." to email me.
Here's my email address for autospammers: postmaster@fbi.gov
------------------------------
Date: Fri, 19 Jan 2001 12:45:25 -0500
From: Drew Dowling <drewhead.nospam@drewhead.org>
Subject: MIME::Parser Finding decoded files
Message-Id: <3A687D35.A2E2371A@drewhead.org>
I'm writing a little program that will take a file sent via email (MIME
attachments), decode the mail message to the file, and then do stuff
with it. I've found MIME::Tools to be quite useful, specifically the
MIME::Parser. I can easily receive and decode MIME attachments to a tmp
dir. What I don't seem to be able to do is access the names of the
files that my parser just created. I've looked through perldoc of
Tools, Parser, Entity, and various subclasses, but can't seem to find
(or clue in) to a method of getting the files that I just created. I'd
rather not have to look in the tmp directory since I may have more than
one iteration running at any given time, and I'd rather not bother
building unique tmp dirs to hold all contents for the duration of the
iteration. Obviously the module recognized what the filenames were
since it just wrote them.
If I process a message that contains two files, foo and bar; I'd like to
be able to access those two file names as an array slice. Am I missing
something easy here?
------------------------------
Date: Fri, 19 Jan 2001 16:14:52 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: More questions about pattern matching
Message-Id: <t6gpvse3dmt25a@corp.supernews.com>
Peter J. Acklam <jacklam@math.uio.no> wrote:
> Chris Stith <mischief@velma.motion.net> writes:
>> #####################################################
>> #!/usr/bin/perl -w
>> use strict;
>> my $good_ip = 0;
>> [...]
>> ###############################################
> Creating a regex that matches the integers from 0 to 255 is easy:
> [0-1]?[0-9]?[0-9] # 0 .. 199
> | 2[0-4][0-9] # 200 .. 249
> | 25[0-5] # 250 .. 255
Yes, I admit I wrote my IP regex in haste and it is broken.
I only tested it ad-hoc, and stated that. It was a mistake
to post something that broken.
The only change my fully regex code needs, though, is this:
my $section = '(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9]))';
My previous regex-only code did miss the following valid ranges
of IP addresses due to a hasty oversight in the regex on my part:
206-209
216-219
226-229
236-239
246-249
*eats hat*
Why you felt the need to quote a completely different example
I still don't know. If you wish to criticize my code, please
quote the section you are criticizing. I would consider that
a common courtesy.
Chris
--
Christopher E. Stith
Disclaimer: Actual product may not resemble picture in ad in any way.
------------------------------
Date: Fri, 19 Jan 2001 19:03:52 GMT
From: Terrence Brannon <brannon@lnc.usc.edu>
Subject: My hash slice is yielding a syntax error.. please help
Message-Id: <lbsnmf749z.fsf@lnc.usc.edu>
The commented out line is yielding a syntax error. I was simply trying
to create a hash slice. Why isn't it working? Thanks in advance.
use strict;
my @a = qw(1 1 2 4 5);
my %H;
for my $a (@a) {
$H{$a}++;
}
#%H{@a} = {@a};
print join ':', keys %H;
--
Terrence Brannon
Carter's Compass...
I know I'm on the right track when by deleting code I'm adding
functionality.
------------------------------
Date: Fri, 19 Jan 2001 17:01:15 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Newbie questions: variable scope
Message-Id: <slrn96gm0j.7l0.tadmc@tadmc26.august.net>
L-X-Q <lxq79@hotmail.com> wrote:
>
>Btw, I got this message when tried to lookup for 'our':
>[bk@mercury perl]$ perldoc -f our
>No documentation for perl function `our' found
You have one of:
1) a version of perl < 5.6 (when our() was added to perl)
or
2) a broken install of perl 5.6
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 19 Jan 2001 18:51:16 +0000
From: nobull@mail.com
Subject: Re: opening file into filter
Message-Id: <u97l3rctd2.fsf@wcl-l.bham.ac.uk>
bolero92@my-deja.com writes:
> how can I open a file to a filter
> so that the input to the filter contains
> no more than 2 newline?
> open (FILE, "what should I put here |");
You are explicitly asking for a shell script (i.e. non-Perl) solution
a problem that is trivial in Perl. Why? And why are you asking in a
Perl newsgroup?
open (FILE, "head -2 readme.txt |");
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 19 Jan 2001 16:55:22 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Pattern Matching Problem
Message-Id: <t6gsbq35400u08@corp.supernews.com>
Abigail <abigail@foad.org> wrote:
> Rick Delaney (rick.delaney@home.com) wrote on MMDCXCVIII September
> MCMXCIII in <URL:news:3A67C133.B9A65188@home.com>:
> If the datafile consists of records, each started with and ended with
> <--n-->, with the numbers in sequence and nothing else in the file,
> you could do:
> $/ = "<--1-->\n";
> my $record = "";
> while (<>) {
> $record .= $_ . <>;
> $record =~ s!$/!!g;
> do_something_with $record;
> }
> continue {
> $/ =~ s/(\d+)/$1 + 1/e;
> $record = "";
> }
That's the best use of a continue block I've seen in a long time.
Updating $/ on the fly in a loop is a nice solution here.
--
Christopher E. Stith
Disclaimer: Actual product may not resemble picture in ad in any way.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 99
*************************************