[17314] in Perl-Users-Digest
Perl-Users Digest, Issue: 4736 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 26 18:10:33 2000
Date: Thu, 26 Oct 2000 15:10:18 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <972598217-v9-i4736@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 26 Oct 2000 Volume: 9 Number: 4736
Today's topics:
Re: How to connect perl+oracle? 5defcon5@my-deja.com
Re: Japanese Girl Has PERL Request. newt@veko.mediaSPAMLESSone.net
Re: jpeg image manipulation <bart.lateur@skynet.be>
Re: log in on a UNIX machine <Jonathan.L.Ericson@jpl.nasa.gov>
Re: newline in Unix and DOS [Was: Removing line breaks <mjcarman@home.com>
Re: newline in Unix and DOS [Was: Removing line breaks <MBalenger@worldnet.att.net>
Re: newline in Unix and DOS [Was: Removing line breaks <bart.lateur@skynet.be>
OLE array-based properties <tonyschmitt@cs.com>
Password Authentification (getpwent) 5defcon5@my-deja.com
Re: pattern matching help ( ~s/// ) <star@sonic.net>
Perl and Lotus Notes <lmoran@wtsg.com>
Re: perl not resolving dns in a cgi script <dpalmeNOSPAM@unitedtraffic.com>
Re: perl not resolving dns in a cgi script <dpalmeNOSPAM@unitedtraffic.com>
Re: perl not resolving dns in a cgi script <dpalmeNOSPAM@unitedtraffic.com>
Question about "use strict" <vautour@unb.ca>
Re: Question about "use strict" <UlleAckermann@t-online.de>
Re: Question about "use strict" (Tad McClellan)
Re: Question about "use strict" (Colin Watson)
Re: reading/writing binary data <cak@putzl.com>
Re: socket flushing problem <uri@sysarch.com>
Re: Sorting is too slow for finding top N keys... - UPD (Marko R. Riedel)
Re: Starting background process from Perl <Jonathan.L.Ericson@jpl.nasa.gov>
Re: String Comparison <ren.maddox@tivoli.com>
Tracking memory usage in Perl <dheaberl@us.ibm.com>
Re: Use VS Require <bart.lateur@skynet.be>
Re: What is the point of the new keyword 'our'? (Mark-Jason Dominus)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 26 Oct 2000 19:27:57 GMT
From: 5defcon5@my-deja.com
Subject: Re: How to connect perl+oracle?
Message-Id: <8ta0jm$ei$1@nnrp1.deja.com>
I use the PERL DBI module and it works well . . .
In article <8t9n08$o5h$1@nnrp1.deja.com>,
Phil xxx <phil_xxx@my-deja.com> wrote:
> I was wondering what is the best module to use to connect perl to
oracle
> 8.16. I preferably want to use sqlnet rather than odbc.
>
> Thanks in advance!
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 26 Oct 2000 18:11:29 GMT
From: newt@veko.mediaSPAMLESSone.net
Subject: Re: Japanese Girl Has PERL Request.
Message-Id: <lt_J5.2134$Cn4.9060@typhoon.ne.mediaone.net>
brian d foy <brian@smithrenaud.com> wrote:
> In article <Pine.LNX.4.21.0010121115590.19951-100000@hawk.ce.mediaone.net>, "Andrew N. McGuire " <anmcguire@ce.mediaone.net> posted:
>> On Thu, 12 Oct 2000, Kaori Ayn Honeywell quoth:
>> KAH> Can someone please send me the PERL code
>> KAH> that I need to interface the form with the Access
>> KAH> database to make this work?
>> So you want us to provide programs and documentation for your porn
>> site? I don't think so.
> however, there is no reason why anyone should be locked out of
> using Perl, unless you think freedom (whether libre or no-cost)
> is something reserved for linux weenies.
He's not locking anyone out. He's just saying that he's not about to provide
freebies for somebody else's commercial endeavor with which he has no sympathy.
He's free to do that, no?
------------------------------
Date: Thu, 26 Oct 2000 18:47:17 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: jpeg image manipulation
Message-Id: <5uugvsctn7n7988i5j1hhp768omud20kj9@4ax.com>
ejehoel@my-deja.com wrote:
>I'd like to manipulate (jpeg) images using perl. For example to
>generate thumbnails of large images or to increase the
>compression ratio.
Image::Magick and Perl::Magick.
<http://www.wizards.dupont.com/cristy/ImageMagick.html>
I've not used this just yet, but I probably will, very soon.
--
Bart.
------------------------------
Date: Thu, 26 Oct 2000 12:55:16 -0700
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: log in on a UNIX machine
Message-Id: <39F88C24.F761597@jpl.nasa.gov>
Lex Hagen wrote:
> Does anyone know how to log-in on a UNIX machine from a WinNT machine
> using PERL? So connecting, logging in (giving username, p.w.).
What protocol are you using? TELNET? FTP? Chances are you want a
module from CPAN. (http://search.cpan.org will get you started). (BTW,
it's Perl or perl - not PERL.)
> I would like to eventuelly do this from Visual Basic, does anyone know
> if that is possible also?
Probably, but why?
Jon
--
Knowledge is that which remains when what is
learned is forgotten. - Mr. King
------------------------------
Date: Thu, 26 Oct 2000 15:39:57 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: newline in Unix and DOS [Was: Removing line breaks from a string - HELP!]
Message-Id: <39F8969D.80D34065@home.com>
Michael Balenger wrote:
>
> > > I'm transferring source code and data from my home office PC to
> > > my client site Unix machine.
> >
> > Blah. Any decent FTP program will perform this translation for
> > you when you transfer the files in text mode.
>
> But I'm not using FTP because I'd like to preserve directory
> structures. I'd also like to avoid the banal, error-prone, tedious
> interface of requiring a couple 'o mouse clicks per file.
A decent program will also support directory-level copies, with enough
intelligence to only transfer new(er) files. No per-file action
required.
> Do other archivers do that kind of translation? It sounds appealing
> in this case, but would definately be a problem with binary data. :-)
Actually, this isn't a problem, because you configure the FTP client to
recognize text/binary files based on the file extension. You typically
put the client in "auto" transfer mode which means "tranfer everything
as a binary file unless it matches one of the text format file
extensions." And then you tell it that .txt, .html, .pl, etc. are all
text files.
I know that WS-FTP can do all this. There are undoubtably many other
programs as well. I suggest you do a Net search to find something that
meets your needs.
Of course, if you're moving huge amounts of data, you may want to zip it
up in order to save transfer time over a slow connection. But then you
have to weigh that against the pain of doing all the CRLF conversions
yourself afterward.
-mjc
------------------------------
Date: Thu, 26 Oct 2000 19:27:02 GMT
From: "Michael Balenger" <MBalenger@worldnet.att.net>
Subject: Re: newline in Unix and DOS [Was: Removing line breaks from a string - HELP!]
Message-Id: <aA%J5.7461$UL.450722@bgtnsc07-news.ops.worldnet.att.net>
[cut]
Thanks!
> > Real Motivation:
> >
> > I'm transferring source code and data from my home office PC to my
> > client site Unix machine.
>
> Blah. Any decent FTP program will perform this translation for you when
> you transfer the files in text mode.
But I'm not using FTP because I'd like to preserve directory structures.
I'd also like to avoid the banal, error-prone, tedious interface of
requiring a couple 'o mouse clicks per file. I've seen (non-standard)
versions of tar or cpio that do translations, but I'm not using them.
Do other archivers do that kind of translation? It sounds appealing in this
case, but would definately be a problem with binary data. :-)
================================================================
Mike Balenger
MBalenger@att.net migrating toward MichaelRunningWolf@att.net)
(732)809-3613 cell
All mammals learn by playing.
------------------------------
Date: Thu, 26 Oct 2000 19:59:25 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: newline in Unix and DOS [Was: Removing line breaks from a string - HELP!]
Message-Id: <g33hvs003mqge9sr5fossdfiqte3vhnka5@4ax.com>
Michael Balenger wrote:
>Seems that within Perl "\n" means different things on Unix and Win32
>systems. (So far, no brainer. Classic Unix vs. DOS (and of course
>WinDOS) brain split.)
>
>Here's where the brain split comes in for me.
>
>Where does the translation happen?
open OUT, ">test.txt";
print OUT "\012";
close OUT;
print -s "test.txt";
-->
2
In Win32, "\n" IS LF, chr(10), or whatever you want to call it. It's
printing it to a non-binmode()d file that converts it into CRLF. Read in
a text file, and CRLF is turned into "\012". But, be aware, that a bare
CR, chr(13), "\015" in a source file is *not* converted, and remains in
your input file; and a bare "\012"/LF/"\n", also remains as is.
In fact, you can simply convert a UNix text file to a PC text file with
the "script":
#! perl -pi.bak
--
Bart.
------------------------------
Date: Thu, 26 Oct 2000 17:14:51 -0400
From: Tony Schmitt <tonyschmitt@cs.com>
Subject: OLE array-based properties
Message-Id: <39F89ECB.ACE133E@cs.com>
I have been using a COM object from Graphics Server under ASP/Vbscript
for some time. Recently, I found a need to use this under PERL as
well. The problem comes into play when I try to set the array-based
properties of the graph object.
Here is the native VBScript code...
Set Graph1 = Server.CreateObject("GS.GSPropVB")
Graph1.Path = Server.MapPath(Graph1.URL)
Graph1.GraphTitle = "TESTING"
Graph1.NumSets = 1
Graph1.NumPoints = 10
For i = 1 to Graph1.NumSets
Graph1.ThisSet = i
For x = 1 to Graph1.NumPoints
Graph1.Data(x) = i * 20 + x * 5
Next
Next
FileName = Graph1.DrawGraph
FileExt = Graph1.Output
Set Graph1 = Nothing
... and in PERL...
use strict;
use Win32::OLE;
my $graph;
Win32::OLE::CreateObject("GS.GSPropVB", $graph) || die "CreateObject:
$!";$graph->{GraphType} = 6;
$graph->{Path} = ".";
$graph->{GraphTitle} = "TESTING";
$graph->{NumSets} = 1;
$graph->{NumPoints} = 10;
for (my $i=1;$i<=$graph->{NumSets};$i++)
{
print "set $i\n";
$graph->{ThisSet} = $i;
for (my $x=1;$x<=$graph->{NumPoints};$x++)
{
print "point $x = ",($i*20+$x*5),"\n";
$graph->{Data($x)} = ($i*20+$x*5); # *** Here is the problem
line ***
}
}
my $filename = $graph->DrawGraph();
my $fileext = $graph->{Output};
print "Filename = ".$filename.$fileext."\n";
undef $graph;
On the problem line, perl returns the error "Undefined subroutine
&main::Data". I have also tried a few permutations of setting this
property, such as "$graph->{Data}{$x} =", which does not generate an
error, but also does not set any data.
The maker of Graphics Server does not have any support information for
perl, so I've been basing this on other OLE objects in perl, like the MS
Excel application. It uses array-based properties too, like this one:
$sheet->Cells(1,1)->{Value} = "foo";
which sets a value to particular cell in a spreadsheet. However, in
this case "Value" is part of the property.
Does anyone have a clue how to make this work?
Tony Schmitt
CompuServe
tonyschmitt@cs.com
------------------------------
Date: Thu, 26 Oct 2000 18:12:11 GMT
From: 5defcon5@my-deja.com
Subject: Password Authentification (getpwent)
Message-Id: <8t9s5l$sjm$1@nnrp1.deja.com>
I'm trying to use perl to authenticate and entered user_id / password
against the system password file for an intranet system where the users
already have entries on the machine. I am looking at the getpwent()
function but can't figure it out very well. Can I use this function to
verify a user / passw coming from a web form.
Any suggestions / examples??
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 26 Oct 2000 21:41:13 GMT
From: arthur <star@sonic.net>
Subject: Re: pattern matching help ( ~s/// )
Message-Id: <B61CA1C3.9D19%star@sonic.net>
in article 39e3b80f.0@206.30.194.5, jim and lois at kf4dmb@net-magic.net
wrote on 10/10/00 4:38 PM:
> $string = " t:\test/one/jim.txt";
> $string = ~s ///\/ ;
>
> I get errors . what am I doing wrong ?
>
>
I think you have a space between the equal sign and the tilde '~' that you
should not have.
I am no pro but it does not seem to work
~arthur
------------------------------
Date: Thu, 26 Oct 2000 15:50:54 -0400
From: Lou Moran <lmoran@wtsg.com>
Subject: Perl and Lotus Notes
Message-Id: <r42hvs4car0c04tr46ce3p9ddajjv8guvn@4ax.com>
---When I am not reading comp.lang.perl.misc I am working with Lotus
Notes making DBs and such. A lot of times I think, "grr Lotus Script
doesn't do that!" or "Harrumph! I could do that in perl in three
lines!" (I try to keep my growling and harrumphing to myself.) I
often dream of my Louts Notes running on Linux and of using perl
instead of Lotus Script or the incredibly bizarre @Formula Language.
However I haven't done either of those things in an actual work
enviroment.
---I know about Notes on Linux and I don't like it so I was
wondering....
---Has/is anyone using perl on Lotus Notes (Domino) right now? Can it
even be done (w/o exporting everything .csv and shoving it back into
an .nsf)?
---I know how nicely perl works with MySQL/DBI and Notes is for all
intents and purposes a Databasing program, it seems likely. I know
the Web Server portion of Notes does support perl, but I was thinking
more along the lines Notes DBs and mucking with their contents.
---the grass is always greener....
"...mmmmm, pointy..."
lmoran@wtsg.com
Registered Linux user number 187055
------------------------------
Date: Thu, 26 Oct 2000 15:23:10 -0500
From: "D.W." <dpalmeNOSPAM@unitedtraffic.com>
Subject: Re: perl not resolving dns in a cgi script
Message-Id: <8ta46u$p9n$1@nntp9.atl.mindspring.net>
That's what we're using, the only problem is if the remote host is a
straight IP address its not getting it. The raw access log shows the
correct IP address.....which would tell me apache is working correctly.
Douglas
"Rafael Garcia-Suarez" <rgarciasuarez@free.fr> wrote in message
news:slrn8vfjoc.onb.rgarciasuarez@rafael.kazibao.net...
> D.W. wrote in comp.lang.perl.misc:
> >I have a section of code which used the system parameter to resolve an ip
> >address to a host name; but its not working. It returns a null or blank
> >field.
> >
> >This is running on an apache server, which has hostname lookups on.
>
> If you want the hostname of the client of your web server, then it is
> in the REMOTE_HOST environment variable.
>
> --
> # Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: Thu, 26 Oct 2000 15:24:28 -0500
From: "D.W." <dpalmeNOSPAM@unitedtraffic.com>
Subject: Re: perl not resolving dns in a cgi script
Message-Id: <8ta470$p9n$2@nntp9.atl.mindspring.net>
Peter,
My apology
my $hostname = $ENV{'REMOTE_HOST'};
If the REMOTE_HOST = an IP address and doesn't resolve to a dns name, its
not showing up....the variable is a null (blank field) however, in the raw
access log its showing the IP address.
Douglas
"Peter Sundstrom" <peter.sundstrom@eds.com> wrote in message
news:8t87ll$6jf$1@hermes.nz.eds.com...
>
> D.W. <dpalmeNOSPAM@unitedtraffic.com> wrote in message
> news:8t79o8$hv9$1@nntp9.atl.mindspring.net...
> > I have a section of code which used the system parameter to resolve an
ip
> > address to a host name; but its not working. It returns a null or blank
> > field.
> >
> > This is running on an apache server, which has hostname lookups on.
> >
> > Is there something else I should check or a module that needs to be
> > installed?
>
> It would *really* help if you showed what code you are using.
>
>
------------------------------
Date: Thu, 26 Oct 2000 15:25:55 -0500
From: "D.W." <dpalmeNOSPAM@unitedtraffic.com>
Subject: Re: perl not resolving dns in a cgi script
Message-Id: <8ta471$p9n$3@nntp9.atl.mindspring.net>
Jason,
Again my apologies:
my $hostname = $ENV{'REMOTE_HOST'};
if the REMOTE_HOST is a straight IP address the variable $hostname is blank,
a null value.....however the raw access log shows the IP address correctly.
Douglas
"jason" <elephant@squirrelgroup.com> wrote in message
news:MPG.1462442611f7a9d4989858@localhost...
> D.W. wrote ..
> >I have a section of code which used the system parameter to resolve an ip
> >address to a host name; but its not working. It returns a null or blank
> >field.
> >
> >This is running on an apache server, which has hostname lookups on.
> >
> >Is there something else I should check or a module that needs to be
> >installed?
>
> nope - the code you've shown is working perfectly
>
> --
> jason -- elephant@squirrelgroup.com --
------------------------------
Date: Thu, 26 Oct 2000 15:45:23 -0300
From: Gil Vautour <vautour@unb.ca>
Subject: Question about "use strict"
Message-Id: <39F87BC3.F846AFB5@unb.ca>
Hello,
I have a variable declared and assigned a value in the body of my
script. I also have 'use strict" turned on. In the same script I have
a subroutine that would just love to be able reference the variable, how
can I have the subroutine access the variable??
------------------------------
Date: Thu, 26 Oct 2000 20:18:46 +0200
From: Ulrich Ackermann <UlleAckermann@t-online.de>
Subject: Re: Question about "use strict"
Message-Id: <39F87586.C1C7A1BD@t-online.de>
Gil Vautour wrote:
>
> Hello,
>
> I have a variable declared and assigned a value in the body of my
> script. I also have 'use strict" turned on. In the same script I have
> a subroutine that would just love to be able reference the variable, how
> can I have the subroutine access the variable??
Hi Gil,
why don't you just pass the variable to the subroutine?
# Code from a Perl-Novice:
my $variable;
my $returnValue = subroutine($variable);
sub subroutine {
my ($copyOfVariable) = @_; # call by value
$_[0] = 1; # set $variable to 1 (call by
reference)
}
HTH, Ulrich
------------------------------
Date: Thu, 26 Oct 2000 15:46:51 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Question about "use strict"
Message-Id: <slrn8vh2hb.ge6.tadmc@magna.metronet.com>
On Thu, 26 Oct 2000 15:45:23 -0300, Gil Vautour <vautour@unb.ca> wrote:
>I have
>a subroutine that would just love to be able reference the variable, how
>can I have the subroutine access the variable??
Pass the variable as an argument to the subroutine.
perldoc perlsub
tells how to pass/access subroutine arguments.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 26 Oct 2000 21:07:00 GMT
From: cjw44@flatline.org.uk (Colin Watson)
Subject: Re: Question about "use strict"
Message-Id: <8ta6dk$4u8$1@riva.ucam.org>
Gil Vautour <vautour@unb.ca> wrote:
>I have a variable declared and assigned a value in the body of my
>script. I also have 'use strict" turned on. In the same script I have
>a subroutine that would just love to be able reference the variable, how
>can I have the subroutine access the variable??
If you don't want to pass the variable explicitly, then make sure you
declare the variable with my() before declaring the sub.
--
Colin Watson [cjw44@flatline.org.uk]
"However, most netters acknowledge the offline world's advantages,
despite the fact that it is slow, clunky, and hogs bandwidth."
- "Surfing on the Internet", J.C. Herz
------------------------------
Date: Thu, 26 Oct 2000 13:34:07 -0700
From: Chris Kantarjiev <cak@putzl.com>
Subject: Re: reading/writing binary data
Message-Id: <39F8953F.464BD754@putzl.com>
I'd be most interested in something like this - I'm trying to write a
simple perl client/test program for a TCP protocol that exchanges C
structures like this one:
struct tClientPacket //Data packet from client to svr
{
long ProductIndicator;
long ProtocolVer;
long UMID;
short int SessionKey;
short int PadVal1;
enumCmdId cmdID;
short int SequenceNo;
short int PadVal2;
long DataSize;
};
I haven't figured out a good way to deal with this in perl, but I'm
quite the newbie, too. The camel book would lead me to believe that I
should be able to do this with pack/unpack, or I should write a wrapper
for some C code that does the work ... somehow.
If your code will help me with this, I'd be most interested - and if
there are other ideas about how to do it, I'd love to hear them, too.
Thanks,
chris
------------------------------
Date: Thu, 26 Oct 2000 19:09:26 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: socket flushing problem
Message-Id: <x7vgufl8re.fsf@home.sysarch.com>
>>>>> "RBN" == Rod B Nussbaumer <bomr@lin01.triumf.ca> writes:
>> solution: use sysread and make the socket nonblocking (with fcntl). use
>> IO::Select to see if the socket has data to read. i bet your c code
>> uses read which does not look for a record terminator.
RBN> Your surmise is correct.
>> note: never mix <> and sysread on a given file handle unless you know
>> deep black magic.
RBN> Right. As I see it, I need to use strictly sysread & syswrite for
RBN> any non line-oriented socket IO. I will try that. Maybe that's
RBN> why my server doesn't see the $Struct packet immediately, too.
again, it seems to be your use of <> is causing either side to block
until it gets a line. non-line terminated structs will get written and
read but not returned to the reader until the next cycle which sends a
newline.
you can print non-line data as long as you flush the buffers by setting
autoflush or using POSIX::fflush. but you can't use <> on non-line data.
RBN> Thanks for your patient replies. Did I miss this info in a book,
RBN> man file, help document, FAQ or somewhere else, or is this the
RBN> only/best way to find out about this stuff.
perlipc has plenty on this. so does the perl cookbook. it is all there.
RBN> Oh, and if you don't mind my editorializing just a bit, I think
RBN> it kind of sucks when perl documentation explains things by
RBN> simply saying 'This is the very same as the related UNIX
RBN> mechanism', and leaving it at that. I'm not saying this is your
RBN> fault, Uri. Just that I find it irksome, and felt a need to
RBN> say where someone else can hear it.
well, would you have perl just copy all the underlying unix docs and
redistibute them? it is simpler and less error prone to refer to the
docs on your OS. especially since there can be flavored behavior that
perl could never document properly across all platforms. so if the perl
function is basically a wrapper to the c/unix function, it is better to
refer to the c/unix man page.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: 26 Oct 2000 22:32:08 +0200
From: mriedel@neuearbeit.de (Marko R. Riedel)
Subject: Re: Sorting is too slow for finding top N keys... - UPDATE: Clarification.
Message-Id: <lz7l6v5oon.fsf@linuxsexi.neuearbeit.de>
mriedel@neuearbeit.de (Marko R. Riedel) writes:
> mriedel@neuearbeit.de (Marko R. Riedel) writes:
>
> > Greetings.
> >
> > There was a thread in this group about a year and a half ago where the
> > use of sorting algorithms to extract order statistics was discussed. I
> > presented several implementations of the QuickSelect algorithm. I
> > didn't properly credit the people who taught me about this algorithm.
> >
> > I learned about the algorithm itself from the writings of Conrado
> > Martinez and Salvador Roura (UPC Barcelona), and had the privilege to
> > discuss algorithms and data structures with Philippe Flajolet (INRIA)
> > on several occasions, whose book "An introduction to the Analysis of
> > Algorithms" (with Robert Sedgewick) is also relevant to the subject.
> >
> > Regards,
> >
> > Marko R. Riedel
>
>
> Re. sorting. I forgot to mention the paper on sorting by Uri Guttman
> and Larry Rosler on www.perl.com.
>
> Marko
I can't seem to get it right. That should be 'award-winning paper'.
Marko
------------------------------
Date: Thu, 26 Oct 2000 12:36:37 -0700
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: Starting background process from Perl
Message-Id: <39F887C5.F5FBFE29@jpl.nasa.gov>
djoerg@my-deja.com wrote:
> I want to start a new process from a perl script, but the script always
> waits until the process is complete (the new process takes very long to
> complete and the webserver should get back a message from the script).
> Is there any way to launch the process so that perl doesn't wait for the
> child to complete?
'perldoc -f fork' and 'perldoc -f exec', or perlipc if you want to
communicate with your child.
Jon
--
Knowledge is that which remains when what is
learned is forgotten. - Mr. King
------------------------------
Date: 26 Oct 2000 15:17:44 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: String Comparison
Message-Id: <m3k8avwe53.fsf@dhcp11-177.support.tivoli.com>
Martin McWhorter <m_mcwhorter@prairiegroup.com> writes:
> Hello,
>
> I am having trouble with a simple string comparison. I have paisted my
> code and a sample logfile that is parsed to the bottom.
>
> In the second if operation it checks if the $to field of the logfile eq
> the $address. It clearly does, i dont understand why this isnt true?
$to has a newline on it. You need to chomp to fix it. That will fix
the problem, but here are some more comments.
> All Help Apretiated.
>
> Code:
>
> #!/usr/bin/perl
You really should use:
#!/usr/bin/perl -w
It's just a good idea.
In a similar vein, you should also use:
use strict;
which will require you to be more explicit with your variables, but if
done appropriately it can help to you produce much better code.
> # logthis.pl
>
> # Find number incomming and outgoing
>
>
>
> $address = "\<person\@domain.com\>";
With strict enabled, you will need a "my" here. Also, the angle
brackets to not need to be escaped. But since the "@" does, you might
as well use single quotes:
my $address = '<person@domain.com>';
Also going to need to declare $from_count and $to_count outside of the
loop:
my($from_count, $to_count);
> open (SMTP,
> '/home/samba/MERCURY/E$/Netscape/Server4/msg-mercury/log/smtp/smtp');
Always, always, always check the result of "open" (and include $! in
the error):
my $file = '/home/samba/MERCURY/E$/Netscape/Server4/msg-mercury/log/smtp/smtp';
open SMTP, $file or die "Could not open $file, $!";
>
> foreach (<SMTP>) {
You generally should use:
while (<SMTP>) {
instead of foreach to avoid reading the entire file at once. No point
in wasting memory unnecessarily.
This is also where you want to add "chomp":
chomp;
> if (/SMTP-Accept/) {
> ($date, $hour, $minute, $second, $notice, $module, $envelope,
> $id,
> $peer, $host, $from, $size, $num, $to) = split(/:/);
Will need a "my" there as well.
> if ($from eq $address) {
> print "$date:$hour:$minute:$second From $from To $to";
Since $to no longer has a newline at the end, you'll have to put it
back in this print statement:
print "$date:$hour:$minute:$second From $from To $to\n";
> $from_count++;
> }
>
>
> if ($to eq $address) {
> print "$date:$hour:$minute:$second From $from To $to";
Same as above.
> $to_count++;
>
> }
>
> }
>
> }
>
>
> print "\n\n\nUser: $address From: $from_count To: $to_count\n\n\n";
[Data omitted, though I during testing I did have to remove some extra
newlines that were presumably just a product of posting.]
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Thu, 26 Oct 2000 15:22:45 -0400
From: "Douglas C. Heaberlin" <dheaberl@us.ibm.com>
Subject: Tracking memory usage in Perl
Message-Id: <39F88485.1ECFF3EA@us.ibm.com>
I am a fairly new user of Perl with what seems like a fairly basic
question: how does one get information from Perl about its utilization
of dynamic memory? For example, I would like to be able at any point in
a script to determine 1) how much total dynamic memory is available to
my process, 2) how much of this memory Perl has already consumed (from
UNIX's point of view), and 3) how much of the memory allocated to Perl
is actually free (from Perl's point of view) as the result of internal
garbage collection. It would also be great to be able simply to
determine exactly how much memory is used by a specific data structure.
Are there ways to do any or all of these?
I am mid-way through the implementation of a moderately sized system,
and Perl so far has done everything I've asked and has continually blown
me away with its speed. Since I am aware of Perl's reputation for using
lots of memory, however, I have this nagging fear that some of the
features that work so wonderfully on my test cases will explode when
used with larger sets of data. At the very least I would like to
determine the limitations of my system in terms of input size; ideally
I would like to be able to compare the memory utilization of different
implementations so that I can choose one that represents an optimum mix
of performance and memory consumption. I have been unable to find any
reference to this subject in the FAQ, the Perl documentation, or any of
the books I have. Many thanks to anyone who can point me in the right
direction.
Doug Heaberlin
IBM Microelectronics
Essex Junction, Vermont
------------------------------
Date: Thu, 26 Oct 2000 18:42:01 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Use VS Require
Message-Id: <idugvs4lb7n92i1891qh8u429cpum6b57j@4ax.com>
Troy Rasiah wrote:
> can anyone tell me whats the advantages and disadvantages of using
>"Use" instead of "Require"
It's "use" and "require". Perl is case sensitive.
"use" works at compile time. There's no stopping it. Even if it's a
module you only need 10% of the time the script is run, it *will be
compiled*. require() works at the time you need it.
Also, functions declared in a use()d module are known at compile time.
Thus, you can drop parentheses for duntions if you like. You can't for
functions in a require()d file.
And finally, a difference which is what the ocs stress the most: use()
also calls an "import" sub from the module, if it's there. That way, it
can import its functions to your namespace, and you no longer have to
fully qualify the subs/variables that are imported. That won't ever work
with a require()d file. Sometimes, such a file declares its main
functions in the main:: namespace, but it's not ideal, and it won't do
you any good if you call the functions from a separate package. And, if
you require() the same file into two packages, only one will work as you
expect! The second time, the file will not even be loaded again.
That's the reason why the import() mechanism was invented.
--
Bart.
------------------------------
Date: Thu, 26 Oct 2000 19:17:46 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: What is the point of the new keyword 'our'?
Message-Id: <39f88359.3db$3dc@news.op.net>
In article <39f840ad@news.barak.net.il>,
Shimon Bollinger <bollinge@wholefamily.com> wrote:
>I couldn't find an answer in the Perl 5.6 FAQ.
It's to replace the old 'use vars' construction.
(See http://www.plover.com/~mjd/perl/FAQs/Namespaces.html)
The advantage over 'use vars' is that it has lexical scope, so you can
declare that you'll be using a certainl global variable, but only
inside of one block, and the global variable will still raise an error
if you use it accidentally somewhere else.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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.
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 4736
**************************************