[9491] in Perl-Users-Digest
Perl-Users Digest, Issue: 3085 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 7 18:07:12 1998
Date: Tue, 7 Jul 98 15:00:19 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 7 Jul 1998 Volume: 8 Number: 3085
Today's topics:
Re: -w on production code (was Re: better way of gettin (Craig Berry)
Re: 2 dimensional array - Help needed <jc@ral1.zko.dec.com>
Re: 5.004_69 win32 Glob problem (Tye McQueen)
Re: Accessing shell variables in a perl script <jc@ral1.zko.dec.com>
Re: Accessing UDB from perl? smmcdowell@west.com
Re: File Upload - Need Help... <abaugher@rnet.com>
Getting Yesterday's Date schumacc@db.erau.edu
Re: Getting Yesterday's Date (Kelly Hirano)
Re: Getting Yesterday's Date <scott.ranzal@mci.com>
Re: Getting Yesterday's Date (Bob Trieger)
Graphics DB and CGI programming. <sloscialo@chubb.com>
Re: How to in perl <abaugher@rnet.com>
Re: HTTP connections WITHOUT the libwww module? <domainsource@usa.net>
Re: HTTP connections WITHOUT the libwww module? (brian d foy)
Re: limits of glob() ? and number of sub-dirs in win95 (Tye McQueen)
Re: Microsoft Client IE 4 vs Netscape HTTP Server <jc@ral1.zko.dec.com>
Re: Oh man, DO I love Perl ! (References to things that (Ilya Zakharevich)
Re: Out of memory in sort (Ilya Zakharevich)
Pattern matching problems <rmullen@mcmail.com>
Pattern matching problems <rmullen@mcmail.com>
Perl under AIX v4.3.1 (help) mgrabenstein@my-dejanews.com
Re: print multiline strings (Larry Rosler)
Re: serious bug in Time::Local? (John Stanley)
Re: system commands in perl (Mark-Jason Dominus)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 7 Jul 1998 21:37:58 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: -w on production code (was Re: better way of getting the last modified file?)
Message-Id: <6nu4fm$3l8$1@marina.cinenet.net>
Tina Marie Holmboe (tina@scandinaviaonline.se) wrote:
: I thought I'd add a comment... personally I would *strangle* anyone
: who left -w in production code; and be tempted to be rather mean to them
: even with development ditto.
:
: This, my attitude, has a reason. My current workplace has alot of people
: developing alot of programs meant for running by HTTP servers. It is known
: as "CGI-programming"... :)
:
: Most of the scripts written are not heavily debugged to rid themselves
: of warnings. Like so many others I tend to tail -f the error logs when
: I testrun CGI-script.
Then what are they doing in production?? Making production scripts run
warning-free (either through fixing all the warning-producing constructs,
or careful and limited use of localized $^W to turn off warnings in a
small scope) is the best way to save yourself grief in the long term.
This is a tautology, but warnings are warning you about something.
Pulling the batteries out of a smoke alarm doesn't put out the fire. :)
: And when people then use -w the net result is a furiously scrolling
: screen, with absolutely *no* way of seeing any of the more serious
: errors that might occur.
So change your development culture to insist on -w -clean code. Then move
on to use strict -clean. It'll pay for itself, and sooner than you think.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Tue, 07 Jul 1998 15:57:39 -0400
From: John Chambers <jc@ral1.zko.dec.com>
Subject: Re: 2 dimensional array - Help needed
Message-Id: <35A27DB3.6F81AD28@ral1.zko.dec.com>
brian d foy wrote:
>
> In article <35a24750.15648766@news.tm.net.my>, wong2020@tm.net.my (Huang) posted:
>
> > I have an input file with the following format
> >1 2 3
> >4 5 6
> >7 8 9
>
> > I wish to input it into an array.
> >The results I wish to accomplish is
> >@x[1,1]=1
>
> those aren't the results that you want. those are array slices -
> somthing completely different (but it's not time for that yet).
>
> how about multi-dimensional arrays, as discussed in the perldsc
> man page?
>
> $matrix[$m][$n] = $value; #and so on.
And, of course, there's always the perl4 hack using hashes:
$x{1,1} = 1;
...
$x{3,3} = 9;
This is somewhat slower than real 2-D arrays, but I keep finding that
it's fast enough for most purposes, and it's more readable. You also
don't have to worry about making sure that the first-level vectors have
been allocated. And for sparse arrays it often uses far less memory.
------------------------------
Date: 7 Jul 1998 16:36:32 -0500
From: tye@fohnix.metronet.com (Tye McQueen)
Subject: Re: 5.004_69 win32 Glob problem
Message-Id: <6nu4d0$dd4@fohnix.metronet.com>
Matthew Morley <m.morley@NOSPAM.worldnet.att.net> writes:
)
) Thanks, good suggestion. I implemented my own recursive function
) that returns the same values that glob("$dir") does called
) "myglob($dir, $depth, ...)" that looks pretty ugly but works well.
) I count the "/" characters in a string using "tr" to keep track of the
) recursion depth. Its amazing all the work (<*/*/*/*-*>) used do!
) I heard somewhere that glob() is pretty inefficient so prehaps this
) is a blessing in disguise. I also filed a trouble report to ActiveState
) which they are probably expecting anyway.
To make it efficient, just do:
C:> set PERL5OPT=-MFile::DosGlob=glob
or
use File::DosGlob qw(glob);
then glob("*/*/*/*-*") will probably be more efficient than
anything you throw together.
) > > Is there a more efficient way to return a list of subdirectories with
) > > the 4-th level subdirectory matching in "*-*" (star dash star)?
) > > without using globing?
Using glob() from any module [File::DosGlob or File::KGlob as two
examples] is about as efficient as you can get.
) > Personally, I'd use the File::Find module to select the target files.
That would do the same work as glob() but would waste work finding
things you didn't want.
--
Tye McQueen Nothing is obvious unless you are overlooking something
http://www.metronet.com/~tye/ (scripts, links, nothing fancy)
------------------------------
Date: Tue, 07 Jul 1998 16:25:44 -0400
From: John Chambers <jc@ral1.zko.dec.com>
Subject: Re: Accessing shell variables in a perl script
Message-Id: <35A28448.4B9C7666@ral1.zko.dec.com>
Mark Evan Jones wrote:
>
> Sean McAfee wrote:
> >
> > In article <35A246CF.B7426CBF@mindless.com>,
> > Mark Evan Jones <xmarkjones@mindless.com> wrote:
> > >We've got a handy little %ENV for accessing environment settings. But
> > >is there
> > >any way to access the shell's own variables?
> >
> > No. Variables which are not exported are simply not available to child
> > processes of the shell (eg, Perl). You can either a) export the
> > appropriate variables prior to running Perl, or b) pass the (expanded)
> > variables as arguments to Perl. If you don't know ahead of time which
> > shell variables you need, and can't use either of the above methods (for
> > whatever reason), it's probably time to rethink your approach.
>
> Hm. It's not exactly my approach. I've been told to write something to
> be
> run within a shell script that makes use of a certain variable within
> that
> script. Ah well, now I know to try and make them do this another way.
Maybe not. All you have to do is make sure that those variables are
in the shell's list of exported variables (for sh, ksh or bash), or
assigned via "setenv" rather than "set" (for csh and tcsh).
There's a bit of confusion over such things, caused by different handling
of variables in the sh-type shells from the csh-type shells. In csh,
there are actually two separate symbol tables, the ones created by "set"
and "setenv". You can have a variable by the same name in each, with
different values. Only the "setenv" variables are passed to children.
With the sh-type shells, there is only one symbol table, and you use the
"export" command to say which are passed to children.
If you were told specifically to not use "setenv" or "export", then you
have a problem. But this probably wasn't mentioned. If not, use "setenv"
or "export", and it should solve your problem.
------------------------------
Date: Tue, 07 Jul 1998 20:00:05 GMT
From: smmcdowell@west.com
Subject: Re: Accessing UDB from perl?
Message-Id: <6ntuo5$280$1@nnrp1.dejanews.com>
In article <6nqs5r$kd$1@flood.xnet.com>,
no_junk_mail.shah@xnet.com wrote:
>
>
> Folks,
>
> Is there a perl library/module I can use to access DB2 UDB on AIX?
>
> Thanks in advance :-)
>
> To reply, please remove no_junk_mail from my e-mail address.
> --
> Hemant Shah, LIDP Inc. /-------------------\ ^~~~~^
> Voice: +1 630 960 0133 x 664 |TECHNOLOGY | | |
> Fax: +1 630 960 0717 |No place for wimps | o|-OO-|o
> E-mail: shah@xnet.com | -Dilbert |--- | () |
> \-------------------/ | |
> -----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
> I haven't lost my mind, Above opinions are mine only.
> it's backed up on tape somewhere. Others can have their own.
>
I'm using the one for DB2 version 2.1 and setting the environment variable
DB2_HOME=/usr/lpp/db2_05_00.
It seems to be working fine to this poing
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: 07 Jul 1998 16:15:33 -0500
From: Aaron Baugher <abaugher@rnet.com>
Subject: Re: File Upload - Need Help...
Message-Id: <m21zrxwefe.fsf@haruchai.rnet.com>
Nick Forte <webmaster@triologic.com> writes:
> Thanks. I'm kinda new to PERL, so bare with me. What's the
> difference if I have a PERL file create and write to a file on the
> server (which I can do) or if I have upload it from a user's PC?
> Both ways are entrusting the PERL script to handle it.
When you run a Perl script from the command line, you are running it
as your own UID, and thus if it does something screwy, you can only
damage your own files, no one else's. Presumably, you know what you
are doing, and aren't going to be doing something malicious.
When the web server runs a CGI script, it runs it on behalf of some
anonymous and possibly evil person out there, so you really don't want
to give it the right to write to your server unless you are very
confident in the security of your script. At the least, you could
allow someone to fill up your hard drive with garbage.
At worst, let's say you get your script working, and you want users to
be able to upload files, so you make the script run as root with
setuid. I come along and upload a file named "/etc/passwd", thus
replacing your password file with one of my own.
This is an extreme example, but it makes the point. Running the web
server's children as a restricted user like 'nobody' cuts down on the
potential for attacks (or dangerous script errors) by severly limiting
their rights. If you need to allow files to be uploaded through a
CGI, use the CGI.pm package, create a directory that is owned by the
UID that the script will run under, and test your script with 'taint'
checking (-T) turned on.
--
Aaron Baugher - abaugher@rnet.com
Extreme Systems Consulting - http://haruchai.rnet.com/esc/
CGI, Perl, Java, and Linux/Unix Administration
------------------------------
Date: Tue, 07 Jul 1998 20:52:57 GMT
From: schumacc@db.erau.edu
Subject: Getting Yesterday's Date
Message-Id: <6nu1r9$6le$1@nnrp1.dejanews.com>
I have a need within a Perl script to get yesterday's date. We are on AIX 4.0
and I checked the man page for date, but found no option which will return
yesterday's date. Is there an easy way to do this within Perl or UNIX? I
thought I could just subtract one from the day, but that quickly becomes more
complicated than I want to deal with. Any suggestions would be greatly
appreciated. Could you e-mail me as well as posting any ideas. I don't get to
read the news group regularly.
TIA,
Chris Schumacher.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Chris Schumacher (System Administrator) E-Mail: schumacc@db.erau.edu
Embry-Riddle Aeronautical University Fax: (904) 226-7000
600 S. Clyde Morris Blvd. Phone: (904) 226-6449
Daytona Beach, FL 32114
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: 7 Jul 1998 14:07:38 -0700
From: hirano@Xenon.Stanford.EDU (Kelly Hirano)
To: schumacc@db.erau.edu
Subject: Re: Getting Yesterday's Date
Message-Id: <6nu2mq$eu5@Xenon.Stanford.EDU>
In article <6nu1r9$6le$1@nnrp1.dejanews.com>, <schumacc@db.erau.edu> wrote:
>I have a need within a Perl script to get yesterday's date. We are on AIX 4.0
>and I checked the man page for date, but found no option which will return
>yesterday's date. Is there an easy way to do this within Perl or UNIX? I
>thought I could just subtract one from the day, but that quickly becomes more
>complicated than I want to deal with. Any suggestions would be greatly
>appreciated. Could you e-mail me as well as posting any ideas. I don't get to
>read the news group regularly.
my $yesterday = localtime (time - 86400); # 86400 seconds in a day
--
Kelly William Hirano Stanford Athletics:
hirano@cs.stanford.edu http://www.gostanford.com/
hirano@alumni.stanford.org (WE) BEAT CAL (AGAIN)! 100th BIG GAME: 21-20
------------------------------
Date: Tue, 07 Jul 1998 21:20:54 GMT
From: "Scott Ranzal" <scott.ranzal@mci.com>
Subject: Re: Getting Yesterday's Date
Message-Id: <Wiwo1.420$FO3.751984@pm01nn>
Chris
If you use localtime() and get the current epoch time you can subtract 86400
seconds from that. 86400 is the number of seconds in one day.
Then you can feed localtime($today-86400), which will give you yesterday,
regardless of what yesterday was.
Look in camel on page 185 for localtime();
------------------------------
Date: Tue, 07 Jul 1998 21:20:12 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: Getting Yesterday's Date
Message-Id: <6nu3ig$tlt$1@strato.ultra.net>
[ posted and mailed ]
schumacc@db.erau.edu wrote:
-> I have a need within a Perl script to get yesterday's date.
Modules are your friends.
Check out Date::Calc and it's `calc_new_date' routine.
HTH
Bob Trieger
sowmaster@juicepigs.com
" Cost a spammer some cash: Call 1-800-286-0591
and let the jerk that answers know that his
toll free number was sent as spam. "
------------------------------
Date: Tue, 7 Jul 1998 16:05:37 -0400
From: "Sergio Loscialo" <sloscialo@chubb.com>
Subject: Graphics DB and CGI programming.
Message-Id: <6ntv11$345@sidney.chubb.com>
I have a SQL Server database that has a field of type image that I
am trying to pull from a Perl CGI script. I can access the database
and get some data, but I am having trouble writing the piece of code
that will display, not only the surrounding HTML, but the JPEG image
as well.
Basically, the CGI script opens a socket and transmits the SQL to
SQL Server. The socket sends back the blob data, but I can't get
Perl to display it.
I call the CGI script via the following method in HTML:
<img src="/cgi-bin/graphic.cgi?code=1" border=0 align="Left">
The graphic script runs correctly (meaning it pulls the correct data
from the database, but it doesn't return anything useful.
Graphic.cgi does the following:
print "Content-Type: image/jpeg\n\n";
print &GetData
Where &GetData returns the blob from SQL server.
Do I need to do anything to the blob information? Am I using
the right data type (should I be using varBinary)? Also, I am not
even sure that if I generate the image tag dynamically from
another Perl script if it would even run the second one. Has
anyone solved this problem of getting graphic images from
a database to display in HTML pages?
Any help would be appreciated,
----
Sergio Loscialo
Chubb Computer Services
http://ccs.chubb.com
------------------------------
Date: 07 Jul 1998 15:56:30 -0500
From: Aaron Baugher <abaugher@rnet.com>
Subject: Re: How to in perl
Message-Id: <m23ecdwfb5.fsf@haruchai.rnet.com>
11:55:56 GMT, Matt Heusser <matt@pcr7.pcr.com> says...
> how about something like this?
>
> #---------------
> #sample.pl
> my $counter
> $counter = 1;
> while (<>) {
> if ($counter>6) print $_;
> $counter++;
> {
> #-------------EOF
lr@hpl.hp.com (Larry Rosler) writes:
> There are two syntax errors in the above snippet.
Heck, I think I see three! Anyone else?
--
Aaron Baugher - abaugher@rnet.com
Extreme Systems Consulting - http://haruchai.rnet.com/esc/
CGI, Perl, Java, and Linux/Unix Administration
------------------------------
Date: Tue, 7 Jul 1998 17:33:54 -0400
From: "David Thompson" <domainsource@usa.net>
Subject: Re: HTTP connections WITHOUT the libwww module?
Message-Id: <6nu414$9q1$1@winter.news.erols.com>
The problem is that I can't use any modules at my webhost. They are not
very developer-friendly. If I transfer the code from the module
directly into the script, that's a valid solution, just messy.
I guess the socket 80 solution mentioned in another response might work,
but maybe if I elaborate a little more I will be able to help you help
me... :)
What I am looking to do is have a perl script fetch a URL and store it
in a string (or any other method possible). I know what the URLs will be
(approximately, varies based on user input) and they aren't huge files.
I can't use any modules (other than CGI.pm) in the script, which thew me
a little bit. It should be reasonably stable (it has to go on a couple
different servers) and take processor overhead into consideration (but
disk space and/or script length aren't big factors).
I'm going to try porting the code from the LWP module into the script
and see how that goes - but is there a more "elegant" way to do this
(especially with a code sample)?
Thanks so much!!!
(by the way, if you want a free URL submission to 200 search engines for
your help, just let me know).
David
brian d foy wrote in message ...
>In article <6nrn6u$k8b$1@winter.news.erols.com>, "David Thompson"
<domainsource@usa.net> posted:
>
>>Is it possible to retrieve a URL (and store for later parsing) WITHOUT
>>using the LibWWW module?
>
>well, the LWP module retreives a URL without the LWP module, so
>it must be possible ;)
>
>just open a socket and do the HTTP stuff like any other client/server
>app. look at Socket.pm or IO::Socket. [NB: not for the timid]
>
>>Is it possible to just import the useragent functions into a script?
>>(not my preferred solution, but workable).
>
>well, if you are using the UserAgent stuff, you're using LWP, which
>you didn't wnat to use.
>
>perhaps this isn't the problem though. why can't you use LWP?
>
>--
>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>
>Perl Mongers Travel Deals! <URL:http://www.pm.org/travel.html>
------------------------------
Date: Tue, 07 Jul 1998 17:53:49 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: HTTP connections WITHOUT the libwww module?
Message-Id: <comdog-ya02408000R0707981753490001@news.panix.com>
Keywords: from just another new york perl hacker
In article <6nu414$9q1$1@winter.news.erols.com>, "David Thompson" <domainsource@usa.net> posted:
>The problem is that I can't use any modules at my webhost. They are not
>very developer-friendly. If I transfer the code from the module
>directly into the script, that's a valid solution, just messy.
then get another webhost, or learn how to install modules in your
own directory (see the FAQ or the module README for details).
the business is competitive enough that you don't have to settle
for less than you want. :)
--
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>
Perl Mongers Travel Deals! <URL:http://www.pm.org/travel.html>
------------------------------
Date: 7 Jul 1998 16:23:34 -0500
From: tye@fohnix.metronet.com (Tye McQueen)
Subject: Re: limits of glob() ? and number of sub-dirs in win95
Message-Id: <6nu3km$9ke@fohnix.metronet.com>
Palisade Corporation <admin@palisade.com> writes:
)
) @fileList = glob "*/*";
) print "$#fileList";
)
) from the root of my D: drive tells (111) me I have 112 files/
) directories. There are over 3,000. This on NT 4.0 (ntfs).
I apologize for my presumption but I think you might be mistaken.
perl -e "@x=glob('*/*/*/*'); print 0+@x"
counts up over 5000 files for me. Perhaps the "over 3,000"
number you mention is the number of files in all subdirectories,
not just the files and directories that are exactly one
subdirectory deep? I guess that because without using Perl,
I can't think of a good way under Win32 to count how many files
should match "*/*" but it is trivial to count the number of
files in all subdirectories.
Like most things in Perl, glob(), barring bugs, can handle as
many items as will fit into virtual memory.
For the record, I'm using Perl5.004_04 plus some minor patches
and perlglob.bat not perlglob.exe [otherwise glob("*/*") wouldn't
match anything] under WinNT 4.0 SP3 on NTFS.
To really test glob(), try this:
perl -e "$n=0;$x='*';while(1){@x=glob($x);print $n+=0+@x,qq.\n.;$x.='/*'}"
That should eventually tell you the total number of files and
directories in all subdirectories of your current directory
[though not in a particularly efficient manner -- but in a manner
that tests glob()]. Hit Ctrl-C when the numbers stop going up.
Compare this to results of chkdsk, dir/s/a, or folder properties
[adjusting for which ones count . and .., etc.].
For me it counts past 40,000 items and glob() matched over
12,000 in a single call.
If you still find things being missed by glob(), then we need to
fix something so give us specifics and show us how to reproduce
them.
--
Tye McQueen Nothing is obvious unless you are overlooking something
http://www.metronet.com/~tye/ (scripts, links, nothing fancy)
------------------------------
Date: Tue, 07 Jul 1998 16:18:24 -0400
From: John Chambers <jc@ral1.zko.dec.com>
Subject: Re: Microsoft Client IE 4 vs Netscape HTTP Server
Message-Id: <35A28290.A4C78F0B@ral1.zko.dec.com>
William L Cooper wrote:
>
> I am having a problem with IE 4 using Netscape Fastract HTTP Server.
> When the IE 4 preference
>
> View/Internet Options/Advanced/HTTP 1.1 Settings/Use Http 1.1
>
> is set, I have a problem when a cgi program runs. The problem is that
> the IE 4 client is waiting for the transaction to complete while the
> server cgi program has sent the HTML termination
>
> ?</BODY></HTML>?
>
> and performed an exit. This does not happen if the client is Netscape
> Ver 3 or 4 nor does it happen if the client is IE 3.
>
> The problem also does not happen with IE 4 if the server is CERN.
>
> Is there an HTTP 1.1 requirement to signal end of HTML page other than
> ?</BODY></HTML>? ?
This seems to be a known bug in some versions of TCP, most notoriously
Microsoft's. I asked about the same thing a few months ago, and got several
explanations. I'll see if I can find some of them. The reason that you
don't see it with Netscape seems to be that on DOS/W95, more of TCP is in
the link libraries than on Unix, and so the behavior varies from program to
program. You probably picked up a binary from Netscape, which was linked
with their TCP library, and it isn't as buggy as Microsoft's. The bug
involves the part of the TCP protocol that handles shutting down a link,
which Microsoft sometimes doesn't do right. After a while, the server
gives up and goes away, and then IE never sees the final shutdown message.
We're running the Apache server here, and we see the same problems with IE
as you're seeing. One curiosity: When IE hangs, we can hit the stop button
and refresh the page, and the second time it usually works fine. It's sort
of random, depending on the exact timing of low-level events.
The later releases of IE have fewer problems than the earlier ones. If
you're not running the latest IE, you might want to upgrade.
------------------------------
Date: 7 Jul 1998 20:49:41 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Oh man, DO I love Perl ! (References to things that go out of scope)
Message-Id: <6nu1l5$1oe$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to John Chambers
<jc@eddie.mit.edu>],
who wrote in article <35A24CC2.300C141@ral1.zko.dec.com>:
> Also, OO is much more difficult to learn and debug. The perl debugger
> seems to have problems with it: "my" variables always come up null,
> references display as hex values, and so on. You are pretty much reduced
> to the old "add another print" to find out what's gone wrong. So it's
> easy to write something first in a non-OO fashion, so you can use the
> debugger. And then, once you've got it running, you think that you
> should redo it in OO style, but you have other tasks that are higher
> priority, so it gets put aside for now ...
Not for people who took a minute and did what the debugger suggests to
do:
h h
Ilya
------------------------------
Date: 7 Jul 1998 21:48:15 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Out of memory in sort
Message-Id: <6nu52v$8f7$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Chris Crook
<chris@zucchini.linz.govt.nz>],
who wrote in article <01bda9da$b978ac60$45144290@pcxtmcc.linz.govt.nz>:
> Hi All
>
> I am sorting a file of about 5 Mb size consisting of about 150000 approx 30
> character records. My first approach was to read the file into an array,
> sort it, and write it out, ie
>
> open(F,'myfile');
> @data = <F>;
> close(F);
>
> @data = sort @data;
>
> open(F,'>myfile');
> print F @data;
> close(F);
>
> This failed with an "Out of Memory error" when running on an Intel Pentium
> machine with 80Mb RAM. I tried both ActiveState 3.16 perl under Win 95 and
> perl 5.004_? under linux with the same result (so it is probably a
> consequence of perl memory management rather than OS memory management?)
I will not comment about junkware date, but people usually say that
linux's malloc() is not bad. Below is the data with Perl's malloc:
wc myfile
100561 503008 3870111 myfile
Memory allocation statistics after compilation: (buckets 4(4)..8184(8192)
17240 free: 172 67 29 24 11 8 2 1 1 0 0
452 110 17 3 16
43436 used: 83 60 97 38 5 8 2 11 0 1 1
59 60 153 81 9
Total sbrk(): 63432/8:156. Odd ends: pad+heads+chain+tail: 1992+764+0+0.
Memory allocation statistics after execution: (buckets 4(4)..528376(524288)
5718224 free: 4647 3347 7363 12974 27360 568 6 1 0 0 0 1 0 0 0 0 0
17025 3497 7365 16970 196
11139720 used: 4533 3384 7442 16662 2032 568 6 4827 0 1 1 0 0 0 0 0 3
16701 3473 7510 17050 21854
Total sbrk(): 17711048/152:300. Odd ends: pad+heads+chain+tail: 1992+423080+0+428032.
> I have been able to get around this using
>
> # read file as before
>
> my @lineno = (0..$#data);
> @lineno = sort {$data[$a] cmp $data[$b]} @lineno;
>
> open(F,'>myfile');
> print F @data[@lineno];
> close(F);
Memory allocation statistics after compilation: (buckets 4(4)..8184(8192)
17760 free: 171 67 13 21 11 8 2 1 1 0 0
448 108 4 36 16
44932 used: 84 60 113 41 5 8 2 11 0 1 1
63 62 166 90 9
Total sbrk(): 65480/9:157. Odd ends: pad+heads+chain+tail: 1992+796+0+0.
Memory allocation statistics after execution: (buckets 4(4)..528376(524288)
29236 free: 56 45 37 28 14 5 2 0 0 0 0 1 0 0 0 0 0
158 95 41 34 5
14795624 used: 4534 3384 7460 12992 27362 571 6 6846 1 1 1 0 0 0 0 0 4
16705 3475 7524 17060 195
Total sbrk(): 15275976/149:297. Odd ends: pad+heads+chain+tail: 1992+324196+0+124928.
As you see, it is 17.7M of memory vs. 15.3M of memory. So most
probably it is your malloc() which is at fault (or less probably the
qsort(), if you run pretty old Perls, like 5.004_04).
Ilya
------------------------------
Date: Tue, 07 Jul 1998 22:06:51 +0100
From: Ross Mullen <rmullen@mcmail.com>
Subject: Pattern matching problems
Message-Id: <35A28DEB.2508E8A7@mcmail.com>
I have a two parts of a program which I am trying to accomplish,
the first searches any text input by the user for a email address, I
have wrote it out in theory however in practice it has proved difficult
to implement. I have been trying to use the pattern matching functions
to find the @ character and then find the first space before and the
first after, then create an email hyperlink to the user. But can only
find references in the manual I have to characters directly
before/after.
The second also involves pattern matching, it again reads an input and
any vowels encountered changes them to another vowel and prints out the
first change the (whole word with the first character changed) then the
second change in the whole word and so on. I have set-up a loop to count
through each position in the string, and then used the substitution
method to change to a vowel. However if I miss out the global operator
on the end it only changes the first occurrence if I leave it in it
changes all occurrences in one cycle, is it possible to change it on
every loop cycle.
If possible I don't want to use any external modules
Thanks in advance for any advice offered.
------------------------------
Date: Tue, 07 Jul 1998 22:10:49 +0100
From: Ross Mullen <rmullen@mcmail.com>
Subject: Pattern matching problems
Message-Id: <35A28ED9.15D9171F@mcmail.com>
I have a two parts of a program which I am trying to accomplish,
the first searches any text input by the user for a email address, I
have wrote it out in theory however in practice it has proved difficult
to implement. I have been trying to use the pattern matching functions
to find the @ character and then find the first space before and the
first after, then create an email hyperlink to the user. But can only
find references in the manual I have to characters directly
before/after.
The second also involves pattern matching, it again reads an input and
any vowels encountered changes them to another vowel and prints out the
first change the (whole word with the first character changed) then the
second change in the whole word and so on. I have set-up a loop to count
through each position in the string, and then used the substitution
method to change to a vowel. However if I miss out the global operator
on the end it only changes the first occurrence if I leave it in it
changes all occurrences in one cycle, is it possible to change it on
every loop cycle.
If possible I don't want to use any external modules
Thanks in advance for any advice offered.
------------------------------
Date: Tue, 07 Jul 1998 21:00:06 GMT
From: mgrabenstein@my-dejanews.com
Subject: Perl under AIX v4.3.1 (help)
Message-Id: <6nu28m$79p$1@nnrp1.dejanews.com>
Trying to get PERL v5.004_04 compiled under AIX 4.3.1 using IBM's xlc (cc)
compiler.
Initially I got stopped on:
extern int h_errno;
Commenting it out allows the compile to continue and seems to jive with the
new macro definition in netdb.h (from IBM source): extern void
*h_errno_which(void); #define h_errno (*(int *)h_errno_which())
That seems to get me through the compile completly, but it fails on several
tests, like:
pragma/locale.....FAILED at test 0
lib/filecopy......FAILED at test 6
lib/filefind......ok
lib/filehand......FAILED at test 0
lib/filepath......ok
lib/findbin.......ok
lib/gdbm..........FAILED at test 0
lib/getopt........ok
lib/hostname......ok
lib/io_dup........FAILED at test 0
lib/io_pipe.......FAILED at test 0
lib/io_sel........ok
lib/io_sock.......FAILED at test 0
lib/io_taint......FAILED at test 0
lib/io_tell.......FAILED at test 0
lib/io_udp........FAILED at test 0
lib/io_xs.........FAILED at test 0
lib/ndbm..........FAILED at test 0
lib/odbm..........FAILED at test 0
lib/opcode........FAILED at test 0
lib/open2.........FAILED at test 0
lib/open3.........FAILED at test 0
lib/ops...........FAILED at test 0
lib/parsewords....ok
lib/posix.........FAILED at test 0
lib/safe1.........FAILED at test 0
lib/safe2.........FAILED at test 0
lib/sdbm..........FAILED at test 0
lib/searchdict....ok
lib/selectsaver...ok
lib/socket........FAILED at test 0
Running perl harness just core dumps...
Anyone have some good hints for compiling on AIX 4.3.1 ?
I do get a lot of warning like:
WARNING: Exported symbol not defined: Perl_abs_amg
When DynaLoader is linked... (Perl_abs_amg might be the wrong symbol, going on
memory here. I found it in the embed.h file though...) :-)
Please CC me on any response. TIA.
thanks,
Mike
#include <std.disclaimer>
mgrabens@popd.isinet.com
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Tue, 7 Jul 1998 12:58:15 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: print multiline strings
Message-Id: <MPG.100c1db41383075d9896ed@nntp.hpl.hp.com>
In article <#7IVxgdq9GA.210@upnetnews05> on Tue, 7 Jul 1998 13:57:39 -
0500, Howard Dierking <howard@vortexweb.com> says...
> I'm using something like *print <<Lots_of_HTML* to print HTML with tables
> and forms and all that--however, I wasn't really planning on using all of
> the associated CGI.pm functions. I was just going to try and print. Now, I
> know that I need to \" all of the quotes. However, am I going to need to do
> that for all "=", " &", ";" -- I keep getting an error saying that it can't
> find the *Lots_of_HTML* before EOF. Thanks
The beauty of HERE documents is that you don't have to escape *anything*
in the document. The following is perlfaq4, "Why don't my <<HERE
documents work?":
Check for these three things:
1.There must be no space after the << part.
2.There (probably) should be a semicolon at the end.
3.You can't (easily) have any space in front of the tag.
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 7 Jul 1998 20:19:40 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: serious bug in Time::Local?
Message-Id: <6ntvss$6f1$1@news.NERO.NET>
In article <35a2687e.0@news.uni-rostock.de>,
Kajetan Hinner <kh052@cks1.rz.uni-rostock.de> wrote:
>$time1=timelocal(0,0,5,31,3,1998);
>$time2=timelocal(0,0,5,1,4,1998);
>
>we get:
>893991600, 893991600, 893973600
>
>-----------
>
>am i wrong? i think there's no difference between 31/3 and 1/4.
What is the problem? You go the same answer for both calls. Most time
routines silently roll an invalid day of month into the next month,
and that is what is happening here. When you try to talk about the 31st
day of April, which doesn't exist, you get May 1. At least, April 31
doesn't exist in the US. "30 days hath September, April..." yep, no
31st of April.
------------------------------
Date: 7 Jul 1998 16:05:54 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: system commands in perl
Message-Id: <6ntv32$g4r$1@monet.op.net>
In article <35A0EA6E.2156ED36@americasm01.nt.com>,
Frenette, Neil (EXCHANGE:CAR:9L23) <nfrenett@americasm01.nt.com> wrote:
>Is there a way to capture the output of a unix command when
>you execute it from a perl script using the system(" ") command ????
No. You need to use the qx{...} operator instead.
This is a FAQ.
------------------------------
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 3085
**************************************