[11504] in Perl-Users-Digest
Perl-Users Digest, Issue: 5104 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 10 18:07:26 1999
Date: Wed, 10 Mar 99 15:00:22 -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 Wed, 10 Mar 1999 Volume: 8 Number: 5104
Today's topics:
Re: FAQ 3.24: How can I get C<#!perl> to work on [MS-DO <cassell@mail.cor.epa.gov>
FAQ 3.25: Can I write useful perl programs on the comma <perlfaq-suggestions@perl.com>
Filecheck-like utility?? <psmith01@mindspring.com>
Re: Finding comments in a file using regular expression (Larry Rosler)
Re: FL - Boca Raton - Sr. Programmer/Analyst <estabroo@ispn.com>
How best to do multi-file scripts <benbean@yahoo.com>
Re: How best to do multi-file scripts <psmith01@mindspring.com>
Re: How to do a Case-insensitive Sort? (Larry Rosler)
Re: I want to know where I can get a sendmail program t <psmith01@mindspring.com>
I want to know where I can get a sendmail program that <rollo@enter.net>
Re: MS ACCESS database with perl <gellyfish@btinternet.com>
Re: Need advice <upsetter@ziplink.net>
Newbe Perl question: fs equiv? <rwilliamson@uno.gers.com>
Re: Newbe Perl question: fs equiv? <psmith01@mindspring.com>
newbie help request <c.coughlan@ucl.ac.uk>
Re: newbie help request (I R A Aggie)
Re: Newbie question about references/deferencing <jglascoe@giss.nasa.gov>
Re: Ok, this is a weird phenomenon... (John Klassa)
Re: Ouput to textbox w/o rewriting page <upsetter@ziplink.net>
Re: Perl and Syslog (Juergen Heinzl)
Re: Perl comment <martinb@talx.com.no.spam>
Re: Perl scripts written for UNIX. Will they work on NT <cpierce1@ford.com>
Re: PerlTk for Win32 ? <benbean@yahoo.com>
Re: problems reading HTML file <jglascoe@giss.nasa.gov>
Re: Problems with Perl and tar <gellyfish@btinternet.com>
Re: RegEx extended ASCII problem (Ilya Zakharevich)
Re: RegEx extended ASCII problem <jeffp@crusoe.net>
Re: Speed-optimizing regular expressions (Sean McAfee)
Re: The millennium cometh -- eventually (Martien Verbruggen)
Re: Using Modules on Win95 Platform <ldemarest@mindspring.com>
Re: Using Modules on Win95 Platform <ldemarest@mindspring.com>
Re: why does my browser show my scripts instead of runn <kperrier@blkbox.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 10 Mar 1999 14:21:37 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
To: Tom and Gnat <perlfaq-suggestions@perl.com>
Subject: Re: FAQ 3.24: How can I get C<#!perl> to work on [MS-DOS,NT,...]?
Message-Id: <36E6F071.3789471A@mail.cor.epa.gov>
Tom Christiansen wrote:
[snipped down to relevant chunk]
> The Win95/NT installation, when using the ActiveState port of
> Perl, will modify the Registry to associate the `.pl' extension
> with the perl interpreter. If you install another port (Gurusamy
> Sarathy's is the recommended Win95/NT port)
Errm.. I guess I'm confused. Tom, forgive me if I'm too
unix-centric (:-) but isn't Gurusamy Sarathy working for ActiveState
now? Isn't the ActiveState port considered the current recommended
win-port? If I'm not confused (about this one thing, anyway)
then may I suggest updating the FAQ?
--
David
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 10 Mar 1999 14:16:42 -0700
From: Tom Christiansen <perlfaq-suggestions@perl.com>
Subject: FAQ 3.25: Can I write useful perl programs on the command line?
Message-Id: <36e6e13a@csnews>
(This excerpt from perlfaq3 - Programming Tools
($Revision: 1.33 $, $Date: 1998/12/29 20:12:12 $)
part of the standard set of documentation included with every
valid Perl distribution, like the one on your system.
See also http://language.perl.com/newdocs/pod/perlfaq3.html
if your negligent system adminstrator has been remiss in his duties.)
Can I write useful perl programs on the command line?
Yes. Read the perlrun manpage for more information. Some examples
follow. (These assume standard Unix shell quoting rules.)
# sum first and last fields
perl -lane 'print $F[0] + $F[-1]' *
# identify text files
perl -le 'for(@ARGV) {print if -f && -T _}' *
# remove (most) comments from C program
perl -0777 -pe 's{/\*.*?\*/}{}gs' foo.c
# make file a month younger than today, defeating reaper daemons
perl -e '$X=24*60*60; utime(time(),time() + 30 * $X,@ARGV)' *
# find first unused uid
perl -le '$i++ while getpwuid($i); print $i'
# display reasonable manpath
echo $PATH | perl -nl -072 -e '
s![^/+]*$!man!&&-d&&!$s{$_}++&&push@m,$_;END{print"@m"}'
Ok, the last one was actually an obfuscated perl entry. :-)
--
_doprnt(pat, args, &fakebuf); /* what a kludge */
--Larry Wall, from util.c in the v5.0 perl distribution
------------------------------
Date: Wed, 10 Mar 1999 17:49:06 -0500
From: Peter Smith <psmith01@mindspring.com>
Subject: Filecheck-like utility??
Message-Id: <36E6F6E2.392D7556@mindspring.com>
I need to quickly scan a file for non-alphanumeric and non-space
characters. Ideally I'd like to spit-out line numbers, and even
the offending character positions - assuming records are delimited
by newlines. Basically I'm looking for FILECHK-like ability for
anyone familiar with this dandy tool. Pretty sure I can gem a
script out fairly quick, not sure how efficient I could make it
though.
Thanks for any pointers.
--
--Peter--
psmith01@mindspring.com
------------------------------
Date: Mon, 8 Mar 1999 12:07:52 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Finding comments in a file using regular expressions
Message-Id: <MPG.114dcdf28fbc6173989710@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <Pine.A41.4.05.9903081048060.58606-100000@unix4.UVic.CA> on
Mon, 8 Mar 1999 11:10:27 -0800, Draco Paladin <paladin@uvic.ca> says...
...
> ... [^\#] matches anything that is not a literal '\' or '#'. Inside a
> character class the only characters you need to quote are:
> \], \a, \n, \r, \t, \f, \d, \w, \s. To include a [ put it first in the
> list and to include a ^ put it anywhere but first. (I'm working from
> memory here so I might have forgot one or two.)
Your understanding of backslash escape sequences is faulty.
Unless the succeeding character is such that the sequence backslash-
character has a special meaning (you show a few above, but by no means
all), the backslash is ignored. In other words, the default meaning for
backslash-character is just character, not backslash and character. To
get a literal backslash, you need to use two of them.
As you say, the rest of your observation is incomplete. The best way to
post is simply to refer to the paragraph on character classes in perlre,
or to quote it directly:
You can specify a character class, by enclosing a list of characters in
[], which will match any one character from the list. If the first
character after the ``['' is ``^'', the class matches any
character not in the list. Within a list, the ``-'' character is used to
specify a range, so that a-z represents all characters between ``a'' and
``z'', inclusive. If you want ``-'' itself to be a member
of a class, put it at the start or end of the list, or escape it with a
backslash. (The following all specify the same class of three
characters: [-az], [az-], and [a\-z]. All are different from
[a-z], which specifies a class containing twenty-six characters.)
--
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 10 Mar 1999 15:15:30 -0600
From: Eric Estabrooks <estabroo@ispn.com>
Subject: Re: FL - Boca Raton - Sr. Programmer/Analyst
Message-Id: <36E6E0F2.C33CCDB3@ispn.com>
Jennifer Larson wrote:
>
> Mulligan Services is currently in need of a Perl/CGI Guru in South Florida.
> Superior programming and systems analysis skills. 3+ years using Perl and
> CGI to develop real world web applications, 2+ years using Perl to access a
> relational database (Sybase preferred), 2+ years using Unix, knowledge of
> Apache Web Server, C, shell scripting, vi editor. Great benefits, excellent
> starting salary, 55k - 100k. EOE
>
> Send correspondence or resume to:
> resume@mulliganservices.com
> fax: 954-741-2106
Is relocation a requirement?
Eric
estabroo@ispn.com
------------------------------
Date: Wed, 10 Mar 1999 21:33:56 GMT
From: Benjamin Smith <benbean@yahoo.com>
Subject: How best to do multi-file scripts
Message-Id: <36E6E543.794BFCAA@yahoo.com>
What is the best strategy for working on a large script that would be
better suited to breaking up into separate files. Go to all the trouble
of defining each section as a module, or is there some easier C-style
#include equivalent. The Camel's references on use and require seem a
little vague about this from a non-modular viewpoint. All I want to do
is to be able to break a bunch of functions out into separate files and
call them as though they were one. Unless anybody can give me a
compelling reason why not in Perl.
Thanks!
Ben.
------------------------------
Date: Wed, 10 Mar 1999 17:54:15 -0500
From: Peter Smith <psmith01@mindspring.com>
Subject: Re: How best to do multi-file scripts
Message-Id: <36E6F817.A3F13815@mindspring.com>
think you're looking for 'require' as in the following statment:
require 'my_subroutines.pl';
Just make sure you have the statement:
1;
at the end of each subroutine file you wish to include...
Benjamin Smith wrote:
>
> What is the best strategy for working on a large script that would be
> better suited to breaking up into separate files. Go to all the trouble
> of defining each section as a module, or is there some easier C-style
> #include equivalent. The Camel's references on use and require seem a
> little vague about this from a non-modular viewpoint. All I want to do
> is to be able to break a bunch of functions out into separate files and
> call them as though they were one. Unless anybody can give me a
> compelling reason why not in Perl.
>
> Thanks!
>
> Ben.
--
--Peter--
psmith01@mindspring.com
------------------------------
Date: Mon, 8 Mar 1999 11:54:31 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How to do a Case-insensitive Sort?
Message-Id: <MPG.114dcad6ea5c8e5498970f@nntp.hpl.hp.com>
In article <7c0r12$n6l$1@info2.uah.edu> on 8 Mar 1999 15:40:18 GMT, Greg
Bacon <gbacon@itsc.uah.edu> says...
> In article <MPG.1149e3b51bf998109896e9@nntp.hpl.hp.com>,
> lr@hpl.hp.com (Larry Rosler) writes:
> : 1. Timing many iterations of a tiny sort distorts the measurements so
...
> Rob mentions this:
>
> Rule 3. Fancy algorithms are slow when n is small, and n is usually
> small. Fancy algorithms have big constants. Until you know
> that n is frequently going to be big, don't get fancy.
> (Even if n does get big, use Rule 2 first.) For example,
> binary trees are always faster than splay trees for
> workaday problems.
>
> Anyone who doesn't recognize this excerpt should immediately proceed to
> <URL:http://www.lysator.liu.se/c/pikestyle.html>.
That is an excellent work (published in 1989), which I reread a few days
ago after the URL was reposted in this newsgroup. I didn't remember it
well enough to attribute it in my observation of O(n) overhead. :-<
> : 2. Nevertheless, your generalization that a Schwartz Transform loses
> : when the comparison function is simply lc() is correct. Greg Bacon sees
> : 'Too many lc()s' and concludes incorrectly that this is expensive.
>
> You cannot label my statement incorrect (nor can I defend my assertion)
> without some knowledge of the size of the data.
No. I'm sorry, Greg. It is demonstrably incorrect.
A summary for those who might not recall the issue:
Naive sort: sub sortsub { lc($a) cmp lc($b) }
Schwartz Transform (ST) sort:
O(n) setup of arrays with lc as second element.
sub sortsub { $a->[1] cmp $b->[1] }
O(n) recovery of the data from the arrays.
Simple benchmark of sortsub alone:
#!/usr/local/bin/perl -w
use Benchmark;
my ($a, $b, $c, $d) = ('foo', 'bar', [ 0, 'foo' ], [ 0, 'bar' ]);
sub Cntrl { $a cmp $b }
sub Lcase { lc($a) cmp lc($b) }
sub ST { $c->[1] cmp $d->[1] }
timethese(1 << (shift || 0), {
Cntrl => \&Cntrl,
Naive => \&Naive,
ST => \&ST,
});
__END__
Benchmark: timing 1048576 iterations of Cntrl, Naive, ST...
Cntrl: 5 wallclock secs ( 5.41 usr + 0.00 sys = 5.41 CPU)
Naive: 8 wallclock secs ( 7.83 usr + 0.00 sys = 7.83 CPU)
ST: 8 wallclock secs ( 8.05 usr + 0.00 sys = 8.05 CPU)
As the two sortsubs take about the same time to execute, the overhead of
the ST cannot be recovered for any size of the data set. QED
...
> : 3. Factor out as much overhead as possible.
>
> What do you think doing O(n) lc()s instead of O(n lg n) lc()s is?
See above. It is *adding* overhead, for any n.
--
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 10 Mar 1999 17:50:57 -0500
From: Peter Smith <psmith01@mindspring.com>
Subject: Re: I want to know where I can get a sendmail program that will work with NT.
Message-Id: <36E6F751.E7BBF7AC@mindspring.com>
look-up 'CDONTS' on the ms site....think it's an ADO installed with
the MS smtp server in latest IIS download...stands for Collective
Data Objects NT Services or something...
Rollo Lawson wrote:
>
> Iam a new programmer to perl, and I was wondering where I can get a simple
> program that sends mail
> in an NT web environment. Does anybody have a Url or ftp that has one that
> will work please help
>
> rollo lawson
> rollo@enter.net
--
--Peter--
psmith01@mindspring.com
------------------------------
Date: Wed, 10 Mar 1999 17:24:55 -0500
From: "Rollo Lawson" <rollo@enter.net>
Subject: I want to know where I can get a sendmail program that will work with NT.
Message-Id: <36e6f07a.0@news3.enter.net>
Iam a new programmer to perl, and I was wondering where I can get a simple
program that sends mail
in an NT web environment. Does anybody have a Url or ftp that has one that
will work please help
rollo lawson
rollo@enter.net
------------------------------
Date: 10 Mar 1999 21:40:56 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: MS ACCESS database with perl
Message-Id: <7c6ot8$mf$1@gellyfish.btinternet.com>
On Wed, 10 Mar 1999 15:14:08 GMT John Casey wrote:
> Do you have to use Active State or can you use Perl 5.0004 (not sure
> how many zeros) from www.perl.com?
>
T use the DBD::ODBC package available from Activestate yes you do have to
use ActivePerl. There is (was?) a binary of Win32::ODBC available for the
5.004.02 binary distribution but I cant speak for DBI / DBD::ODBC.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Wed, 10 Mar 1999 21:00:41 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: Need advice
Message-Id: <Z3BF2.187$oi7.31967@news.shore.net>
Alex Iatskovski <74642.3600@NOSPAM.compuserve.com> wrote:
: Well, I need an advice. I have perl CGI program that can be executed only
: by authorized users. It is located in secure directory secured by HTTP
: Basic Authentication (. htpaccess), Unix platform of course. But I'd like
: to get information who exactly is executing this script in moment of
: execution.
If the script is running under basic authentication, the user name should
be in the variable $ENV{'REMOTE_USER'}. This is probably web server
dependent, but that would be the first place to look.
--Art
--
--------------------------------------------------------------------------
National Ska & Reggae Calendar
http://www.agitators.com/calendar/
--------------------------------------------------------------------------
------------------------------
Date: Wed, 10 Mar 1999 13:21:28 -0800
From: "Rusty Williamson" <rwilliamson@uno.gers.com>
Subject: Newbe Perl question: fs equiv?
Message-Id: <RnBF2.101$UK6.1442@news.connectnet.com>
Hi!
I need to get filesystem stats (total Mb, free, inodes, unused) -- I'm on a
UNIX box. Short of back quoting the fs command does Perl have a function
(it has PS)? I searching the doc -- so far zip. Hopefully I'm just missing
it.
Thanks,
Rusty Williamson
------------------------------
Date: Wed, 10 Mar 1999 17:55:47 -0500
From: Peter Smith <psmith01@mindspring.com>
Subject: Re: Newbe Perl question: fs equiv?
Message-Id: <36E6F873.758C9829@mindspring.com>
check out 'stat'
Rusty Williamson wrote:
>
> Hi!
>
> I need to get filesystem stats (total Mb, free, inodes, unused) -- I'm on a
> UNIX box. Short of back quoting the fs command does Perl have a function
> (it has PS)? I searching the doc -- so far zip. Hopefully I'm just missing
> it.
>
> Thanks,
> Rusty Williamson
--
--Peter--
psmith01@mindspring.com
------------------------------
Date: Wed, 10 Mar 1999 21:40:22 GMT
From: "cathal coughlan" <c.coughlan@ucl.ac.uk>
Subject: newbie help request
Message-Id: <01be6b3d$bc965b20$86c666c3@e-base.u-net.com>
Hi,
Sorry to just barge into the group, but desperation and a looming deadline
just got
the better of me...
I wonder if anyone could find the time to help me out with this script. It
presently searches a formatted textfile database quite efficiently, using
one variable value sent from a HTML form.
However... now I need it to accept values of TWO variables from a HTML
form, though, and
carry out a joined search (a Boolean AND, in effect), returning the records
which meet both criteria.
Here's the script:
#!/bin/perl
# requires cgi-lib.pl
require "cgi-lib.pl";
# grab values passed from form:
&ReadParse(*in);
print "Content-type: text/html\n\n";
# print the top part of the response
print "<HTML><HEAD><TITLE>Organisations Search Results</TITLE></HEAD>\n";
print "<body bgcolor=\"#FFFFFF\" text=\"maroon\" link=\"#990000\"
vlink=\"#666666\" alink=\"#CC9900\"><CENTER><h3><font face=\"verdana,
arial, helvetica\" color=\"maroon\">";
#Tower Hamlets Agenda 21 Community Network</FONT></h3></CENTER>\n";
print "<center><img src=\"images/a21_hd.jpg\">\n";
print "<center><font face=\"verdana, arial, helvetica\"><H5>The
organisations or individuals whose details most closely fit your search
criteria are as follows:</H5>\n";
print "<table><tr><td><center><font face=\"verdana, arial, helvetica\"
SIZE=-1>\n";
# read and parse data file
$data="director.dat";
open(DATA,"$data") || die "Can't open $data: $!\n</BODY></HTML>\n";
while(<DATA>) {
chop; # delete trailing \n
if (/^\s*$/) {
# break between records
if ($match) {
# if anything matched, print the whole record
&printrecord($record);
$nrecords_matched++;
}
undef $match;
undef $record;
next;
}
# tag: value
($tag,$val) = split(/:/,$_,2);
if ($tag =~ /^First Name/i) {
$match++ if( $in{'First Name'} && $val =~ /\b$in{'First Name'}/i) ;
$record ="<B>$val</B>";
next;
}
if ($tag =~ /^Last Name/i) {
$match++ if( $in{'Last Name'} && $val =~ /\b$in{'Last Name'}\b/i) ;
$record .= "<B>$val</B>";
next;
}
if ($tag =~ /^Organisation/i) {
$match++ if( $in{'Organisation'} && $val =~ /\b$in{'Organisation'}\b/i) ;
$record .= "\n<br><B>$val</B>" if ($val);
next;
}
if ($tag =~ /^Address/i) {
$match++ if( $in{'Address'} && $val =~ /\b$in{'Address'}\b/i) ;
$record .= "\n<BR>$val" if ($val);
next;
}
if ($tag =~ /^District/i) {
$match++ if( $in{'District'} && $val =~ /\b$in{'District'}\b/i) ;
$record .= "\n<br> $val" if ($val ne " ");
next;
}
if ($tag =~ /^Postcode/i) {
$match++ if( $in{'Postcode'} && $val =~ /\b$in{'Postcode'}\b/i) ;
$record .= "\n<BR>London $val" if ($val ne " ");
next;
}
if ($tag =~ /^Work Tel/i) {
$match++ if( $in{'Work Tel'} && $val =~ /\b$in{'Work Tel'}\b/i) ;
$record .= "\n<BR><b>Daytime Telephone:</b> $val" if ($val ne " ");
next;
}
if ($tag =~ /^Work Ext/i) {
$match++ if( $in{'Work Ext'} && $val =~ /\b$in{'Work Ext'}\b/i) ;
$record .= " <b>Extension:</b> $val" if ($val ne " ");
next;
}
if ($tag =~ /^Home Telephone/i) {
$match++ if( $in{'Home Telephone'} && $val =~ /\b$in{'Home
Telephone'}\b/i) ;
$record .= "\n<BR><b>Home Telephone:</b> $val" if ($val ne " ");
next;
}
if ($tag =~ /^Map/i) {
$match++ if( $in{'Map'} && $val =~ /\b$in{'Map'}\b/i) ;
$record .= "<BR><br><FONT SIZE=\"-2\"><B><A
HREF=\"http://uk.multimap.com/p/browse.cgi?pc=$val\"
TARGET=\"multimap\">Click here to see location on Multimap in a new
window</A></B></FONT>";
next;
}
#anything else
#$record .= $_;
}
close DATA;
if (! defined $nrecords_matched)
{ print "<H3>Sorry, there are no records matching your enquiry</H3>\n"; }
else {
print "<p>$nrecords_matched records matched<HR NOSHADE>"; }
#print "<p align=\"center\"><img src=\"images/blesepa.gif\"></p>\n";
print "<a href=\"index.html\"><h3>Search again</a></p></h3>\n";
print "<a href=\"add.html\"><h3>Add a name to the database</a></p></h3>\n";
print "</td></tr></table></center></BODY></HTML>\n";
exit;
sub printrecord {
local($buf) = @_;
print "<HR>\n$buf\n";
}
Thanks for reading this.
Cathal Coughlan (c.coughlan@ucl.ac.uk)
------------------------------
Date: 10 Mar 1999 22:43:08 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: newbie help request
Message-Id: <slrn7edttl.tf.fl_aggie@stat.fsu.edu>
On Wed, 10 Mar 1999 21:40:22 GMT, cathal coughlan <c.coughlan@ucl.ac.uk> wrote:
+ However... now I need it to accept values of TWO variables from a HTML
+ form, though, and
If you can extract one value, you can do N values...
+ carry out a joined search (a Boolean AND, in effect), returning the records
+ which meet both criteria.
You might want to do this in two passes: first, find the matches for
one variable, and from that data, find the matches for the second variable.
That seems ugly to me, but it will work, and I'm not feeling creative
enough to propose other solutions.
+ Here's the script:
+ if ($tag =~ /^First Name/i) {
+ $match++ if( $in{'First Name'} && $val =~ /\b$in{'First Name'}/i) ;
+ $record ="<B>$val</B>";
+ next;
+ }
This stuff looks obscenely familiar. This is Laura LeMay's HTML 4.0
book, isn't it? I hacked on this code about two months ago for my
former webmeister. I may have even implemented what you're asking
for.
Butt ugly code, to my eyes...
James
------------------------------
Date: Wed, 10 Mar 1999 16:05:32 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: Scott Stark <sstark@informix.com>
Subject: Re: Newbie question about references/deferencing
Message-Id: <36E6DE9C.73327E7B@giss.nasa.gov>
[courtesy copy of post sent to Scott]
Scott Stark wrote:
>
> Here's a code snippet:
>
> &check_flags2(\$preserve);
> print "The value of preserve is " . ${$preserve} . ".\n";
The scalar "$preserve" is sent to "&check_flags2" as a scalar reference.
But, it's still a scalar outside of the subroutine.
>
> sub check_flags2 {
> my($preserveP)=@_;
> $$preserveP=1;
> }
try this:
print "The value of preserve is $preserve\n";
> When I run it I get the following message (line 20 is the print line):
>
> Can't use string ("1") as a SCALAR ref while
> "strict refs" in use at getargsP.pl line 20.
yes, "${$preserve}" evaluates to "${1}". Narf!
> Can someone tell me what I'm doing wrong? If I don't "use strict" all I get is:
>
> The value of preserve is .
interesting. You must have captured the text "." using
a regular expression earlier?
Jay Glascoe
--
"It's okay to grow up--just as long as you
don't grow old. Face it... you are young."
--Pulp, http://www.rise.co.uk/pulp
------------------------------
Date: 10 Mar 1999 21:03:05 GMT
From: klassa@aur.alcatel.com (John Klassa)
Subject: Re: Ok, this is a weird phenomenon...
Message-Id: <7c6mm9$ba2$1@aurwww.aur.alcatel.com>
On 10 Mar 1999 18:40:06 GMT, Nobody <nobody@dewpoint.eng.sun.com> wrote:
> 10 sub first_step;
> 11 {
> 12 printf("You're in first_step routine.\n");
> 13 }
Note the semicolon after "first_step". There's your culprit.
--
John Klassa / Alcatel / Raleigh, NC, USA / $pm{Raleigh}[0] / \/\/&/\/\ / <><
------------------------------
Date: Wed, 10 Mar 1999 22:26:25 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: Ouput to textbox w/o rewriting page
Message-Id: <lkCF2.200$oi7.34362@news.shore.net>
Graphics i.e. <graphxie@ix.netcom.com> wrote:
: Is it possible to return the results of a form submitted to a perl script
: back to a textbox without rewriting the entire page? If it is possible can
: someone give me a clue on how to do this.
I'm not really sure what you want to do, but I'm pretty sure the answer is
"no".
--Art
--
--------------------------------------------------------------------------
National Ska & Reggae Calendar
http://www.agitators.com/calendar/
--------------------------------------------------------------------------
------------------------------
Date: Wed, 10 Mar 1999 21:34:51 GMT
From: juergen@monocerus.demon.co.uk (Juergen Heinzl)
Subject: Re: Perl and Syslog
Message-Id: <slrn7edpas.4c.juergen@monocerus.demon.co.uk>
In article <36E632C2.8F3D5FAB@hik.fzk.de>, News System wrote:
>Hi,
>I am using SuSE Linux 6.0 with Kernel 2.2.1 and Perl 5.00502.
>Setting up INN 2.2 I found a problem when trying to write to
>Syslog from Perl.
Some things ... syslogd must be started with -r and the h2ph
generated files might need some tweaking.
[...]
>Can't locate stdarg.ph in @INC (did you run h2ph?) (@INC contains:
Yup, remove that one since it is one. syslog.ph does not need any
other files, but h2ph needs some human help here. My syslog.ph is
for glibc-2.1, so it might differ.
Cheers,
Juergen
--
\ Real name : J|rgen Heinzl \ no flames /
\ EMail Private : juergen@monocerus.demon.co.uk \ send money instead /
\ Phone Private : +44 181-332 0750 \ /
------------------------------
Date: Wed, 10 Mar 1999 14:24:37 -0600
From: "Martin Bertolino" <martinb@talx.com.no.spam>
Subject: Re: Perl comment
Message-Id: <7c6kk2$bq5$1@newsin-1.starnet.net>
You could do the following:
if (0) {
# the whole block of code you want to comment out
}
this is a variation of:
#if 0
// block of code
#endif
in C/C++ compiler using the preprocessor.
Martin
George Crissman wrote in message <36e69979.4817047@news2.tmisnet.com>...
>On Fri, 05 Mar 1999 10:46:21 +0100, Philip Newton wrote:
>
>>George Crissman wrote:
>>>
>>> On Mon, 01 Mar 1999 12:07:06 +0100, Philip Newton wrote:
>>> >KC wrote:
>>> >> dubing wrote:
>>> >> > Is there any easy way to comment out a block of Perl code (like how
------------------------------
Date: Wed, 10 Mar 1999 10:13:26 -0500
From: Clinton Pierce <cpierce1@ford.com>
To: Chris <chris.ball@spsg.org>
Subject: Re: Perl scripts written for UNIX. Will they work on NT?
Message-Id: <36E68C16.7D786A6A@ford.com>
[author CC'd in E-Mail]
Chris wrote:
>
> Can you help? We are about to move our web site from a UNIX server
> to one running Windows NT 4.0. Does anyone know if we will encounter
> any problems with our Perl scripts when we move them over? (these
> are currently used to accomplish tasks such as; Logging information,
> updating pages, and managing a chat room).
If the perl scripts are well written, only very small changes might be
needed. Such as, anywhere you do pathname manipulation (because your
separator changes from "/" to "\"). There's even portable ways of doing
this, because you can query Perl for the OS's pathname separator (use Config
I think). ...and you did put all of your hard-coded
pathnames-to-useful-things in one place, right? :-)
Some changes are going to be needed if you relied on server-specific aspects
of CGI. I've found that things like $ENV{DOCUMENT_ROOT} don't appear under
IIS and do under Apache, and have to be calculated differently. Your
Mileage Will Vary.
Otherwise, there should be no major problems. I develop CGI under UNIX, and
move it to NT/IIS all the time. It helps to think portably before you write
the scripts in the first place.
> or is as simple as changing the file names/references?
If they're well written, it should be simple, even transparent.
--
Clinton A. Pierce "If you rush a Miracle Man, you get rotten
clintp@geeksalad.org Miracles." -- Miracle Max, The Princess Bride
http://www.geeksalad.org
------------------------------
Date: Wed, 10 Mar 1999 22:03:09 GMT
From: Benjamin Smith <benbean@yahoo.com>
Subject: Re: PerlTk for Win32 ?
Message-Id: <36E6EC1C.DA9330FC@yahoo.com>
Yes... you can install it with the ppm.pl script included in the
ActiveState distribution's bin directory. It has been a while since I
was in Windows so I can't remember the exact syntax. I think there is
documentation for ppm in the HTML docs though, and it is pretty
straight-forward.
Patrick Fichou wrote:
>
> Hi,
>
> Does Tk module for Win32 Perl (Activestate) exists ?
>
> Thanks
>
> Patrick
------------------------------
Date: Wed, 10 Mar 1999 15:58:24 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: Cybernetic Bear <"cybear_x[nospam]"@geocities.com>
Subject: Re: problems reading HTML file
Message-Id: <36E6DCF0.9623858C@giss.nasa.gov>
[courtesy copy of post sent to cited author]
Cybernetic Bear wrote:
>
> I am trying to read an HTML file into a PERL script, but the script
> doesn't read the file in properly, and for the life of me I can't
> figure out why.
> open (FILE, $indexfile);
> while (<FILE>){
this assigns a line from "FILE" to "$_" each time
through the loop.
> my $line = <FILE>;
okay, now you're reading another line from "FILE"
into "$line". You seem to be skipping every other line
here.
try this:
while (my $line = <FILE>) {
# do something with "$line"
}
--
"Narf!"
--Pinky
------------------------------
Date: 10 Mar 1999 21:56:19 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Problems with Perl and tar
Message-Id: <7c6pq3$n8$1@gellyfish.btinternet.com>
On 9 Mar 1999 14:59:18 +0800 Steve Lamb wrote:
> I've been working on a script that does some interesting things with tar
> for backups. One of the things we wanted to do was to have tar create a
> file, export it to the console, pipe it to tee, then have the tee send it to
> another tar to extract (mirroring the mount) as well as create a tar for
> backup elsewhere.
>
> From the command line, it works fine. Inside perl, however, the console
> gets spew from tar at some point. Here is the command:
>
You could try the Archive::Tar module from CPAN :
http://www.perl.com/CPAN/authors/id/SRZ/Archive-Tar-0.21.tar.gz
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 10 Mar 1999 21:01:31 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: RegEx extended ASCII problem
Message-Id: <7c6mjb$912$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to
<desprem@statcan.ca>],
who wrote in article <7c6lhm$blf$1@nnrp1.dejanews.com>:
> $TestString =~ /\bIdifice\b/; # Match 1
> $TestString =~ /Idifice\b/; # Match 2
[Drat Emacs! That question mark should have been accented E]
Did you
use locale;
? Why not? In "C" locale Perl uses by default high-bit chars are not
alphanumbs.
Ilya
------------------------------
Date: Wed, 10 Mar 1999 16:06:15 -0500
From: evil Japh <jeffp@crusoe.net>
Subject: Re: RegEx extended ASCII problem
Message-Id: <Pine.GSO.3.96.990310160007.10818I-100000@crusoe.crusoe.net>
> I'm trying to match text using Perl's grep function. I've narrowed down t=
he
> problem to the regular expression I'm feeding it. The script I've written=
has
> to handle both French and English characters, and matches only full words=
=2E
> And in almost all cases it does without fail. The sole exception is when =
the
> matching text's first letter is a extended ASCII (as are French accented
> characters).
You need to set the character set to the local one. Regular ASCII
alphanumeric chars are A-Za-z0-9_. Thus, the '=C9' character is not an
alphanum.
\b is the boundary between a non-alphanum and an alphanum.
$TestString =3D "L'=C9difice gouvernementale";
$TestString =3D~ /\b=C9difice\b/;
# fails because ' is not an alphanum and =C9 is not an alphanum
$TestString =3D~ /=C9difice\b/;
# succeeds, that's ok
$TestString =3D~ /\bdifice\b/;
# succeeds, because the boundary (\b) is between =C9 and d
Look at perldoc locale for more information.
--=20
Jeff Pinyan (jeffp@crusoe.net)
www.crusoe.net/~jeffp
Crusoe Communications, Inc.
973-882-1022
www.crusoe.net
------------------------------
Date: Wed, 10 Mar 1999 21:53:32 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: Speed-optimizing regular expressions
Message-Id: <wRBF2.10834$Ge3.43045840@news.itd.umich.edu>
In article <7mg17dqdcm.fsf@glory.besmarter.com>,
Uri Guttman <uri@ibnets.com> wrote:
>>>>>> "JS" == Joe Stewart <complangperlmisc@NOSPAMPLEASE.httptech.com> writes:
> JS> I cut down the number of lines per run to 10000 to prevent out of
> JS> memory errors, but the speed difference is phenomenal, it only
> JS> took slightly over minute to sort an 84 meg logfile. The old
> JS> method would have taken over an hour to run through all the
> JS> domains.
>why not open all the domain log files first, store the handles by a hash
>indexed by the domain name and write to the file according to the domain
>in the log line.
This was the first method I thought of, but Joe mentioned that there were
~250 different domains. I assumed that most operating systems won't allow
this many open files at once. I just tried opening lots of files on
Solaris 2.6, and it balked at opening the 61st. Hmmm. Now I tried the
same test on AIX 4.2, and it complained about the 1998th. Win95, the
510th.
I should have made a note of this in my original article. If your OS can
accomodate a large number of open files, it's most likely more efficient
to use Uri's method. I was coding around a limitation that doesn't exist
on all systems.
>pseudo (but close to reality) code:
>foreach $domain (@domains) {
> $handle{$domain} = IO::File->new( ">>$domain.log" ) ;
>}
>while ($logline = <LOG>) {
> ($domain, $line ) = split( ' ', $logline, 2 ) ;
> $handle{$domain}->print $line ;
>}
If the domains aren't known in advance, this will do the trick (reverting
to my original notation):
use IO::File;
open(IN, "master_access_log") || die "Can't open master_access_log: $!\n";
while (<IN>) {
($domain, $data) = split / /, $_, 2;
$handle{$domain} ||= new IO::File ">${domain}_access_log"
or die "Can't open ${domain}_access_log: $!\n";
print {$handle{$domain}} $data;
}
close($_) foreach values %handle;
close(IN);
--
Sean McAfee mcafee@umich.edu
print eval eval eval eval eval eval eval eval eval eval eval eval eval eval
q!q@q#q$q%q^q&q*q-q=q+q|q~q:q? Just Another Perl Hacker ?:~|+=-*&^%$#@!
------------------------------
Date: Wed, 10 Mar 1999 21:49:01 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: The millennium cometh -- eventually
Message-Id: <hNBF2.665$ge1.692@nswpull.telstra.net>
In article <19990309.001201.3R9.rnr.w164w@locutus.ofb.org>,
Russell Schulz <Russell_Schulz@locutus.ofB.ORG> writes:
> this is why I disagree with the FAQ's insistence that `perl has as much
> or as little of a y2k problem as a pencil does'.
Nonsense. perl has no y2k problem. Perl has no y2k problem. As
explained countless times before: The y2k problem is a programming
problem here, wetware. Not perl or Perl. You can't even blame Perl's
language structure or perl's tools, because it is as easy to use them
correctly as it is to use them wrongly. It's up to the programmer, and
it's up to the programmer in any language.
Martien
--
Martien Verbruggen |
Interactive Media Division | Little girls, like butterflies, need no
Commercial Dynamics Pty. Ltd. | excuse - Lazarus Long
NSW, Australia |
------------------------------
Date: Wed, 10 Mar 1999 16:14:50 -0500
From: "Lynn Demarest" <ldemarest@mindspring.com>
Subject: Re: Using Modules on Win95 Platform
Message-Id: <7c6noj$3po$1@camel18.mindspring.com>
Uh, I guess I answered my own question and then developed more.
If I put the WWWgrab.pm in the c:\perl\lib directory, it works fine if I do
this:
perl -Ic:\perl\lib test1.pl
But how do I manipulate the @INC variable so that it includes c:\perl\lib
automatically?
------------------------------
Date: Wed, 10 Mar 1999 16:51:39 -0500
From: "Lynn Demarest" <ldemarest@mindspring.com>
Subject: Re: Using Modules on Win95 Platform
Message-Id: <7c6ptm$3df$1@camel18.mindspring.com>
Once again, I seem to have answered my own question.
The paths used by the system to find libraries are in the DOS environment
variable PERL5LIB, so as soon as I did this:
set PERL5LIB=c:\perl\lib
everything worked great!
Thanks for your help, Lynn! 8^)
------------------------------
Date: 10 Mar 1999 16:17:01 -0600
From: Kent Perrier <kperrier@blkbox.com>
Subject: Re: why does my browser show my scripts instead of running them
Message-Id: <ysi67896lcy.fsf@blkbox.com>
"Michael Georgiadis" <mgeorgiadis@hotmail.com> writes:
> what do you mean 'proper' cgi bin? i put it in the bin created with apache
> server/
apache (at least on unix) has a configuration file called httpd.conf that
tells the server to treat the files in the defined directory as cgi scripts.
Perhaps you need to read the apache documentation again.
Kent
------------------------------
Date: 12 Dec 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 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 5104
**************************************