[8050] in Perl-Users-Digest
Perl-Users Digest, Issue: 1675 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 19 18:17:18 1998
Date: Mon, 19 Jan 98 15:00:25 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 19 Jan 1998 Volume: 8 Number: 1675
Today's topics:
Re: Another Stupid Question (sort) (Greg Bacon)
can i do this? <richard.remington@gateway2000.com>
Re: can i do this? <johnrs@dc.net>
Re: Changing Case (brian d foy)
Re: Deleting specific lines from text files. <ebohlman@netcom.com>
Re: Deleting specific lines from text files. (Matthew Cravit)
Re: Determining file type (Martien Verbruggen)
Re: differences <johnrs@dc.net>
Re: Exporter Question <dgoddard@us.oracle.com>
handling <input type=image> <none@nowhere.net>
Re: How do I convert 19971016085243 to time since the e <blazer@mail.nevalink.ru>
Re: How do I convert 19971016085243 to time since the e <sgordon@athena.lbl.gov>
Re: Is there a way to list all source used by perl pgm? <johnrs@dc.net>
Re: MacPerl carriage returns <aaron@soltec.net>
Re: Perl 5 and ORACLE 7 on Windows 95 (Martien Verbruggen)
Re: PERL forking (Charles DeRykus)
PERL+ODBC vs Delphi for webwork (Jeffery Chow)
Re: PERL+ODBC vs Delphi for webwork (Todd Vallie)
Re: Perl5 NT FTP Library (Jeffrey Drumm)
Re: Puzzling behavior of c.l.p.* readers (Pete Bevin)
Re: Puzzling behavior of c.l.p.* readers (Greg Bacon)
Re: Puzzling behavior of c.l.p.* readers (Greg Bacon)
Re: REGEXP: Does it need optimization? (Greg Bacon)
Re: Sorting an Associative Array (brian d foy)
Re: Sorting an Associative Array (Mike Stok)
Re: Sorting an Associative Array (Juergen Heinzl)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 19 Jan 1998 22:26:22 GMT
From: gbacon@adtran.com (Greg Bacon)
To: Todd McLaughlin <toddm@rahul.net>
Subject: Re: Another Stupid Question (sort)
Message-Id: <6a0jue$20k$6@info.uah.edu>
[Posted and mailed]
In article <6a05lt$2kr$1@samba.rahul.net>,
Todd McLaughlin <toddm@rahul.net> writes:
: How do I sort a 2D array by the second field (numeric)?
Assuming you'd want something like
( [ 'apple', 2 ], [ 'orange', 1 ] )
to become
( [ 'orange', 1 ], [ 'apple', 2 ] )
you want
@sorted = sort { $a->[1] <=> $b->[1] } @array;
Hope this helps,
Greg
--
open G,"|gzip -dc";$_=<<EOF;s/([0-9a-f]+)/print G pack"h*",$1/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF
------------------------------
Date: Mon, 19 Jan 1998 14:47:57 -0600
From: Richard Remington <richard.remington@gateway2000.com>
Subject: can i do this?
Message-Id: <34C3BBFD.E22BEBED@nowhere>
i have a simple script that reads from an html template file, makes
substitutions, and then prints it out to a browser.
but i want to do the reading and writing at the same time. i have tested
it and it works fine. but i have some undefined reservations, especially
for hi-load situations. maybe because i am keeping the file open for
longer then if i slurp it in @in = <TEMP>??
any comments greatly appreciated
open (TEMP, $FileToOpen);
while(<TEMP>) {
s/<<one>>/$string/g;
s/<<title>>/$title/g;
etc...
print;
}
close(TEMP);
------------------------------
Date: Mon, 19 Jan 1998 16:56:49 -0500
From: john -r s <johnrs@dc.net>
To: Richard Remington <richard.remington@gateway2000.com>
Subject: Re: can i do this?
Message-Id: <34C3CC20.7BACE702@dc.net>
You should be able to slurp it in and then still handle each line
separatley. Try this:
.
.
@in = (<TEMP>);
close(TEMP);
foreach $line (@TEMP){
s/<<one>>/$string/g;
s/<<title>>/$title/g;
etc...
print $line;
}
As for performance and saftey of open file handles, It is probably dependant
on your system unique situation. Still this is not much of a change and is
much safer than leaving the file handle open. Good-luck.
Richard Remington wrote:
> i have a simple script that reads from an html template file, makes
> substitutions, and then prints it out to a browser.
> but i want to do the reading and writing at the same time. i have tested
> it and it works fine. but i have some undefined reservations, especially
> for hi-load situations. maybe because i am keeping the file open for
> longer then if i slurp it in @in = <TEMP>??
>
--
john -r s (unix spelling)
johnr~s (Windows 3.1 spelling)
JOHNRS (DOS spelling)
John R S (Win95 spelling)
------------------------------
Date: Mon, 19 Jan 1998 16:36:13 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Changing Case
Message-Id: <comdog-ya02408000R1901981636130001@news.panix.com>
Keywords: from just another new york perl hacker
In article <En1HvI.A6@mail2.ccs.bbk.ac.uk>, mick@picus.dcs.bbk.ac.uk (Mick Farmer) posted:
>Dear Brad,
>
>Something like this should work.
>
> $text = ...;
> $nice = join ' ', map ucfirst lc, split / /, $text;
hmmm....
#!/usr/bin/perl
$text = "just another 'new york' perl hacker";
$nice = join ' ', map ucfirst lc, split / /, $text;
print $nice;
__END__
Just Another 'new York' Perl Hacker
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
------------------------------
Date: Mon, 19 Jan 1998 21:27:42 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Deleting specific lines from text files.
Message-Id: <ebohlmanEn1vM6.3Hs@netcom.com>
James <James@cydaps.nospam.co.uk> wrote:
: I am setting up a registration page where a user enters various
: information (ie email address, name, password, username, likes,
: dislikes) and this is sent to a perl script I have created that stores
: this information in a pipe delimited text file which is then read by the
: server when the user logs in. Each user that registers is placed in this
: one file but the problem I have is that sometimes a user wants to
: unregister and this means that I have to manually remove his/her listing
: from the file which can be difficult with 10,000 users in there or so!
You might want to look into maintaining your database using sprite.pm,
available on CPAN. It will take care of this sort of thing for you.
10,000 records is going to be pushing it, but it's going to be pushing
*any* flat-file based storage scheme, and sprite's interface (based on a
subset of SQL) is closer to what you'd be using if you went to a more
formal database engine.
------------------------------
Date: 19 Jan 1998 14:35:11 -0800
From: mcravit@best.com (Matthew Cravit)
Subject: Re: Deleting specific lines from text files.
Message-Id: <6a0kev$8m6$1@shell3.ba.best.com>
In article <pzCs3AAHx3w0Ew+v@cydaps.co.uk>,
James <James@cydaps.nospam.co.uk> wrote:
>I am wondering if anyone knows how I can allow the user to delete
>his/her information from this file without deleting anything else. They
>would enter their usename and password and click a button that would
>delete them from the server.
In addition to the other suggestions which have been made, you could use
a DBM file instead of a text file to store the registration data. Then,
you can use the Perl tie construct to access the file. The perltie man
page has more details, but basically you'd do something like this:
# Load the modules
use Fcntl;
use AnyDBM_File;
@AnyDBM_File::ISA = qw(NDBM_File GDBM_File DB_File);
# Tie the data file
tie %USERS, "NDBM_File", "userdb", O_RDWR|O_CREAT, 0755 or die "tie: $!\n";
# Add some users to the database
$USERS{'joesmith'} = "Joe Smith|password|Joe Smith|...";
$USERS{'annejones'} = "Anne Jones|mypass|Anne Jones|...";
# Remove a user from the database
delete $USERS{'joesmith'};
# Close the data file
untie %USERS;
Hope this helps.
/MC
--
Matthew Cravit, N9VWG | Experience is what allows you to
E-mail: mcravit@best.com (home) | recognize a mistake the second
mcravit@taos.com (work) | time you make it.
------------------------------
Date: 19 Jan 1998 22:25:41 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Determining file type
Message-Id: <6a0jt5$i7a$4@comdyn.comdyn.com.au>
In article <34C2F0A8.3F15D7@5sigma.com>,
"Joseph N. Hall" <joseph@5sigma.com> writes:
> I am sure that I have seen some discussion of a module along the
> lines of the file(1) command, but now I can't find it. Well, ok,
> maybe I was dreaming.
Now that you mention it.. I seem to recall something about that as
well, but it probably was a long time ago. I can't find anything on
CPAN. I guess the person suggesting it never got around to actually
implement it.
> Speaking of which, have you heard of the file(1) command?
Sure, but that's not perl. It cannot be relied on to be available on
every platform perl runs on.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | A Freudian slip is when you say one
Commercial Dynamics Pty. Ltd. | thing but mean your mother.
NSW, Australia |
------------------------------
Date: Mon, 19 Jan 1998 17:09:45 -0500
From: john -r s <johnrs@dc.net>
Subject: Re: differences
Message-Id: <34C3CF28.8E83705D@dc.net>
The = is an assignment. This means you are going to "set" something to
something else. like: $myvar = 1;
The == is a testing operator. This is used to check if something is
already set to something else. like: if ($myvar == 1)
The eq is also a test operator. It is used to test something and see if
it contains alpabetic types of data. These are sometimes called char's
or strings. Otherwise it is very similar to the ==.
The =~ is used when matching "things" (thats a technical word) to
certain other things.
To find out more you should go the Comprehensive Perl Archive Network
(CPAN). Here is a link for your web browser to get you started:
http://www.perl.com
There are also many good books to get you started with Perl
programming. Good-luck Klaus!
Jahnel Klaus wrote:
> what are the big diferences between
> = , == , =~ and eq ?
> Klaus
--
john -r s (unix spelling)
johnr~s (Windows 3.1 spelling)
JOHNRS (DOS spelling)
John R S (Win95 spelling)
------------------------------
Date: Mon, 19 Jan 1998 14:21:21 -0800
From: Denis Goddard <dgoddard@us.oracle.com>
To: Verma Kakarlapudi <vkakarla@adelphia.net>
Subject: Re: Exporter Question
Message-Id: <34C3D1E1.B04FB493@us.oracle.com>
Verma Kakarlapudi wrote:
> I am moving old Perl4 code to Perl5 and have been struggling
> to understand the significance of Exporter function.
> ...
> WHY.. WHY..?
Well, one thing I like about using the Exporter is that it makes highly
modular code
a lot easier to maintain.
Consider:
#!/usr/local/bin/perl
use MyModule qw( Procedure1 Procedure2 SomeProcedure AnotherProcedure );
use YourModule ( Foo Bar Glarch );
...
&SomeProcedure(arg, arg);
&Glarch(arg);;
1. When you refer to the procedures in the used module, the module name
is not
"hardcoded". So if you merge or split or rename the modules, you don't
have to muck
with all the code. You just muck with the few 'use' lines.
But yet at the same time....
2. When somebody goes to maintain your code, they can see exactly where
&SomeProcedure is defined. A bit like the rigorous convention is some C
shops where
they list the reason why each .h file is #included (which is sometimes
non-obvious).
For example:
#include <unistd.h>; /* has fsync() */
Readability, modularity, and maintainability are more important than
most anything else,
IMHO
-Denis
------------------------------
Date: Mon, 19 Jan 1998 16:37:51 -0600
From: adam <none@nowhere.net>
Subject: handling <input type=image>
Message-Id: <34C3D5BF.662A495D@nowhere.net>
what is the easiest way to handle this in perl? i have a few on a page
that each trigger different events.
but, the input image returns a number as value. so i have to give each
image a different name and check for the name. it seems like there must
be an easier way to handle this. i have seen any examples of handling
multiple <input type=image> anywhere on the net.
does anybody have any suggestions?
adam
------------------------------
Date: Tue, 20 Jan 1998 00:59:44 +0300
From: Mike <blazer@mail.nevalink.ru>
To: sgordon@athena.lbl.gov
Subject: Re: How do I convert 19971016085243 to time since the epoch??
Message-Id: <34C3CCD0.234C@mail.nevalink.ru>
I don't know what does each field mean, but the beginning looks like
yyyymmdd. And the rest may be hhmmss ?
You can extract them with
$_= '19971016085243';
($year, $mon, $mday, $hour, $min, $sec) =
/^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/;
hth
--
***************************
Mike Blazer
blazer@mail.nevalink.ru
***************************
Shawn Gordon <sgordon@athena.lbl.gov> g`ohq`mn b qr`r|~
<34C3A4DB.BC7380DD@athena.lbl.gov>...
> brian d foy wrote:
>
> >
> > use the Date modules which you find on CPAN [1].
> >
> or unpack...
>
> shawn
>
------------------------------
Date: Mon, 19 Jan 1998 14:38:46 -0800
From: Shawn Gordon <sgordon@athena.lbl.gov>
To: blazer@mail.nevalink.ru
Subject: Re: How do I convert 19971016085243 to time since the epoch??
Message-Id: <34C3D5F6.7CFA9CEF@athena.lbl.gov>
Mike wrote:
>
> I don't know what does each field mean, but the beginning looks like
> yyyymmdd. And the rest may be hhmmss ?
> You can extract them with
> $_= '19971016085243';
> ($year, $mon, $mday, $hour, $min, $sec) =
> /^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/;
>
> hth
Hi Mike,
By unpack, I mean:
($year,$mon,$mday,$hour,$min,$sec) = unpack "a4"."a2" x 5, $_;
Of course, matching regex defn. works, but if the record your
extracting the data from ALWAYS matches this structure, then
(I believe - anyone care to refute?) that the unpack is slightly
more time efficient. I ran each of these through Benchmark and found
unpack to run 24% faster than match.
Take Care,
shawn
------------------------------
Date: Mon, 19 Jan 1998 17:16:28 -0500
From: john -r s <johnrs@dc.net>
To: Richard Frenkel <infobord@shore.net>
Subject: Re: Is there a way to list all source used by perl pgm?
Message-Id: <34C3D0BC.E258C880@dc.net>
Richard Frenkel wrote:
> Without proof, I strongly suspect if I could gather all the modules in one
> file the parsing of the file would be much faster than fetching them from
> all over the file system. This is not really precompiling since everything
> would be left in source code, but it would help reduce at least one source
> of overhead.
I tried this once many years ago. I was creating an application in RBASE. I
figured if everything was stored in one "giant" module, the thing would run
like gangbusters. It ran pretty slow and I always thought "wow just think if
this was in separate modules - it would really be slow".
As time went by more people were added to the little project and I (screamming
and kicking about performance the whole way) was forced to split the
application apart.
In the end it was composed of 70 modules about 1-2 screens full of code each.
It ran about 10 times faster than before. Go -Figure!
--
john -r s (unix spelling)
johnr~s (Windows 3.1 spelling)
JOHNRS (DOS spelling)
John R S (Win95 spelling)
------------------------------
Date: Mon, 19 Jan 1998 15:49:26 -0600
From: Aaron Young <aaron@soltec.net>
Subject: Re: MacPerl carriage returns
Message-Id: <34C3CA65.66909CDC@soltec.net>
Thank you very much
that seems to have done it
I also will take note of the \n vs \015 informati
Paul J. Schinder wrote:
> In <aaron-1801982151190001@digi2-059.wwa.com> "Aaron Young" <aaron@soltec.net> writes:
>
> >Hello everyone
>
> >I am trying to write a client that talks to a pop server on a macintosh.
> >When I send the USER command like this
>
> >USER username\n
>
> In *all* your Perl scripts, you should get out of this bad habit.
> \n != \012. \n is a symbol that means "end of line on this platform". On
> a Macintosh, \n = \015. I can't look at the relevant RFC's at the moment,
> but I'd guess that POP3 is yet another protocol that wants \015\012 at
> the end of the line. If this is the case, then you write
>
> USER username\015\012 (or \0xd\0xa if you want).
>
> Even better, don't reinvent the wheel. Graham Barr's libnet package has
> a Net::POP3 module that works quite well, and libnet is included in recent
> MacPerl distributions. You should use Shuck to read the pod in
> :MacPerl f:lib:Net:POP3.pm.
>
> >The server seems to be timing out on me
>
> >Is there another way I should be sending the carriage return since it is
> >sitting on a macintosh?
>
> >If I point it at a pop server sitting on a unix box, it works
>
> >Aaron
> --
> --------
> Paul J. Schinder
> NASA Goddard Space Flight Center
> schinder@leprss.gsfc.nasa.gov
------------------------------
Date: 19 Jan 1998 22:06:50 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl 5 and ORACLE 7 on Windows 95
Message-Id: <6a0ipq$i7a$3@comdyn.comdyn.com.au>
In article <01bd21ff$43f5c800$1a2bcbd0@mzelmanov.qquest.com>,
"Mikhail Zelmanov" <mzelmanov@qquest.com> writes:
> I am running Perl 5 and ORACLE 7 on Windows 95 .
> Does someone can tell me how can I access ORACLE 7 database from Perl 5 in
> Windows 95 .
You could have a look at the DBI package with the Oracle driver:
http://www.hermetica.com/technologia/DBI/
or you could have a look at the Win32::ODBC package, and use an Oracle
ODBC driver. (You'll have to ask Oracle or Microsoft for that)
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | In a world without fences, who needs
Commercial Dynamics Pty. Ltd. | Gates?
NSW, Australia |
------------------------------
Date: Mon, 19 Jan 1998 19:49:44 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: PERL forking
Message-Id: <En1r2w.L6p@bcstec.ca.boeing.com>
perldoc -f fork and read the section following the sentence
below:
"If you fork() with without ever waiting on your children,
you will accumulate zombies:"
HTH,
--
Charles DeRykus
In article <34C382E9.6CBA41C2@oso.chalmers.se>,
Anders Nilsson <an@oso.chalmers.se> wrote:
>
> I am working with a perl program to administrate a large number of
> calculations. When a subprocess terminates from a fork it becomes a
> zombie. I haven't checked everything all through but judging from
> the simple csh program I wrote, the problem seems to be that perl
> refuses to release the control until the mother process dies. It is
> a real problem since the the actual loop will not be formed as below
> in the future. It will probably include a couple of thousand runnings
> and I don't think that a thousand zombies is particularly healthy for
> a linux machine. It's not a linux problem since it works the same on
> a HP-UX machine.
>
> The active part of my test program is included below. Let me also tell
> that I have tried with: system("cmd"); and: `cmd`; for the row exec cmd;
> with the same result. The command cmd is a simple csh program for
> testing
> purposes including a find and an echo terminated by exit(0).
> The subroutine get_load extracts the load using csh uptime.
>
> My question is: is this a bug in perl or is there another way to do it?
> I would prefer not to kill the main program and restart it.
>
> for ( $z=0; $z< 100 ; $z++ ) {
> print "Lap $z\n";
> ( $load_01_min, $load_05_min, $load_15_min) = get_load();
> if ( $load_01_min < 0.6 ) {
> if ( $pid = fork ) {
> print "Main Process\n";
> } else {
> print "Starting child process $pid\n";
> exec cmd;
> exit 0;
> }
> } else {
> print "Not starting any process\n";
> }
> sleep 5;
> }
>
------------------------------
Date: 19 Jan 1998 20:52:21 GMT
From: jefferyc@unixg.ubc.ca (Jeffery Chow)
Subject: PERL+ODBC vs Delphi for webwork
Message-Id: <6a0ee5$hl9$1@nntp.ucs.ubc.ca>
Hi. I apologize for the crosspost, but I'm desperate for comments and
was hoping to get as many views as possible.
I'm faced with a difficult decision that I must make for
my boss in one of my university's co-op offices. We have a paradox7
database that we'd like to publish on the www and allow students to
make changes to their status/information/etc.
I've implemented a stopgap solution using PERL32 and the ODBC
library, but the ODBC driver we're using (by MS, came bundled
with Office97 Dataacc package) is failing with an obscure error
that MS won't solve for me.
We're willing to purchase a commercial ODBC driver (looking at
Intersolv's DataDirect line) but I'd like to take this chance to
see if we're approaching this the wrong way.
Basically, it's a decision between PERL+ODBC and Delphi (or
whatever solution you'd like to recommend). Keeping these
issues in mind (to follow), what would be your recommendation?
PERL+ODBC:
(+) I'm already familiar with it, and have already written a moderate
amount of PERL code
(+) continuing with PERL+ODBC is cheapest solution, ODBC driver costs
$800
(-) PERL scripts have notable overheads when loading interpreter
Delphi:
(+) strong integration with Paradox, proven to work
(*) Is delphi as strong with other DBMSs out there? SQL Server? Access?
(-) I haven't worked with it before, will have to spend time learning,
must discard existing code
(-) quite expensive, about $2300 for professional suite and client/server
suite (but I'm not sure about academic pricing).
Please comment on these topics, any views would be greatly appreciated.
more of a unix person,
Jeff
|======================================================|
| Jeffery Chow 4th year Computer Science, UBC |
|------------------------------------------------------|
| http://www.ugrad.cs.ubc.ca/spider/j8g1/fdoor.html |
| "Here lives a competent, trustworthy salesman of |
| propane and propane accessories." -- H. Hill |
| This message brought to you by Bill Gates, inventor |
| of DOS, the World Wide Web, and the modern GUI. |
|======================================================|
------------------------------
Date: 19 Jan 1998 21:17:40 GMT
From: nomail@nomail.com (Todd Vallie)
Subject: Re: PERL+ODBC vs Delphi for webwork
Message-Id: <6a0ftk$gru$1@kodak.rdcs.Kodak.COM>
Try Cold Fusion by allaire. If you know perl, this will seem like cake
for you. It's basically html & sql combined. Theres a version for unix
and NT, and the database doesn't need to be on the same server you're
running your web server from.
It works with any odbc database and I think it even comes with the drivers
you need.
--
-Todd
************************************
Disclaimer so I can keep my job:
Any opinion expressed above is mine
and mine alone. My vews do not represent
those of my employer. My opinion is
simply that.
------------------------------
Date: Mon, 19 Jan 1998 22:15:54 GMT
From: drummj@mail.mmc.org (Jeffrey Drumm)
Subject: Re: Perl5 NT FTP Library
Message-Id: <34c3d04b.680946266@news.mmc.org>
On Mon, 19 Jan 1998 11:20:42 -0500, "David Mohorn"
<david.mohorn@sourcebbs.com> wrote:
>Does anyone know if there is any Perl-5 for NT libraries for using FTP?
>
>...david
>david.mohorn@norfolkva.ncr.com
Yes, someone does know. And he/she found out by first checking the source
from whence all searches for Perl enlightenment spring . . .
http://www.perl.com.
There you will find hundreds of modules . . . at least one of which may do
what you're hoping. Assuming, of course, you're using the "right" Perl.
Hint: ActiveState's may not be "it".
If Gurusamy Sarathy's port of Perl 5.004.02 meets your needs, you will find
that it comes with the libnet modules. They almost work, but a few methods
aren't quite there yet. What problems I've found with Net::FTP have been
resolved with release 1.06.03 of libnet, and I assume that later is better.
The update is easily installable on NT, no C compiler required.
--
Jeffrey R. Drumm, Systems Integration Specialist
Maine Medical Center Information Services
420 Cumberland Ave, Portland, ME 04101
drummj@mail.mmc.org
------------------------------
Date: 19 Jan 1998 20:53:34 GMT
From: moose@bestiary.com (Pete Bevin)
Subject: Re: Puzzling behavior of c.l.p.* readers
Message-Id: <40733296C9E6739F.57186C36EE91ABB9.B00BB4E4A417F47F@library-proxy.airnews.net>
Brandon S. Allbery writes:
>| >: > if ( $firstchar == "Y" ) || ( $firstchar == "y" ) { ...
>
>...and nobody's yet mentioned the missing pair of parens that will prevent it
>from compiling in the first place....
Yeah. Jeez, folks -- if you're going to post an example of non-working
code, at least make sure it compiles...
Pete, *sheesh*
--
Pete Bevin <moose@bestiary.com>, quietly taking a leak in the gene pool.
==> Spam welcomed at <banme@bestiary.com> <==
------------------------------
Date: 19 Jan 1998 21:54:17 GMT
From: gbacon@adtran.com (Greg Bacon)
Subject: Re: Puzzling behavior of c.l.p.* readers
Message-Id: <6a0i29$20k$2@info.uah.edu>
In article <69r62i$bm4@fridge.shore.net>,
nvp@shore.net (Nathan V. Patwardhan) writes:
: Well, at least nobody's mentioned Hitler or Mussolini yet. ;-)
How neo-nazifascist of you to say!! :-) ** 3
Greg
--
open G,"|gzip -dc";$_=<<EOF;s/([0-9a-f]+)/print G pack"h*",$1/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF
------------------------------
Date: 19 Jan 1998 22:01:21 GMT
From: gbacon@adtran.com (Greg Bacon)
To: "David A. Frantz" <wizard@eznet.net>
Subject: Re: Puzzling behavior of c.l.p.* readers
Message-Id: <6a0ifh$20k$3@info.uah.edu>
[Posted and mailed]
In article <34bff535.0@news.eznet.net>,
"David A. Frantz" <wizard@eznet.net> writes:
: Andy Lester wrote in message <69ordb$mi3$1@usenet48.supernews.com>...
: >* People who negate any chance of correspondence in their spamanoia. This
: >is all over Usenet, of course, but I'm amazed whenever I see it:
: >"Remove the '.fuckyouspammers' from my email address in order to send me
: >mail." No, I won't. You're on your own.
:
: Andy for the most part I would agree with you and I'am a new PERL user.
: But the above remark kinda leaves me wondering if you have every
: recieved on occasion to much junk mail. Its sad but there may be good
: reason for some to respond as above.
I couldn't disagree more. ObPerl: filtering spam is a perfect
application for a language like Perl. I use a filter written in Perl.
Besides, when people take the time to unmunge your address for a reply,
it's in the To: header, free for the address harvesters to grab.
(You'll notice that your email address is unmunged in the To: header of
this very post. What has munging bought you?)
The effect is to inconvenience others who have a legitimate reason to
contact you and to break what has always worked. Address munging is a
poor solution to an already disgusting problem.
Greg
--
open G,"|gzip -dc";$_=<<EOF;s/([0-9a-f]+)/print G pack"h*",$1/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF
------------------------------
Date: 19 Jan 1998 22:22:34 GMT
From: gbacon@adtran.com (Greg Bacon)
To: rick@marinweb.com
Subject: Re: REGEXP: Does it need optimization?
Message-Id: <6a0jna$20k$5@info.uah.edu>
[Posted and mailed]
In article <34c57b20.12120348@nntp2.ba.best.com>,
rick@marinweb.com (Rick Freeman) writes:
: I'm pretty new to this and was wondering if anhone has any suggestions
: here. A search script I modified now uses the following regexp to
: exclude portions of an HTML page from searches:
:
: s#(^.*)(</head>.*<!--content-->)(.*)(<!--/content-->.*$)#\1 \3#i
Use
s#^(.*)(</head>.*<!--content-->)(.*)(<!--/content-->.*$)#$1 $3#i
Beware HTML hacking with regoxen. You can usually get by with it for
simple cases, but in others, you'll need to use a proper parser, like
HTML::Parser which comes with the LWP distribution.
: 1. Should I be using the non-greedy modifier on any of the *
: quantifiers? (Would that make it run faster?)
Use the cautious quantifiers if you need them. The way it's implemented
now, here's the difference: the greedy constructs race as far ahead as
they can, but cautious constructs pause at each step and try to give
control to whatever is next in the regex. In general, cautious
quantifiers produce slower matching regoxen. Use them when you want a
minimal match. Read up on minimal matching in the perlre manpage.
: 2. Is the performance hit from using /i very significant?
Hard to say. Use the Benchmark module and compare the two.
: 3. /o wouldn't be useful here... would it?
/o only makes a difference when you're interpolating variables into your
regex like
/I'm looking for a $foo/o;
and not a literal as above.
: And yes, some day I *do* plan to read "Mastering Regular Expressions."
Good call. For those not in the know
Mastering Regular Expressions
Jeffrey E. F. Friedl
ISBN 1-56592-257-3
US $29.95 / CAN $42.95
...and worth every penny/Pfennig/farthing/lira/Rickbeck.
Greg
--
open G,"|gzip -dc";$_=<<EOF;s/([0-9a-f]+)/print G pack"h*",$1/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF
------------------------------
Date: Mon, 19 Jan 1998 16:38:03 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Sorting an Associative Array
Message-Id: <comdog-ya02408000R1901981638030001@news.panix.com>
Keywords: from just another new york perl hacker
In article <34C3AEC7.4556C90D@d.umn.edu>, Xiong Wang <xwang@d.umn.edu> posted:
>Does anybody know how to sort an associate array?
yes, for certain definitions of sort.
>For example, I have %assoc_array = (3 =>"dddd", 4=>"aaaa",
>2=>"cccc"....). And I want to change it into: (4=>"aaaa", 2=>"cccc",
>3=>"dddd".....).
if you are trying to affect the order in which keys will be
returned by the likes of keys() and each(), this won't do it.
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
------------------------------
Date: 19 Jan 1998 16:31:36 -0500
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Sorting an Associative Array
Message-Id: <6a0gno$1ve$1@stok.co.uk>
In article <34C3AEC7.4556C90D@d.umn.edu>, Xiong Wang <xwang@d.umn.edu> wrote:
>Does anybody know how to sort an associate array?
>For example, I have %assoc_array = (3 =>"dddd", 4=>"aaaa",
>2=>"cccc"....). And I want to change it into: (4=>"aaaa", 2=>"cccc",
>3=>"dddd".....).
The hash is intrinsically unsorted, but you can sort the keys of the hash
as a normal list so that you end up with a list of keys which will access
the hash in the apprpriate order e.g.
%hash = (3 => 'dddd', 4 => 'aaaa', 2 => 'cccc');
@keys = sort {$hash{$a} cmp $hash{$b}} keys %hash;
leaves @keys containing (4, 2, 3)
If you have a recent perl then the perldoc command should be installed to
let you read parts of the Frequently Asked Questions (FAQ) which now come
as part of the distribution.
perldoc perlfaq4
should geet you information on sorting arrays. If you have an older perl
then browsing http://www.perl.com/ or going to a Comprehensive Perl
Archive Network site (the master site is at ftp.funet.fi under
/pub/languages/perl/CPAN and has a list of mirror sites) should get you to
the documentation.
http://www.perl.com/CPAN-local/doc/FMTEYEWTK has a section on sorting.
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: 19 Jan 1998 21:56:20 GMT
From: juergen@unicorn.noris.de (Juergen Heinzl)
Subject: Re: Sorting an Associative Array
Message-Id: <slrn6c7jbg.67.juergen@unicorn.noris.de>
In article <34C3AEC7.4556C90D@d.umn.edu>, Xiong Wang wrote:
>Does anybody know how to sort an associate array?
That does not make sense, since hashing is used anyway, though
of course you can say sort [keys | values] %assoc_array;
Bye, Juergen
--
\ Real name : Juergen Heinzl \ no flames /
\ EMail Private : unicorn@noris.de \ send money instead /
\ Phone Private : +49 911-4501186 \ /
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.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 1675
**************************************