[15735] in Perl-Users-Digest
Perl-Users Digest, Issue: 3148 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 24 14:10:43 2000
Date: Wed, 24 May 2000 11:10:21 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <959191821-v9-i3148@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 24 May 2000 Volume: 9 Number: 3148
Today's topics:
Loginsystem <e9ravn@etek.chalmers.se>
RE: Loginsystem <canq@MailAndNews.com>
Re: Loginsystem (brian d foy)
LWP::Simple problem <rcorfiel@lucent.com>
Re: LWP::Simple problem <richard@corfield.SPAMMIT.f9.co.uk>
Re: Matching Question (Peter J. Acklam)
Re: Matching Question <red_orc@my-deja.com>
Re: Matching Question nobull@mail.com
Re: my algorythms suck <mjcarman@home.com>
Re: newbie question - relative addressing <gi59@dial.pipex.com>
Re: newbie question - relative addressing <jeff@vpservices.com>
Newbie: libpcap and tcpdump question hgraef@my-deja.com
Re: Objects, SUPER:: and parameters... <aqumsieh@hyperchip.com>
Re: odd behavior printing after randomizing an array fr <iltzu@sci.invalid>
Re: odd behavior printing after randomizing an array fr <sue@pennine.com>
Re: odd behavior printing after randomizing an array fr (Abigail)
Re: opinion on libwww (Jerome O'Neil)
Re: opinion on libwww <rootbeer@redcat.com>
Re: package naming <rootbeer@redcat.com>
Passing an array to a regexp (Ben Hambidge)
Re: Passing an array to a regexp <iltzu@sci.invalid>
Re: Passing an array to a regexp (Abigail)
Perl Extention <lambertm@sfcommerce.com>
Re: Perl Extention <lambertm@sfcommerce.com>
Problem with XS nosmo_1@my-deja.com
Re: Proxy authentication solution CPAN module <rjbragg@my-deja.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 24 May 2000 17:52:32 +0200
From: Robert Rehammar <e9ravn@etek.chalmers.se>
Subject: Loginsystem
Message-Id: <392BFAC0.B67177@etek.chalmers.se>
I need to make omesort of loginsystem with cgi/perl. I suppose this is
done with cookies or somting but cannot find any useful information on
the web. Anyone know how this is done, or where I can find some
documentation on it.
regards,
-- =
Robert Rehammar mail:ravn@gmx.net web:come.to/ravn
Fyrverkareg. 11 e9ravn@etek.chalmers.se =
etek.chalmers.se/~e9ravn
L=E4genhet 20 phone:031-182556 ICQ:19846915
413 21 GBG 0736-594691 finger e9ravn for more
nfo
------------------------------
Date: Wed, 24 May 2000 11:57:02 -0400
From: Canq <canq@MailAndNews.com>
Subject: RE: Loginsystem
Message-Id: <393757EB@MailAndNews.com>
You could use .htaccess/.htpasswd
and a cgi program to create new users.... I just made
something like this recently... do contact me if you
need it.
Cheers.
>===== Original Message From e9ravn@etek.chalmers.se =====
>I need to make omesort of loginsystem with cgi/perl. I suppose this is
>done with cookies or somting but cannot find any useful information on
>the web. Anyone know how this is done, or where I can find some
>documentation on it.
>
>regards,
------------------------------------------------------------
http://hostfree.cc/cgi-bin/referer.cgi?hostinfo
Quality hosting plans.
------------------------------------------------------------
------------------------------
Date: Wed, 24 May 2000 13:10:53 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Loginsystem
Message-Id: <brian-ya02408000R2405001310530001@news.panix.com>
In article <392BFAC0.B67177@etek.chalmers.se>, e9ravn@etek.chalmers.se posted:
> I need to make omesort of loginsystem with cgi/perl. I suppose this is
> done with cookies or somting but cannot find any useful information on
> the web. Anyone know how this is done, or where I can find some
> documentation on it.
then you haven't seen the CGI Meta FAQ :)
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>
------------------------------
Date: Wed, 24 May 2000 16:11:10 +0100
From: Richard Corfield <rcorfiel@lucent.com>
Subject: LWP::Simple problem
Message-Id: <392BF10E.FE71C03D@lucent.com>
Hi,
I thought I would quickly write a short, simple bit of code this morning that
reads URLs from a text file and then retrieves the web pages. I've done this
before using:
$content = get $URL ;
..and it worked fine then. However I ran into problems in that this time it
wasn't retrieving the (different) web pages. After spending much longer on this
than I'd originally planned it seems that I can retrieve pages from within the
company intranet, but not from outside using this method. A typical error I get
is:
500 Can't connect to www.drudgereport.com:80 (Interrupted system call)
<URL:http://www.drudgereport.com/>
...from the line of code:
getprint "http://www.drudgereport.com/";
The site is clearly up, because Netscape grabs the page in a flash.
Is my observation merely coincidental, or relevant? If so I guess I probably
need to start looking at LWP::UserAgent ... in which case I've run out of
available time to spend on this problem...
Thanks in advance.
Richard
------------------------------
Date: Wed, 24 May 2000 18:27:16 +0100
From: "Richard Corfield" <richard@corfield.SPAMMIT.f9.co.uk>
Subject: Re: LWP::Simple problem
Message-Id: <jhUW4.1235$%5.64967@wards>
OK ..... so I've discovered it's because of the proxy server I'm behind -
any ideas of how to get round this as painlessly as posssible?
Thanks
Richard
Richard Corfield <rcorfiel@lucent.com> wrote in message
news:392BF10E.FE71C03D@lucent.com...
> Hi,
>
> I thought I would quickly write a short, simple bit of code this morning
that
> reads URLs from a text file and then retrieves the web pages. I've done
this
> before using:
>
> $content = get $URL ;
>
> ..and it worked fine then. However I ran into problems in that this time
it
> wasn't retrieving the (different) web pages. After spending much longer on
this
> than I'd originally planned it seems that I can retrieve pages from within
the
> company intranet, but not from outside using this method. A typical error
I get
> is:
>
> 500 Can't connect to www.drudgereport.com:80 (Interrupted system call)
> <URL:http://www.drudgereport.com/>
>
> ...from the line of code:
>
> getprint "http://www.drudgereport.com/";
>
> The site is clearly up, because Netscape grabs the page in a flash.
>
> Is my observation merely coincidental, or relevant? If so I guess I
probably
> need to start looking at LWP::UserAgent ... in which case I've run out of
> available time to spend on this problem...
>
> Thanks in advance.
>
> Richard
------------------------------
Date: 24 May 2000 18:37:05 +0200
From: jacklam@math.uio.no (Peter J. Acklam)
Subject: Re: Matching Question
Message-Id: <wkvh039a6m.fsf@math.uio.no>
amerar@my-deja.com writes:
> I need to do a series of pattern matchings. For example, I need to
> search a string for 9 digits in a row, or I need to find a pattern of
> 2 digits, followed by letters FR followed by 5 more digits.
>
> Anyhow, upon finding the match, I need to extract the pattern from the
> string.
>
> I can find out whether or not a pattern is in the string as in this
> case: ($x =~ /\d{9}/)
>
> But how do I extract the string? I do not even know where the string
> starts.......
( $matched_text ) = $x =~ /(\d{9})/;
Peter
--
$\="\n";$_='The quick brown fox jumps over the lazy dog';print +(split
//)[20,5,24,31,3,36,14,12,31,1,2,11,9,23,33,29,35,15,32,36,7,8,28,29];
------------------------------
Date: Wed, 24 May 2000 16:31:43 GMT
From: Rodney Engdahl <red_orc@my-deja.com>
Subject: Re: Matching Question
Message-Id: <8gh05f$i29$1@nnrp1.deja.com>
In article <8ggq3g$d7t$1@nnrp1.deja.com>,
amerar@my-deja.com wrote:
>
>
> Hello,
>
> Here is a dumb question. I need to do a series of pattern matchings.
> For example, I need to search a string for 9 digits in a row, or I
need
> to find a pattern of 2 digits, followed by letters FR followed by 5
more
> digits.
you do not specify here if it can be more than 9 digits (wanting just
the first 9) or if it can be more than 2 preceding digits and/or more
than 5 trailing digits, just so long as it is ##FR##### in between. it
would be nice to know that, and if the target pattern is delimited by
anything (white space, commas, etc.)
>
> Anyhow, upon finding the match, I need to extract the pattern from the
> string.
>
> I can find out whether or not a pattern is in the string as in this
> case: ($x =~ /\d{9}/)
>
> But how do I extract the string? I do not even know where the string
> starts.......
>
looks like you read perlre. you musta missed the part about the
bracketing construct ( .. ). the line below should place the first
consecutive 9 digits matched into $1, assuming that $x has a string of
at least 9 consecutive digits in it. I say at least because ##########
contains an example of #########, which matches.
$x =~ /(\d{9})/ ;
the following will result in $1 containing the string of 2
digits followed by FR followed by 5 digits, assuming that $x contains
somewhere in it a string of (at least) 2 digits, FR and (at least) 5
digits. I say (at least) because ###FR###### contains an example of
##FR#####, which matches.
$x =~ /(/d{2}FR\d{5})/ ;
Like I said, would be nice if there were white space or commas to
delimit data . . .
assuming that white space delimits, and that we are looking for nine
digits preceded and followed by white space:
$x =~ /\w(\d{9})\w/ ; # match 9 digits bounded by white space
$x =~ /\w(\d{2}FR\d{5})\w/ ; # match ##FR#####
<caveat>
if you actually execute the two lines above, a match in the second will
overwrite a match in the first, a non-match on the second will not be
reflected in $1 if there was a match on the first.
</caveat>
if you have white space delimited string, and you want to look for one
of your patterns or the other, and only care about the first match found
in the string:
$x =~ /\s((d{2}FR\d{5})|(\d{9}))\s/ ; #capture either 9 digits or 2FR5
$1 will contain the first match
$2 will contain the match if it is 2FR5
$3 will contain the match if it is 9 digits
<NOTE>
any and/or all of the above may be ugly/less than optimal, which i
freely admit. others more capable than i will likely point that out and
provide better examples.
<NOTE>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 24 May 2000 17:48:09 +0100
From: nobull@mail.com
Subject: Re: Matching Question
Message-Id: <u9snv7ki7q.fsf@wcl-l.bham.ac.uk>
amerar@my-deja.com writes:
> Here is a dumb question.
The pattern matching operator is described in the perlop manpage.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 24 May 2000 11:36:45 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: my algorythms suck
Message-Id: <392C051D.62D14BE5@home.com>
David Wall wrote:
>
> I understood the recursive version just by scanning through it,
> but the non-recursive version [Bart] posted is not as obvious to me. So
> is it a safe generalization to say that recursive algorithms are
> usually simpler but less efficient than non-recursive algorithms that
> produce the same output?
Recursion is often simpler, at least in having fewer lines of code, but
isn't necessarily slower. There are some extra hoops you have to jump
through to unwrap and inline this. (All those push()es and pop()s take
time.)
Benchmark: timing 10000 iterations of Inline, Thread...
Inline: 3 secs ( 3.15 usr 0.01 sys = 3.16 cpu)
Thread: 3 secs ( 2.58 usr 0.00 sys = 2.58 cpu)
Of course, that's just for this case, where recursion is a fairly
natural choice. Inlining may well be faster under different
circumstances, and both algorithms could probably be tweaked up a bit.
Also, Perl has no limits on recursion depth, so why not use it in spots
like this?
-mjc
------------------------------
Date: Wed, 24 May 2000 18:14:26 +0100
From: "Alan Hood" <gi59@dial.pipex.com>
Subject: Re: newbie question - relative addressing
Message-Id: <8gh2ab$5te$1@lure.pipex.net>
Thanks Jeff - I will be a bit more precise next time.
The problem seems to be that I use relative addresses. This also occurs when
I try to access files.
Is this a problem with activestate perl ?.
Is there a reference for differences between perl on Unix & NT?.
Alan Hood
Jeff Zucker wrote in message >
> use lib '/full/path/to/your/modules/dir/';
>
>at the top of your script.
>
>In the future, please use a more informative subject line for you
>postings. Thanks!
>
>--
>Jeff
------------------------------
Date: Wed, 24 May 2000 10:23:16 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: newbie question - relative addressing
Message-Id: <392C1004.CC665096@vpservices.com>
Alan Hood wrote:
>
> The problem seems to be that I use relative addresses. This also occurs when
> I try to access files.
>
> Is this a problem with activestate perl ?.
No, it is a problem in general that is particularly severe with CGI
scripts. The question is "relative to what?". Well, you say, relative
to my current working directory. Ok, what is that? It *may* be the
directory where your script is "physically" located, but then again it
may not be. When CGI scripts operate, they do so in a different
environment which may include a different setting for the current
working directory. Even outside of CGIs, some OSs define working
directory differently than you might expect. Therefore relative
directories can not be trusted. If you absolutely (ahem) must use
relative directories, use the FindBin module to determine what directory
your script actually thinks it is operating in.
> Is there a reference for differences between perl on Unix & NT?.
Start-Menu / Programs / ActivePerl / Online-Documentation
And look in the table of contents on the left for "ActivePerl-FAQ" and
the subheading under it "Windows 95/NT" and look for "Core Perl
Documents" and the subheading under it "perlport".
--
Jeff
------------------------------
Date: Wed, 24 May 2000 17:05:39 GMT
From: hgraef@my-deja.com
Subject: Newbie: libpcap and tcpdump question
Message-Id: <8gh24o$jni$1@nnrp1.deja.com>
Hi all,
can anybody tell me where the differences between the tcpdump bpf
interface and the libpcap are.
Information:
I am writing a perl script for sniffing for CDP packets.
this expression works fine with tcpdump:
tcpdump -e -i eth0 'ether[6:2] == 0x2000'
but the same filter statement in perl fails:
#some code extraction
$filtern='ether[6:2] == 0x2000';
$result = Net::Pcap::compile($pcap_t, \$filter,$filtern, 0, $mask);
It sees the packets but don't pass it to the application.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 24 May 2000 15:14:56 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: Objects, SUPER:: and parameters...
Message-Id: <7a1z2sx9n8.fsf@Merlin.i-did-not-set--mail-host-address--so-shoot-me>
Zak McGregor <zapcs@icon.co.za> writes:
> use strict;
> use Pg;
> use vars qw(@ISA);
> @ISA=qw(Pg);
It's better to use the base pragma:
use base qw/Pg/;
> my $_conn_options;
> my $_conn;
> sub new {
> my $proto = shift;
> my $class = ref($proto) || $proto;
> my $self = bless {}, $class;
> if ($self->{_conn}) {
> $self->_parse();
> }
> else {
> $self->{_conn}=$self->SUPER::connectdb("dbname=xxxxxxxxx user=xxxxxx");
> #
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this doesn't seem to get passed on... :(
> }
I don't see the reason for the if() statement. As it stands, the body of
the if() will never execute, and the else() body will always execute.
> return bless $self, "Pg";
Why are you blessing $self again? I don't see a need for that.
I tried this, and it works:
package Pg;
sub connectdb {
print "Connecting: @_.\n";
}
package A;
use strict;
use vars qw(@ISA);
@ISA=qw(Pg);
my $_conn_options;
my $_conn;
sub new {
my $proto = shift;
my $class = ref($proto) || $proto;
my $self = bless {}, $class;
if ($self->{_conn}) {
$self->_parse();
}
else {
$self->{_conn}=$self->SUPER::connectdb("dbname=xxxxxxxxx user=xxxxxx");
}
return $self;
}
package main;
my $A = new A;
__END__
Connecting: A=HASH(0x80e1720) dbname=xxxxxxxxx user=xxxxxx.
--Ala
------------------------------
Date: 24 May 2000 15:48:23 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: odd behavior printing after randomizing an array from STDIN
Message-Id: <959183074.21628@itz.pp.sci.fi>
In article <slrn8iqg1t.be8.tjla@thislove.dyndns.org>, Gwyn Judd wrote:
>I was shocked! How could Decklin Foster <fosterd@hartwick.edu>
>say such a terrible thing:
>>OK, now do it in a constant amount of space. That is, I can feed the
>>program a 10GB file and it will still work (we'll assume here you have
>>less than that much RAM.) Hint: it can be done in one line.
>
>I don't think you can do it in constant space. Look to get a randome
>line number you have to know how many lines there are. How will you know
..so obviously the answer given in the FAQ can't work? ;-)
>>> Why is the sky blue? [0]
>>
>>Magic. ;-)
>
>Actually it's the scattering effect of water particles in the atmosphere
<pedant>Air molecules. Some of those are H2O, of course, but N2 and
O2 contribute a much higher percentage.</pedant>
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla and its pseudonyms - do not feed the troll.
------------------------------
Date: 24 May 2000 09:18:58 -0700
From: Sue Spence <sue@pennine.com>
Subject: Re: odd behavior printing after randomizing an array from STDIN
Message-Id: <8ggvdi$2all@drn.newsguy.com>
In article <84BF13308AFA8255.1CFB92267BA562CA.0F5E9952FEF66BDA@lp.airnews.net>,
Kiera says...
>
>Ok, the basics: running win98 with ActivePerl (version 5.005_03,
>build 522)
>
>Am working thru the Exercises in "Learning Perl on Win32 Systems" and
>I get to the 3rd exercise in the 3rd chapter:
>
>"Write a program that reads a list of strings and then selects and
>prints a random string from the list."
>
>Easy.
>
>#!perl -w
>srand;
>print "List of strings: ";
>my @b = <STDIN>;
>print "Answer: $b[rand(@b)]";
>#__END__
>
>Right? Cept.. it didn't print anything. Not even the word "Answer:".
>No warnings, no nuthin'. Oh, and that code above is almost character
>for character from the Answer page in the book (I added the -w and the
>my - behavior didn't change when I removed them).
>
>What did change the outcome was adding a \n right before Answer:
> print "\nAnswer: $b[rand(@b)]";
>
>Ok, so I guess my question is... is this behavior specific to win98?
Maybe. It seemed "obvious" to me that you should have a "\n" on the end of your
print statement. But I tried that on Win98 with ActiveState v5.6 and that
didn't flush the buffer the way I had expected it to. Strangely, as you say,
the only thing that works is to put the newline at the beginning of the print
string. Weird. Works as expected on solaris 5.6 w/perl 5.005_02.
>Is it because of the ctrl-z needed to stop reading in strings from the
>command window? Is this documented anywhere (I've been looking but
>haven't found it yet)?
I wouldn't have thought so, but anything is possible in windoze.
------------------------------
Date: 24 May 2000 17:26:43 GMT
From: abigail@arena-i.com (Abigail)
Subject: Re: odd behavior printing after randomizing an array from STDIN
Message-Id: <8gh3cj$63o$1@news.panix.com>
On Wed, 24 May 2000 14:59:06 GMT, Gwyn Judd <tjla@guvfybir.qlaqaf.bet> wrote:
++ I was shocked! How could Decklin Foster <fosterd@hartwick.edu>
++ say such a terrible thing:
++ >Kiera <kiera@nnickee.com> writes:
++ >
++ >> #!perl -w
++ >> srand;
++ >> print "List of strings: ";
++ >> my @b = <STDIN>;
++ >> print "Answer: $b[rand(@b)]";
++ >> #__END__
++ >
++ >OK, now do it in a constant amount of space. That is, I can feed the
++ >program a 10GB file and it will still work (we'll assume here you have
++ >less than that much RAM.) Hint: it can be done in one line.
++
++ I don't think you can do it in constant space. Look to get a randome
++ line number you have to know how many lines there are. How will you know
++ how many lines there are till you have read them all in? Ah but you say
++ I can simply read them all in and then reopen the file and read them
++ again to the calculated line. But I say, what if I was doing this?:
You can do it in constant space if you may make the assumption the
strings have at most a certain, pre determined, length.
perl -nwe '$a = $_ if rand $. < 1; END {print $a}'
The math is simple. Suppose there are N lines on the input. The chance that
line M will be the line printed is:
N
1 ___ k-1 1 M 1
_ * | | --- = - * - == -
M | | k M N N
k=M+1
And that's for all M.
Abigail
------------------------------
Date: Wed, 24 May 2000 16:19:07 GMT
From: jerome@activeindexing.com (Jerome O'Neil)
Subject: Re: opinion on libwww
Message-Id: <%hTW4.6412$QB4.474904@news.uswest.net>
arpith@my-deja.com elucidates:
>
> Is that a good idea ? To have many clients ? I think the reason for
> using different clients on many domains was to use different IPs to
> avoid getting banned from search engines, but does it generally
> increase the processing time ? Or is it a more efficient method of
> doing things ?
Well, no. The way to avoid getting banned is to write a well behaved
crawler. Then people will think well of you for being considerate
of their server's time.
The bennefit of many clients is that you can crawl many sites. But that
is not to say that you should crawl one site completely, and then crawl
the next site.
Take a "breadth before depth" approach, and it will aid your efforts.
Good Luck!
------------------------------
Date: Wed, 24 May 2000 09:20:04 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: opinion on libwww
Message-Id: <Pine.GSO.4.10.10005240909070.23375-100000@user2.teleport.com>
On Wed, 24 May 2000 arpith@my-deja.com wrote:
> > Don't neglect the Robot Rules. Cheers!
> Are there any laws ? :)
First Law of Websurfing Robots: A Websurfing Robot shall always read and
obey the /robots.txt file.
Second Law of Websurfing Robots: A Websurfing Robot shall always read and
obey the /robots.txt file.
Third Law of Websurfing Robots: A Websurfing Robot shall always read and
obey the /robots.txt file.
That should about cover it. :-)
> Anyway, I read this in someone else's resume:
>
> "Finding out the Urls for 20 search engines was done . The script
> operates on an client server basis . One server script can have
> numerous client scripts running in different domains . The server
> scripts hands out necessary keywords , logs submission time , spidered
> time and clicked time."
>
> Is that a good idea ?
I have no idea; I can hardly understand it. :-)
> To have many clients ? I think the reason for using different clients
> on many domains was to use different IPs to avoid getting banned from
> search engines,
Which - if true - sounds evil. If you're doing something that should get
you banned, trying to evade the ban is not fair. (But if you obey the
robot rules and don't overload a site with requests, you shouldn't be in
danger of being banned.)
> but does it generally increase the processing time ? Or is it a more
> efficient method of doing things ?
If you want greater efficiency, consider doing requests in parallel with
the ParallelUA. But if you need to find out more about making web robots
in general, you may be getting off-topic for this newsgroup, since those
don't have to be written in Perl. In general, if the question would be the
same were the program written in another language, it's not a Perl
question.
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 24 May 2000 11:03:10 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: package naming
Message-Id: <Pine.GSO.4.10.10005241057100.14618-100000@user2.teleport.com>
On Wed, 24 May 2000, Kenneth Lee wrote:
> Suppose I'm subclassing A::B, would it be better to name the subclass
> A::B::C, or A::C?
It depends. :-)
> A is a non-existent package, there's no A.pm et al.
> I just want keep my modules alone from the public ones.
Then call them MyPrivate::A::B::C, or NOT_PUBLIC::A::B::C, or whatever.
That should work. Of course, you should be prepared to rename them if
you'll ever make them public.
> I know the name is nothing to do with inheritance, I just want to see
> which one people usually choose, and happy with, and looks nice, and..
Well, now you're adding criteria!
> An example would be the HTML::* modules. There's no HTML.pm, and
> HTML::HeadParser is a subclass of HTML::Parser.
Not that there's anything wrong with that. It could have been called
HTML::Parser::Head, but I don't see any need for that name. In the end,
though, it's a judgment call.
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 24 May 2000 15:24:29 GMT
From: newsmay2000@ordinate.co.uk (Ben Hambidge)
Subject: Passing an array to a regexp
Message-Id: <392bf388.2052011@news.freeserve.net>
I have the following condition:
if ( $x =~ /^[one|two|three|four]/ ) { ...}
However, I would like to test for values in an array; for example:
@array = ( "one", "two", "three", "four" );
Can I now write the regexp to pull out the values of the array
instead, making the regexp flexible depending on the values in the
array at the time?
Cheers
Ben
------------------------------
Date: 24 May 2000 15:58:09 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Passing an array to a regexp
Message-Id: <959183416.22231@itz.pp.sci.fi>
In article <392bf388.2052011@news.freeserve.net>, Ben Hambidge wrote:
>I have the following condition:
>if ( $x =~ /^[one|two|three|four]/ ) { ...}
>However, I would like to test for values in an array; for example:
>@array = ( "one", "two", "three", "four" );
I presume your real code has () instead of [] in the regexp?
my $re = join '|' => map "\Q$_" => @array;
if ( $x =~ /^($re)/ ) { ... }
Remove the 'map "\Q$_" =>' part if you want the array elements to be
interpreted as regexps.
Depending on exactly what you're doing, this may or may not be the
most efficient way, but it should work. If you plan to apply the same
regexp to several values, precompiling it with qr// is recommended.
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla and its pseudonyms - do not feed the troll.
------------------------------
Date: 24 May 2000 17:41:10 GMT
From: abigail@arena-i.com (Abigail)
Subject: Re: Passing an array to a regexp
Message-Id: <8gh47m$63o$2@news.panix.com>
On Wed, 24 May 2000 15:24:29 GMT,
Ben Hambidge <newsmay2000@ordinate.co.uk> wrote:
++ I have the following condition:
++
++ if ( $x =~ /^[one|two|three|four]/ ) { ...}
I very much doubt you want the [ and ] there. All the above regex does
is testing wether the first character of $x is a o, n, e, |, t, w, h, r,
f or u.
++ However, I would like to test for values in an array; for example:
++
++ @array = ( "one", "two", "three", "four" );
++
++ Can I now write the regexp to pull out the values of the array
++ instead, making the regexp flexible depending on the values in the
++ array at the time?
Sure.
{local $" = '|';
my @array = map {quotemeta} @array; # Not necessary if no element of
# @array contains a regex meta char.
if ($x =~ /^@array/) { ... }
}
Abigail
------------------------------
Date: Wed, 24 May 2000 13:54:12 -0400
From: "Mario Lambert" <lambertm@sfcommerce.com>
Subject: Perl Extention
Message-Id: <rEUW4.30349$HG1.617817@nnrp1.uunet.ca>
I need to know how to get parameter after a call to a C function in dynamic
library and continue my perl script with this parameters!
ex:
(call) sfClientPerl::processRequest (szConfigFile,szRequest, szResponse,
iStatus, szErrorDesc);
my .xs Extention is :
int
processRequest (szConfigFile,szRequest, szResponse, iStatus, szErrorDesc)
char * szConfigFile
char * szRequest
char * szResponse
int &iStatus
char * szErrorDescr
PROTOTYPE: DISABLE
OUTPUT:
szResponse
iStatus
szErrorDesc
------------------------------
Date: Wed, 24 May 2000 13:56:10 -0400
From: "Mario Lambert" <lambertm@sfcommerce.com>
Subject: Re: Perl Extention
Message-Id: <hGUW4.30361$HG1.617835@nnrp1.uunet.ca>
excuse me !!!
i forgot my coor.
:)
thanks a lot !!
Mario Lambert
lambertm@sfcommerce.com
Mario Lambert <lambertm@sfcommerce.com> wrote in message
news:rEUW4.30349$HG1.617817@nnrp1.uunet.ca...
> I need to know how to get parameter after a call to a C function in
dynamic
> library and continue my perl script with this parameters!
>
> ex:
> (call) sfClientPerl::processRequest (szConfigFile,szRequest,
szResponse,
> iStatus, szErrorDesc);
>
> my .xs Extention is :
> int
> processRequest (szConfigFile,szRequest, szResponse, iStatus, szErrorDesc)
> char * szConfigFile
> char * szRequest
> char * szResponse
> int &iStatus
> char * szErrorDescr
>
> PROTOTYPE: DISABLE
> OUTPUT:
> szResponse
> iStatus
> szErrorDesc
>
>
>
------------------------------
Date: Wed, 24 May 2000 16:00:23 GMT
From: nosmo_1@my-deja.com
Subject: Problem with XS
Message-Id: <8gguac$gld$1@nnrp1.deja.com>
I am writing a perl extension. The details of what it does isn't
relevant, but the fact that it core dumps is. In my .xs file, I have
the following
typedef struct {
...
char *line ;
...
} parse_data ;
parse_data pd ;
There is a function that at one point does:
pd.line = strdup(s) ;
What I want to do later is return the string that I have stored, and
free up the memory. The following is one example of how I have tried to
do it:
void
get_line ()
PPCODE:
EXTEND(SP, 1) ;
PUSHs (sv_2mortal(newSVpv(pd.line,0))) ;
free (pd.line) ;
pd.line = 0 ;
The problem is with the call to free. If this is included, perl core
dumps. The strack trace looks like this:
emergency_sbrk(blah)
morecore(blah)
Perl_sv_grow(blah)
Perl_sv_catpvn(blah)
Perl_pp_concat(blah)
Perl_runops_standard(blah)
Moving the call to free to just before where I reassign a new line
works, like this:
if (pd.line) free (pd.line) ;
pd.line = strdup(s) ;
but after the last call, I would end up with a chunk of unfreed memory
hanging around.
I have tried replacing the current calls to maloc/free/strdup with the
XS approved version, and this makes no difference.
I *thought* that newSVpv allocated the memory to store the string in,
and then copied in my string. If it doesn't, and just runs down the
pointer I gave it, then it will of course blow up. How can I pass the
value out to Perl and not leave allocated memory hanging about?
Yours banging head against wall,
Nosmo
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 24 May 2000 16:21:12 GMT
From: Myself <rjbragg@my-deja.com>
Subject: Re: Proxy authentication solution CPAN module
Message-Id: <8ggvh5$hip$1@nnrp1.deja.com>
I don't think that this is where the change should be made.
I would prefer to put it at a lower level so that on the first call
through the proxy the userid/password are set into some persistent
scalars.
Then each time a new call is made these will be automatically called
and inserted.
LWP already has authentication routines.
It's mirror sub maybe needs to use LWP->request rather than simply
calling HTTP::request.
To me this was a quick fudge as a fairly new perl user to get CPAN to
work.
In article <Pine.GSO.4.10.10005181457080.25459-
100000@user2.teleport.com>,
Tom Phoenix <rootbeer@redcat.com> wrote:
> I don't know whether this should or should not be changed - but if it
> should, it should be made in the LWP sources. Have you sent a patch
to the
> LWP mailing list yet? (The address is in the LWP manpage.)
>
> Cheers!
>
> --
> Tom Phoenix Perl Training and Hacking Esperanto
> Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
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 V9 Issue 3148
**************************************