[10200] in Perl-Users-Digest
Perl-Users Digest, Issue: 3793 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 23 02:07:14 1998
Date: Tue, 22 Sep 98 23:00:19 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 22 Sep 1998 Volume: 8 Number: 3793
Today's topics:
Re: already made binaries for DEC_ALPHA? <sugalskd@netserve.ous.edu>
Re: any way to encrypt my script? (Ronald J Kimball)
Can't locate any modules <nospam@nospam.com>
Re: cat reese > /dev/null (was Re: Perl & Java - differ (David Formosa)
Re: CGI (David Adler)
Re: changing $ 'variables' in regexprs <mgregory@asc.sps.mot.com>
Database trouble with Cookies <bellears@deakin.edu.au>
Re: FORMAT problem <rick.delaney@shaw.wave.ca>
Re: Hashes springing into existence [Was: more regex/pa <uri@sysarch.com>
Re: How to count match pattern? (Martien Verbruggen)
Re: How to count match pattern? (Ronald J Kimball)
Re: How to count match pattern? (Sean McAfee)
Re: How to count match pattern? <rick.delaney@shaw.wave.ca>
Re: How to count match pattern? (Craig Berry)
Learning Perl Advice (David Cochran)
Re: Perl & Java - differences and uses <borg@imaginary.com>
Re: Perl & Java - differences and uses <ajohnson@gpu.srv.ualberta.ca>
Re: requiring into multiple namespaces (Mark-Jason Dominus)
Re: speed of subroutine call vs. call by function refer <sugalskd@netserve.ous.edu>
Re: unlink() not working in NT!!?? (Martien Verbruggen)
Re: where is Date::Parse (CPAN.pm)? <rra@stanford.edu>
Re: where is Date::Parse? (Leslie Mikesell)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 23 Sep 1998 03:01:49 GMT
From: Dan Sugalski <sugalskd@netserve.ous.edu>
Subject: Re: already made binaries for DEC_ALPHA?
Message-Id: <6u9oat$hfj$1@news.NERO.NET>
In comp.lang.perl.misc Steffen Beyer <sb@engelschall.com> wrote:
: In comp.lang.perl.misc Kurt Lange <milkman@dave-world.net> wrote:
:> My company is looking for the binaries that are already made for DBI and the
:> DEC_ALPHA running vms 7.1. My company does not want to buy a C Compliler.
: Poor company... ;-)
: How did you compile Perl in the first place?
Might have snagged a binary distribution. Other than the e-mail addresses
(which are usually mine :), the VMS build's pretty system-independent.
:> They are not cheap, we are just selling a product in which we don't want to
:> require the customer to buy a C Compliler, just to run Perl DBI. If there
:> is someone out there willing to give or sell it to us(depending on the
:> price), we would greatly appreciate. Or maybe there is a free C Compliler
:> for the DEC_ALPHA that we don't know about. If anyone knows of a free or
:> cheap C Compliler, we would appreciate knowing about it.
: Doesn't the GNU C Compiler (gcc) work on Alpha's, too?!?!
Yep, but you can't build perl with it right now. (Gnu C's *real* new on
OpenVMS Alpha, and all the vms-specific Gnu C stuff's for Vaxen. There are
some problems with that)
Doesn't make much differnece though--even if you could build perl with Gnu
C, none of the database vendors that I know of support it yet. (Or ever,
possibly) Dec C's not that expensive if you get in Digital/Compaq's
developer program.
Dan
------------------------------
Date: Tue, 22 Sep 1998 23:53:12 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: any way to encrypt my script?
Message-Id: <1dfs6ya.1ljan2y1mefmxlN@bay1-301.quincy.ziplink.net>
<bitnut1@my-dejanews.com> wrote:
> >------------------------------------------
> > Ben Sauvin <sauvin@osmic.com>: ....
> > Nobody who has never written or maintained a compiler, interpreter
> > or other computer language translator should really be commenting in
> > this thread.
> >------------------------------------------
>
> Your suggestion that only compiler writers should talk about them
> is akin to saying that only astronauts should talk about stars.
Note that he did not say that only compiler writers should talk about
compilers. He said that only compiler writers should be participating
in this thread.
Perhaps it's more akin to saying that only astrophysicists should make
authoritative comments about the composition of stars.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Tue, 22 Sep 1998 22:48:59 -0700
From: "Raza Muzaffar" <nospam@nospam.com>
Subject: Can't locate any modules
Message-Id: <6ua1vn$ha2@sjx-ixn5.ix.netcom.com>
Hi:
Can someone please give me some advice or clue as to what possibly can be
wrong with my perl. I cannot use any perl modules/library. For example when
I say use File::Find, after compiling I get the error:
Can't locate the module File::Find etc
I am unable to use any modules. I have also tried to enter correct path in
the @INC variable in the program(push(@INC,/my/library/directory) but it
does not seem to work either.
Any suggestions or recommendation would be very much appreciated.
Thanks,
Raza
------------------------------
Date: 23 Sep 1998 13:19:22 +1000
From: dformosa@zeta.org.au (David Formosa)
Subject: Re: cat reese > /dev/null (was Re: Perl & Java - differences and uses)
Message-Id: <6u9pbq$jkm$1@godzilla.zeta.org.au>
In <VkRN1.1403$Ge.4351102@ptah.visi.com> George Reese <borg@imaginary.com> writes:
>In comp.lang.java.programmer Uri Guttman <uri@camel.fastserv.com> wrote:
>: tho it is nice to hear that someone has seen his OO code and it is as
>: logical as he is.
>Abigail is blowing smoke. At no time has Abigail seen anything
>representative of my work.
It is possable that Abigail has seen some of your work, possably when
thay where doing matence on your system built by you.
------------------------------
Date: 23 Sep 1998 04:08:33 GMT
From: dha@panix.com (David Adler)
Subject: Re: CGI
Message-Id: <6u9s81$doi@news1.panix.com>
On Mon, 21 Sep 1998 09:57:29 -0500, Eric Von Zee
<evonzee@tritechnet.com> wrote:
>Best book I ever read on Perl was 'Perl5 Quick Reference Guide', by
>Micheal o Foghlu.
Far be it from me to try to limit anyone's personal choice, but I feel
obligated to point out that this book does *not* fare well on the
"camel critiques" page at
<http://language.perl.com/critiques/index.html>, probably a good place
to look when choosing a perl book...
This has been a perlblic service announcement...
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"i don't play lead. it interferes with my drinking." - Malcolm Young
------------------------------
Date: 23 Sep 1998 11:50:29 +0930
From: Martin Gregory <mgregory@asc.sps.mot.com>
Subject: Re: changing $ 'variables' in regexprs
Message-Id: <r8zpbr36z6.fsf@asc.sps.mot.com>
4newsargus@mail.entrsft.com (David Rouse) writes:
> I'm setting up a script to clean up (poorly) automatically generated HTML.
> I'm using this contruct:
>
> $fileholder =~ s/<p><HR>([^-|\n]+)(-|\n)/<P><HR><B>$1<\/B>$2/g;
>
> to find all the text starting with <p><HR> and ending with a '-' or a
> newline and put bold tags around the text. All is well,
First, I don't know that all is actually well. You can't use a | to
mean 'or' in a character set, so if a | happens to be in your text you
will be in trouble... luckily character sets are 'or' things anyhow,
so the solution to that one is easy...
> but what I really need to be able to do is force $1 into ALL
> CAPS. Sadly, this is a 'read only variable' and a one line command.
> Any advice welcome!
You can use the \U operator:
$fileholder =~ s/<p><HR>([^-\n]+)(-|\n)/<P><HR><B>\U$1\E<\/B>$2/g;
[If you need to do anything more tricky (such as execute a function on
$1) you could look up the /e modifier of the substitution operator]
HTH.
Martin.
------------------------------
Date: Wed, 23 Sep 1998 15:12:12 +1000
From: Mick <bellears@deakin.edu.au>
Subject: Database trouble with Cookies
Message-Id: <3608832C.1E9B6E31@deakin.edu.au>
This is a multi-part message in MIME format.
--------------43DA91C89426D62B04A22761
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hi Everyone!
I'm currently running Apache 1.3.1 with mod_perl and postgresql for the
database.
I've changed from Basic Authentication to cookies but I'm having a
little
trouble...I now can connect to the database with the users cookie
credentials, but when I get transported to another page, the credentials
are not carried through, ie. I get user not authenticated!!!
I'm using a login script in /unprotected to get tryout.pl which is
located
in /unprotected/protected, I have in AuthCookieHandler.pm some Print
STDERR, so I know it is connecting and working in there, but when
tryout.pl is loaded I get no authentication!!, how do I pass on these
credentials???
I hope you can help, I'm really banging my head up against a wall with
this!!! :)
(Files included AuthCookieHandler.pm, login.pl, logout.pl and tryout.pl)
Thanks in advance,
Mick
--------------43DA91C89426D62B04A22761
Content-Type: text/plain; charset=us-ascii; name="Authco~1.pm"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="Authco~1.pm"
package Sample::AuthCookieHandler;
my $r = Apache->request;
use strict;
use Apache;
use Apache::Constants qw(:common);
use Apache::AuthCookie;
use Carp;
use vars qw($VERSION @ISA);
$VERSION = substr(q$Revision: 1.2 $, 10);
@ISA = qw(Apache::AuthCookie);
sub authen_cred ($$\@) {
my $self = shift;
my $r = shift;
my @creds = @_;
# This would really authenticate the credentials
# and return the session key.
# Here I'm just using setting the session
# key to the credentials and delaying authentication.
#
# Similar to HTTP Basic Authentication, only not base 64 encoded
join(":", @creds);
}
sub authen_ses_key ($$$) {
my $self = shift;
my $r = shift;
my($user, $password) = split(/:/, shift, 2);
my $dbh = DBI->connect( "dbi:Pg:dbname=cmct","cmct","" ) or die "Error: $DBI::errstr\n";
my $remoteUser = $ENV{"REMOTE_USER"};
my $sql = "SELECT p_id, p_title, p_fname, p_sname FROM person WHERE p_account='$user'";
my $cursor = $dbh->prepare($sql);
$cursor->execute;
my $p_id;
#print STDERR "user password- $user $password\n";
if ( ( $p_id, my $p_title, my $p_fname, my $p_sname ) = $cursor->fetchrow )
{
print STDERR "Success- $user $password\n";
print STDERR "Unit listing for:$p_title $p_fname $p_sname - $user $password\n";
}
else
{
print STDERR "Fail- $user $password\n";
print STDERR "SERVER FAILURE: Can NOT determine user.\n";
return 1;
}
}
sub dwarf {
my $self = shift;
my $r = shift;
my $user = $r->connection->user;
if ("bashful doc dopey grumpy happy sleepy sneezy programmer"
=~ /\b$user\b/) {
# You might be thinking to yourself that there were only 7
# dwarves, that's because the marketing folks left out
# the often under appreciated "programmer" because:
#
# 10) He didn't hold 8 to 5 hours.
# 9) Sometimes forgot to shave several days at a time.
# 8) Was always buzzed on caffine.
# 7) Wasn't into heavy labor.
# 6) Prone to "swearing while he worked."
# 5) Wasn't as easily controlled as the other dwarves.
#
# 1) He posted naked pictures of Snow White to the Internet.
return OK;
}
return FORBIDDEN;
}
1;
--------------43DA91C89426D62B04A22761
Content-Type: application/x-perl; name="Login.pl"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="Login.pl"
use strict;
my $r = Apache->request;
$r->status(200);
my $uri = $r->prev->uri;
my $a_type = $r->prev->auth_type;
my $a_name = $r->prev->auth_name;
my $form = <<HERE;
<HTML>
<HEAD>
<TITLE>Enter Login and Password</TITLE>
</HEAD>
<BODY onLoad="document.forms[0].credential_0.focus();">
<FORM METHOD="GET" ACTION="$uri">
<TABLE WIDTH=60% ALIGN=CENTER VALIGN=CENTER>
<TR><TD ALIGN=CENTER>
<H1>This is a secure document</H1>
</TD></TR>
<TR><TD ALIGN=LEFT>
<P>Please enter your login and password to authenticate.</P>
</TD>
<TR><TD>
<INPUT TYPE="hidden" NAME="AuthType" VALUE="$a_type">
<INPUT TYPE="hidden" NAME="AuthName" VALUE="$a_name">
</TD></TR>
<TR><TD>
<TABLE ALIGN=CENTER>
<TR>
<TD ALIGN=RIGHT><B>Login:</B></TD>
<TD><INPUT TYPE="text" NAME="credential_0" SIZE=10 MAXLENGTH=10></TD>
</TR>
<TR>
<TD ALIGN=RIGHT><B>Password:</B></TD>
<TD><INPUT TYPE="password" NAME="credential_1" SIZE=8 MAXLENGTH=8></TD>
</TR>
<TR>
<TD COLSPAN=2 ALIGN=CENTER><INPUT TYPE="submit" VALUE="Continue"></TD>
</TR></TABLE>
</TD></TR></TABLE>
</FORM>
</BODY>
</HTML>
HERE
$r->no_cache(1);
my $x = length($form);
$r->content_type("text/html");
$r->header_out("Content-length","$x");
$r->header_out("Pragma", "no-cache");
$r->send_http_header;
$r->print ($form);
--------------43DA91C89426D62B04A22761
Content-Type: application/x-perl; name="Logout.pl"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="Logout.pl"
use strict;
my $r = Apache->request;
my $auth_type = $r->auth_type;
my $auth_name = $r->auth_name;
my $path = $r->dir_config($auth_name . "Path");
$r->no_cache(1);
$r->status(200);
$r->header_out("Pragma", "no-cache");
$r->header_out("Set-Cookie",$auth_type . "_" . $auth_name . "=; path=" .
$path . "; expires=Mon, 21-May-1971 00:00:00 GMT");
$r->content_type("text/html");
$r->send_http_header;
print <<EOF;
<HTML>
<HEAD><TITLE>Logged Out</TITLE></HEAD>
<BODY>
<P>You have been logged out and the cookie deleted from you browser.</P>
<P><A HREF="get_me.html">Go ahead and try it again.</A></P>
</BODY>
</HTML>
EOF
--------------43DA91C89426D62B04A22761
Content-Type: application/x-perl; name="Tryout.pl"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="Tryout.pl"
#see Apache::Registry
use DBI;
use strict;
my $r = Apache->request;
$r->no_cache(1);
$r->status(200);
$r->header_out("Pragma", "no-cache");
$r->content_type("text/html");
$r->send_http_header();
print "<TITLE>School of Computing and Mathematics MB</TITLE>\n";
print "<BODY TEXT=\"#000000\" BGCOLOR=\"#FFFFFF\" LINK=\"#0000FF\" VLINK=\"#000080\" ALINK=\"#FF0000\">\n";
my $now = scalar localtime time;
print "<CENTER><B><FONT SIZE=+1>School of Computing And Mathematics<BR></FONT></B>\n";
print "<tt>$now</tt><br>\n";
print "<HR WIDTH=\"100%\">\n";
my $dbh = DBI->connect( "dbi:Pg:dbname=cmct","cmct","" ) or die "Error: $DBI::errstr\n";
my $remoteUser = $ENV{"REMOTE_USER"};
my $sql = "SELECT p_id, p_title, p_fname, p_sname FROM person WHERE p_account = '$remoteUser'";
my $cursor = $dbh->prepare($sql);
$cursor->execute;
my $p_id;
if ( ( $p_id, my $p_title, my $p_fname, my $p_sname ) = $cursor->fetchrow )
{
print "<P>Unit listing for:<P><B>$p_title $p_fname $p_sname</B><P><BR>\n";
}
else
{
print "<P>SERVER FAILURE: Can NOT determine user.<P>\n";
print "<a href=\"/unprotected/protected/get_me.html\">Get me</A>\n";
return 1;
}
my $sql = "SELECT c_code,c_description,c_uri,pcl_type FROM unit,person_unit_link WHERE unit.c_code = person_unit_link.pcl_ccode AND person_unit_link.pcl_pid = '$p_id' ORDER BY c_code";
my $cursor = $dbh->prepare($sql);
$cursor->execute;
print "<TABLE BORDER=0 CELLSPACING=3 CELLPADDING=6 COLS=2 WIDTH=\"90%\" BGCOLOR=\"#d0d0FF\">\n";
print "<TR BGCOLOR=\"#c0c0c0\">\n";
print "<TD WIDTH=\"20%\"><DIV ALIGN=center><B><TT><FONT SIZE=+2>Code</FONT></TT></B></DIV></TD>\n";
print "<TD WIDTH=\"80%\"><DIV ALIGN=center><B><TT><FONT SIZE=+2>Unit Name</FONT></TT></B></DIV></TD>\n";
print "</TR>\n";
while ( (my $ccode,my $cdesc,my $url, my $type) = $cursor->fetchrow )
{
my $text;
if ( $type == 150 )
{
$text = "<BR><FONT SIZE=-1><I>(Administrator)</I></FONT>";
}
elsif ( $type == 100 )
{
$text = "<BR><FONT SIZE=-1><I>(Lecturer)</I></FONT>";
}
elsif ( $type == 50 )
{
$text = "<BR><FONT SIZE=-1><I>(Tutrorer)</I></FONT>";
}
elsif ( $type == 20 )
{
$text = "<BR><FONT SIZE=-1><I>(Marker)</I></FONT>";
}
else
{
$text = "";
}
print "<TR>\n";
print "<TD WIDTH=\"20%\"><DIV ALIGN=center><B><TT><FONT SIZE=+1><a href=\"$url\" target=\"_top\">$ccode</a></FONT></TT></B></DIV></TD>\n";
print "<TD WIDTH=\"80%\"><DIV ALIGN=left><B><TT><FONT SIZE=+1><a href=\"$url\" target=\"_top\">$cdesc</A>$text</FONT></TT></B></DIV></TD>\n";
print "</TR>\n";
}
#}
#print "<TD WIDTH=\"20%\"><DIV ALIGN=left><B><TT><FONT SIZE=+1><a href=\"/add_course/add_course.pl\"><img src=\"/add_course/add_unit.gif\"></A></FONT></TT></B></DIV></TD>\n";
#print "<TD WIDTH=\"80%\"><DIV ALIGN=left><B><TT><FONT SIZE=+1><a href=\"/add_course/add_course.pl\">Add a Course</A></FONT></TT></B></DIV></TD>\n";
#print "<TD WIDTH=\"80%\"><DIV ALIGN=center><B><TT><FONT SIZE=+2>Unit Name</FONT></TT></B></DIV></TD>\n";
#print "<TD WIDTH=\"80%\"><DIV ALIGN=left><B><TT><FONT SIZE=+1><a href=\"add_course/add_course.pl\" target=\"_top\">Add</A></FONT></TT></B></DIV></TD>\n";
#print "<P><CENTER><A HREF="\add_course\add_course.pl">Add a Unit</A></CENTER></P>\n";
print "</TABLE>\n";
$cursor->finish;
$dbh->disconnect;
print "<P><CENTER>\n";
print "<HR WIDTH=\"100%\"></CENTER>\n";
print "</BODY>\n";
--------------43DA91C89426D62B04A22761--
------------------------------
Date: Wed, 23 Sep 1998 04:02:15 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: FORMAT problem
Message-Id: <36087452.A3AC74AC@shaw.wave.ca>
[posted & mailed]
Phil R Lawrence wrote:
>
> Hello, I have a new format problem.
I'll say, fix those line lengths! :-)
[snip]
>
> for (1..3) {write REPORT}
> # You see I tried resetting the accumulator.
> $- = 0;
Yes, but REPORT isn't the currently selected filehandle. Select, then
reset:
select( (select(REPORT), $- = 0)[0] );
> close REPORT or die;
You shouldn't need the close since the next open will take care of it.
In fact, if you leave it in you will still have the same problem.
I'm not sure why that is, but I hope this helps.
--
Rick Delaney
rick.delaney@shaw.wave.ca
------------------------------
Date: 22 Sep 1998 23:03:43 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Hashes springing into existence [Was: more regex/pattern substitution]
Message-Id: <x767efwmwg.fsf@sysarch.com>
>>>>> "TC" == Tom Christiansen <tchrist@mox.perl.com> writes:
TC> [courtesy cc of this posting sent to cited author via email] In
TC> comp.lang.perl.misc, Uri Guttman <uri@camel.fastserv.com> writes:
TC> : push( @{$hash{$key}}, $val ) ; :if you had to init it, you would
TC> have to do this before every push: : $hash{$key} = [] unless
TC> exists $hash{$key} ; :which will slow things down and add
TC> repetative code.
TC> Well, modulo the obvious:
TC> push(@{ $hash{$key} ||= [] }, $val);
tom wins again!
but shouldn't that be |||= ?
:-)
TC> As seen in PCB chapter 11:
i haven't read that far yet. i need to put pcb higher on my read queue.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire ---------------------- Perl, Internet, UNIX Consulting
uri@sysarch.com ------------------------------------ http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: Wed, 23 Sep 1998 03:09:00 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: How to count match pattern?
Message-Id: <gDZN1.1224$0r6.80994@nsw.nnrp.telstra.net>
In article <6u9fet$v$1@nnrp1.dejanews.com>,
hup@addall.com writes:
> Hi,
> I hope this is not a FAQ.
> I wonder how could I find out how many pattern are match/replace?
FAQ? It's in the standard documentation... Did you read it?
# perldoc perlop
[snip]
In a scalar context, m//g iterates through the
string, returning TRUE each time it matches, and
FALSE when it eventually runs out of matches. (In
other words, it remembers where it left off last
time and restarts the search at that point.
[snip]
s/PATTERN/REPLACEMENT/egimosx
Searches a string for a pattern, and if found,
replaces that pattern with the replacement text and
returns the number of substitutions made. Otherwise
it returns false (specifically, the empty string).
[snip]
So, for just a match, wrap it in a while loop, and count, or do it in
a list context, and count the number of elements in the returned list.
For replace, just inspect the return value.
Use the /g modifier. And please, read the documentation.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | If it isn't broken, it doesn't have
Commercial Dynamics Pty. Ltd. | enough features yet.
NSW, Australia |
------------------------------
Date: Tue, 22 Sep 1998 23:53:15 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: How to count match pattern?
Message-Id: <1dfs78l.co0ygg94sxb2N@bay1-301.quincy.ziplink.net>
<hup@addall.com> wrote:
> I hope this is not a FAQ.
> I wonder how could I find out how many pattern are match/replace?
Hmm... In other words, if you do s/pattern/replace/g;, you want to know
how many times the replacement occured?
That's a good question. I don't know of a straightforward way to do it.
Here's one possibility:
$count = 0;
s/pattern/$count++; "replace"/ge;
Then the value of $count will be the number of times the replacement
occured.
This should work too:
$count = () = m/pattern/g;
s/pattern/replace/g;
But then you're doing the matching part twice, which seems inefficient.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Wed, 23 Sep 1998 04:14:23 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: How to count match pattern?
Message-Id: <zA_N1.4272$F7.15951032@news.itd.umich.edu>
In article <1dfs78l.co0ygg94sxb2N@bay1-301.quincy.ziplink.net>,
Ronald J Kimball <rjk@coos.dartmouth.edu> wrote:
><hup@addall.com> wrote:
>> I hope this is not a FAQ.
>> I wonder how could I find out how many pattern are match/replace?
>Hmm... In other words, if you do s/pattern/replace/g;, you want to know
>how many times the replacement occured?
>That's a good question. I don't know of a straightforward way to do it.
Uh, the substitution operator returns the number of matches.
$count = $string =~ s/pattern/replace/g;
--
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
| K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
| tv+ b++ DI++ D+ G e++>++++ h- r y+>++** | umich.edu
------------------------------
Date: Wed, 23 Sep 1998 04:13:57 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: How to count match pattern?
Message-Id: <36087714.838B7411@shaw.wave.ca>
[posted & mailed]
Ronald J Kimball wrote:
>
> <hup@addall.com> wrote:
>
> > I hope this is not a FAQ.
> > I wonder how could I find out how many pattern are match/replace?
>
> Hmm... In other words, if you do s/pattern/replace/g;, you want to
> know how many times the replacement occured?
>
> That's a good question. I don't know of a straightforward way to do
^^^^^^^^^^^^^^^
> it.
You mean besides
$count = s/pattern/replace/g;
?
Surely you know this, Ronald? Am I missing something?
--
Rick Delaney
rick.delaney@shaw.wave.ca
------------------------------
Date: 23 Sep 1998 05:39:19 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: How to count match pattern?
Message-Id: <6ua1i7$d24$1@marina.cinenet.net>
Ronald J Kimball (rjk@coos.dartmouth.edu) wrote:
: <hup@addall.com> wrote:
: > I hope this is not a FAQ.
: > I wonder how could I find out how many pattern are match/replace?
:
: Hmm... In other words, if you do s/pattern/replace/g;, you want to know
: how many times the replacement occured?
:
: That's a good question. I don't know of a straightforward way to do it.
(Hope I'm not walking into unmarked sarcasm, here...)
>From perldoc perlop:
s/PATTERN/REPLACEMENT/egimosx
Searches a string for a pattern, and if found,
replaces that pattern with the replacement text and
returns the number of substitutions made. Otherwise
it returns false (specifically, the empty string).
Thus, oddly, it's easier to get the replacement count for s///g than the
match count for m//g:
$repCount = $text =~ s/foo/bar/g;
There are two ways to tackle the m//g count problem:
$matchCount = () = $text =~ m/foo/g;
...which builds and tosses away an intermediate list, which may or may not
matter performance- or esthetics-wise to you (I rather prefer this form,
esthetically), and
$matchCount = 0;
$matchCount++ while $text =~ m/foo/g;
HTH!
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| "Ripple in still water, when there is no pebble tossed,
nor wind to blow..."
------------------------------
Date: Wed, 23 Sep 1998 04:55:31 GMT
From: dcochran@earthlink.net (David Cochran)
Subject: Learning Perl Advice
Message-Id: <36087e18.52332034@hermosa>
I am interested in learning perl and was wondering if anyone could
recommend a good learning source. I was in Fry's today and saw a
package entitled "The Complete PERL Training Course" by Ellie Quigley.
Has anyone used this source and if so is it any good. If it is bad,
any recommendations on a different source?
Thanks
david
------------------------------
Date: Wed, 23 Sep 1998 03:09:22 GMT
From: George Reese <borg@imaginary.com>
Subject: Re: Perl & Java - differences and uses
Message-Id: <CDZN1.1499$Ge.4670316@ptah.visi.com>
In comp.lang.java.programmer Zenin <zenin@bawdycaste.org> wrote:
: George Reese <borg@imaginary.com> wrote:
: >snip<
: : So let's review. You have worked hard to get three quotes. Of the
: : three quotes, you have one quote that, taken alone out of context,
: : *might* lead one to the *assumption* that I am suggesting OO is
: : everything.
: And if one refers back to the articles those quotes where taken
: from, it would prove this viewpoint beyond any doubt.
: If you've had a change of heart after going through this thread,
: have the dignity to admit it, but don't patronize the other
: readers here by suggesting that you never thought "OO is
: everything". That's a lie, as the first 3/4ths of this thread
: clearly prove.
Since when are you the expert on what I think? And exactly what
motivation do I have for lying about what I believe?
There first 3/4's of this thread were only slightly related to OO
issues.
: : On the other hand, you have many, many posts of me explicitly saying
: : otherwise.
: In your last few posts, sure. This is just more of the massive
: amount of contradictions you keep making. If you want to make
: believe you never wrote any of the things you've written, you might
: want to see about getting your articles removed from DejaNews.
If you want to claim I am saying things that I say I did not say, THEN
PROVE IT. Post the quotes here. I cannot prove a negative, and
asking me to do so is utter bullshit.
: : Clearly you desperately want to assign this belief to me. By doing
: : so, you can write me off as a zealot who does not understand the real
: : world. Give it up. I do not hold that belief, I have never held that
: : belief, and throughout the entire thread I have done nothing to
: : promote that belief.
: Ya see, that's just it. With the exception of the last few
: posts from you, the only thing you have done throughout this entire
: thread is prove yourself a zealot.
No, you have tried to characterize me as such. You don't have the
first bit of evidence to back up that characterization.
: : : This begs the question of whether the OO paradigm *ought* to be
: : : maintained across the process. Clearly, you think it does.
: :
: : And I have provided support for that belief in other posts. I even
: : went so far as to sum it up into premises and a conclusion.
: Your own assertions do not equal "support".
In fact, they do. You can argue with those assertions. But a
supported argument is one in which the premises lead to the
conclusion. I have provided premises that do lead to my conclusion.
You can argue the premises, but you cannot argue that I have failed to
provide support.
: : :> You should parse the [pattern match] results within an OO framework.
: :
: : : This is saying that all operations, regardless of scale, should
: : : be performed in an OO framework. Which sounds a lot like
: : : "OO Everywhere" to me.
: :
: : How does it sound like that?
: Keywords, "You should".
: : Again, you took the quote out of context.
: Ok, stick it back in context. It binds this line of thought
: even stronger.
Oh, bullshit. Read it in the original context. While I can
understand the confusion on this issue, I believe John even
agrees with me that what I claim now is what I meant then and he
brought this quote up.
: : The context was not so much that pattern match results
: : should be in an OO framework, but that they should be handled within
: : some structure imposed by the language in question.
: And we'd all agree with you, if that was indeed what you said.
It was what I said.
: Read that comment above again. Basically you're saying if you
: have a hammer and a nail that you should not try to use the hammer
: on the nail as you would a screwdriver.
Will you stop forcing arguments on me?
: : For example, lisp pattern matching is not OO, but it is handled within
: : the Lisp paradigm. I support that for Lisp. I support the OO paradigm
: : for python. Perl, however, is a hodge podge of paradigms. And I do not
: : support that.
: So basically, if one is using language Foo and comes to a problem
: that is best solved with the paradigm of language Bar, that it is
: best to create a workaround kluge using only Foo's paradigm?
This is a silly question because you should determine your language
based on the requirements of your system. So if your problem requires
paradigm A, you use a language that supports paradigm A. If it
instead requires paradigm B, you use a language that supports paradigm
B.
How hard is this principle for you to understand?
: What if Java had closures. Would it be "wrong" to actually use them?
: Or would Java some how be less of a language for even supporting
: such a paradigm?
Java has method pointers. A similar concept that does work in an OO
paradigm.
: >snip<
: : What? Please try and describe how you get that from the above
: : quotes. As I read them, they are all variations of: "if you want code
: : reuse, OO is the way to go".
: Which, without sighting evidence you still have failed to
: provide, is dogma.
If that was the only statement I had ever made in this thread, you
would be correct. However, I have said a lot more than that.
: : : So, are we unclear as to where you stand on OO?
: :
: : Evidently, you are. And what is really funny, you will not take my
: : explicit statements as proof.
: You could be Jesus. Your statements alone would still not be
: "proof". Maybe you have a different definition of "proof" then
: the rest of us?
My statements alone are not proof of where I stand? WHAT THE FUCK
ELSE COULD PROOF OF WHERE I STAND?
: : You instead spend a lot of time reading into other statements
: : non-explicit meanings.
: Oh, you've been quite explicit. There is no need to read anything
: into your statements as you've made yourself quite clear.
Then please quote them.
: >snip<
: : This is true only if the strength of perl lies in where OO is weak.
: : This is not the case. OO's weakness lies in performance of speed
: : critical systems--usually in the embedded systems world.
: :
: : For those things where taking an OO approach will not work, perl,
: : python, and java are all bad solutions.
: So, the only reason OO design should ever not be used is
: performance? So, if OO had no performance issues, it would
: have no weaknesses? Now you're back on the "OO Everywhere"
: theme. You flip-flop faster then a politician.
You are a master of taking something someone says and then extending
it beyond their words into an extremist state.
I said that OO's weakness lies in performance of speed critical
systems. That implies that I think an OO programming approach is bad
for such systems. That does not imply those are the only systems for
which such an approach is bad.
There are a lot of such systems. Most of the reasons for not doing
other such systems are political and not technical.
By the way, how many exceptions do I have to give you before you stop
assigning me the extremist position?
Or better yet, would you like to provide an example of an application
for which OO is not appropriate on technical merits not related to
performance?
: : : (Of course, I admit that that is faulty, since in fact Python does
: : : not enforce OO any more than Perl does. But that's a different
: : : argument...)
: :
: : Would you care to back this up?
: Why bother? DejaNews already has a copy of your python own code
: that proves it.
If you really believe this is an argument, you are an idiot.
--
George Reese (borg@imaginary.com) http://www.imaginary.com/~borg
PGP Key: http://www.imaginary.com/servlet/Finger?user=borg&verbose=yes
"Keep Ted Turner and his goddamned Crayolas away from my movie."
-Orson Welles
------------------------------
Date: Tue, 22 Sep 1998 23:51:14 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Perl & Java - differences and uses
Message-Id: <36087E42.4B261D4A@gpu.srv.ualberta.ca>
George Reese wrote:
!
[snip]
George Reese wrote:
!
[snip]
! I have provided premises which you can debate or not. You have not
! chosen to debate those premises. What exactly do you want?
!
! If I say:
!
! All Americans speak French.
! I am American.
! Therefore I speak French.
!
! As this argument follows from the premises, I have provided an
! argument with support. You can either choose to debate my premises or
! concede that I speak French.
that is not an argument following from premises, it is a logical
conclusion, and while taken all together it is internally
consistent that does not make it a 'supported' argument --- you need
to support your premises as well.
! I think the premises I have offered in this past support this
! statement. If you disagree, please address the problematic premise.
I have done so ... I will do so once again, since you still do
not see the problem:
Here are your original premises, followed with word substitutions for
terms you later clarified:
(1)
! * In order to get quality software, you need a method of guaranteeing
! results given a problem.
you later said change 'get' to 'guarantee' and that the 'results'
being discussed was the 'production of software':
In order to "guarantee" quality software, you need a method of
guaranteeing "the production of software" given a
problem.
(2)
! * If you want to guarantee results, you need to be able to reduce a
! process to a replicatable algorithm.
now again, 'results' is the 'production of software', so
premise two is:
If you want to guarantee "the production of software", you
need to be able to reduce a process to a replicable algorithm
now, you never mentioned what the 'process' was --- but I think we can
infer that you meant something like: "you need to be able to reduce
the process of producing software to an algorithm"
(feel free to correct me if my inferences are incorrect)
(3)
! * OO is the closest thing to a replicatable algorithm we have in
! software engineering today.
(this is the 'skyhook', for Dennet fans)
4)
! * OO does sometimes incur performance costs and thus the predticability
! of the process is sometimes offset by these performance costs.
(5)
! * Most software engineering tasks do not encounter a requirement for
! the the level of performance cost by OO software engineering.
(these last two are not really germane to main problem with the logic)
(conclusion)
! - Therefore, it is the best solution for any software engineering task
! where the side effects
you corrected this to read:
Therefore, it is the best solution for most software engineering
tasks.
---------
summary: if you want to guarantee the production of quality software,
you need a method which guarantees the production of software, and
furthermore, to be such a guarantor, such a method must be reducible
to an algorithm --- OO is the nearest thing we have to being an
algorithm for software production, therefore, it is the best
solution for most software production.
George, leaving aside questions about whether there is any support for
any of your premises, you've unwittingly made an unsound leap between
premise 2 and 3 --- premise 2 poses a 'necessary condition' ... that
the process or 'method of software production' must be reducible to
an algorithm in order to guarantee results. This is obviously Not a
'sufficient condition' for guaranteeing the *quality* results... if
someone poses an algorithm that guarantees "the production of
software", that does not mean it also guarantees "the production of
*quality* software" does it?
Therefore, even if you had shown that OO does have the property of
algorithmic reduction (you didn't), it couldn't guarantee *quality*
software unless OO already had the property of guaranteeing
*quality* software --- the property of algorithmic reduction only
guarantees consistent results, the quality of those results is still
dependent upon the method you've reduced. You cannot use algorithmic
reduction as a skyhook for your beloved OO methodology, even if you
could demonstrate such a reduction.
Now do you see how your conclusion does not follow from your premises?
end of my address of the 'problematic issues'.
BTW, you have still yet to comment on my previous remarks about
"freedom" in programming with regard to OO, namely, does an OO
programmer have the 'freedom' to choose among various possible OO
implementations of a solution to a problem --- or do you somehow
still believe that 'freedom' has no place in programming, and that
for any problem there is only one implementable and correct solution?
regards
andrew
------------------------------
Date: 23 Sep 1998 00:40:35 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: requiring into multiple namespaces
Message-Id: <6u9u43$ldv$1@monet.op.net>
In article <36084432.16428668@news.ne.mediaone.net>,
James Galagan <jgalag@mit.edu> wrote:
>Any advice would be much appreciated.
`do' instead of `require'.
------------------------------
Date: 23 Sep 1998 03:06:02 GMT
From: Dan Sugalski <sugalskd@netserve.ous.edu>
Subject: Re: speed of subroutine call vs. call by function reference
Message-Id: <6u9oiq$hfj$2@news.NERO.NET>
John Klassa <klassa@aur.alcatel.com> wrote:
: I was benchmarking the time it takes to call a subroutine the normal way
: vs. the time it takes to use a reference to a function (I was expecting the
: former to be faster). The results were a bit surprising.
: Under 5.004_04, I get:
: Benchmark: timing 1000000 iterations of function pointer, subroutine call...
: function pointer: 7 secs ( 7.95 usr 0.00 sys = 7.95 cpu)
: subroutine call: 8 secs ( 8.23 usr 0.00 sys = 8.23 cpu)
: Under 5.005_01, I get:
: Benchmark: timing 1000000 iterations of function pointer, subroutine call...
: function pointer: 20 secs (18.92 usr 0.00 sys = 18.92 cpu)
: subroutine call: 18 secs (17.59 usr 0.00 sys = 17.59 cpu)
: Both versions of perl were compiled with -O, FWIW.
Yeah, but you built 5.005_01 with threads. I can tell from those numbers.
Threads really kill subroutine call speeds. There's a lot more overhead in
general (bunch 'o locking and mutex checking going on) which adds up.
Lexical @_ seems to add some overhead too.
: I am perplexed by two things:
: 1. Why is calling a function via a function reference *faster*
: than a straight subroutine call in 5.004_04? Seems like there
: ought to be an extra level of indirection, and hence a
: slowdown.
You'd think so, but that's not the case. A ref to a subroutine points
directly to the exact subroutine you want to call, while just using the
name needs some lookup to see if it's been overridded. (IIRC. This is from
memory, so I might be a bit off)
: 2. Why is 5.005_01 so much slower? In the discussions I'd
: seen here, the slowdown associated with having threading
: available (even if not used) was on the order of a few
: percent -- not 100%!
: Can the perl-internals-savvy among us elaborate?
Threads. Threads are the killer. Try 5.005_02 without threads and you'll
see more reasonable numbers.
Dan
------------------------------
Date: Wed, 23 Sep 1998 03:10:58 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: unlink() not working in NT!!??
Message-Id: <6FZN1.1278$0r6.80994@nsw.nnrp.telstra.net>
In article <36085a50$0$25505@nntp1.ba.best.com>,
"David Watson" <standfast@mindspring.com> writes:
> # The open() succeeds. The unlink() fails only on NT.
> #
>
> $thefile = "C:/tmp/perltest";
>
> if (!open(TEST, "> $thefile")) {
> die($errno);
> }
>
> print("Opened OK\n");
>
> $result = unlink "$thefile" ;
> printf("Result is %s\n", $result);
You don't close the file. On some operating systems, and I believe
that includes NT, file locking happens.
If you know that unlink fails, you should inspect the $! variable.
Whenever you use a system call and it fails, check $!.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | I'm just very selective about what I
Commercial Dynamics Pty. Ltd. | accept as reality - Calvin
NSW, Australia |
------------------------------
Date: 22 Sep 1998 20:24:10 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: where is Date::Parse (CPAN.pm)?
Message-Id: <yl1zp3y0it.fsf@windlord.stanford.edu>
Steffen Beyer <sb@engelschall.com> writes:
> There's a new Perl Resource Kit from the german section of O'Reilly
> coming soon ("Programmieren mit Perl-Modulen" = "Programming with Perl
> Modules") which will include a new tool called "Build'n'Play" which
> offers that.
> You can install Perl (including all the modules you like) and other
> distributions (like Gimp, ImageMagick, and soon gcc and more) with it
> using all the flexibility and computational power of Perl.
I'll be interested to see what it looks like when it's out. Are you using
some sort of a standard package scheme like RPM or the like?
> And finally, you will be able to install to a software installation
> hierarchy which allows grouping of your installed software packages into
> categories (subdirectories) as well as guaranteed residue-free
> de-installation.
> No more trampling over one another in /usr/local/bin anymore, no more
> uncontrolled copying of files over your whole file system when doing
> "make install".
This is actually a solved problem for me, since we use AFS, so chances are
high that whatever scheme some other tool uses is just going to conflict
with the scheme that we're already using. That's one of the reasons why I
just started writing this myself.
> If you want to check this tool out, mail me and I give you the password
> to the betatest download area,
> http://www.engelschall.com/u/sb/download/bnp/
I probably don't have time to evaluate something in detail right now, I'm
afraid, as the system that I have is currently mostly working and is doing
what I need it to do and I have to move on to other projects. But I'll
keep an eye on this.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: 23 Sep 1998 00:09:43 -0500
From: les@MCS.COM (Leslie Mikesell)
Subject: Re: where is Date::Parse?
Message-Id: <6u9vqn$3t5$1@Venus.mcs.net>
In article <6u8mme$5n8$2@client3.news.psi.net>,
Abigail <abigail@fnx.com> wrote:
>Why? CPAN.pm doesn't go out to a CPAN site and check the version
>number of a module. It uses the 02packages.details.txt file.
>So can I. I don't need a module to interpret the line
>Apache 1.22 DOUGM/mod_perl-1.15.tar.gz
>for me.
Yes, it does effectively. It automatically pulls the current
list files from CPAN the first time you need them in a session.
>Switching to root to run CPAN? Are you insane? Of course not. I don't
>need root to install anything for Perl - it's installed using a
>separate uid. And both ftp and lynx work fine for that user.
Hmmmm, very curious how something like ftp or lynx could break
simply because they are invoked by perl. Even if there are
firewall options involved, perl shouldn't be munching your
environment or config file settings.
Les Mikesell
les@mcs.com
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 3793
**************************************