[22798] in Perl-Users-Digest
Perl-Users Digest, Issue: 5019 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 21 11:07:16 2003
Date: Wed, 21 May 2003 08: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)
Perl-Users Digest Wed, 21 May 2003 Volume: 10 Number: 5019
Today's topics:
Alarm + System zombies (Vinicio Tavares)
Re: awstats ignores HostAliases if using %virtualname <abigail@abigail.nl>
Re: Can This Be Done with a Windows One-Liner? (Veky)
CPAN finds outdated Chart::Graph::Gnuplot <marcjmims@hotmail.com>
Re: CPAN finds outdated Chart::Graph::Gnuplot (Randy Kobes)
Re: Crypt-SSLeay & Openssl want a divorce (Sebastien@Patriate)
Re: cut and paste using perl script <ubl@schaffhausen.de>
Re: error handling on file open <barryk2@SPAM-KILLER.mts.net>
Re: eval question <uri@stemsystems.com>
Re: eval question <w.koenig@acm.org>
Re: finding "mailto:" strings in html files (Veky)
Re: help selecting and displaying specific files after <barryk2@SPAM-KILLER.mts.net>
Re: Help with perl string match <barryk2@SPAM-KILLER.mts.net>
move() from File::Copy package fails with cross-device (Carlton Brown)
Re: removing a word using a regexp doesn't w =?ISO-8859 <bigj@kamelfreund.de>
Re: Sending email with perl. <andrew.rich@bigpond.com>
The n'th character of a string <nomail@hursley.ibm.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 21 May 2003 06:13:55 -0700
From: vtmcs@terra.com.br (Vinicio Tavares)
Subject: Alarm + System zombies
Message-Id: <a165b9fc.0305210513.1574ea57@posting.google.com>
I have this code, it creates zombies, how can I solve this problem? Thanks.
...
eval {
local $SIG {ALRM} = sub { die "..." };
alarm $timx;
system "...";
alarm 0;
}
...
Vinicio
------------------------------
Date: 21 May 2003 14:34:19 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: awstats ignores HostAliases if using %virtualname
Message-Id: <slrnbcn3jb.kuj.abigail@alexandra.abigail.nl>
gooze (g000ze@gmx.net) wrote on MMMDL September MCMXCIII in
<URL:news:e09c7315.0305210433.5192451e@posting.google.com>:
"" Abigail <abigail@abigail.nl> wrote in message news:<slrnbclboq.kuj.abigail@alexandra.abigail.nl>...
"" > gooze (g000ze@gmx.net) wrote on MMMDXLIX September MCMXCIII in
"" > <URL:news:e09c7315.0305200328.1927c5df@posting.google.com>:
"" > ||
"" > || Now my question: Does somebody know awstats? Is somebody able to
"" > || modify awstats so that awstats cares about both fields, the SiteDomain
"" > || AND the HostAliases, although the "%virtualname" value is in the
"" > || LogFormat field?
"" >
"" >
"" > Where is your Perl question?
"" >
"" Where would you post in my situation? The awstats page does not react.
alt.flame, where else?
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$==-2449231+gm_julian_day+time);do{until($=<$#r){$_.=$r[$#r];$=-=$#r}for(;
!$r[--$#r];){}}while$=;$,="\x20";print+$_=>September=>MCMXCIII=>=>=>=>=>=>=>=>'
------------------------------
Date: Wed, 21 May 2003 13:29:22 +0000 (UTC)
From: veky@cromath.math.hr (Veky)
Subject: Re: Can This Be Done with a Windows One-Liner?
Message-Id: <bafuvi$p4o$1@bagan.srce.hr>
Dok je Veky citao comp.lang.perl.misc, pod PIDom 21189 (290653 off, 1 to go...),
primijetio je kreaturu zvanu "Buck Turgidson" <jc_va@hotmail.com>,
ispod cijih su prstiju izasle (izmedu ostalih) sljedece rijeci:
|I am an Oracle type, not a perl type, but I think I could write something to
|parse out the filename (*.alt) and the byte size. But could somthing like
|that be done with a one-liner in Windows?
|
|<IMG SRC="/icons/text.gif" ALT="[ ]"> <A
|HREF="20020123164834test.alt">20020123164834test.alt</A> 25k
($filename,$bytesize)=/<A HREF="(\w+\.alt)">\1<\/A>\s+(\w+)/
--
\#{% Sad gradi svoj grad iz snova... znaj da mozes i znaj da znas...
------------------------------
Date: Wed, 21 May 2003 08:51:50 -0500
From: Marc Mims <marcjmims@hotmail.com>
Subject: CPAN finds outdated Chart::Graph::Gnuplot
Message-Id: <XdadnQUn0rLrGVajXTWcow@comcast.com>
When I search for Chart::Graph::Gnuplot in the CPAN shell, the only
module returned is version 1.1. The current version seems to be 2.0.
Is this a bug that needs reporting, a pontential configuration problem
on my end, or just a lack of understanding about how CPAN searches are
supposed to work?
Here's the relevant output from the CPAN shell:
cpan> i /Chart::Graph::Gnuplot/
CPAN: Storable loaded ok
Going to read /root/.cpan/Metadata
Database was generated on Wed, 21 May 2003 02:45:06 GMT
Module id = Chart::Graph::Gnuplot
CPAN_USERID MHYOUNG (Michael Young <mhyoung@ucsd.edu>)
CPAN_VERSION undef
CPAN_FILE M/MH/MHYOUNG/Chart-Graph-1.1.tar.gz
MANPAGE Chart::Graph::Gnuplot
INST_FILE /usr/local/share/perl/5.8.0/Chart/Graph/Gnuplot.pm
INST_VERSION 2
I downloaded and installed version 2 manually, thus the INST_VERSION
2, above, I assume.
Searching for the distribution does find both versions:
cpan> i /Chart-Graph/
Distribution C/CA/CAIDAPERL/Chart-Graph-2.0.tar.gz
Distribution M/MH/MHYOUNG/Chart-Graph-1.1.tar.gz
2 items found
-Marc
------------------------------
Date: 21 May 2003 14:12:24 GMT
From: randy@theoryx5.uwinnipeg.ca (Randy Kobes)
Subject: Re: CPAN finds outdated Chart::Graph::Gnuplot
Message-Id: <slrnbcn1ha.p3a.randy@theoryx5.uwinnipeg.ca>
On Wed, 21 May 2003 08:51:50 -0500, Marc Mims <marcjmims@hotmail.com> wrote:
>When I search for Chart::Graph::Gnuplot in the CPAN shell, the only
>module returned is version 1.1. The current version seems to be 2.0.
>Is this a bug that needs reporting, a pontential configuration problem
>on my end, or just a lack of understanding about how CPAN searches are
>supposed to work?
>
>Here's the relevant output from the CPAN shell:
>
> cpan> i /Chart::Graph::Gnuplot/
> CPAN: Storable loaded ok
> Going to read /root/.cpan/Metadata
> Database was generated on Wed, 21 May 2003 02:45:06 GMT
> Module id = Chart::Graph::Gnuplot
> CPAN_USERID MHYOUNG (Michael Young <mhyoung@ucsd.edu>)
> CPAN_VERSION undef
> CPAN_FILE M/MH/MHYOUNG/Chart-Graph-1.1.tar.gz
> MANPAGE Chart::Graph::Gnuplot
> INST_FILE /usr/local/share/perl/5.8.0/Chart/Graph/Gnuplot.pm
> INST_VERSION 2
>
>I downloaded and installed version 2 manually, thus the INST_VERSION
>2, above, I assume.
>
>Searching for the distribution does find both versions:
>
> cpan> i /Chart-Graph/
> Distribution C/CA/CAIDAPERL/Chart-Graph-2.0.tar.gz
> Distribution M/MH/MHYOUNG/Chart-Graph-1.1.tar.gz
> 2 items found
From the i /Chart::Graph::Gnuplot/, it looks like
this module is registered to MHYOUNG. If Chart-Graph-2.0
was meant to be an upgrade, then I believe ownership of
the module would have to be transferred to (or perhaps
shared with) CAIDAPERL - this can be done through the
web interface to PAUSE.
--
best regards,
randy kobes
------------------------------
Date: 21 May 2003 07:13:07 -0700
From: sebastien@patriate.com.au (Sebastien@Patriate)
Subject: Re: Crypt-SSLeay & Openssl want a divorce
Message-Id: <24827557.0305210613.743178a9@posting.google.com>
Okay now I ran the perl debugger and found out where my problem is in
the Net::SSL package.
Debugger output
===============
390==>b my $self = shift;
391: my $ctx = *$self->{ssl_ctx};
392
393: my $count = 0;
394: for ('HTTPS_PKCS12_FILE', 'HTTPS_CERT_FILE',
'HTTPS_KEY_FILE') {
395: my $file = $ENV{$_};
396: if($file) {
397: (-e $file) or die("$file file does not exist:
$!");
398: $count++;
399: if (/PKCS12/) {
DB<7> s
Net::SSL::configure_certs(D:/Perl/site/lib/Net/SSL.pm:391):
391: my $ctx = *$self->{ssl_ctx};
DB<7>
Net::SSL::configure_certs(D:/Perl/site/lib/Net/SSL.pm:393):
393: my $count = 0;
DB<7> p $ctx
Crypt::SSLeay::CTX=SCALAR(0x2292e48)
DB<8> p $self
LWP::Protocol::https::Socket=GLOB(0x213b0a0)
Net::SSL::configure_certs(D:/Perl/site/lib/Net/SSL.pm:401):
401: $ctx->use_pkcs12_file($file
,$ENV{'HTTPS_PKCS12_PASSWORD'}) || die("failed to load $file: $!");
The call to $ctx->use_pkcs12_file never returns, now I've checked the
args passed and they are fine.
Went looking for this routine and think it exists in
D:\Perl\site\lib\auto\Crypt\SSLeay\SSLeay.dll
This is the file that was installed with Crypt-SSLeay.
So now how can I find out where the hell its at?
Cheers,
Sebastien
------------------------------
Date: Wed, 21 May 2003 15:08:11 +0200
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: cut and paste using perl script
Message-Id: <bag0sk$1p5$1@news.dtag.de>
Perl_hungry wrote:
> Dear members,
> I am new at perl.
> Question: How can cut and paste lines using perl script.
> (line numbers will be provided as arguments).
Well, you can cut and paste to an from the windows clipboard using the
Win32::Clipboard module
http://search.cpan.org/author/ACALPINI/Win32-Clipboard-0.51/Clipboard.pm
That's probably not what you meant, though. See Tad's post for a better
answer.
malte
------------------------------
Date: Wed, 21 May 2003 08:43:34 -0500
From: Barry Kimelman <barryk2@SPAM-KILLER.mts.net>
Subject: Re: error handling on file open
Message-Id: <MPG.19353e831803c1a9897d7@news.mts.net>
[This followup was posted to comp.lang.perl.misc]
In article <baebsj$slmfu$1@ID-65612.news.dfncis.de>, Rene Scheibe
(Rene.Scheibe@gmx.net) says...
> i have some questions about handling errors
> when opening files. for example you can do
>
> open (FILE, "filenpath") or die("cannot open file");
>
> my questions:
> 1) what is the difference using "or" or "||"?
There is no functional difference. Some prefer to
use "or" because it makes the code look more readable.
>
> 2) how can i run more than one command after "or"?
> the following doesnt work:
> open (FILE, "filepath") or {
> print "cannot open file";
> print "exiting script";
> exit; }
unless ( open(FILE,"filepath") ) {
print "cannot open file : $!\n";
die("Goodbye...\n");
}
>
> thanks rene
---------
Barry Kimelman
Winnipeg, Manitoba, Canada
email : bkimelman@hotmail.com
------------------------------
Date: Wed, 21 May 2003 13:43:10 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: eval question
Message-Id: <x7vfw476vl.fsf@mail.sysarch.com>
>>>>> "SH" == Stephen Hildrey <steve@uptime.orgNo.ukSpam> writes:
SH> In article <4a0341c8.0305210307.234e4494@posting.google.com>, Shankar wrote:
>> $x = "abc";
>> $abc = { "a" => 1, "b" => 2, "c" => 3 };
>>
>> How do I get the same result as $abc->{a} using $x?
>> I tried something like:
>> $y = eval $x;
>> print "$y->{a}\n";
SH> As long as your target variable is global, you can use symbolic
SH> references thus:
don't give out symref answers. for why, search google for many threads
on this subject. there is no reason to use symrefs unless yoy are
munging the symbol table. and the symbol table is just a special hash
tree. so use a proper perl data structure. symrefs are for symbols and
NOT for data structures.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Wed, 21 May 2003 16:52:16 +0200
From: Winfried Koenig <w.koenig@acm.org>
Subject: Re: eval question
Message-Id: <3ECB92A0.1060603@acm.org>
Shankar wrote:
> $x = "abc";
> $abc = { "a" => 1, "b" => 2, "c" => 3 };
>
> How do I get the same result as $abc->{a} using $x?
> I tried something like:
> $y = eval $x;
> print "$y->{a}\n";
>
> .. but it did not work.
try:
print index($x, 'a') + 1, "\n";
print index($x, 'b') + 1, "\n";
print index($x, 'c') + 1, "\n";
Winfried Koenig
------------------------------
Date: Wed, 21 May 2003 13:58:12 +0000 (UTC)
From: veky@cromath.math.hr (Veky)
Subject: Re: finding "mailto:" strings in html files
Message-Id: <bag0lk$dgh$1@bagan.srce.hr>
Dok je Veky citao comp.lang.perl.misc, pod PIDom 22953 (290622 off, 5 to go...),
primijetio je kreaturu zvanu clos@trentu.ca (Netware60),
ispod cijih su prstiju izasle (izmedu ostalih) sljedece rijeci:
|I need to search thru a list of html text files and find and extract
|out all the occurrences of the word "mailto:" followed by an email
|address . So something like "" or "mailto: juser@host.domain.com". I
|just need to create a report of all the mailto occurrences contained
|in my file list.
|I'd like my report to like this if possible:
|
|mailto:juser@host.domain.com
|mailto:juser@hosta.domain.com
|mailto:juser2@hostb.domain.com
|mailto:juser3@hostc.domain.com
@ARGV=<*.html>;while(<>){
push@spamlist,@f if@f=/"(mailto:[\w@.])"/g
};print join"\n",sort@spamlist
--
\#{% Sad gradi svoj grad iz snova... znaj da mozes i znaj da znas...
------------------------------
Date: Wed, 21 May 2003 08:31:52 -0500
From: Barry Kimelman <barryk2@SPAM-KILLER.mts.net>
Subject: Re: help selecting and displaying specific files after reading directory:
Message-Id: <MPG.19353bc79711f6329897d6@news.mts.net>
[This followup was posted to comp.lang.perl.misc]
In article <bkvya.214620$My6.3447198@twister.tampabay.rr.com>,
Scaramouche (spamReallySucks@forgetit.com) says...
> using xp-pro and perl 5.6.1.
> i'm opening and reading a directory with the hopes of selecting specific
> files, those with *.tmp extension. then i plan on using 'unlink' so as to
> delete these files:
>
> $currentDir = ".";
> opendir(CURRENT_DIR, $currentDir) || die "can't opendir $currentDir: \n$!";
> @filenames = readdir(CURRENT_DIR);
> @allFiles = grep(/.tmp/ , @filenames);
>
> closedir CURRENT_PB_DIR;
> print("The following *.tmp files were found: @allFiles\n");
>
> here's my question, although the above works, i cannot seem to display such
> files one per line, even though i'm using \n within the print statement.
> will i need a loop for that being that @allFiles is a list or array?
> is there a more efficient way of doing this with perl?
>
> i then plan to do something like:
> unlink<@allFiles>;
>
> i have not tested that part yet though.
>
> thanks
Note : You can use the "glob" function to do the file name matching. So
your code could look like the following :
@matches = glob("*.tmp");
if ( 1 > @matches ) {
print "No matches for '*.tmp'\n";
}
else {
print "Delete the following files : ",join("\n",@matches),"\n";
unlink @matches;
}
--
---------
Barry Kimelman
Winnipeg, Manitoba, Canada
email : bkimelman@hotmail.com
------------------------------
Date: Wed, 21 May 2003 08:50:36 -0500
From: Barry Kimelman <barryk2@SPAM-KILLER.mts.net>
Subject: Re: Help with perl string match
Message-Id: <MPG.19354026aa48e06f9897d8@news.mts.net>
[This followup was posted to comp.lang.perl.misc]
In article <c5a86edd.0305210445.e036e97@posting.google.com>, Yuchung
Cheng (yuchung@mail.com) says...
> I want to parse this string
>
> 1053320039:143483 REXMIT 2188605148 rexmits 1, timeout 278 ms,
> destined for 140.229.17.222
>
> ($epoch_sec, $nsec, $nrexmit, $timeout, $ip_addr) = \
> $line ~= /^(\d+):(\d+).*rexmits (\d+), timeout (\d+) ms, destined for
> (\w+)/;
>
> is not working, can someone help me writing better and correct regex?
> thanks.
>
> yuchung
>
I see several problems :
(1) the matching operator should be "=~" not "~="
(2) the text in your regex is lowercase and the data in your string
is uppercase; therefor you will need to do a case-insensitive
match just to be on the safe side.
Try the following :
$line =~ /^(\d+):(\d+)\s+rexmit\s+(\d+),\s+timeout (\d+) ms, destined for
(\w+)/i;
--
---------
Barry Kimelman
Winnipeg, Manitoba, Canada
email : bkimelman@hotmail.com
------------------------------
Date: 21 May 2003 07:21:28 -0700
From: carltonbrown@hotmail.com (Carlton Brown)
Subject: move() from File::Copy package fails with cross-device link
Message-Id: <aa611a32.0305210621.38f9ded0@posting.google.com>
If it is true that the move() method in File::Copy uses a
copy-and-delete strategy to "move" a file from one file system to
another, then why do I get a "Cross-device link" error using the
move() function between files on different file systems?
I am aware that it is impossible to truly "move" a file between file
systems in the inode sense, but I thought the move() method was
designed to commit the same sort of fraud as the "mv" shell command in
giving the appearance of "moving" a file between file systems. That
is the desired effect here.
For example, see the the code fragment below (marked by an explanatory
comment). This is for a log archiving utility.
# perl v. 5.005_03 on solaris 8 (yes I realize it is a fossil, it's
beyond my control).
unless (move("$currFile","$dstFile")) {
# Why is $! "Cross-device link" in this block?
logger("Failed moving $currFile to $dstFile operation failed
because: $!");
return 1;
} else {
logger("Success moving $currFile to $dstFile");
}
------------------------------
Date: Wed, 21 May 2003 12:33:26 +0200
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: removing a word using a regexp doesn't w =?ISO-8859-1?Q?_ork_with_the_characters_'=E5',_'=E4'_and_'=F6'?=
Message-Id: <pan.2003.05.21.10.33.26.146819@kamelfreund.de>
Leif Wessman wrote at Wed, 21 May 2003 05:59:10 -0700:
> Hi Janek! I really appreciate your help. However, I don't get your
> code to work.
>
> You said:
> $text =~ s/(?<![\wÄÖÜäöü])det(?![\wÄÖÜäöü])/ig;
>
> I've tried it, it doesn't work. So I've tried something similar:
What didn't work.
Did you get an error message?
Did you get a wrong result.
It seems to work on my computer :-o
> $text =~ s/([^\wÄÖÜäöü])?det([^\wÄÖÜäöü])?//ig;
>
> that almost work for me... however, when I try the following:
>
> $text = "det mandelträdet det nisse det";
> $text =~ s/([^\wÄÖÜäöü])det([^\wÄÖÜäöü])//ig;
Try instead
$text =~ s/([^\wÄÖÜäöü])det([^\wÄÖÜäöü])/$1$2/ig;
> then $text becomes "mandelträdetnisse det"
> I was expecting: " mandelträdet nisse ";
>
> I must admit that I'm not 100% sure of what I'm doing here. I hope
> that you can help me again. I'm sure that for an expert (like
> yourself) could solve this in 2 secs.
Read perldoc perlre for the details.
Greetings,
Janek
------------------------------
Date: Thu, 22 May 2003 00:37:41 +1000
From: "Andrew Rich" <andrew.rich@bigpond.com>
Subject: Re: Sending email with perl.
Message-Id: <pan.2003.05.21.14.37.39.264140@bigpond.com>
Sorry I gooffed up, you needed a "< /dev/null" at the end of mail bit
mail -v -s HOST_DOWN email@address < /dev/null
works for me a treat !
On Tue, 20 May 2003 02:41:04 +0000, Chip wrote:
> I am trying to have a simple script email me when a
> server is not responding to ping.
>
> I can run mailx from the command line and it works
> fine but the script never sends mail.
>
> I also tried Net::smtp with no luck.
>
>
>
> #!/usr/bin/perl
> #
> use Net::Ping;
>
> @hosts = ("192.168.0.1", "192.168.0.2", "192.168.0.3");
>
> while (1)
> {
> $p = Net::Ping->new();
> foreach (@hosts)
> {
> if ($p->ping($_))
> {
> print "$_ is alive\n";
> }
> else
> {
> print "$_ is DOWN!.\n";
> system("mailx administrator@host.com", "Alert", "Server $_ is
> down", ".", " ");
> }
> $p->close();
> sleep 15;
> }
> }
>
> Any and all help is greatly appriceated,
> Chip
------------------------------
Date: Wed, 21 May 2003 22:06:36 +0800
From: Derek Fountain <nomail@hursley.ibm.com>
Subject: The n'th character of a string
Message-Id: <3ecb8748$0$31519$5a62ac22@freenews.iinet.net.au>
Someone just asked me how to find print the n'th character of a given
string. I immediately thought along the lines of $string{$n} in PHP or
string[n] in Python, but I couldn't come up with the Perl equivalent.
I satisfied the asker with either:
print substr( "derek", 2, 1 );
or
print( (split(//,"derek"))[2] );
to pick out the 'r', but I can't help thinking I've missed something. Is
there a simple syntax for a getting a single character from a string given
the index?
------------------------------
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 5019
***************************************