[17295] in Perl-Users-Digest
Perl-Users Digest, Issue: 4717 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 25 00:05:36 2000
Date: Tue, 24 Oct 2000 21:05:11 -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: <972446711-v9-i4717@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 24 Oct 2000 Volume: 9 Number: 4717
Today's topics:
Re: Bi-directional pipes with NT <elephant@squirrelgroup.com>
CODE: variable replication in fork() eric@on-e.com
Re: Determining the length of a string <ruben@llinderman.dental.nyu.edu>
Re: Email.pm and file attachments <ruben@llinderman.dental.nyu.edu>
Re: File locking <mikecook@cigarpool.com>
Gnome example confusion <maraist@udel.edu>
grep with perl ! I am very new at this. msalerno@my-deja.com
Re: grep with perl ! I am very new at this. dragnovich@my-deja.com
Re: grep with perl ! I am very new at this. <quantum_mechanic@my-deja.com>
Help with ActiveState PerlSvc (WinNT) <harasty@my-deja.com>
Re: How do I do 'use $lib;' where $lib is a variable pa <jihad.battikha@sharewire.com>
Re: how do I run (Maggert)
How to pass a String to the STDIN of an other prg? dragnovich@my-deja.com
Re: How to pass a String to the STDIN of an other prg? <bwalton@rochester.rr.com>
Re: How to send via sendmail after a 1 hour delay? (Joe Smith)
Re: Length of a string stored in a scalar <uri@sysarch.com>
Re: Length of a string stored in a scalar (Gwyn Judd)
Re: local binmode? (Ilya Zakharevich)
loop through all symbol table entries <rfoskett@my-deja.com>
Re: loop through all symbol table entries <ianb@ot.com.au>
LWP???? gary.lefko@usafa.af.mil
Re: Make me a hot or not script (Gwyn Judd)
memory allocation and my (Brian)
Re: memory allocation and my <skuo@mtwhitney.nsc.com>
Re: Monitor TCP ports <elaine@chaos.wustl.edu>
Re: New to Perl, Need Help ! (Gwyn Judd)
Re: Object destructors not working properly? (Ilya Zakharevich)
Re: Object destructors not working properly? (Ilya Zakharevich)
Re: OT: Jihad definition <jeff@vpservices.com>
Re: OT: Jihad definition <jkline@one.net>
Re: OT: Jihad definition (Gwyn Judd)
Re: Paragraph slurping for reading records from config (Gwyn Judd)
Re: Paragraph slurping for reading records from config (Gwyn Judd)
Re: parentheses turns into a function mbil_99@my-deja.com
Re: parentheses turns into a function <elephant@squirrelgroup.com>
Re: parse url <elephant@squirrelgroup.com>
Re: Printing parameters <tzz@heechee.beld.net>
Re: use strict; with eval:: error messages to stderr <james@NOSPAM.demon.co.uk>
Re: use strict; with eval:: error messages to stderr <bbrown@addtoit.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 25 Oct 2000 15:02:20 +1000
From: jason <elephant@squirrelgroup.com>
Subject: Re: Bi-directional pipes with NT
Message-Id: <MPG.1461146413833af6989848@localhost>
macdo wrote ..
>In NT is it possible to impliment bi-directional communication via pipes
>between a parent and a child.
they work for me in 5.6.0 on NT4
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Wed, 25 Oct 2000 03:04:34 GMT
From: eric@on-e.com
Subject: CODE: variable replication in fork()
Message-Id: <65sJ5.17$XM5.664@typhoon.san.rr.com>
I've got some sample server code that grabs a large number of records out
of a Mysql database and then pre-forks a large number of servers. After
that, each server will query shared memory to get the next item in the list,
but all the servers are replicating the large data set and I'm running out
of memory. According to the documentation, the data set is not supposed to
be replicated but shared among all the processes. What am I doing wrong?
I tried to store the $sth handle in an IPC object and then undef $sth but that
didn't work. :-/
#!/usr/bin/perl -w
use strict;
use Mysql;
use POSIX;
use Symbol;
use IO::Socket;
use IPC::ShareLite;
$MAX_SERVERS = 64;
$server = IO::Socket::INET->new( Proto => 'tcp',
LocalPort => 9000,
Listen => 256, # SOMAXCONN
Type => SOCK_STREAM,
Reuse => 1);
die "can't setup server" unless $server;
$dbh = Mysql->connect("localhost", "Mysql_DB", "nobody", undef) || die $Mysql::db_errstr;
# Table 'MyTable' contains 3.1 million records
$SQL = "SELECT * FROM MyTable";
$sth = $dbh->query($SQL);
print "[Server $0 accepting clients]\n";
$Connects = new IPC::ShareLite( -key => 1971, -create => 'yes', -destroy => 'no' ) or die $!;
$Connects->store(0);
%children = ();
$children = 0;
for (1 .. $MAX_SERVERS) {
make_new_child();
}
$SIG{ CHLD } = \&REAPER;
$SIG{ INT } = \&HUNTSMAN;
while(1) {
sleep;
}
exit 0;
...
# REST OF PROGRAM DELETED
------------------------------
Date: Wed, 25 Oct 2000 03:17:16 GMT
From: <ruben@llinderman.dental.nyu.edu>
Subject: Re: Determining the length of a string
Message-Id: <0hsJ5.77$LO5.490@typhoon.nyu.edu>
David H. Adler <dha@panix.com> wrote:
Was strlen not available
;)
Ruben
> /(.)\z/s;
> $length = rindex($_, $1)+1;
> dha, who really hates this question... :-/
> --
> David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
> "Take myself, subtract films, and the remainder is zero"
> - Akira Kurosawa
------------------------------
Date: Wed, 25 Oct 2000 03:21:35 GMT
From: <ruben@llinderman.dental.nyu.edu>
Subject: Re: Email.pm and file attachments
Message-Id: <3lsJ5.78$LO5.490@typhoon.nyu.edu>
I've used Mimelite to solve this problem.
It's on CPAN
Ruben
------------------------------
Date: Tue, 24 Oct 2000 19:40:33 -0700
From: "Michael Cook" <mikecook@cigarpool.com>
Subject: Re: File locking
Message-Id: <0MrJ5.1382$PY3.272221@news.uswest.net>
Thanks Bart!
But my question is not *how* to flush per filehandle, but *should* I?
Michael
--
== CigarPool ==
http://www.cigarpool.com
"Bart Lateur" <bart.lateur@skynet.be> wrote in message
news:dgbavsgco7cli0b8chkeubd2q2lsfhrt2p@4ax.com...
> Michael Cook wrote:
>
> >I have read it most carefully - you have given *how* to flush. What if
you
> >are writing to more than 1 file with the same script? Should you flush
for
> >each? Or is 1 flush at the beginning of the script sufficient?
>
> Autoflush is per filehandle. Actually, even $| is only for the currently
> selected handle. If you'd want to autoflush them all, you'd have to
> select them all one by one, and set $| each time.
>
> my $stdout = select FH1;
> $| = 1;
> select FH2;
> $| = 1;
> select FH3;
> $| = 1;
> select $stdout;
>
> In such a case, several lines like
>
> $fh->autoflush;
>
> wouldn't look as silly.
>
> --
> Bart.
------------------------------
Date: Tue, 24 Oct 2000 22:52:40 -0400
From: "Michael Maraist" <maraist@udel.edu>
Subject: Gnome example confusion
Message-Id: <8t5i3s$fj1$1@news.udel.edu>
The following URL was really awsome for explaining Gnome + Perl
http://www.perl.com/pub/2000/10/gnome.html
I had recently already begun the lengthy process of learning Gnome (with a
definate perl bias). This page was really cool, but the examples don't seem
to work properly for me.
I've gotten most of the example elements to work, specfically the parts that
don't involve menubars / toolbars.
I'm using Gtk-Perl-0.7000; the only other one that seems likely is
Gtk-0.5120, which I assume is the older version of the first.
Neither seem to be able to handle many of the advanced functions in the
examples.
Has anyone had success?
-Michael
------------------------------
Date: Wed, 25 Oct 2000 01:44:08 GMT
From: msalerno@my-deja.com
Subject: grep with perl ! I am very new at this.
Message-Id: <8t5dt8$84c$1@nnrp1.deja.com>
I am writing a script and part of it required me to do a grep. I know
that there is a built in grep function but I don't know if I can use it
to grep files. I need to do the equivelent of a grep -ic to a file and
I would like to use a built in function if possible. Also I have
written a small script to do the grep calling the grep binary. It does
everything, but I need to take the value (a number) and use it within
the script, but I can't figure out how.
system "grep -ic 47 snmnefle.cfg"
Is there a way to do either ?
Please help
Thanks,
Matt
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 25 Oct 2000 02:04:31 GMT
From: dragnovich@my-deja.com
Subject: Re: grep with perl ! I am very new at this.
Message-Id: <8t5f3b$940$1@nnrp1.deja.com>
Whell you can use =~ for matching something in your perl program but
you really need to study =)
first get the file in an @array and the with a foreach, search it wiht
something like if($line =~ /$searh/i) { .... }
=)
In article <8t5dt8$84c$1@nnrp1.deja.com>,
msalerno@my-deja.com wrote:
> I am writing a script and part of it required me to do a grep. I know
> that there is a built in grep function but I don't know if I can use
it
> to grep files. I need to do the equivelent of a grep -ic to a file
and
> I would like to use a built in function if possible. Also I have
> written a small script to do the grep calling the grep binary. It
does
> everything, but I need to take the value (a number) and use it within
> the script, but I can't figure out how.
>
> system "grep -ic 47 snmnefle.cfg"
>
> Is there a way to do either ?
> Please help
>
> Thanks,
> Matt
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
--
------------------------
Juan Carlos Lopez
QDesigns President & CEO
http://www.qdesigns.com
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 25 Oct 2000 02:48:20 GMT
From: Quantum Mechanic <quantum_mechanic@my-deja.com>
Subject: Re: grep with perl ! I am very new at this.
Message-Id: <8t5hli$b55$1@nnrp1.deja.com>
In article <8t5dt8$84c$1@nnrp1.deja.com>,
msalerno@my-deja.com wrote:
<snip>
> system "grep -ic 47 snmnefle.cfg"
>
<snip>
$search = shift or die "No search string\n";
$count = 0;
while (<>)
{
if ( /$search/oi) # /o is for one time interpolation
{
$count++;
}
if ( eof( ARGV ) ) # check for eof on current file
{
if ( $count )
{
print "$ARGV: $count\n"; # $ARGV is current file name
$count = 0;
}
}
}
__END__
There are faster ways, but this is perhaps easier for newbies ;)
If you want to write a generalized grep like the unix variety, you
might check out pgrep on www.cpan.org.
-QM
--
Quantum Mechanics: The dreams stuff is made of.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 25 Oct 2000 03:48:43 GMT
From: Dan Harasty <harasty@my-deja.com>
Subject: Help with ActiveState PerlSvc (WinNT)
Message-Id: <8t5l6q$e1r$1@nnrp1.deja.com>
Hi --
I'm trying to get a simple "Perl Service" working using ActiveState's
"PerlSvc" control from the Perl Dev Kit, 2.0.
The example from the docs seems to "build" fine (actually running
PerlSvc) but after installing the service (with the NtResKit's "sc")
command, the service doesn't seem to start.
My only clue is a message in the EventLog:
The description for Event ID ( 0 ) in Source ( PerlMsg ) cannot be
found. The local computer may not have the necessary registry
information or message DLL files to display messages from a remote
computer. The following information is part of the event: testService
error: 1063, StartServiceCtrlDispatcher failed..
Any clues?
Also: the example from the docs is ambiguous on the use of
"ContinueRun". Is this a function or a scalar?
TIA - Dan Harasty
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 24 Oct 2000 21:07:46 -0400
From: Jihad Battikha <jihad.battikha@sharewire.com>
Subject: Re: How do I do 'use $lib;' where $lib is a variable package name read from a file?
Message-Id: <39F63262.51547B83@sharewire.com>
Ren Maddox wrote:
> You likely already know this, but I'll point out for Craig's
> benefit that this solution will not work for his problem as
> $bar would be imported too late (unless declared with
> "use vars qw($bar)" or the like, but that is probably not
> desirable).
Good point. Probably BEGIN { eval "use $lib" } would be better and
wouldn't need vars, assuming that $lib could be populated adequately up
front.
--
Jihad Battikha <jihad.battikha@sharewire.com>
Sharewire, Inc. --- http://www.sharewire.com/
- Free forms, programs, and content for web sites.
- No assembly required.
Disclaimer:
Before sending me commercial e-mail, the sender must first agree
to my LEGAL NOTICE located at: http://www.highsynth.com/sig.html
------------------------------
Date: Wed, 25 Oct 2000 02:04:20 GMT
From: mag@ionet.net (Maggert)
Subject: Re: how do I run
Message-Id: <39f63f54.230750742@news.ionet.net>
On Mon, 23 Oct 2000 16:06:18 -0400, tadmc@metronet.com (Tad McClellan)
wrote:
>On Mon, 23 Oct 2000 21:45:04 +0100, Cool <cool@pullen81.demon.co.uk> wrote:
>
>> Subject: Re: how do I run
>
>
>Put one foot in front of the other, similar to walking, only faster.
>
>
In no time you'll be doing 10K's and maybe even marathons. <G>
MP
------------------------------
Date: Wed, 25 Oct 2000 01:33:23 GMT
From: dragnovich@my-deja.com
Subject: How to pass a String to the STDIN of an other prg?
Message-Id: <8t5d93$7ks$1@nnrp1.deja.com>
Hello folks! I have this problem an don't know how to solve it =)
Ok I have two programs and i like run one program since my perl
program, and send some text to this program and wait for a responce and
asign this responce to a variable. The problem is that the called
program waits for the text writed from the STDIN and I dont know how to
send this text tru that... can you help me ??
Heres are two example programs:
# Program: mainprg.pl (this dont works but I maybe you can help)
$responce = system("called.pl","hi");
print "The program responds: $responce\n";
# Program: called.pl
print "Tell me something: ";
$say = <STDIN>;
print "\n";
if($a eq "") { print "You say nothing\n"; }
else { print "You say $say.\n"; }
but when I run the mainprg.pl I get this responce "The program
responds: 65280" and not "You say: hi." what is happening? =)
Regards! =)
------------------------
Juan Carlos Lopez
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 25 Oct 2000 03:43:46 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: How to pass a String to the STDIN of an other prg?
Message-Id: <39F656DE.25A7163B@rochester.rr.com>
dragnovich@my-deja.com wrote:
>
> Hello folks! I have this problem an don't know how to solve it =)
>
> Ok I have two programs and i like run one program since my perl
> program, and send some text to this program and wait for a responce and
> asign this responce to a variable. The problem is that the called
> program waits for the text writed from the STDIN and I dont know how to
> send this text tru that... can you help me ??
>
> Heres are two example programs:
>
> # Program: mainprg.pl (this dont works but I maybe you can help)
> $responce = system("called.pl","hi");
> print "The program responds: $responce\n";
>
> # Program: called.pl
> print "Tell me something: ";
> $say = <STDIN>;
> print "\n";
> if($a eq "") { print "You say nothing\n"; }
> else { print "You say $say.\n"; }
>
> but when I run the mainprg.pl I get this responce "The program
> responds: 65280" and not "You say: hi." what is happening? =)
>
> Regards! =)
> ------------------------
> Juan Carlos Lopez
...
You need to look up what the system function does:
perldoc -f system
There you will find that it does *not* return the standard output of the
called program, but rather its exit status. To get the standard output
of the called program, use the backtick quoting operator (also known as
qx//), as in:
$responce=`called.pl hi`;
for example. See:
perldoc perlop
Second, you will find that extra parameters supplied to system do not
appear on STDIN in the called program, but rather appear as command line
arguments. I am guessing that STDIN probably returns end-of-file right
off in this case.
--
Bob Walton
------------------------------
Date: 25 Oct 2000 02:07:58 GMT
From: inwap@best.com (Joe Smith)
Subject: Re: How to send via sendmail after a 1 hour delay?
Message-Id: <8t5f9u$eh2$1@nntp1.ba.best.com>
In article <T_IG5.781$gu5.275051@news.uswest.net>,
Jim Gaasedelen <jim@usjet.net> wrote:
>You probably need to use Cron.
No, 'cron' is for repeating jobs. Use 'at' to run once at a specific time.
>... but the script would need to be running all
>the time in a loop checking the time; Not too elegant.
That's why `echo date | at +1 hour` is more appropriate. See `man at`.
-Joe
--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.
------------------------------
Date: Wed, 25 Oct 2000 03:08:40 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Length of a string stored in a scalar
Message-Id: <x7u2a1mxc7.fsf@home.sysarch.com>
>>>>> "JO" == Jerome O'Neil <jerome@activeindexing.com> writes:
JO> Jeff H <jeffahill@_ANTISPAM_.lucent.com> elucidates:
>> This may seem like a stupid question, but how do I determine the
>> length of a string stored in a scalar? I've read the perldoc on
>> Perl data types, but it didn't seem to tell how to do this. It
>> would be incredibly handy information to have in some of my
>> applications.
JO> The 'length' function, oddly enough, might do what you want.
we have to make a page of self answering questions. this is happening
too often. larry did too good a job naming many of perl's functions.
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: Wed, 25 Oct 2000 03:27:26 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Length of a string stored in a scalar
Message-Id: <slrn8vckor.me9.tjla@thislove.dyndns.org>
I was shocked! How could Jeff H <jeffahill@_ANTISPAM_.lucent.com>
say such a terrible thing:
>This may seem like a stupid question, but how do I determine the length of a
>string stored in a scalar? I've read the perldoc on Perl data types, but it
>didn't seem to tell how to do this. It would be incredibly handy information to
>have in some of my applications.
Funnily enough this question gets asked a lot. The answer is 'length'.
my $length = length '12345';
print $length; # prints 5
>Also, does Perl store a scalar string as in other languages, such as a Sting in
>C++ or Java? Or does it have it's own internal representation? This is more
>for my own edification, and not necessarily important that it get answered.
Check the documentation:
perldoc perlguts
Look for 'PV' 's I think
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
A bit of talcum
Is always walcum
-- Ogden Nash
------------------------------
Date: 25 Oct 2000 02:23:59 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: local binmode?
Message-Id: <8t5g7v$9te$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was NOT sent to Martien Verbruggen
<mgjv@tradingpost.com.au>],
who wrote in article <slrn8vc24m.a0g.mgjv@verbruggen.comdyn.com.au>:
> > >Why the heck would you want to do something like that? Either a file is
> > >binary or it isn't. WHat's the point of switching half way through?
> >
> > For example Postscript files can contain both text parts and pure binary
> > parts.
Another example is mailbox files, which are line-oriented, may include
char counts in some fields. Are these charcounts before newline
translation or after it?
> But, as Craig Berry pointed out to me a little while ago in private
> correspondence, it is not formally correct to call binmode after any
> I/O is done on the filehandle. it may work for you, but it shouldn't.
And, as I said it many times already, this is a bug in Perl.
Programmer should be free to combine print, read, sysread, and
syswrite in an arbitrary order. Perl has enough information to
intertwine these calls by all the necessary seek()s (if needed).
And due to a possibility to call "foreign" methods, nobody but Perl
has enough info about what was the last operation done on the filehandle...
Ilya
------------------------------
Date: Wed, 25 Oct 2000 00:57:10 GMT
From: rog <rfoskett@my-deja.com>
Subject: loop through all symbol table entries
Message-Id: <8t5b53$5tf$1@nnrp1.deja.com>
Hi, does anyone know a simple way to somehow access the Symbol Table
and return a list of all the functions in a currently executing perl
script? (no I dont want to open the file and grep for 'sub' :-)
I've got Devel::Symdump to have alook at but was trying to find some
documentation on the details. The best I found so far was stuff about
accessing *known* symbol table entries in perlmod.
There has to be some way of looping around all the entries in main::
perhaps something like this will work:
foreach (keys %main::) {
print "key = '$_'\n";
}
Can anyone help?
thanks
rog
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 25 Oct 2000 11:42:47 +1100
From: Ian Boreham <ianb@ot.com.au>
Subject: Re: loop through all symbol table entries
Message-Id: <39F62C87.8BE2E583@ot.com.au>
rog wrote:
> There has to be some way of looping around all the entries in main::
> perhaps something like this will work:
> foreach (keys %main::) {
> print "key = '$_'\n";
> }
Did you even try it?
Ian
------------------------------
Date: Wed, 25 Oct 2000 03:42:26 GMT
From: gary.lefko@usafa.af.mil
Subject: LWP????
Message-Id: <8t5kr1$dmr$1@nnrp1.deja.com>
Is LWP a Perl Module, if so are their references for it (web or book)?
GAry
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 25 Oct 2000 03:30:01 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Make me a hot or not script
Message-Id: <slrn8vcktn.me9.tjla@thislove.dyndns.org>
I was shocked! How could Uri Guttman <uri@sysarch.com>
say such a terrible thing:
>>>>>> "MvD" == Matthijs van Duijvenbode <matthijs@vanduijvenbode.com> writes:
>
> MvD> I need to find a cgiprogrammer to do a proposal to build a script
> MvD> similar to that one can see at www.amihotornot.com. (Perl, UNIX)
> MvD> I´m looking for someone who can give me a fixed price.
>
>$50,000. take it or leave it.
Cheapskate. I would do it for $100000. Of course that's in New Zealand
dollars so it may be worth less over there.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
"Senate? We have woman senators?"
"I think it's great that we have more chicks in the senate."
"The Infinite Wisdom of Mr. Kevin Giffhorn"
------------------------------
Date: Wed, 25 Oct 2000 02:15:43 GMT
From: perl-news@axehind.com (Brian)
Subject: memory allocation and my
Message-Id: <39f63d49.353810504@news.ne.mediaone.net>
While looking at a co-workers perl script I noticed that he had
something like this
my @data;
while(<FILE>) {
if(/^foo/) {
@data = split(/:/);
&sub_func(\@data);
}
}
When I asked him why @data was "declared" outside the while loop or if
statement, he said that the memory would have to be re-allocated for
the array everytime there was a match if the array @data was declared
inside the loop. By "declaring" it outside the loop, memory doesnt
have to be allocated every match.
Is there any truth to this?
Brian Pontz
------------------------------
Date: Tue, 24 Oct 2000 20:57:46 -0700
From: Steven Kuo x7914 <skuo@mtwhitney.nsc.com>
To: Brian <perl-news@axehind.com>
Subject: Re: memory allocation and my
Message-Id: <Pine.GSO.4.21.0010242055150.21952-100000@mtwhitney.nsc.com>
On Wed, 25 Oct 2000, Brian wrote:
> While looking at a co-workers perl script I noticed that he had
> something like this
>
> my @data;
> while(<FILE>) {
> if(/^foo/) {
> @data = split(/:/);
> &sub_func(\@data);
> }
> }
>
> When I asked him why @data was "declared" outside the while loop or if
> statement, he said that the memory would have to be re-allocated for
> the array everytime there was a match if the array @data was declared
> inside the loop. By "declaring" it outside the loop, memory doesnt
> have to be allocated every match.
>
> Is there any truth to this?
>
> Brian Pontz
One can check with:
#! /usr/local/bin/perl -w
# foo
use strict;
my @data;
while (<DATA>)
{
if (/^foo/)
{
@data = split (/:/);
print \@data, "\n";
}
elsif (/^bar/)
{
my @data2 = split (/:/);
print \@data2, "\n";
}
}
__END__
foo: tofo : kungfoo: foo-fighters
bar: behind-bars: bar-brawl : no-holds-barred
foo: foo-man-chu : foo-lish : foobar
bar: bar-maid : bar-nacle : barn
===
The results are:
ARRAY(0xcaed4)
ARRAY(0xcaf58)
ARRAY(0xcaed4)
ARRAY(0xd42c0)
Notice how the reference for @data stays the same while that
for @data2 does not?
--
Steven Kuo
------------------------------
Date: Wed, 25 Oct 2000 01:48:36 GMT
From: Elaine Ashton <elaine@chaos.wustl.edu>
Subject: Re: Monitor TCP ports
Message-Id: <B61BB434.8328%elaine@chaos.wustl.edu>
in article 39F5E8F5.E881965B@iname.com, Kjetil Skotheim at
kjetilskotheim@iname.com quoth:
> This type of program is called a network sniffer. Lots of such
No, a sniffer is used to scan multi-protocol packets across a network
interface[s] and a program that monitors a port is a daemon.
Depending on the kind of passive port logging the original poster is
seeking, there are a few security software packages that include a random
stealth port daemon to log portscans and the like.
http://search.cpan.org/search?dist=Net-Daemon may also be of some use.
e.
------------------------------
Date: Wed, 25 Oct 2000 02:57:54 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: New to Perl, Need Help !
Message-Id: <slrn8vcj1g.me9.tjla@thislove.dyndns.org>
I was shocked! How could Larry Rosler <lr@hpl.hp.com>
say such a terrible thing:
>Are the strings '127.0.0.1' and '127.000.000.001' not equivalent
>representations for 'localhost', for example?
Heh. I'm always tripping myself up with stuff like that.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
To see you is to sympathize.
------------------------------
Date: 25 Oct 2000 02:26:18 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Object destructors not working properly?
Message-Id: <8t5gca$9vd$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Sverre Froyen
<sverre@viewmark.com>],
who wrote in article <39F5CBF8.F000326B@viewmark.com>:
> #!/usr/local/bin/perl
> use Director;
> $d = Director->new();
This is not scoped in any way. There is no way to define the order of
destruction of non-scoped variables.
Ilya
------------------------------
Date: 25 Oct 2000 02:28:22 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Object destructors not working properly?
Message-Id: <8t5gg6$a0r$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Michael Balenger
<MBalenger@worldnet.att.net>],
who wrote in article <bupJ5.5137$MR3.273766@bgtnsc04-news.ops.worldnet.att.net>:
> My better question became: Why are all my objects getting GC'd after exit?
>
> That had a better answer: Because the containing object was actually
> contained by another object. I had created a module level cache to
> speed up subsequent lookups. The cache was held in a file scoped
> hash. That hash referenced my containers.
Such caches should contain weak references.
Hope this helps,
Ilya
------------------------------
Date: Tue, 24 Oct 2000 18:09:09 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: OT: Jihad definition
Message-Id: <39F632B5.3A8D880D@vpservices.com>
Larry Rosler wrote:
>
> Enough already! There is plenty of animosity here relating to Perl,
> without dragging this stuff in here also.
Agreed. But it was not Joe, or Nate, or I that dragged it in. I have
stopped reading or responding to other bits of nonsense spewed by the
nameless one. But in the same way that some people feel it is necessary
to correct the bits of Perl misinformation promulgated by that one (a
task I am not up to), I feel that I can not allow racist garbage to
become part of the conversation we call clpm without comment. If it
becomes acceptable to allow such racism to be stated in this forum and
acceptable for such racism to be joke fodder here but not acceptable to
make a serious objection to its horrendousness, then I am out of here
for good.
Ok, so now I have objected, and now I will shut up about it.
P.S. $64,000 question: what is the next entry in alphabetical order
after "Godwin's Law" in the Jargon File? Fact really is stranger than
fiction.
--
Jeff
------------------------------
Date: Tue, 24 Oct 2000 22:47:06 -0400
From: Joe Kline <jkline@one.net>
Subject: Re: OT: Jihad definition
Message-Id: <39F649AA.6C692CFB@one.net>
Jeff Zucker wrote:
>
> P.S. $64,000 question: what is the next entry in alphabetical order
> after "Godwin's Law" in the Jargon File? Fact really is stranger than
> fiction.
That is so bizarre.
--
Joe Kline
It takes a lot of brains to enjoy satire, humor, and wit;
but none to be offended by them. ---The Midnight Skulker
------------------------------
Date: Wed, 25 Oct 2000 03:08:39 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: OT: Jihad definition
Message-Id: <slrn8vcjll.me9.tjla@thislove.dyndns.org>
I was shocked! How could Jeff Zucker <jeff@vpservices.com>
say such a terrible thing:
>P.S. $64,000 question: what is the next entry in alphabetical order
>after "Godwin's Law" in the Jargon File? Fact really is stranger than
>fiction.
Too weird :)
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
I'd rather push my Harley than ride a rice burner.
------------------------------
Date: Wed, 25 Oct 2000 02:45:00 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Paragraph slurping for reading records from config files
Message-Id: <slrn8vci9a.me9.tjla@thislove.dyndns.org>
I was shocked! How could xerxes_2k@my-deja.com <xerxes_2k@my-deja.com>
say such a terrible thing:
>as opposed to you. u seem to like going round and beeting newbies into
>the ground, trying to put them off from even learning perl.
>you are more content on ripping peoples code apart rather than, giving
>them any help.
Learn to take a bit of constructive criticism. And don't post code that
doesn't work unless your question is "Why does this code not work?"
>sure i am only a begginer, im sure my code nor anyone elses is as good
>as yours. but hey you were in the same position as all the begginers out
>once.
I freely admit that many people here write code that is better than
mine. I restrict helping people to areas I am confident in and I test
code that I post before I do so. I suggest you do the same. It's obvious
from the posts you've made that you don't have sufficient experience to
help others so all you are doing is adding to the confusion level.
>You obviously are on some kind of power trip. Beating down everyone in
>your path.
Whatever.
>Your problem is you take perl, and the use of it far too seriously.
So I have high standards and you have low ones.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
A critic is a bundle of biases held loosely together by a sense of taste.
-Whitney Balliett
------------------------------
Date: Wed, 25 Oct 2000 02:56:24 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Paragraph slurping for reading records from config files
Message-Id: <slrn8vcium.me9.tjla@thislove.dyndns.org>
I was shocked! How could Bruce Phipps <bruce_phipps@my-deja.com>
say such a terrible thing:
>>And the fact that you forgot to remove the
>> leading null field. <
>
>Where does the null field come from when you "slurp" in each record
>(paragraph) ?
It comes from before the first field. Because the pattern /^([^:]+):\s*/
matches right from the start, Perl inserts a null field before that in
the return from the split.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Fortune's real live weird band names #193:
Dog Shit Rangers
------------------------------
Date: Wed, 25 Oct 2000 01:11:29 GMT
From: mbil_99@my-deja.com
Subject: Re: parentheses turns into a function
Message-Id: <8t5bvt$6mq$1@nnrp1.deja.com>
In article <MPG.145fa62a4e22698a989841@localhost>,
jason <elephant@squirrelgroup.com> wrote:
> which perl are you using ? .. 5.6.0 doesn't treat either any
differently
actually perl5.6.0 treats them differently too.
Jeff Pinyan's post clearified it for me as to what was going on
perl doesn't want you to screw up.
perl5.6.0 -w -e 'print ("foo")' # this will complain
perl5.6.0 -w -e 'print("foo")' # this wont
-mbil
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 25 Oct 2000 13:10:48 +1000
From: jason <elephant@squirrelgroup.com>
Subject: Re: parentheses turns into a function
Message-Id: <MPG.1460fa486dde02bf989846@localhost>
mbil_99@my-deja.com wrote ..
>In article <MPG.145fa62a4e22698a989841@localhost>,
> jason <elephant@squirrelgroup.com> wrote:
>> which perl are you using ? .. 5.6.0 doesn't treat either any
>differently
>
>actually perl5.6.0 treats them differently too.
>Jeff Pinyan's post clearified it for me as to what was going on
>perl doesn't want you to screw up.
>
>perl5.6.0 -w -e 'print ("foo")' # this will complain
>perl5.6.0 -w -e 'print("foo")' # this wont
very interesting .. I missed something all along .. the lack of a
trailing semi-colon .. here I am trying this
perl -w -e"print ('foo');"
and it still wasn't giving me any error .. only when the semi-colon is
dropped does the error pop up
some investigations in perldiag led me to the rather informative "Terms
and List Operators (Leftward)" section of the perlop manual
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Wed, 25 Oct 2000 13:14:08 +1000
From: jason <elephant@squirrelgroup.com>
Subject: Re: parse url
Message-Id: <MPG.1460fb0b1aab0f2c989847@localhost>
Jim Mauldin wrote ..
>jason wrote:
>>
>> Peter Clarke wrote ..
>> >Is there a more efficient way of doing this? I wont to separate the host,
>> >path and query from a given url. It works but seems long winded.
>>
>> 'working' is such a relative term .. your code demonstrates that you do
>> not know how URLs are correctly formed .. 'http://www.foo.com/' is a
>> correctly formed URL .. whereas 'www.foo.com/index.html' is not
>
>IETF RFC 1738
>
>A URL has the following form:
>
><scheme>:<scheme-specific-part>
Jim .. you've lost me .. were you responding to what I said ? .. or were
you adding to what I said and responding to the originator ?
I'm just at a loss to find anything incorrect about what I said - or
contrary to the RFC
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: 24 Oct 2000 22:48:49 -0400
From: Ted Zlatanov <tzz@heechee.beld.net>
Subject: Re: Printing parameters
Message-Id: <m3y9zdeium.fsf@heechee.beld.net>
Gil Vautour <vautour@unb.ca> writes:
> "John J. Trammell" wrote:
> > printf "This is my form value: '%s'", $query->param("foo");
> So this can only be done with printf, no such equivalent for a "here
> doc"?
my $foo = <<EOP;
This is one line with data [%s]
This is another line with data [%s]
EOP
printf $foo, $query->param('1'), $query->param(2);
Obviously not exactly what you want, but close.
--
Teodor Zlatanov <tzz@iglou.com>
"Brevis oratio penetrat colos, longa potatio evacuat ciphos." -Rabelais
------------------------------
Date: Wed, 25 Oct 2000 02:06:49 +0100
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: use strict; with eval:: error messages to stderr
Message-Id: <ant250149bc8fNdQ@oakseed.demon.co.uk>
In article <39F623F2.2A9486A3@addtoit.com>, William Lewis Brown
<URL:mailto:bbrown@addtoit.com> wrote:
> Unfortunately, it seems as if any errors associated with "use strict" are spit
> out on stderr and do not appear as part of $@.
> What is the best way for me to work around this problem?
Can't you just error trap the eval compilation stage by wrapping the
eval inside another eval block?
--
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02
------------------------------
Date: Wed, 25 Oct 2000 00:04:46 -0400
From: William Lewis Brown <bbrown@addtoit.com>
Subject: Re: use strict; with eval:: error messages to stderr
Message-Id: <39F65BDE.3492AC15@addtoit.com>
Hi,
Thanks for the response, but I don't understand how a nested eval will help.
How will it change the fact that "use strict;" is writing to stderr? Once the
error message is sent to stderr, its gone and I can't report it back to the
user.
I was hoping to find either a way to get "use strict;" to place its errors in a
variable, this would be very nice, or a nice perl way to redirect writes to
stderr to a buffer during the duration of the eval.
Did I completely miss the point of your suggestion? Thanks again.
Bill
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
James Taylor wrote:
>
> In article <39F623F2.2A9486A3@addtoit.com>, William Lewis Brown
> <URL:mailto:bbrown@addtoit.com> wrote:
> > Unfortunately, it seems as if any errors associated with "use strict" are spit
> > out on stderr and do not appear as part of $@.
> > What is the best way for me to work around this problem?
>
> Can't you just error trap the eval compilation stage by wrapping the
> eval inside another eval block?
>
> --
> James Taylor <james (at) oakseed demon co uk>
> PGP key available ID: 3FBE1BF9
> Fingerprint: F19D803624ED6FE8 370045159F66FD02
--
William L. Brown
Work: 603-465-2114
Fax: 603-465-2114
Cell: 617-803-9156
Email: bbrown@addtoit.com
Home: 603-465-2948
------------------------------
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 4717
**************************************