[13052] in Perl-Users-Digest
Perl-Users Digest, Issue: 462 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 11 13:07:24 1999
Date: Wed, 11 Aug 1999 10:05:12 -0700 (PDT)
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, 11 Aug 1999 Volume: 9 Number: 462
Today's topics:
Re: array and file processing <USENET@questionexchange.com>
Re: Browser detection - write different html <fkrul@acc.com>
Re: Fastest way to search a txt <USENET@questionexchange.com>
Re: glob() question <USENET@questionexchange.com>
Re: hash in record (David Alan Black)
Re: hash in record <stampes@xilinx.com>
Re: Help - Split Function Blowing My Mind Away!! (Matthew Bafford)
How to share constants across modules? <david@coppit.org>
Re: HTTP_REFERER and Frames <dave_man@my-deja.com>
Re: Improving speed of a sub (Jack Applin)
Info about Visitors <christian.wirth@eunet.at>
Re: Info about Visitors (Steve Linberg)
info on CGI client (Gabriele Gallacci)
Re: info on CGI client (Steve Linberg)
Initializing variables [was Re: is our reese the author (Steve Linberg)
Re: is our reese the author of mysql book? (John Porter)
Re: is our reese the author of mysql book? (Steve Linberg)
Re: is our reese the author of mysql book? <uri@sysarch.com>
Re: is our reese the author of mysql book? <sto@storm.com>
Japanese Girl Needs Help. <kaori@japanesegirl.com>
Looking for Reviews - Perl <JFedor@datacom-css.com>
Re: meaning of $mode (lstat) <joepepin@att.com>
Re: Msql-Mysql-modules-1.2202 <Nick.Djurovich@btinternet.com>
Parse::RecDescent, optional subrules, and errors (Rand Bamberg)
Perl Sockets on Linux <Scott.Wachtler@cdc.com>
Re: Reset .. ie clear out a hash array <tchrist@mox.perl.com>
Re: Run a script from a web browser and put it in the b (Steve Linberg)
s/// and interpolation <chris_conway@my-deja.com>
Re: searching complex data structure <uri@sysarch.com>
Re: Some help needed - NOT ! (Michel Dalle)
Re: while loop teminates too early <joel.neely@entpm4.prod.fedex.com>
Re: why doesnt this work? <USENET@questionexchange.com>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 11 Aug 1999 16:57:15 GMT
From: QuestionExchange <USENET@questionexchange.com>
Subject: Re: array and file processing
Message-Id: <763qx@questionexchange.com>
> Another Newbie...... needs help. Hello and thanks to everyone
> for help. My next dilemna involves processing arrays in Perl. I
> have a database with student names, test scores and courses. I
> need to load data into an array, sort the array on test scores
> field (without screwing up order of other fields) and choose
> only the top ten students. Next, I want to calculate average of
> these 10 students and print the results. Here's what I'm trying
> to do: $numstuds = 10; $count = 0; foreach $i (@indata) {
> #remove hard return character from each record chop($i); #split
> fields on pipe character #assign a variable name to each of the
> fields ($student,$testscore,$course) = split(/\|/,$i); $count
> = $count + 1; # ?? Can I do this ?????????????????? %topscore
> [$i]=('student',$student,'scores',$testscore,'courses',
> $course); # create 1 associative array to handle input and
> allow for sorting # all 3 values in correct order @testscores
> = $testscore; @students = $student; @courses = $course; #
> create 3 parallel ordinal arrays for calculating handicap index
> #add a new row to the table for each record print ""; print
> "$student"; print "$testscore"; print "$course"; print "\n";
> #close the loop } #close the table print ""; #close the HTML
> document if ($count > 9) { @thebest = sort values %topscore; #
> see p.77 of Rob's Perl for above # all items must sort in sych
> foreach $i (keys %topscore) # foreach (@thebest) # need to
> limit this to 10 times only { $total = $total +
> $topscore{'testscore'}; # top ten students print
> "$topscore{'testscore'} and loop value is $i"; print "$total";
> print ""; # check values last if $i > 9; } # end of foreach
> $ave = $total/$numstuds; I'm not sure whether I should be
> using parallel ordinal arrays or an associative array. Can I
> use a subscript with an associative array? Thanks in advance
> for your insights! Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
# ?? Can I do this ??????????????????
%topscore[$i]=('student',$student,'scores',$testscore,'courses'
, $course); You can do what you mean but
this is not it. You can't assign a list to an array item:
arrays can only contain scalars. Luckily, a scalar can be a
*reference* to a hash, so what you should do is Also, what you
want to do is to *push* the element on the array. So, the
expression should be push @topscore, { student => $student,
score => $testscore, courses => $course }; Read the
"perldata" and "perlref" and "perldsc" manpages for more info.
For sorting, use a schwartzian transform: @sortedscore = sort
{ $a->{score} <=> $b->{score} } @topscore;
--
This answer is courtesy of QuestionExchange.com
http://www.questionexchange.com/servlet1/showUsenetGuest?ans_id=2582&cus_id=USENET&qtn_id=1660
------------------------------
Date: Wed, 11 Aug 1999 09:53:01 -0700
From: Frank Krul <fkrul@acc.com>
To: Robert <ducott@intergate.bc.ca>
Subject: Re: Browser detection - write different html
Message-Id: <37B1AA6D.D90C61D4@acc.com>
Robert,
First of all let me apologize for most of these respondents. Truly this
newsgroup does have a few helpful souls.
#1: Even though some people say otherwise, since 94 my stats from a number of
different servers have never had problem identifying the HTTP_USER_AGENT
environment variable from any client. Any browser that does not follow the
HTTP1.0 or 1.1 protocol and identify itself is non-standardized, and I've never
see one. Even home made browsers have IDs (it's the ego at work). Web
anonymizers are out there, that will downgrade their browsers in the eyes of
your code logic...but they can always press a link to get the "high bandwidth"
button if they so choose on your page.
#2 Do this is in Javascript. It's easy, your server is less utilized allowing
it to dessiminate pages instead of making decisions for those who don't know
what browser they have. (Are you providing an elegant solution or assuming your
demographic are morons who can't id their software's capabilities?)
#3 This is a perl newsgroup, go here:
http://developer.netscape.com
to get the code and get lost. ;)
Robert wrote:
> What we are looking for is a perl/cgi script or a java script that will
> accomplish the following...When a user comes to our page, the script will
------------------------------
Date: 11 Aug 1999 16:57:33 GMT
From: QuestionExchange <USENET@questionexchange.com>
Subject: Re: Fastest way to search a txt
Message-Id: <764qx@questionexchange.com>
> Hi, I hope I don't get roasted for asking this... I was
> wondering what would be a very efficient (fast) way to examine
> a text file line by line to search for keywords, such as
> "error", or "warning". The code I'm working on now takes the
> file and redefines $/, which allows a chunk of the file to be
> extracted, and then has perl search the entire chunk for one of
> the keywords. If a keyword is detected in the chunk, then the
> chunk is split into lines and each line is examined for the
> information and certain count variables are updated depending
> on how many lines contain a keyword. I suppose some issues are
> that maybe the file doesn't contain any keywords at all. Would
> it be too slow to have perl search the entire file for a
> keyword? Is it quicker to search the file chunk by chunk
> rather than just search the entire file once for a keyword?
> Anyway, if you understand what I'm asking I'd appreciate any
> input. Thanks. SRHADDEN Sent via Deja.com
> http://www.deja.com/ Share what you know. Learn what you don't.
It all depends on various variables like your operating system,
the size of the file, the probability of there being no
keywords in the file etc. "too slow" is problem-dependent.
If the file is not too large i.e. fits well in main memory, and
it is likely that there are no keywords, then slurping the file
at one go (undef $/) and then searching that is the way to go.
If the file is *REALLY* big, i.e. bigger than your main memory,
and there is likely to be a keyword near the beginning (I'm
assuming that finding the first set of keywords stops the
search), then chunk by chunk is it. I recommend doing
benchmarks with various read sizes. Note that you might want to
check out e.g. sysread for reading big chunks at a time. Of
course, Perl might be the wrong tool here - "grep" is an
optimized C program for searching things in files.
--
This answer is courtesy of QuestionExchange.com
http://www.questionexchange.com/servlet1/showUsenetGuest?ans_id=2581&cus_id=USENET&qtn_id=1665
------------------------------
Date: 11 Aug 1999 16:57:51 GMT
From: QuestionExchange <USENET@questionexchange.com>
Subject: Re: glob() question
Message-Id: <765qx@questionexchange.com>
> Looked though the FAQ and didn't come across this: The
> following code snippet will pass through the first loop but not
> the second. In advance I know that no file that looks like
> *zork* exists under the /tmp directory. Is this an expected
> result? foreach $file_name (glob("/tmp/zork")) {
> print "loop 1 >>$file_name\n"; }; foreach $file_name
> (glob("/tmp/zork*")) { print "loop 2 >>$file_name\n";
> }; I used to use opendir() but have gotten lazy lately. I'm
> getting around this by using the -f file test operator (i.e.
> next if ! -f $file_name) -- Andy Cantrell -
> cantrela@agcs.com AG Communication Systems Office (AZ) (623)
> 582-7495 (Voice mail) Office (WI) (414) 249-0215 Modem (WI)
> (414) 249-0239
This behaviour is in common with the unix shell: lukka:/tmp>
echo foo foo lukka:/tmp> echo foo* echo: No match. lukka:/tmp>
This is so that users who give programs a file name or globs
can give a file name that does not exist yet. Perl inherited
this by calling csh to glob for a long time and now, even when
it is an internal routine, the behaviour still remains for
compatibility.
--
This answer is courtesy of QuestionExchange.com
http://www.questionexchange.com/servlet1/showUsenetGuest?ans_id=2584&cus_id=USENET&qtn_id=1668
------------------------------
Date: 11 Aug 1999 12:27:59 -0400
From: dblack@pilot.njin.net (David Alan Black)
Subject: Re: hash in record
Message-Id: <7os8af$qp$1@pilot.njin.net>
gary@onegoodidea.com (Gary O'Keefe) writes:
>A keyboard was smashed into Peter Huesser's face and out came:
>[ nasty mime stuff snipped ]
>>$rec = (
>> total => 10,
>> LOOKUP => { %some_table } ,
>>);
>This is a hash, not a scalar, assignment. You got it right for
>%some_table.
>%rec = (
> total => 10,
> LOOKUP => { %some_table };
>);
>>print $rec->{LOOKUP}{'gaga'},"\n";
>print $rec{LOOKUP}{gaga}, "\n";
I suspect the mistake was using () instead of {}, thus generating a
list of four elements rather than a reference to a hash.
Thus:
$rec = { total => 10,
LOOKUP => { %some_table } # or \%some_table, if copy not needed
};
print $rec->{ etc... then makes sense.
-w would have had this to say:
Useless use of a constant in void context at p line 14.
Useless use of a constant in void context at p line 14.
Useless use of a constant in void context at p line 14.
but it wasn't consulted.
--
David Alan Black blackdav@shu.edu or dblack@pilot.njin.net
Associate Professor Department of Communication
Seton Hall University South Orange, NJ 07079
http://pirate.shu.edu/~blackdav includes Syllabus Markup Language (SyML)
------------------------------
Date: 11 Aug 1999 15:32:55 GMT
From: Jeff Stampes <stampes@xilinx.com>
Subject: Re: hash in record
Message-Id: <7os537$na1@courier.xilinx.com>
Peter Huesser <huesser@physik.unizh.ch> wrote:
: This is a multi-part message in MIME format.
Don't do that. Usenet is an ASCII forum.
: --------------678A1726D132A5B1EBA2205A
Pretty, huh?
: I have a problem with hashes within a record. The following code doesn't
: do
: what is expected:
Sure it does....just not what YOU expect.
: #!/usr/bin/perl
/usr/bin/perl -w would have told you you were doing something wrong.
: %some_table = (
: 'gaga' => 1,
: 'baba'=> 2,
: );
: print $some_table{'gaga'},"\n";
: $rec = (
: total => 10,
: LOOKUP => { %some_table } ,
: );
Assiging a list to a scalar? How odd....maybe you meant to make that
a ref to an anonymous hash?
$ref = { total => 10
LOOKUP => { %some table },
};
You should read the perldsc
--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com
------------------------------
Date: Wed, 11 Aug 1999 16:17:26 GMT
From: *@dragons.duesouth.net (Matthew Bafford)
Subject: Re: Help - Split Function Blowing My Mind Away!!
Message-Id: <slrn7r37um.hc2.*@dragons.duesouth.net>
On 11 Aug 1999 15:41:48 GMT, Mike Kozlowski) held some poor sysadmin at
gunpoint, and typed the following into comp.lang.perl.misc:
: In article <MPG.121a4f373dba2a21989e26@nntp.hpl.hp.com>,
: Larry Rosler <lr@hpl.hp.com> wrote:
: >
: >Use of incorrect context: my $x = @_; my ($y) = @_;
:
: Are you saying that both of those are wrong, or that the first is wrong
: and the second correct?
He's not saying either is wrong.
Consider:
#!/usr/bin/perl -w
@_ = qw.foo bar baz.;
my $a = @_;
my($b) = @_;
my $c = localtime;
my($d) = localtime;
print <<EOT;
a: $a
b: $b
c: $c
d: $d
_____
EOT
__END__
a: 3
b: foo
c: Wed Aug 11 12:06:22 1999
d: 22
_____
HTH,
: Michael Kozlowski
--Matthew
------------------------------
Date: Wed, 11 Aug 1999 12:39:46 -0400
From: David Coppit <david@coppit.org>
Subject: How to share constants across modules?
Message-Id: <Pine.GSO.4.05.9908111108520.15561-100000@mamba.cs.Virginia.EDU>
Hi all,
I'd like to say that the constant DEBUG has the same value in this module as
in the main module. Here's what seems to work for Perl 5.00502:
# DEBUG for this package is the same as the main.
use constant DEBUG => main::DEBUG;
Unfortunately, some people on different computers/versions are saying that
their version of perl is translating "main::DEBUG" into "&main::-1". (Sorry I
don't have the details of their platform and installation.)
I use the DEBUG constant in the module, and also in a function in main called
"dprint":
sub dprint
{
return unless DEBUG;
print join '',@_;
return 1;
}
For each module, I alias a local dprint to the one in main:
sub dprint;
*dprint = \&main::dprint;
It's when the local dprint is called that perl dies and says it can't find
"&main::-1".
I'm not sure if it's just the setting of the constant that is broken, or if
Perl is getting confused about the function alias and the multiple DEBUG
definitions... Is there a better, more portable way of setting a constant this
way at compile time? Below is a sample script that shows how I'm using this
stuff. Run it with and without the -d flag to see how it works.
----------
use strict;
use Getopt::Std;
use vars qw(%opts);
BEGIN
{
getopt('ioc',\%opts);
}
use constant DEBUG => $opts{d} || 0;
sub dprint
{
return unless DEBUG;
print join '',@_;
return 1;
}
package Test;
use constant DEBUG => main::DEBUG;
sub dprint;
*dprint = \&main::dprint;
dprint "This is a test.";
----------
Thanks,
David
_________________________________________________________________________
David Coppit - Graduate Student david@coppit.org
The University of Virginia http://coppit.org/
"Yes," said Piglet, "Rabbit has Brain." There was a long silence.
"I suppose," said Pooh, "that that's why he never understands anything."
------------------------------
Date: Wed, 11 Aug 1999 16:33:06 GMT
From: TVsezSO <dave_man@my-deja.com>
Subject: Re: HTTP_REFERER and Frames
Message-Id: <7os8k2$f0s$1@nnrp1.deja.com>
i think that from what both of you guys have told me i would be better
off duplicating the script for each page so there is no chance of
REFERER botching it. since the unreliability would make the entire
script useless anyway it is the way i will have to go. space isn't an
issue, i am just a perfectionist and neurotic about packing code as
efficiently and tight as possible with the fewest files. i did end up
asking my question in the right place. if i would have asked in a cgi
group they might have answered my question and i would have created a
worthless program. in the long run you saved me much time and some
hair. so thank both of you for your help. --Dave
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 11 Aug 1999 16:29:15 GMT
From: neutron@fc.hp.com (Jack Applin)
Subject: Re: Improving speed of a sub
Message-Id: <7os8cr$e7g$1@fcnews.fc.hp.com>
Jack Applin <neutron@bamboo.verinet.com> writes:
> The /o flag would make it faster, since $foo doesn't change in the loop:
>
> s/referrer/$foo/o;
Larry & Ala both pointed out that /o only helps if the pattern is variable.
Ala was a bit harsh calling my advice "useless", but they're correct.
-Jack Applin
neutron@fc.hp.com
------------------------------
Date: Wed, 11 Aug 1999 18:18:39 +0200
From: Christian Wirth <christian.wirth@eunet.at>
Subject: Info about Visitors
Message-Id: <37B1A25F.629230FE@eunet.at>
Hi,
I would need a script that finds out some facts about the visitors, most
important is where they live (country or more detailed). I've heared
there exists an Enviroment-Variable for that.
Thanks,
Chris, Austria
------------------------------
Date: Wed, 11 Aug 1999 12:31:17 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Info about Visitors
Message-Id: <linberg-1108991231170001@ltl1.literacy.upenn.edu>
In article <37B1A25F.629230FE@eunet.at>, Christian Wirth
<christian.wirth@eunet.at> wrote:
> Hi,
>
> I would need a script that finds out some facts about the visitors, most
> important is where they live (country or more detailed). I've heared
> there exists an Enviroment-Variable for that.
Nope. And thank God there isn't. I don't want you tracking me.
(Assuming you're talking about browsers and the web.)
You can only find out what the visitors are willing to give you. They
aren't required to give you anything, and anything they do give you can be
faked.
--
Steve Linberg, Systems Programmer &c.
National Center on Adult Literacy, University of Pennsylvania
print 'Just Another Perl ' . $perl_hierarchy[(USER+EXPERT)/2];
------------------------------
Date: 11 Aug 1999 15:18:35 GMT
From: info@gallacci.com (Gabriele Gallacci)
Subject: info on CGI client
Message-Id: <8E1FB0E3Amailbygallaccicom@news.tin.it>
Hello,
do you know how to grab the ip of a client from the cgi runned?
thank you
gabriele
gabriele@gallacci.com
PS: can you suggest me a good cgi programming book?
------------------------------
Date: Wed, 11 Aug 1999 12:29:11 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: info on CGI client
Message-Id: <linberg-1108991229110001@ltl1.literacy.upenn.edu>
In article <8E1FB0E3Amailbygallaccicom@news.tin.it>, info@gallacci.com
(Gabriele Gallacci) wrote:
> Hello,
> do you know how to grab the ip of a client from the cgi runned?
You can't in any reliable way. It could be faked, given from a proxy
server, or not given at all.
Seek your general CGI answers in comp.infosystems.www.authoring.cgi.
--
Steve Linberg, Systems Programmer &c.
National Center on Adult Literacy, University of Pennsylvania
print 'Just Another Perl ' . $perl_hierarchy[(USER+EXPERT)/2];
------------------------------
Date: Wed, 11 Aug 1999 13:02:53 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Initializing variables [was Re: is our reese the author of mysql book?]
Message-Id: <linberg-1108991302530001@ltl1.literacy.upenn.edu>
In article <x74si69shc.fsf@home.sysarch.com>, Uri Guttman
<uri@sysarch.com> wrote:
> why initialize aggregates when they don't cause warnings when using them
> uninitialized?
<snip>
> as for scalars, i would only initialize them as needed. if i am doing
> .= i init to ''. for math maybe to 0 if i was doing += but maybe
> not for ++ since it doesn't generate warnings on undefined values.
I understand and appreciate your explanation. I don't initialize
variables to avoid warnings, I do it because (a) improperly initialized
variables are a major source of bugs in general, and (b) it makes it
easier for me to look back on and grok my own code. Although it isn't so
important in Perl, it sure was in assembler way back when, and even in
some of the early (crufty) C compilers I used, where defined but
uninitialized variables would contain whatever memory they happened to be
mapped to.
It's a habit that I have no matter what language I'm writing in.
Sometimes it's important, sometimes it isn't, and usually I'm too lazy to
burn braincells thinking about it. Although I do the majority of my work
in Perl these days, I still feel overall that it's a habit that has served
me well, maybe at the expense of a few cycles and electrons.
What I'm wondering, as I respect your superior knowledge and experience,
is whether and why you think it's a *bad* idea, or whether it's more that
you just regard it as unnecessary and slighly wasteful.
Thanks, Uri.
--
Steve Linberg, Systems Programmer &c.
National Center on Adult Literacy, University of Pennsylvania
print 'Just Another Perl ' . $perl_hierarchy[(USER+EXPERT)/2];
------------------------------
Date: Wed, 11 Aug 1999 16:18:59 GMT
From: jdporter@min.net (John Porter)
Subject: Re: is our reese the author of mysql book?
Message-Id: <slrn7r38ji.1f7.jdporter@min.net>
In article <x7d7wu9uso.fsf@home.sysarch.com>, Uri Guttman wrote:
>
> it's funny how well known matt is but you never see him post (at least
> not here where he is most revered).
In fact, I've never seen *anything* from the mind of Matt Wright
apart from the wretched Perl code. Maybe he's an experimental
perl-generating back-end from some backwater R&D lab...
> the chapter on the o'reilly site is on perl and has these gems:
I think it's safe to assume that george reese was not responsible
for the perl content of this book.
> they are inconsistant with () around the my args.
Inconsistent? Why, the semantics are different in a critical way.
Isn't it possible they are doing the right thing in each case?
> i blame o'reilly as much as the trio of
> authors.
Indeed, I blame O'Reilly for hiring george reese in any capacity.
>on the good side all the examples use -w and strict but i doubt they all
>run as i have shown several real bugs in both syntax and code. and i
>have only gone thru half the chapter and not with a finetoothed comb.
All things considered, this is probably no worse than any first
edition. Be realistic, man!
--
John Porter
------------------------------
Date: Wed, 11 Aug 1999 12:36:35 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: is our reese the author of mysql book?
Message-Id: <linberg-1108991236350001@ltl1.literacy.upenn.edu>
In article <x7d7wu9uso.fsf@home.sysarch.com>, Uri Guttman
<uri@sysarch.com> wrote:
> my @ids = ();
> my %subjects = ();
>
> useless init with ().
> for scalars, initing to '' or 0 makes some sense with -w but not with
> aggregates.
Could you explain this a little more, Uri? I always initialize everything
this way - aggregates with (), scalars to '' or 0, even though it's
strictly unnecessary. I've always considered it one of my better
mindless, defensive programming habits.
--
Steve Linberg, Systems Programmer &c.
National Center on Adult Literacy, University of Pennsylvania
print 'Just Another Perl ' . $perl_hierarchy[(USER+EXPERT)/2];
------------------------------
Date: 11 Aug 1999 12:45:03 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: is our reese the author of mysql book?
Message-Id: <x74si69shc.fsf@home.sysarch.com>
>>>>> "SL" == Steve Linberg <linberg@literacy.upenn.edu> writes:
SL> In article <x7d7wu9uso.fsf@home.sysarch.com>, Uri Guttman
SL> <uri@sysarch.com> wrote:
>> my @ids = ();
>> my %subjects = ();
>>
>> useless init with ().
>> for scalars, initing to '' or 0 makes some sense with -w but not with
>> aggregates.
SL> Could you explain this a little more, Uri? I always initialize
SL> everything this way - aggregates with (), scalars to '' or 0, even
SL> though it's strictly unnecessary. I've always considered it one
SL> of my better mindless, defensive programming habits.
why initialize aggregates when they don't cause warnings when using them
uninitialized? it is just a waste of text and electrons. you can push
onto an array or access a hash element even thought they we just
declared with my.
as for scalars, i would only initialize them as needed. if i am doing
.= i init to ''. for math maybe to 0 if i was doing += but maybe
not for ++ since it doesn't generate warnings on undefined values.
also if you are going to assign something else to the scalar, why do a
useless init. you sound like you do it for all scalars which is why i
say that. it is only if you are going to use the value where it would
generated a undefined value warning, should you init them to '' or 0.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.
------------------------------
Date: Wed, 11 Aug 1999 16:49:11 +0000
From: Scott Oglesby <sto@storm.com>
Subject: Re: is our reese the author of mysql book?
Message-Id: <37B1A987.5451C810@storm.com>
John Porter wrote:
>
> In article <x7d7wu9uso.fsf@home.sysarch.com>, Uri Guttman wrote:
> >
> > it's funny how well known matt is but you never see him post (at least
> > not here where he is most revered).
>
> In fact, I've never seen *anything* from the mind of Matt Wright
> apart from the wretched Perl code. Maybe he's an experimental
> perl-generating back-end from some backwater R&D lab...
Perhaps you haven't visited http://www.mattwright.com ...
(yes, it is _the_ Matt Wright)
perl -e '$, = " "; print sort {lc $a cmp lc $b} qw(Perl user mere A);'
--
Scott Oglesby
L-3 / Storm Control Systems
------------------------------
Date: Wed, 11 Aug 1999 12:59:43 -0400
From: "Kaori" <kaori@japanesegirl.com>
Subject: Japanese Girl Needs Help.
Message-Id: <o%hs3.10$0K.808@iad-read.news.verio.net>
I am trying to make a PERL script that will
allow me to access individual images by the user
making one event (push button) and then have the
PERL script roam the database and select the correct
images.
Can this be done? Yes? No?
Please tell me.
Sorry if my words is not correct.
My native language is Japanese.
Thank you,
Kaori Ayn Honeywell
kaori@japanesegirl.com
------------------------------
Date: Wed, 11 Aug 1999 13:26:38 -0400
From: "Jody Fedor" <JFedor@datacom-css.com>
Subject: Looking for Reviews - Perl
Message-Id: <7os9mu$nig$1@plonk.apk.net>
Attn: Perl Hackers.....
I'm looking for book reviews on all O'Reilly books. Author Comments are
invited too!
Author Comments to: authors@datacom-css.com
Reviewers to: review@datacom-css.com
Our Everything Perl Section is up (sans shopping cart at this time) at:
http://www.datacom-css.com/books/perl.htm
We'd like to have guest Perl experts on our site too. If you're interested
contact
me at: JFedor@datacom-css.com
Thanks all!
Jody
------------------------------
Date: Wed, 11 Aug 1999 12:16:42 -0400
From: "Joe Pepin" <joepepin@att.com>
Subject: Re: meaning of $mode (lstat)
Message-Id: <7os71b$s1b7@kcweb01.netnews.att.com>
Decimal 33261 is Octal 100755. This is rwxr-xr-x and an ordinary file.
"use POSIX;" provides constants and macro-like things to work with mode
values.
Peter Huesser wrote in message <37B1767E.46679572@physik.unizh.ch>...
>Can anybody explain me the meaninig of the mode field in the lstat
>returnvalue? For example a file with mode
>-rwxr-xr-x gives the number 33261.
>
>Thank's for any help
>
>
> Pedro
>
------------------------------
Date: Wed, 11 Aug 1999 17:04:59 +0000
From: Nick Djurovich <Nick.Djurovich@btinternet.com>
Subject: Re: Msql-Mysql-modules-1.2202
Message-Id: <37B1AD3B.CE390F3F@btinternet.com>
Hi,
Check how the location directory structure is mounted on the file system (temporary
mount??)
Check the file permissions.
I can't help but wonder about the missing '/' before usr/local/..... on the last line of
the
warning.
Try moving it to the same directory as mysql, changing the include directory structure
with
use lib <new path> (might be possible ?;-)
HTH
Gavin G wrote:
> I recently compiled perl 5.005_03 on BSDI 4.01 and then installed MySql. I had
> all this running on a linux machine with no problems. Then when I need to put
> it on to the companies servers I am getting strange errors. I have seen others
> post this problem too, but no resolution. I installed DBI and tried to install
> Mysql perl module. This is the problem
>
> Can't load '/usr/local/lib/perl5/site_perl/5.005/i386-bsdos/auto/DBD/mysql/mysql.so'
> for module DBD::mysql: File not found at
> usr/local/lib/perl5/5.00503/i386-bsdos/DynaLoader.pm line 169.
>
> Now the file is actually there, but its like it cant find it or cant't link it
> properly. This is the first time I have had any problems with perl modules.
> Any help would be greatly appreciated.
>
> PS: Please reply through e-mail
>
> Gavin G
> gavin@enter.net
--
Cheers,
/Nick Djurovich
--
Tel 01273 384 600
E-Mail mailto:Nick.Djurovich@racalitsec.com
ICQ 11810476
WWW http://www.racalitsec.com
Racal Security and Payments
Sussex Innovation Centre
Science Park Square
Falmer
Brighton
BN1 9SB
England
------------------------------
Date: Wed, 11 Aug 1999 16:15:13 GMT
From: rand@qualityic.com (Rand Bamberg)
Subject: Parse::RecDescent, optional subrules, and errors
Message-Id: <37b1a0e6.14128287@news.jump.net>
Any Parse::RecDescent users reading? (Or perhaps Mr. Conway
himself?) I'm having trouble with error reporting and
optional subrules in a production, probably best demonstrated
with a short example:
my $txt = "(FILE (VERSION 1) (REV X) (FRUIT banana))";
my $gmr = q{
file : '(' 'FILE' headers fruit ')' /\Z/
headers: version(?) rev(?)
version: '(' 'VERSION' /\d+/ ')' | <error>
rev : '(' 'REV' /\d+/ ')' | <error>
fruit : '(' 'FRUIT' /\w+/ ')' | <error>
};
Parse::RecDescent->new($gmr)->file($txt);
This produces:
ERROR (line 1): Invalid fruit: Was expecting 'FRUIT'
but found "REV X) (FRUIT banana))" instead
I was expecting it to complain about X, not FRUIT.
I discovered that if I made the subrule rev
non-optional ("headers: version(?) rev"), it would work:
ERROR (line 1): Invalid rev: Was expecting /\d+/
but found "X) (FRUIT banana))" instead
Alternatively, I found another way to trigger expected
results was to inline the "headers" rule:
file : '(' 'FILE' version(?) rev(?) fruit ')' /\Z/
ERROR (line 1): Invalid rev: Was expecting /\d+/
but found "X) (FRUIT banana))" instead
ERROR (line 1): Invalid fruit: Was expecting 'FRUIT'
but found "REV X) (FRUIT banana))" instead
From looking at $::RD_TRACE, I can tell that
rule:rev fires and fails each time; it's just a question
of whether that error gets pruned or not.
Any ideas on what's going on here, or, at least, how I
can get the desired behaviour without in-lining?
This is perl5.00503 under x86 RedHat Linux 6.0,
Parse::RecDescent version 1.66.
Thanks,
Rand.
------------------------------
Date: Wed, 11 Aug 1999 09:07:16 -0700
From: "Scott.R.Wachtler" <Scott.Wachtler@cdc.com>
Subject: Perl Sockets on Linux
Message-Id: <37B19FB4.4C3AD4DF@cdc.com>
Hi,
I'm trying to use sockets via Perl and running into problems. The
server script runs fine on a Unix box and seems to run fine on my Linux
box also. Unfortunately when a client tries to connect to my linux box
it receives a Connection Refused. The "offending" line is
connect($S, $remote_sok) || die $!;
But when a client tries to connect to the Unix server it runs fine.
Anyone know what may be causing the problem or where I can do more
research on Linux flavored perl?
Any and all help is appreciated.
Scott
------------------------------
Date: 11 Aug 1999 10:18:48 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Reset .. ie clear out a hash array
Message-Id: <37b1a268@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
Nick Djurovich <Nick.Djurovich@btinternet.com> writes:
:How can I reset %data to remove any data ? (both keys and values)
:without cycling through *all* the elements.
%data = ();
Sometimes you can also arrange to simply have it be a lexical that goes
out of scope.
--tom
--
Remember though that
THERE IS NO GENERAL RULE FOR CONVERTING A LIST INTO A SCALAR.
--Larry Wall in the perl man page
------------------------------
Date: Wed, 11 Aug 1999 12:38:32 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Run a script from a web browser and put it in the background
Message-Id: <linberg-1108991238320001@ltl1.literacy.upenn.edu>
In article <37B18958.3266BEB0@hotmail.com>, Guideline Chan
<yoursguideline@hotmail.com> wrote:
> I want to run a script from a web browser.
<snip>
Your question has nothing to do with Perl. Please take it to
comp.infosystems.www.authoring.cgi.
--
Steve Linberg, Systems Programmer &c.
National Center on Adult Literacy, University of Pennsylvania
print 'Just Another Perl ' . $perl_hierarchy[(USER+EXPERT)/2];
------------------------------
Date: Wed, 11 Aug 1999 16:33:32 GMT
From: Christopher Conway <chris_conway@my-deja.com>
Subject: s/// and interpolation
Message-Id: <7os8ks$f15$1@nnrp1.deja.com>
I'm writing a simple script where I want to let the
user specify a search and replace expression, and
then execute it. When I do something equivalent to:
$search = '\d{3}-\d{2}-\d{4}' ;
$replace = 'ID#$1$2$3' ;
$record =~ s/$search/$replace/ ;
The variables in the s/// get interpolated, but the
variables in the interpolated string do not. Fine.
How do I fix this? I.e., how do I force Perl to
interpolate recursively one level down?
Thanks,
Chris
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 11 Aug 1999 12:16:09 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: searching complex data structure
Message-Id: <x7907i9tti.fsf@home.sysarch.com>
>>>>> "JK" == Joe Kline <Joe.Kline@sdrc.com> writes:
JK> $k4 = 'criterium1';
JK> $v = 'criterium2';
JK> $k3 = 'dog';
JK> K1:foreach $k1 ( keys %stuff )
try using the each function. it saves you a hash lookup as it gets you
the key and value as a pair. and as you get deeper, you look up only
lower hashes and you don't repeat high level lookups which are
redundant. you can use it for several levels of your loops (untested):
while( ( $k1, $v1 ) = each %stuff ) {
$v1 is now a ref to the next level of hash
JK> {
JK> K2:foreach $k2 ( qw/A B/ )
JK> {
while( ( $k2, $v2 ) = each %$v1 ) {
JK> if ( exists ( $stuff{$k1}{$k2}{$k3}{$k4} ) )
that will autovivify the $k3 level so do separate checks here.
next unless exists $v2->{$k3} ;
$v3 = $v2->{$k3} ;
next unless exists $v3->{$k4} ;
JK> {
JK> push(@matches, grep( @{$stuff{$k1}{$k2}{$k3}{$k4}}) )
JK> }
you don't have a grep operation there.
push( @matches, grep /$v/, @{$v3->{$k4}} ) ;
that should be a lot faster as well as clearer.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.
------------------------------
Date: Wed, 11 Aug 1999 15:51:31 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: Some help needed - NOT !
Message-Id: <7os6b6$3dp$1@news.mch.sbs.de>
In article <7or5q0$e2m@jumbo.cyberp.kemerovo.su>, "S.Berezin" <bsv@mega.kemerovo.su> wrote:
>Hello all!
>I need counter for web pages. It must works without any other programms and
>providers.
>(CGI or Perl script).
>Pls. help me to find it.
>servber@mail.ru
Hmm, Perl scripts usually require the perl program, so I wouldn't use
that if I were you. And CGI scripts require a webserver. That's no good
either, probably.
Try one of those remotely hosted counters, e.g. at the CGI Resource Index :
http://cgi.resourceindex.
com/Programs_and_Scripts/Remotely_Hosted/Access_Counters/
(or anywhere else, for that matter)
Goodbye,
Michel.
------------------------------
Date: Wed, 11 Aug 1999 11:27:26 -0500
From: Joel Neely <joel.neely@entpm4.prod.fedex.com>
Subject: Re: while loop teminates too early
Message-Id: <37B1A46E.FE83E930@entpm4.prod.fedex.com>
Andy Collado wrote:
>
> Andy Collado wrote:
>
> > I have a while loop that should verify that a user is valid, but it will
> > only validate whoever is the first user in the user file.
> > Here's the block of code that I'm using:
> >
> > open (USERS, "C:/www/users");
> > while($line=<USERS>) {
> > if ($line=~/^$user/) {
> > ✓
> > }
> > else { -------!
> > &goaway; -------!
> > } --------!
> > exit;
> > }
> >
> >
>
> Evidently, the while loop does not like the else statement inside it. Once
> I took that out, it worked fine. All i had to do was invoke the sub &goaway
> outside the while loop and all went well.
The fact that your code only looked at the first line of the file has
NOTHING to do with putting "if...else..." inside a "while" and
EVERYTHING to do with the fact that the last statement inside your
loop is "exit".
-jn-
--
public class JoelNeely extends FedEx { // (
String workEMail = "joel'dot'neely'at'fedex.com"; // )
boolean speaksForCompany = false; } // (
// my $ok=($lang=~/^[pj][ea][rv][la]$/i)&&($os=~/.*u.*x/i); // C[_]
------------------------------
Date: 11 Aug 1999 16:58:5 GMT
From: QuestionExchange <USENET@questionexchange.com>
Subject: Re: why doesnt this work?
Message-Id: <766qx@questionexchange.com>
> Hi, I can't get this script to work properly. It's desgined
> for a huge directory file system. I've tested it on a smaller
> file structure and it worked. But if I try it on the intended
> dirs, it doesn't work. The files and their paths indeed exist,
> but the script does nothing when invoked, returning to the
> prompt. #!/public/bin/perl -w $finalDir = "/home/user/";
> chdir "$finalDir" or die "Can't cd to $finalDir: $!\n"; foreach
> $File (<W*/N*/*.txt>) { system("/tools/util/sumfw.pl
> $File"); } Any ideas? Thanks alot ..Tom -------------------
> ---------------------------------------------------------------
> ------- Tom Kralidis Geo-
> Spatial Technologist Canada Centre for Remote Sensing
> Tel: (613) 947-1828 588 Booth Street , Room 241
> Fax: (613) 947-1408 Ottawa , Ontario K1A 0Y7
> http://www.ccrs.nrcan.gc.ca -----------------------------------
> ------------------------------------------------------
Globbing is a fragile operation in Perl - this is on track to
be fixed in some version. It may be that the C shell, which is
called for globbing, barfs on seeing too many files. The
simplest solution is to use opendir and readdir, about which
you can read in the perlfunc manpage.
--
This answer is courtesy of QuestionExchange.com
http://www.questionexchange.com/servlet1/showUsenetGuest?ans_id=2583&cus_id=USENET&qtn_id=1673
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 462
*************************************