[22797] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 5018 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 21 09:06:01 2003

Date: Wed, 21 May 2003 06:05:19 -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: 5018

Today's topics:
    Re: =?ISO-8859-1?Q?removing_a_word_using_a_regexp_doesn (Leif Wessman)
    Re: awstats ignores HostAliases if using %virtualname (gooze)
    Re: awstats ignores HostAliases if using %virtualname (Anno Siegel)
    Re: Best way to compare binary files? <bkennedy@hmsonline.com>
        Can This Be Done with a Windows One-Liner? <jc_va@hotmail.com>
    Re: Can't locate sub.pl <nobull@mail.com>
    Re: copying files between two directories (Helgi Briem)
    Re: Crypt-SSLeay & Openssl want a divorce <kalinabears@hdc.com.au>
        cut and paste using perl script (Perl_hungry)
    Re: cut and paste using perl script (Tad McClellan)
        eval question (Shankar)
    Re: eval question <steve@uptime.orgNo.ukSpam>
    Re: eval question <nobull@mail.com>
    Re: eval question (Anno Siegel)
        finding "mailto:" strings in html files (Netware60)
    Re: finding "mailto:" strings in html files <no@spam.for.me.invalid>
        Help With IO::Socket::INET <sendspamhere@amcc.org.uk>
    Re: Help With IO::Socket::INET <dont@want.spam>
    Re: Help With IO::Socket::INET <sendspamhere@amcc.org.uk>
    Re: Help With IO::Socket::INET <bkennedy@hmsonline.com>
        Help with perl string match (Yuchung Cheng)
    Re: Help with perl string match (Helgi Briem)
    Re: Help with perl string match (Anno Siegel)
    Re: High CPU usage and mem leak problem in a perl routi (Joe Smith)
    Re: Image::Size problem under Win 98 (Joe Smith)
    Re: multiple sort subroutine <spam@thecouch.homeip.net>
        o conf urllist <waty@powerup.com.au>
    Re: why key is added to hash after defined ? (Veky)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 21 May 2003 05:59:10 -0700
From: leifwessman@hotmail.com (Leif Wessman)
Subject: Re: =?ISO-8859-1?Q?removing_a_word_using_a_regexp_doesn't_w?= =?ISO-8859-1?Q?_ork_with_the_characters_'=E5',_'=E4'_and_'=F6'?=
Message-Id: <64beeaad.0305210459.37166ee2@posting.google.com>

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:
$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;

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.

Thank you for your help!!!

Leif




"Janek Schleicher" <bigj@kamelfreund.de> wrote in message news:<pan.2003.05.20.12.57.44.46822@kamelfreund.de>...
> Leif Wessman wrote at Tue, 20 May 2003 06:45:19 -0700:
> 
> > $text = "det mandelträdet";
> > $text =~ s/\bdet\b//ig;
> > 
> > result  : "mandelträ"
> > expected: "mandelträdet"
> > 
> > Why isn't å,ä and ö working. Is there a workaround?
> 
> perldoc perllocale is your answer on the long run.
> 
> But, of course, there's a workaround:
> $text =~ s/(?<![\wÄÖÜäöü])det(?![\wÄÖÜäöü])/ig;
> allthough it's neither nice nor easy to maintain
> (and is still wrong with an ß or similar).
> 
> 
> Greetings,
> Janek


------------------------------

Date: 21 May 2003 05:33:06 -0700
From: g000ze@gmx.net (gooze)
Subject: Re: awstats ignores HostAliases if using %virtualname
Message-Id: <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.


------------------------------

Date: 21 May 2003 12:45:06 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: awstats ignores HostAliases if using %virtualname
Message-Id: <bafsci$ndg$2@mamenchi.zrz.TU-Berlin.DE>

gooze <g000ze@gmx.net> wrote in comp.lang.perl.misc:
> 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.

That makes awstats comp.lang.perl's responsibility?  You have funny
ideas how Usenet works.

Anyway, http://awstats.sourceforge.net/ works fine.  Where did you
look?

Anno


------------------------------

Date: Wed, 21 May 2003 08:48:20 -0400
From: "Ben Kennedy" <bkennedy@hmsonline.com>
Subject: Re: Best way to compare binary files?
Message-Id: <7fycnR5k5_0J6FajXTWJkg@giganews.com>


<ctcgag@hotmail.com> wrote in message
news:20030520110533.496$hp@newsreader.com...
>
> It's not clear what the null hypothesis is, but as you can draw
> as large a sample as you wish to, you can achieve any desired level
> of statistical significance.  The real question is, is it practically
> significant?

Well, MD5 sums are used all the time to verify that files transferred
successfully over the Internet, which would produce only very subtle changes
in files.  Frankly, I do not know how resistant they are to tampering - that
is, could someone go out of their way to brute force a file with equal size
and checksum, but different malicious content.  But for the use described by
the OP, there are 2 ^ 128 different MD5 sums, so using them to digest files
for comparison seems like an acceptable risk.

--Ben Kennedy




------------------------------

Date: Wed, 21 May 2003 13:01:18 GMT
From: "Buck Turgidson" <jc_va@hotmail.com>
Subject: Can This Be Done with a Windows One-Liner?
Message-Id: <755af9ed2518fdee34094eb1f5831679@TeraNews>

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




------------------------------

Date: 21 May 2003 12:20:42 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Can't locate sub.pl
Message-Id: <u9ptmch7g5.fsf@wcl-l.bham.ac.uk>

Pierre Couderc <pierre@couderc.cc> writes:

> And I understand that nothing is simple in perl. I wanted only put
> some instructions in a separate file because they repeat in many
> scripts.

The mechanism provided in Perl5 for this is the module.

> I have solved the problem with absolute path in my script. A solution
> that personnally, I find "horrible".

If I understood your problem correctly then using an absolute path
will not solve it.

Like I said, if multiple modules (or mod_perl-ized CGI scripts)
require() the same file you are playing Russian roulette.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


------------------------------

Date: Wed, 21 May 2003 11:25:54 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: copying files between two directories
Message-Id: <3ecb6222.3530134004@news.cis.dfn.de>

On 20 May 2003 10:44:09 -0700, naina_r@yahoo.com (Naina)
wrote:

>Iam trying to copy files existing under two different root
>directories.Help needed with also if any Attributes  can be used to
>get all files with some extension. Any suggestions would be welcome.

perldoc File::Find
perldoc File::Copy
-- 
Regards, Helgi Briem
helgi DOT briem AT decode DOT is


------------------------------

Date: Wed, 21 May 2003 21:18:35 +1000
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: Crypt-SSLeay & Openssl want a divorce
Message-Id: <3ecb61aa$0$23563@echo-01.iinet.net.au>


"Sebastien@Patriate" <sebastien@patriate.com.au> wrote in message
news:24827557.0305210204.32729d90@posting.google.com...

<snip>
>
> Now I read the following on the net to install Crypt-SSLeay:
> -----------------------------------------------------------
> 1. Installing OpensSSL 0.9.7
> a. Get openssl 0.9.7 from http://www.openssl.org
> b. Follow the instruction to install the openssl 0.9.7. I used VC++ to
> build the dll version
>
> 2. Installing Crypt-SSLeay 0.49
> a. At the c:> prompt, type 'ppm'
> b. Add the repository at winnipeg by doing the following at the ppm
> prompt:
> ppm> rep add winnipeg
> http://theoryx5.uwinnipeg.ca/cgi-bin/ppmserver?urn:/PPMServer58
> ppm> install Crypt-SSLeay
>
> 3. Copy the relevant files into the appropriate perl\site\lib
> directory
> Assume that your perl is installed at c:\Perl and openssl build
> directory at c:\openssl-0.9.7
> From the openssl directory, copy the ssleay32.dll and libeay32.dll in
> c:\openssl-0.9.7\out32dll
> to the directory c:\Perl\site\lib\auto\Crypt\SSLeay
> ---------------------------------------------------------------------

The following script should indicate whether or not you have a functional
installation. If it returns a mass of html, it's working ok. Otherwise,
there's something lacking. (I find it doesn't run real quick - takes about
20-30 seconds for me.)

use warnings;
use strict;
use LWP::UserAgent;

my $url = 'https://www.thawte.com';
#my $url = 'https://www.verisign.com'; # should work

my $ua = new LWP::UserAgent;

my $req = new HTTP::Request('GET', $url);

my $res = $ua->request($req);

if ($res->is_success) {
       print $res->as_string;
} else {
print "Failed: ", $res->status_line, "\n";
   }
__END__

If it doesn't work, then I would suggest the following course of action:
1) Delete all occurrences of the openssl dll's. (Might be best to rename
them  for the moment as it looks like something else might one day need
them.)
2) Delete Crypt::SSLeay.
3) Run:
ppm install http://theoryx5.uwinnipeg.ca/ppms/Crypt-SSLeay.ppd

This will prompt you to accept 2 openssl dll's. Accept the prompt, and
install them in one of the directories in your path. Specify the full path
to the folder in which you wish to place them.

That script should then work and we can start looking at issues as they
arise.
If it still doesn't work, tell us the errors it produces.

Cheers,
Rob




------------------------------

Date: 21 May 2003 04:25:40 -0700
From: rahul_pathak@dacafe.com (Perl_hungry)
Subject: cut and paste using perl script
Message-Id: <45b264ef.0305210325.3a796f45@posting.google.com>

Dear members,
          I am new at perl. 
Question: How can cut and paste lines using perl script. 
(line numbers will be provided as arguments). 

Regards,
Rahul


------------------------------

Date: Wed, 21 May 2003 07:25:30 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: cut and paste using perl script
Message-Id: <slrnbcms1q.4as.tadmc@magna.augustmail.com>

Perl_hungry <rahul_pathak@dacafe.com> wrote:

> Question: How can cut and paste lines using perl script. 


See also this Perl FAQ:

   How do I change one line in a file/
   delete a line in a file/
   insert a line in the middle of a file/
   append to the beginning of a file?


> (line numbers will be provided as arguments). 


--------------------------------------------
#!/usr/local/bin/perl
use strict;
use warnings;

my @cut   = ( 2, 3, 5 );
my @paste = ( 6, 7, 9 );

while ( <DATA> ) {
   next if grep $. == $_, @cut;
   if ( grep $. == $_, @paste ) 
      { print "new data for line $.\n" }
   else
      { print }
}

__DATA__
line 1
line 2
line 3
line 4
line 5
line 6
line 7
line 8
line 9
--------------------------------------------


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: 21 May 2003 04:07:58 -0700
From: SNeelakantan_C@zaplet.com (Shankar)
Subject: eval question
Message-Id: <4a0341c8.0305210307.234e4494@posting.google.com>

$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.

-Shanker


------------------------------

Date: Wed, 21 May 2003 12:18:58 +0100
From: Stephen Hildrey <steve@uptime.orgNo.ukSpam>
Subject: Re: eval question
Message-Id: <1053515938.82318.0@demeter.uk.clara.net>

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"; 

As long as your target variable is global, you can use symbolic
references thus:

    $abc = { "a" => 1, "b" => 2, "c" => 3 };
    # ...
    no strict 'refs';
    my $x   = "abc";
    my $foo = $$x->{a}; # $foo now contains 1

Regards,
Steve


------------------------------

Date: 21 May 2003 12:27:40 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: eval question
Message-Id: <u9llx0h74j.fsf@wcl-l.bham.ac.uk>

SNeelakantan_C@zaplet.com (Shankar) writes:

> $x = "abc";
> $abc = { "a" => 1, "b" => 2, "c" => 3 };
> 
> How do I get the same result as $abc->{a} using $x?

The correct syntax for using a symbolic reference ("abc" is a symbolic
reference to $abc") is the same as for real references and can be
found in perlref.

But you should probably (99.9% certain) use some mechanism other than
symbolic references.

Perhaps you could explain why you want to use symbolic references?

> I tried something like:
> $y = eval $x;

You wouldn't expect.. 
  $y = abc;
 ..to be interpreted as..
  $y = $abc;
 .. would you?

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


------------------------------

Date: 21 May 2003 12:00:28 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: eval question
Message-Id: <bafpos$mja$1@mamenchi.zrz.TU-Berlin.DE>

Shankar <SNeelakantan_C@zaplet.com> wrote in comp.lang.perl.misc:
> $x = "abc";
> $abc = { "a" => 1, "b" => 2, "c" => 3 };
> 
> How do I get the same result as $abc->{a} using $x?

You can do that, but see "perldoc -q 'variable as'" why it is a
bad idea.  Basically, what you want to do leads to a mix of data
(the content "abc" of $x) and program code (the variable $abc).
That makes a program unmaintainable.

The standard solution to your problem is to use a hash entry $hash{ abc}
instead of the variable $abc.  That way what used to be a variable name
becomes a hash key, keeping code and data separate.

Anno


------------------------------

Date: 21 May 2003 03:50:56 -0700
From: clos@trentu.ca (Netware60)
Subject: finding "mailto:" strings in html files
Message-Id: <55964b31.0305210250.3cc91f02@posting.google.com>

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
 .
 .
 .
 .

Sorted on user name if possible.

How would i do this in perl?

TIA


------------------------------

Date: Wed, 21 May 2003 11:24:13 GMT
From: "Nils Petter Vaskinn" <no@spam.for.me.invalid>
Subject: Re: finding "mailto:" strings in html files
Message-Id: <pan.2003.05.21.11.24.15.112532@spam.for.me.invalid>

On Wed, 21 May 2003 03:50:56 -0700, Netware60 wrote:

> I need to search thru a list of html text files and find and extract
[snip extract mailto from html]
> TIA

I think you'll have to tell why you want to do this or a lot of people
will assume you are harvesting email addresses for spam, and choose not to
help you.

NPV


------------------------------

Date: Wed, 21 May 2003 11:10:02 +0100
From: "Chris" <sendspamhere@amcc.org.uk>
Subject: Help With IO::Socket::INET
Message-Id: <eeIya.750$qI5.49452@newsfep2-gui.server.ntli.net>

I am trying to write a perl CGI that reads a remote internet page.
I have written some code to test the principle, that works fine on my PC
with Perl Builder, but when I upload it to the server it will not work. The
connection is made, (ie the code does not die) but no responce is read back,
so $buf remains empty.
I have tried reading from various sites, with no luck.
My test code is:

#!/usr/bin/perl
use DBI;
use CGI qw/:standard/;
use CGI::Carp qw(fatalsToBrowser);
use IO::Socket;
my $line;
my $host="amcc.org.uk";
my $getstring="GET http://www.microsoft.com\n";
my $sock = new IO::Socket::INET(PeerAddr => $host, PeerPort => 80, Proto =>
'tcp') or die "couldn't connect";
print $sock $getstring;
my $buf="";
my $in;
while ($in = <$sock>){
$buf.=$in;
}
close($sock);
print header();
print<<"EOF";
<html>
<body>
$buf
</body>
</html>

EOF
#End

My server is on supanames (UK) which run Linux






------------------------------

Date: Wed, 21 May 2003 11:18:00 +0100
From: Chris Lowth <dont@want.spam>
Subject: Re: Help With IO::Socket::INET
Message-Id: <tnIya.9560$Mu3.177919@newsfep4-glfd.server.ntli.net>

Chris wrote:

> I am trying to write a perl CGI that reads a remote internet page.
> I have written some code to test the principle, that works fine on my PC
> with Perl Builder, but when I upload it to the server it will not work.
> The connection is made, (ie the code does not die) but no responce is read
> back, so $buf remains empty.
> I have tried reading from various sites, with no luck.
> My test code is:
> 
> #!/usr/bin/perl
> use DBI;
> use CGI qw/:standard/;
> use CGI::Carp qw(fatalsToBrowser);
> use IO::Socket;
> my $line;
> my $host="amcc.org.uk";
> my $getstring="GET http://www.microsoft.com\n";
> my $sock = new IO::Socket::INET(PeerAddr => $host, PeerPort => 80, Proto
> => 'tcp') or die "couldn't connect";
> print $sock $getstring;
> my $buf="";
> my $in;
> while ($in = <$sock>){
> $buf.=$in;
> }
> close($sock);
> print header();
> print<<"EOF";
> <html>
> <body>
> $buf
> </body>
> </html>
> 
> EOF
> #End
> 
> My server is on supanames (UK) which run Linux

What version of perl (and the modules) do you have on
 .. your PC
 .. your server

?

Chris

-- 
Real address: chris at lowth dot sea oh em.
GPL e-mail anti-virus: http://protector.sourceforge.net
Linux IPTables wizzards: http://www.lowth.com/LinWiz


------------------------------

Date: Wed, 21 May 2003 12:30:03 +0100
From: "Chris" <sendspamhere@amcc.org.uk>
Subject: Re: Help With IO::Socket::INET
Message-Id: <gpJya.687$PT3.53034@newsfep1-win.server.ntli.net>


"Chris Lowth" <dont@want.spam> wrote in message
news:tnIya.9560$Mu3.177919@newsfep4-glfd.server.ntli.net...
> Chris wrote:
>
> > I am trying to write a perl CGI that reads a remote internet page.
> > I have written some code to test the principle, that works fine on my PC
> > with Perl Builder, but when I upload it to the server it will not work.
> > The connection is made, (ie the code does not die) but no responce is
read
> > back, so $buf remains empty.
> > I have tried reading from various sites, with no luck.
> > My test code is:
> >
> > #!/usr/bin/perl
> > use DBI;
> > use CGI qw/:standard/;
> > use CGI::Carp qw(fatalsToBrowser);
> > use IO::Socket;
> > my $line;
> > my $host="amcc.org.uk";
> > my $getstring="GET http://www.microsoft.com\n";
> > my $sock = new IO::Socket::INET(PeerAddr => $host, PeerPort => 80, Proto
> > => 'tcp') or die "couldn't connect";
> > print $sock $getstring;
> > my $buf="";
> > my $in;
> > while ($in = <$sock>){
> > $buf.=$in;
> > }
> > close($sock);
> > print header();
> > print<<"EOF";
> > <html>
> > <body>
> > $buf
> > </body>
> > </html>
> >
> > EOF
> > #End
> >
> > My server is on supanames (UK) which run Linux
>
> What version of perl (and the modules) do you have on
> .. your PC
> .. your server
>
> ?
>
> Chris
>

My local perl version is 5.6.1, server is 5.6
IO::Socket::Inet version is 1.25 at both locations





------------------------------

Date: Wed, 21 May 2003 08:39:59 -0400
From: "Ben Kennedy" <bkennedy@hmsonline.com>
Subject: Re: Help With IO::Socket::INET
Message-Id: <EWOdndc29fc97lajXTWJiA@giganews.com>


"Chris" <sendspamhere@amcc.org.uk> wrote in message
news:eeIya.750$qI5.49452@newsfep2-gui.server.ntli.net...
> I am trying to write a perl CGI that reads a remote internet page.
> I have written some code to test the principle, that works fine on my PC
> with Perl Builder, but when I upload it to the server it will not work.
The
> connection is made, (ie the code does not die) but no responce is read
back,
> so $buf remains empty.
> I have tried reading from various sites, with no luck.
> My test code is:

In case you're not aware of it, the "LWP" module does exactly what you're
trying to go.  For example,

use LWP::Simple;

my $url = "http://...";
my $content = get($url);

There is also a more advanced LWP::UserAgent module that allows you to craft
custom message objects that let you change any aspect of your headers.

Also, I would not be surpprised if your ISP is simply blocking all outbound
traffic on port 80 in order to curtail worms and such - you could find a
site that runs on 8080 and see if you get the same behavior.

--Ben Kennedy




------------------------------

Date: 21 May 2003 05:45:26 -0700
From: yuchung@mail.com (Yuchung Cheng)
Subject: Help with perl string match
Message-Id: <c5a86edd.0305210445.e036e97@posting.google.com>

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


------------------------------

Date: Wed, 21 May 2003 12:56:55 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Help with perl string match
Message-Id: <3ecb7750.3535556521@news.cis.dfn.de>

On 21 May 2003 05:45:26 -0700, yuchung@mail.com (Yuchung
Cheng) wrote:

>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+)/;

You reversed = and ~ in your assignment operator
and you will need a different regex for the $ip_addr:

my ($epoch_sec, $nsec, $nrexmit, $timeout, $ip_addr) = $line

=~ /^(\d+):(\d+).*rexmits (\d+), timeout (\d+) ms, destined 
for ([\w|\.]+)/;
-- 
Regards, Helgi Briem
helgi DOT briem AT decode DOT is


------------------------------

Date: 21 May 2003 12:59:25 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Help with perl string match
Message-Id: <baft7d$ndg$3@mamenchi.zrz.TU-Berlin.DE>

Yuchung Cheng <yuchung@mail.com> wrote in comp.lang.perl.misc:
> 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.

"...is not working" is not an error description.  If you want people
to help you with a problem, say what you expected, and what happened
instead.  It is rude to expect others to guess your expectations and
test the code against it to find out what you consider "wrong".

One problem is the last part of your regex:  "\w+" doesn't match a dotted
quad because "." isn't a word character.

Anno


------------------------------

Date: Wed, 21 May 2003 10:47:00 GMT
From: inwap@inwap.com (Joe Smith)
Subject: Re: High CPU usage and mem leak problem in a perl routine
Message-Id: <EOIya.18720$io.353021@iad-read.news.verio.net>

In article <pan.2003.05.13.08.20.15.969025@no_spam.movielink.net.au>,
Tony <anthony@no_spam.movielink.net.au> wrote:
>my $file = "/some/path/file";
>
>START: open (FILE, $file) or die "Could not open: $file $!\n";
>         while (my $lines = <FILE>) {
>          chomp ($lines);
>          ...processing the data...
>            {...more processing...
>            fork_sub($some_data);
>            }
>       }
>goto START;   

sub mtime { (stat $_[0])[9]; }

my $file_mtime = 0;

while (1) {		# Loop forever
  if (mtime($file) == $file_mtime) {
    sleep 60;		# Config file not modified; sleep a minute.
  } else {
    ....		# Process the modified configuration file.
}

	-Joe
-- 
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


------------------------------

Date: Wed, 21 May 2003 10:19:55 GMT
From: inwap@inwap.com (Joe Smith)
Subject: Re: Image::Size problem under Win 98
Message-Id: <fpIya.18713$io.353021@iad-read.news.verio.net>

In article <4bv8cv824bgdlqqft8m42u4hev4muo933u@4ax.com>,
m  <removeX_stevensx4000xATearthlinxk.next> wrote:

>my ($w,$h,$t) = imgsize("Gopen.jpg") || warn;
>my @a    = attr_imgsize("Gopen.jpg") || warn;
>
>am I just programming from the elbows down?

Change all occurances of '|| warn' and '|| die'
to 'or warn' and 'or die' to solve your problem.

 my ($w,$h,$t) = imgsize("Gopen.jpg") or warn;
 my @a    = attr_imgsize("Gopen.jpg") or warn;

		-Joe
-- 
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


------------------------------

Date: Wed, 21 May 2003 08:14:32 -0400
From: Mina Naguib <spam@thecouch.homeip.net>
Subject: Re: multiple sort subroutine
Message-Id: <M4Kya.27852$ty5.385441@weber.videotron.net>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

Joe Smith wrote:
> In article <5fWxa.7754$7B6.85884@wagner.videotron.net>,
> Mina Naguib  <spam@thecouch.homeip.net> wrote:
>>>>sub seniority {
>>>>    my $res;
>>>>    foreach (qw(SALARY AGE LAST FIRST)) {
>>>>         if (/^\d+$/) {
>>>>              $res = $a->{$_} <=> $b->{$_};
>>>>         }
>>>>         else {
>>>>              $res = $a->{$_} cmp $b->{$_};
>>>>         }
>>>>         return $res if $res;
>>>>    }
>>>>    return 0;
> 
> The above code is testing the wrong variable for being numeric.
> It should meet Dave's requirements after changing
> 
> 
>>>>         if (/^\d+$/) {
> to
>              if ($a->{$_} =~ /^\d+$/ && $b->{$_} =~ /^\d+$/) {
> Dave,
>   The corrected code will use '<=>' on fields that consist of
> digits only and 'cmp' otherwise.  Like 'or', it will short-circuit
> the evaluation when it is obvious that a difference has been detected.
> In other words, seniority() will do the comparison as you asked.
> 	-Joe

Aha yes.  Thanks for catching that one Joe.

-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE+y22seS99pGMif6wRAtyjAKCmNizvMc/IMi4ptUEuOsO21RpsngCg6+Fi
LDsoyOi+F1UIB5I1EEOTVYQ=
=qYA0
-----END PGP SIGNATURE-----



------------------------------

Date: Wed, 21 May 2003 12:25:32 GMT
From: "Alan Watson" <waty@powerup.com.au>
Subject: o conf urllist
Message-Id: <0fKya.487$iv4.4594@news-server.bigpond.net.au>

I can't seem to reset the default ftp site in CPAN. Can anyone tell me how?
I think the command is something like:

o conf urllist

Thanks,

Alan




------------------------------

Date: Wed, 21 May 2003 12:49:29 +0000 (UTC)
From: veky@cromath.math.hr (Veky)
Subject: Re: why key is added to hash after defined ?
Message-Id: <bafskp$o8u$1@bagan.srce.hr>

Dok je Veky citao comp.lang.perl.misc,
pod PIDom 16835 (290511 off, 78 to go...),
primijetio je kreaturu zvanu Matija Papec <mpapec@yahoo.com>,
ispod cijih su prstiju izasle (izmedu ostalih) sljedece rijeci:

|>The conclusion would be wrong, and, of cource, non valid, by what I
|>wrote down there.
|I thought that with "this way," you've refering to previous expresion.
|Obviously you weren't.

Yes, I was... but only in one direction. ;-)

|>|I see, you're mathematician.. 
|>Of course. Is it so obvious:-? :-)
|I think it is, my math teacher spoke in similar way. :))

ok then. Where are you:-?

|>Not exactly, but... let's say so.
|>Math faculty in Zagreb.
|Cool, kaj se od jezika najvise preferira, C?

OMG... are you aware of which group we are on:-?
You think mentioning C will pass unnoticed because of Croatian:-? :-))

The best working math-related computer-understandable language in the
world - perl, of course... :-)

-- 
\#{%	Sad gradi svoj grad iz snova... znaj da mozes i znaj da znas...


------------------------------

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 5018
***************************************


home help back first fref pref prev next nref lref last post