[19930] in Perl-Users-Digest
Perl-Users Digest, Issue: 2125 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 13 18:06:40 2001
Date: Tue, 13 Nov 2001 15:05:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1005692713-v10-i2125@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 13 Nov 2001 Volume: 10 Number: 2125
Today's topics:
CGI links with a single argument <me@anywhere.com>
Re: CGI links with a single argument <tsee@gmx.net>
code phrases (Houda Araj)
Re: code phrases <holland@origo.ifa.au.dk>
DDE poke error <pj.smit01@quicknet.nl>
detecting OLE failure in perl? <alan_spamoff@deterministicnetworks.com>
ebcdic (was Re: Unencoding) <uri@stemsystems.com>
end-of-file (Newbie)
Re: end-of-file <dperham@dperham.eng.tvol.net>
how do I use gzip <dcsnospam@ntlworld.com>
Re: how do I use gzip <nobody@nowhere.com>
Re: how do I use gzip <holland@origo.ifa.au.dk>
Re: how do I use gzip <tsee@gmx.net>
Re: how do I use gzip <dcsnospam@ntlworld.com>
Re: how do I use gzip <dcsnospam@ntlworld.com>
Re: how do I use gzip <dcsnospam@ntlworld.com>
Re: how do I use gzip <djberge@qwest.com>
Re: how do I use gzip <mgjv@tradingpost.com.au>
Re: How to use Shift and GetOpts (BUCK NAKED1)
Re: IO::Socket write fail <uri@stemsystems.com>
LISA 2001 Early Registration Fee Extended! <mktgadm@usenix.org>
Memory mgt and GC in perl 5.005_3 <temp133@hotmail.com>
Re: Need help with strange performance problem processi <tsee@gmx.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 13 Nov 2001 14:29:31 -0600
From: "Steven" <me@anywhere.com>
Subject: CGI links with a single argument
Message-Id: <20011113.142929.601385644.17659@anywhere.com>
I was wondering if there is a way to use a link with a single argument like
<a href="http://www.anywhere.com/cgi-bin/some.cgi?argument">xxx</a>
without using CGI.pm.
I have got this working got this working using CGI.pm using ('keywords') but
I can't find a good way to build tables dynamically with CGI.pm, which is
what I need to do with my script. The single argument would point to a file,
my script would open that file and build a table out of what it data it
finds there.
Any help appreciated,
Steve.
------------------------------
Date: Tue, 13 Nov 2001 22:00:14 +0100
From: "Steffen Müller" <tsee@gmx.net>
Subject: Re: CGI links with a single argument
Message-Id: <9ss1km$c70$00$1@news.t-online.com>
"Steven" <me@anywhere.com> schrieb im Newsbeitrag
news:20011113.142929.601385644.17659@anywhere.com...
| I was wondering if there is a way to use a link with a single argument
like
I was wondering if there was a more appropriate newsgroup?
comp.infosystems.www.authoring.cgi ?
Anyway:
| <a href="http://www.anywhere.com/cgi-bin/some.cgi?argument">xxx</a>
|
| without using CGI.pm.
|
| I have got this working got this working using CGI.pm using ('keywords')
but
| I can't find a good way to build tables dynamically with CGI.pm, which is
| what I need to do with my script. The single argument would point to a
file,
| my script would open that file and build a table out of what it data it
| finds there.
Why not pass ?file=[file name] instead of just ?[file name] and access it
using CGI's param?
You get the file name from param('file') if you use the above method. Just
note that anybody could send you any file name this way.
You can prevent this by comparing the passed file name to a hash of allowed
file names:
my %allowed_files = (
input.txt => undef,
jokes.dat => undef,
...
);
Now, only open the file if
exists( $allowed_files{$passed_file_name} )
is true.
I could tell you how to directly access the get params, but that'll be an
insecure way and ask for problems, so I'll pass. I hope you don't mind. Read
CGI.pm.
Steffen
--
$_=q;0cb212c210b0bb010c0113bb0c410c0b516c0bb3d212c2b0b0b016b6cb2b2c21010c0
b41110b3bba0e0c0d2c4b2b6bc013d2c0d0b01012b0b0;;s/\n//g;s/(\d)/$1<2?$1:'0'x
$1/ge;s/([a-f])/'1'x(ord($1)-97)/ge;print"\n";$o=$_;push@o,substr($o,$_*8,
8)for(0..24);for(@o){print"\0"x(26-$i).chr(oct('0b'.($_)))."\n";$i++}#st_m
------------------------------
Date: 13 Nov 2001 14:26:30 -0800
From: Houda.Araj@cogmedia.com (Houda Araj)
Subject: code phrases
Message-Id: <21916d9f.0111131426.5224b71@posting.google.com>
Hello,
I have a list of phrases in a file (phrase.txt). Is it possible to
write a perl script that takes this list (phrases.txt) and highlight
every words or phrases it finds in a text called (source.txt)?
Thanks
------------------------------
Date: 13 Nov 2001 23:48:01 +0100
From: Steve Holland <holland@origo.ifa.au.dk>
Subject: Re: code phrases
Message-Id: <w47wv0u8ezi.fsf@origo.ifa.au.dk>
Houda.Araj@cogmedia.com (Houda Araj) writes:
> I have a list of phrases in a file (phrase.txt). Is it possible to
> write a perl script that takes this list (phrases.txt) and highlight
> every words or phrases it finds in a text called (source.txt)?
What do you mean by highlight? Here's a quick-and-dirty perl
script that finds and marks each occurrence of a line in phrases.txt.
Each phrase is replaced by {phrase}.
#!/usr/local/bin/perl -Tw
use strict;
my $phrase_file = "phrases.txt";
my $source_file = "source.txt";
my @phrases;
my @source;
open(PHRASES,$phrase_file) || die "unable to open $phrase_file for reading, $!\n";
while( <PHRASES> ) {
chomp;
push(@phrases,$_);
}
close(PHRASES) || print "unable to close $phrase_file\n";
open(SOURCE,$source_file) || die "unable to open $source_file for reading, $!\n";
while( my $s = <SOURCE> ) {
for (@phrases) {
$s =~ s/$_/{$_}/ig;
}
push(@source,$s);
}
close(SOURCE) || print "unable to close $source_file\n";
print "@source";
=====================================================================
To find out who and where I am look at:
http://www.nd.edu/~sholland/index.html
Spammers: Please send spam to: abuse@aol.com and abuse@yahoo.com
=====================================================================
------------------------------
Date: Tue, 13 Nov 2001 22:17:08 -0800
From: "pipeloi" <pj.smit01@quicknet.nl>
Subject: DDE poke error
Message-Id: <r%fI7.319776$Jy2.19775343@news.quicknet.nl>
I'm trying to write some data to an application containing a dde server by
using the dde client, but can't get of a poke error. The request will work
but writing back...
Any help appreciated, the lines I use are:
use Win32::DDE::Client;
$Client = new Win32::DDE::Client ('GOLDMINE','DATA'); die "Unable to
initiate conversation" if $Client->Error;
#defined ($contact1_company = $Client->Request ('Contact1->company')) ||
die "DDE request failed";
defined ($contact1_accountno = $Client->Request ('Contact1->accountno')) ||
die "DDE request failed";
print "$contact1_accountno\n";
$Client->Poke('InsHistory', "$contact1_accountno", "A", "reference") || die
"DDE poke failed";
#$Client->Poke ('ITEM2', 'VALUE2') ||die "DDE poke failed";
$Client->Disconnect;
AFter running I get the DDE poke failed eror message
------------------------------
Date: Tue, 13 Nov 2001 13:00:01 -0800
From: "Alan" <alan_spamoff@deterministicnetworks.com>
Subject: detecting OLE failure in perl?
Message-Id: <3bf189bd$0$79559$8eec23a@newsreader.tycho.net>
I'm having trouble detecting OLE success/failure status, and any clues would
be much appreciated. It's working in VB but I really don't want to go that
way.
working VB:
database.Export "File", szDbPath, "adsfile.idt" : CheckError
failing perl:
$database->Export("File", $CurrentDirectory, "adsfile.idt") ||
die "Export failed $!";
-- the perl always takes the "die" path even when the export has succeeded
(which I know because the exported file is correct)
I've seen reference to, but can't find, a beginners perl newsgroup so please
direct me there if appropriate.
Many thanks for any help
Alan
(remove "_spamoff" for correct email address)
The full (short) program, with interleaved vb:
use Win32::OLE;
$MSIFile = "test.msi";
Win32::OLE::CreateObject("Scripting.FileSystemObject", $fso) ||
die "CreateObject fso: $!";
$CurrentDirectory = $fso->GetAbsolutePathName(".");
$fso = undef;
$OurInputFile = $CurrentDirectory . "\\" . $MSIFile;
# Connect to Windows installer object
#vb On Error Resume Next
#vb Dim installer : Set installer = Nothing
#vb Set installer = Wscript.CreateObject("WindowsInstaller.Installer") :
CheckError
$Installer = undef;
Win32::OLE::CreateObject("WindowsInstaller.Installer", $Installer) ||
die "CreateObject installer: $!";
#' Open the database
#vb Dim database : Set database = installer.OpenDatabase(databasePath, 1) :
CheckError
$database = undef;
$database = $Installer->OpenDatabase($OurInputFile, 1) ||
die "OpenDatabase $OurInputFile : $!";
print "OLE connection opened to Windows Installer\n";
#vb database.Export "File", szDbPath, "adsfile.idt" : CheckError
$database->Export("File", $CurrentDirectory, "adsfile.idt") ||
die "Export failed $!";
print "exported\n";
#vb Set installer = Nothing
$installer = undef;
------------------------------
Date: Tue, 13 Nov 2001 22:32:36 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: ebcdic (was Re: Unencoding)
Message-Id: <x7ofm6i9lz.fsf_-_@home.sysarch.com>
>>>>> "MV" == Martien Verbruggen <mgjv@tradingpost.com.au> writes:
MV> To come back to the topic: Is there anyone with an EBCDIC machine
MV> reading this that could test that code either to confirm my suspicion
MV> that it won't work, or to prove perl more portanle than that (doubt
MV> it). If it doesn't work, I might try to work up a patch for Lincoln
MV> Stein, since he uses this stuff in CGI.pm as well.
i changed the subject to reflect the topic.
there are definitely ebcdic boxes running web servers out there but i
bet they have to do all their http/url work in ascii as that is what
url's and http headers are defined to have. also on all of those boxes
(i think you mentioned the actual subsystems) they have ascii systems
you can run. IIRC a recent big ibm 390 ran something like 17,000 linux
sessions. :) so anyone running web stuff on an ebcdic box would know
what to do or run it under an ascii subsystem. also i believe that 5.6
is totally flummoxed under ebcdic. so how perl itself handles an ascii
url under ebcdic may be a moot point.
then again, i could be totally wrong. my ebcdic days (thankfully) ended
decades ago.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 13 Nov 2001 13:13:21 -0800
From: youradmirer@onebox.com (Newbie)
Subject: end-of-file
Message-Id: <582bc82b.0111131313.7c37a300@posting.google.com>
Hi,
I'm using Open3 to communicate with another process that I have little
control over (example included). The problem is that the other process
waits for an EOF in the input stream from Open3 in order to proceed.
How can I write an EOF to this input stream? Thanks.
local (*SIN, *SOUT);
my $pid = undef;
my $EOF = ???; # what is heximal/decimal value for EOF on Digital
Unix/Linux?
# I couldn't find it anywhere on the net after hours
of
# searching.
eval {$pid = open3(\*SIN, \*SOUT, \*SOUT, @cmdline)};
print STDERR if $@ =~ /^open3/;
# give the other process some input that needs to be
# terminated by an EOF. How?
print SIN @input;
# print SIN $EOF;
while (<SOUT>) {
# do stuff
.....
}
waitpid($pid, 0);
------------------------------
Date: 13 Nov 2001 17:00:08 -0500
From: Doug Perham <dperham@dperham.eng.tvol.net>
Subject: Re: end-of-file
Message-Id: <818zdaz5zr.fsf@wgate.com>
youradmirer@onebox.com (Newbie) writes:
> Hi,
>
> I'm using Open3 to communicate with another process that I have little
> control over (example included). The problem is that the other process
> waits for an EOF in the input stream from Open3 in order to proceed.
> How can I write an EOF to this input stream? Thanks.
by closing the file handle.
>
> local (*SIN, *SOUT);
> my $pid = undef;
> my $EOF = ???; # what is heximal/decimal value for EOF on Digital
> Unix/Linux?
> # I couldn't find it anywhere on the net after hours
> of
> # searching.
> eval {$pid = open3(\*SIN, \*SOUT, \*SOUT, @cmdline)};
> print STDERR if $@ =~ /^open3/;
>
> # give the other process some input that needs to be
> # terminated by an EOF. How?
> print SIN @input;
>
close(SIN);
> # print SIN $EOF;
>
> while (<SOUT>) {
> # do stuff
> .....
> }
>
> waitpid($pid, 0);
--
Doug Perham o{..}o
dperham@wgate.com moo! (oo)___
WorldGate Communications, Inc. (______)\
/ \ / \
------------------------------
Date: Tue, 13 Nov 2001 19:57:34 -0000
From: "Terry" <dcsnospam@ntlworld.com>
Subject: how do I use gzip
Message-Id: <TTeI7.20912$MN4.2255004@news11-gui.server.ntli.net>
I need to compress a large file on my hosts server and gzip is available.
How do I call\use gzip from within a .pl script
Please be gentle :)
Thanks
Terry
--
remove nospam to reply
------------------------------
Date: Wed, 14 Nov 2001 06:09:23 +1000
From: "Gregory Toomey" <nobody@nowhere.com>
Subject: Re: how do I use gzip
Message-Id: <63fI7.239102$8x1.41452@newsfeeds.bigpond.com>
"Terry" <dcsnospam@ntlworld.com> wrote in message
news:TTeI7.20912$MN4.2255004@news11-gui.server.ntli.net...
> I need to compress a large file on my hosts server and gzip is available.
> How do I call\use gzip from within a .pl script
> Please be gentle :)
>
> Thanks
>
> Terry
Use the 'system' command. e.g. system("gzip ...")
gtoomey
------------------------------
Date: 13 Nov 2001 21:11:08 +0100
From: Steve Holland <holland@origo.ifa.au.dk>
Subject: Re: how do I use gzip
Message-Id: <w47g07ia0tf.fsf@origo.ifa.au.dk>
"Terry" <dcsnospam@ntlworld.com> writes:
> I need to compress a large file on my hosts server and gzip is available.
> How do I call\use gzip from within a .pl script
> Please be gentle :)
#! /usr/local/bin/perl -w
use strict;
my $file = "ttt";
system("gzip -v $file") && die "unable to gzip $file";
Note that you need to use && die instead of || die if you are using a
unix system because unix systems return non-zero values to indicate
fail while perl uses non-zero values to indicate true. Check what
your system does and use && or || as appropriate.
=====================================================================
To find out who and where I am look at:
http://www.nd.edu/~sholland/index.html
Spammers: Please send spam to: abuse@aol.com and abuse@yahoo.com
=====================================================================
------------------------------
Date: Tue, 13 Nov 2001 21:12:33 +0100
From: "Steffen Müller" <tsee@gmx.net>
Subject: Re: how do I use gzip
Message-Id: <9sruqf$8ud$03$1@news.t-online.com>
"Terry" <dcsnospam@ntlworld.com> schrieb im Newsbeitrag
news:TTeI7.20912$MN4.2255004@news11-gui.server.ntli.net...
| I need to compress a large file on my hosts server and gzip is available.
| How do I call\use gzip from within a .pl script
| Please be gentle :)
I'll try.
You can always use system() or backticks to execute arbitrary shell
commands.
Or you can go to search.cpan.org and search for modules that help you:
6 modules found in 6 distributions matching 'gzip'
[snip]
PerlIO-gzip-0.11 by Nicholas Clark Released
29th October 2001
PerlIO::gzip Perl extension to provide a PerlIO layer to gzip/gunzip
Seems the most appropriate.
Read the docs that come with that module, it's not hard to use.
HTH,
Steffen
--
$_=q;0cb212c210b0bb010c0113bb0c410c0b516c0bb3d212c2b0b0b016b6cb2b2c21010c0
b41110b3bba0e0c0d2c4b2b6bc013d2c0d0b01012b0b0;;s/\n//g;s/(\d)/$1<2?$1:'0'x
$1/ge;s/([a-f])/'1'x(ord($1)-97)/ge;print"\n";$o=$_;push@o,substr($o,$_*8,
8)for(0..24);for(@o){print"\0"x(26-$i).chr(oct('0b'.($_)))."\n";$i++}#st_m
------------------------------
Date: Tue, 13 Nov 2001 20:15:26 -0000
From: "Terry" <dcsnospam@ntlworld.com>
Subject: Re: how do I use gzip
Message-Id: <D8fI7.20938$MN4.2261702@news11-gui.server.ntli.net>
Great stuff :)
Thanks
--
remove nospam to reply
"Gregory Toomey" <nobody@nowhere.com> wrote in message
news:63fI7.239102$8x1.41452@newsfeeds.bigpond.com...
> "Terry" <dcsnospam@ntlworld.com> wrote in message
> news:TTeI7.20912$MN4.2255004@news11-gui.server.ntli.net...
> > I need to compress a large file on my hosts server and gzip is
available.
> > How do I call\use gzip from within a .pl script
> > Please be gentle :)
> >
> > Thanks
> >
> > Terry
>
> Use the 'system' command. e.g. system("gzip ...")
>
> gtoomey
>
>
------------------------------
Date: Tue, 13 Nov 2001 20:15:34 -0000
From: "Terry" <dcsnospam@ntlworld.com>
Subject: Re: how do I use gzip
Message-Id: <K8fI7.20939$MN4.2261554@news11-gui.server.ntli.net>
Great stuff :)
Thanks
--
remove nospam to reply
"Steve Holland" <holland@origo.ifa.au.dk> wrote in message
news:w47g07ia0tf.fsf@origo.ifa.au.dk...
> "Terry" <dcsnospam@ntlworld.com> writes:
>
> > I need to compress a large file on my hosts server and gzip is
available.
> > How do I call\use gzip from within a .pl script
> > Please be gentle :)
>
> #! /usr/local/bin/perl -w
> use strict;
> my $file = "ttt";
> system("gzip -v $file") && die "unable to gzip $file";
>
> Note that you need to use && die instead of || die if you are using a
> unix system because unix systems return non-zero values to indicate
> fail while perl uses non-zero values to indicate true. Check what
> your system does and use && or || as appropriate.
>
>
>
> =====================================================================
> To find out who and where I am look at:
> http://www.nd.edu/~sholland/index.html
> Spammers: Please send spam to: abuse@aol.com and abuse@yahoo.com
> =====================================================================
------------------------------
Date: Tue, 13 Nov 2001 20:21:15 -0000
From: "Terry" <dcsnospam@ntlworld.com>
Subject: Re: how do I use gzip
Message-Id: <6efI7.20951$MN4.2263361@news11-gui.server.ntli.net>
Thanks Steffen :)
--
remove nospam to reply
"Steffen Müller" <tsee@gmx.net> wrote in message
news:9sruqf$8ud$03$1@news.t-online.com...
> "Terry" <dcsnospam@ntlworld.com> schrieb im Newsbeitrag
> news:TTeI7.20912$MN4.2255004@news11-gui.server.ntli.net...
> | I need to compress a large file on my hosts server and gzip is
available.
> | How do I call\use gzip from within a .pl script
> | Please be gentle :)
>
> I'll try.
>
> You can always use system() or backticks to execute arbitrary shell
> commands.
> Or you can go to search.cpan.org and search for modules that help you:
>
> 6 modules found in 6 distributions matching 'gzip'
>
> [snip]
>
> PerlIO-gzip-0.11 by Nicholas Clark Released
> 29th October 2001
> PerlIO::gzip Perl extension to provide a PerlIO layer to gzip/gunzip
>
> Seems the most appropriate.
> Read the docs that come with that module, it's not hard to use.
>
> HTH,
> Steffen
> --
> $_=q;0cb212c210b0bb010c0113bb0c410c0b516c0bb3d212c2b0b0b016b6cb2b2c21010c0
> b41110b3bba0e0c0d2c4b2b6bc013d2c0d0b01012b0b0;;s/\n//g;s/(\d)/$1<2?$1:'0'x
> $1/ge;s/([a-f])/'1'x(ord($1)-97)/ge;print"\n";$o=$_;push@o,substr($o,$_*8,
> 8)for(0..24);for(@o){print"\0"x(26-$i).chr(oct('0b'.($_)))."\n";$i++}#st_m
>
>
------------------------------
Date: Tue, 13 Nov 2001 15:22:38 -0600
From: "Mr. Sunblade" <djberge@qwest.com>
Subject: Re: how do I use gzip
Message-Id: <E6gI7.436$6G5.150596@news.uswest.net>
"Terry" <dcsnospam@ntlworld.com> wrote in message
news:6efI7.20951$MN4.2263361@news11-gui.server.ntli.net...
> Thanks Steffen :)
>
> --
> remove nospam to reply
> "Steffen Müller" <tsee@gmx.net> wrote in message
> news:9sruqf$8ud$03$1@news.t-online.com...
> > "Terry" <dcsnospam@ntlworld.com> schrieb im Newsbeitrag
> > news:TTeI7.20912$MN4.2255004@news11-gui.server.ntli.net...
> > | I need to compress a large file on my hosts server and gzip is
> available.
> > | How do I call\use gzip from within a .pl script
> > | Please be gentle :)
> >
> > I'll try.
> >
> > You can always use system() or backticks to execute arbitrary shell
> > commands.
> > Or you can go to search.cpan.org and search for modules that help you:
> >
> > 6 modules found in 6 distributions matching 'gzip'
> >
> > [snip]
> >
> > PerlIO-gzip-0.11 by Nicholas Clark Released
> > 29th October 2001
> > PerlIO::gzip Perl extension to provide a PerlIO layer to gzip/gunzip
> >
> > Seems the most appropriate.
> > Read the docs that come with that module, it's not hard to use.
> >
> > HTH,
> > Steffen
> > --
> >
$_=q;0cb212c210b0bb010c0113bb0c410c0b516c0bb3d212c2b0b0b016b6cb2b2c21010c0
> >
b41110b3bba0e0c0d2c4b2b6bc013d2c0d0b01012b0b0;;s/\n//g;s/(\d)/$1<2?$1:'0'x
> >
$1/ge;s/([a-f])/'1'x(ord($1)-97)/ge;print"\n";$o=$_;push@o,substr($o,$_*8,
> >
8)for(0..24);for(@o){print"\0"x(26-$i).chr(oct('0b'.($_)))."\n";$i++}#st_m
Also see the various Archive:: modules.
Regards,
Mr. Sunblade
------------------------------
Date: Tue, 13 Nov 2001 22:23:36 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: how do I use gzip
Message-Id: <slrn9v37c1.6ia.mgjv@verbruggen.comdyn.com.au>
On Tue, 13 Nov 2001 21:12:33 +0100,
Steffen Müller <tsee@gmx.net> wrote:
> "Terry" <dcsnospam@ntlworld.com> schrieb im Newsbeitrag
> news:TTeI7.20912$MN4.2255004@news11-gui.server.ntli.net...
>| I need to compress a large file on my hosts server and gzip is available.
>| How do I call\use gzip from within a .pl script
>| Please be gentle :)
>
> I'll try.
>
> You can always use system() or backticks to execute arbitrary shell
> commands.
> Or you can go to search.cpan.org and search for modules that help you:
>
> 6 modules found in 6 distributions matching 'gzip'
>
> [snip]
>
> PerlIO-gzip-0.11 by Nicholas Clark Released
> 29th October 2001
> PerlIO::gzip Perl extension to provide a PerlIO layer to gzip/gunzip
I tend to use Compress::Zlib for gzipped files, sometimes together
with Archive::Tar if I need to pack up multiple files.
Martien
--
|
Martien Verbruggen | 42.6% of statistics is made up on the
Trading Post Australia Pty Ltd | spot.
|
------------------------------
Date: Tue, 13 Nov 2001 14:01:57 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: How to use Shift and GetOpts
Message-Id: <25407-3BF17C35-43@storefull-243.iap.bryant.webtv.net>
> > (I thought I read that "shift" without an > > argument uses @_ for
its argument )
> Don't guess about it, read about it in the > perlfunc manual page,
shift section. You > can do that with
>=A0=A0=A0=A0=A0=A0=A0=A0perldoc -f shift
I did read perdoc-f shift before posting the question. Anyway, I
probably shouldn't have used the phrase "I think"... but that just
meant that I read it but wasn't sure that I understood it... which I
didn't.
Regards,
--Dennis
"I believe in humanity, not war" --a metaphorical statement to you know
who
------------------------------
Date: Tue, 13 Nov 2001 20:45:44 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: IO::Socket write fail
Message-Id: <x74rnyjt4j.fsf@home.sysarch.com>
>>>>> "M" == Mark <admin@asarian-host.net> writes:
M> "Uri Guttman" <uri@stemsystems.com> wrote in message
M> news:x77ksvlpgb.fsf@home.sysarch.com...
>> non-blocking writes are tricky. do you really need them? you must check
>> the result of the write call and make sure it sent all the data. you then
>> have to buffer the unsent data and send it the next time the socket is
>> writable. this requires a more complex system and you should think about
>> going to an OO one like Stem, POE or Event.pm. IO::Select is too limited
>> when handling complex asynch I/o situations.
>>
>> for many client/server designs, blocking I/O is ok as long as the
>> protocol on the pipe works that way.
M> If I leave the sockets blocking, what will happen if they block?
M> Does the program just hang in the blocked state? Should I set an
M> alarm to break out of a blocked write? I know that when I set it to
M> blocking, the write either succeeds or fails.
in a single threaded program, writing to a blocking socket will only
block when the socket's buffer is full. you can actually set this buffer
size with setsockopt (which is just a wrapper for the unix call - see
its man page for all the info). for some socket work, increasing the
buffer sizes helps but you need to experiment. why allocate ons of
unneeded space for dozens of sockets. the socket buffer fills only when
you write so much to it and it can't send it out to the other side fast
enough. if the other side stops reading or is too slow, then the sending
socket will also eventually stop. this is when non-blocking sockets can
be a big win. your program then has to do its own output buffering
(beyond the socket's internal buffer). you have to do a select type call
(using event.pm, io::select, POE, Stem, etc.) and when the socket is
writable, send as much as you can. you have to keep track of how much
you write and delete that portion from the buffer (many ways of handling
that).
M> Per your suggestion, I have now not set the sockets to
M> non-blocking. I have actually been able to send rather sizeable
M> chunks (over 256K per write) back to the clients, without any
M> problem whatsoever.
look into the socket buffer sizes too.
>> also you use send/recv and I think you should be using syswrite/sysread
>> which are better as you can control how much is read/written with them.
>> send/recv are just different api's for socket I/o. and in either case,
>> make sure you check the amount of data written to non-blocking sockets.
M> Thank you, Uri. Your contribution has been invaluable. :) I have it
M> working now.
did you switch to syswrite from send? and are you doing your own output
buffering with async writes? non-blocking sockets are powerful but you
have to do all the extra housekeeping yourself.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Tue, 13 Nov 2001 14:32:41 -0800
From: Ann Tsai <mktgadm@usenix.org>
Subject: LISA 2001 Early Registration Fee Extended!
Message-Id: <mktgadm-E6ABFE.14324113112001@reader.news.uu.net>
Keywords: system administrator, system administrations, sys admin, UNIX, LINUX, OS, database, LISA, technical conference, seminar, tutorials, classes, invited talks, refereed papers, white papers, computers, operating systems, applications, hardware, software, SUN, Microsoft, windows, windows NT, symposium, security, databases, development, maintenance, troubleshooting, performance tuning, methodology, training, scaling, integration, programming, network, networking, technology, protocol, Perl, TCP/IP, hubs, routers, servers, CISCO, Oracle, Sybase, Open Systems
The Early Registration Discount for LISA 2001 has been EXTENDED until
November 16th!!
15th Systems Administration Conference (LISA 2001)
December 2-7, 2001 - San Diego, CA USA
http://www.usenix.org/events/lisa2001
LISA continues to provide unparalleled learning and networking
opportunities for system administrators, with 5 technical tracks
covering every major operating system, a special Network/Security track
dedicated to the latest in system and network security, over 40
professional-level TUTORIALS and the first ever CORE CERTIFICATION EXAM
- cSAGE.
Register ONLINE for additional savings!
CONFERENCE HIGHLIGHTS:
*CNN.com: Facing a World Crisis
William LeFebvre, CNN Internet Technologies
September 11 of 2001 saw heinous events of such magnitude that the
entire world was transfixed by disbelief. In the understandable hunger
for news, Net users flocked to news
sites. The unexpected and unprecedented demand quickly drove nearly
every news site into the ground, and CNN.com was no exception. What
brought the CNN site back up was a tremendous effort of teamwork, fast
thinking, and troubleshooting, all happening in the face of a terrible
tragedy. This talk will tell the story of CNN.com and the team that
worked so hard to meet the unbelievable user demand. One of the biggest
challenges faced by the team was induced by cascading failures, so that
increasing capacity alone was
not sufficient to resurrect the site. The talk will conclude with a
discussion about the relevance of this experience to anyone who runs a
Web site.
*Guru is in Sessions on AFS, LDAP, Backups, Email MTAs
*Workshops on: AFS, cfengine, Intrusion Detection & Incident Response,
MetaLISA, Advanced Topics, Teaching Sysadmin, and the taxonomy of
sysadmin project.
*FREE BOOK OFFER
Attendees to LISA 2001 also receive a FREE copy of
SELECTED PAPERS IN SYSTEM ADMINISTRATION,
to be published by Wiley in December and edited by
Eric Anderson, Mark Burgess, and Alva Couch.
The FIRST EVER CORE CERTIFICATION EXAM (cSAGE)!
For one day only, beta testing of the core exam of cSAGE
is being offered at a significantly reduced rate. Slots may still be
available. For more info, visit http://www.sage.org/cert.
Register Today!
================================================================
The 15th Systems Administration Conference (LISA 2001) is sponsored by
USENIX, the Advanced Computing Systems Association, and
SAGE, the System Administrators Guild.
================================================================
------------------------------
Date: Tue, 13 Nov 2001 11:58:46 -0800
From: "Arvin Portlock" <temp133@hotmail.com>
Subject: Memory mgt and GC in perl 5.005_3
Message-Id: <9sru20$1af3$1@agate.berkeley.edu>
I'm using perl 5.005_3 on win dows 95 and never really worried too much
about garbage collection or memory management but now I find that I
have to.
I've written a module that converts text documents into trees. The module
returns a reference to the root of the tree. The tree can have potentially
tens of thousands of nodes but I've never had any problems. Recently, I
wrote a program which loops through a number of documents and builds
a tree for each one, does what it has to do, then moves to the next
document. I eventually encountered an out of memery error. The program
works if I loop through the documents via the shell but not if the loop
is in the program that calls the module. Obviously I forgot to worry
about cleaning up the last tree before I began to construct the new tree.
My question is how do I clean up the previous tree? I would simply undef
the root node but each node has a reference to its parent as well as
references to its siblings and its children. I assume perl's GC relies on
reference counting and since each node may have two references pointing
to it, nothing will get cleaned up. Do I need to iterate through and undef
each
node? Or is there an Easy Way?
Thanks for any light you can shed on the subject.
------------------------------
Date: Tue, 13 Nov 2001 21:25:33 +0100
From: "Steffen Müller" <tsee@gmx.net>
Subject: Re: Need help with strange performance problem processing large files
Message-Id: <9ss134$8nt$07$2@news.t-online.com>
"Tim Moose" <wtmoose@yahoo.com> schrieb im Newsbeitrag
news:48a86175.0111130827.7ab166ae@posting.google.com...
[snip long post]
#!/bin/perl
use strict; # *chanting* Always, always, always...
use warnings; # *chanting* Always, always, always...
# and even:
use diagnostics;
# Use all the help you get.
[snip other packages]
| package Main;
|
| print "\nReading input file.\n\n";
| print "Line# Sec\n";
| print "===== ===\n";
| open FILE, "<slow.txt";
Check the return of open. or die "Could not open file. $!"
| $last = time();
|
| # Read in the file and store some data in some objects.
| while (<FILE>) {
|
| if ($ARGV[0] eq 'weird') {
| # No performance problem when deleting
| # only two characters.
| # This is very weird!
| s/..//;
Why not
substr($_, 2);
| } else {
| # Delete three characters. Is that so bad?
| s/....//;
That's four dots!?
Why not
substr($_, 3);
| }
|
| # Create an object.
| $object = new Object();
|
| if ($ARGV[0] eq 'odd') {
| # No performance problem when dummy object are created.
| # This is very odd!
| $dummy = new Dummy();
| push @dummy, $dummy;
| }
|
| # Assign the modified line to a data member.
| $object->{V1} = $_;
|
| # Store the object away.
| push @objects, $object;
|
| # Every 20000 lines, print out the line number and the time
| # elapsed since the previous line.
| if ($. % 20000 == 0) {
| $now = time();
| print "$.\t${\($now - $last)}\t${average}\n";
| $last = $now;
| }
| }
| ###########################################
I suggest you first start using strict and warnings. Sorry I couldn't help
any more.
Steffen
--
$_=q;0cb212c210b0bb010c0113bb0c410c0b516c0bb3d212c2b0b0b016b6cb2b2c21010c0
b41110b3bba0e0c0d2c4b2b6bc013d2c0d0b01012b0b0;;s/\n//g;s/(\d)/$1<2?$1:'0'x
$1/ge;s/([a-f])/'1'x(ord($1)-97)/ge;print"\n";$o=$_;push@o,substr($o,$_*8,
8)for(0..24);for(@o){print"\0"x(26-$i).chr(oct('0b'.($_)))."\n";$i++}#st_m
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 2125
***************************************