[23421] in Perl-Users-Digest
Perl-Users Digest, Issue: 5638 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 9 06:05:46 2003
Date: Thu, 9 Oct 2003 03:05:08 -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 Thu, 9 Oct 2003 Volume: 10 Number: 5638
Today's topics:
Re: [OT] please ignore <abigail@abigail.nl>
Archive::Tar and write to an open filehandle <ahamm@mail.com>
Re: Archive::Tar and write to an open filehandle <j.m.f.dev.null@gmx.net>
data manipulation <bNOoONb@not.pilbara.net.au>
Re: data manipulation <noreply@gunnar.cc>
Re: EBCDIC-ASCII Conversation <lv@yahoo.com>
Re: EBCDIC-ASCII Conversation <flavell@ph.gla.ac.uk>
Re: How To activate command line history in debugger? <kurt.kronschnabl-nospam@ica-intercom-akademie.de>
Re: i am frantically outer, so I smell you <ujyfjap@yjepv.org>
Re: Mail::POP3Client <sfandino@yahoo.com>
Re: Mail::POP3Client <kalinaubears@iinet.net.au>
Re: Newbie needs some help <go@away.spam>
Re: Newbie needs some help (Sam Holden)
Question about comparing Remote image with Local one (Vijoy Varghese)
Re: Question about comparing Remote image with Local on <neil.shadrach@corryn.com>
regex to get OS from combined log <vervoom@hotmail.com>
Re: Rookie: HTML::TableExtract test will not print <invalid-email@rochester.rr.com>
Re: Rookie: HTML::TableExtract test will not print <sdfg@sdg.com>
Re: Rookie: HTML::TableExtract test will not print (Sam Holden)
Search-replace in multiple files? <no-email@home.se>
Re: Search-replace in multiple files? <noreply@gunnar.cc>
Re: Search-replace in multiple files? <kuujinbo@hotmail.com>
Re: Segmentation Fault - core dumped. Do I have latest <jwillmore@remove.adelphia.net>
Switch and function prototypes <jgottman@carolina.rr.com>
Re: <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 09 Oct 2003 07:33:26 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: [OT] please ignore
Message-Id: <slrnboa3q6.1aa.abigail@alexandra.abigail.nl>
Swen Killer (swen_killer@yahoo.co.uk) wrote on MMMDCLXXXIX September
MCMXCIII in <URL:news:b8e66b67.0310071154.61f172a0@posting.google.com>:
\\ -
Done! Welcome to my killfile.
Abigail
--
package Z;use overload'""'=>sub{$b++?Hacker:Another};
sub TIESCALAR{bless\my$y=>Z}sub FETCH{$a++?Perl:Just}
$,=$";my$x=tie+my$y=>Z;print$y,$x,$y,$x,"\n";#Abigail
------------------------------
Date: Thu, 9 Oct 2003 16:10:50 +1000
From: "Andrew Hamm" <ahamm@mail.com>
Subject: Archive::Tar and write to an open filehandle
Message-Id: <bm2u5e$ht4cu$1@ID-79573.news.uni-berlin.de>
Perl 5.8.0
Archive::Tar 1.05
The doco for the write method says:
$tar->write ( [$file, $compressed, $prefix] )
Write the in-memory archive to disk. The first argument
can either be the name of a file or a reference to an
already open filehandle (a GLOB reference). If the second
argument is true, the module will use IO::Zlib to write
the file in a compressed format. If IO::Zlib is not
available, the "write" method will fail and return.
But using either of these:
open FH, "| filter" or die "cannot pipe to filter: $!\n";
my $fh = IO::File->new("| filter") or die "cannot pipe to filter: $!\n";
with any of these:
$tar->write(*FH);
$tar->write(\*FH);
$tar->write($fh);
I just end up with a file called 'GLOB(hexnum)' or 'REF(hexnum)' or
'IO::File=GLOB(hexnum)'.
What am I missing/mis-understanding?
TIA
------------------------------
Date: Thu, 09 Oct 2003 11:24:09 +0200
From: Jens M. Felderhoff <j.m.f.dev.null@gmx.net>
Subject: Re: Archive::Tar and write to an open filehandle
Message-Id: <bm39ft$mc0$1@newsreader2.netcologne.de>
"Andrew Hamm" <ahamm@mail.com> wrote:
> Perl 5.8.0
> Archive::Tar 1.05
I have 0.22, however...
> The doco for the write method says:
>
> $tar->write ( [$file, $compressed, $prefix] )
> Write the in-memory archive to disk. The first argument
> can either be the name of a file or a reference to an
[...]
> But using either of these:
>
> open FH, "| filter" or die "cannot pipe to filter: $!\n";
> my $fh = IO::File->new("| filter") or die "cannot pipe to filter: $!\n";
I don't know why you'll want to write to a pipe. With my Archive::Tar
version writing to a pipe gives a
Can't call method "gzwrite" on unblessed reference at
/usr/lib/perl5/site_perl/5.005/Archive/Tar.pm line 521.
> with any of these:
>
> $tar->write(*FH);
> $tar->write(\*FH);
> $tar->write($fh);
>
> I just end up with a file called 'GLOB(hexnum)' or 'REF(hexnum)' or
> 'IO::File=GLOB(hexnum)'.
Try something like the following:
$tar->add_files("foo", "bar", "froz", "foobar");
open TARFILE, ">foo.tar" or die "Cannot open tarfile:$!\n";
$tar->write(*TARFILE{IO}); # or \*TARFILE or *TARFILE{FILEHANDLE}
close TARFILE;
That should give you a foo.tar file including the four archive
members.
Cheers
Jens
--
(Intentionally left blank.)
------------------------------
Date: Thu, 9 Oct 2003 16:36:44 +0930
From: "Bob" <bNOoONb@not.pilbara.net.au>
Subject: data manipulation
Message-Id: <bm31e4$6v4$1@mws-stat-syd.cdn.telstra.com.au>
I have a log file i want to further manipulate, and be able to extract info
from.
(the actual output data is from qmail-qread command )
the format of the file is as below
6 Oct 2003 14:01:12 GMT #23456 12345 <email@fake.com>
remote somone@fake.com
done someonelse@fake.com
6 Oct .....
the format is always date, line, followed by 1 or more info lines, that are
either \t or " " indented.
I want to grap each of these "chunks" and then run a regex and output them
when I get a match.
So, using the data I have, I want to read in the (3 lines in this case, but
can 2 to ???? lines) and then output the whole block if I match a regex.
If anyone can recommend some place to start reading It would be appreciated.
------------------------------
Date: Thu, 09 Oct 2003 10:59:39 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: data manipulation
Message-Id: <bm3848$i2lpa$1@ID-184292.news.uni-berlin.de>
Bob wrote:
> I have a log file i want to further manipulate, and be able to
> extract info from.
>
> (the actual output data is from qmail-qread command )
>
> the format of the file is as below
>
> 6 Oct 2003 14:01:12 GMT #23456 12345 <email@fake.com>
> remote somone@fake.com
> done someonelse@fake.com
> 6 Oct .....
>
> the format is always date, line, followed by 1 or more info lines,
> that are either \t or " " indented.
>
> I want to grap each of these "chunks" and then run a regex and
> output them when I get a match.
>
> So, using the data I have, I want to read in the (3 lines in this
> case, but can 2 to ???? lines) and then output the whole block if I
> match a regex.
>
> If anyone can recommend some place to start reading It would be
> appreciated.
http://learn.perl.org/
I'm quite sure that you were able to figure that out yourself, though,
and that you actually wanted somebody to write some code, without
having given it a try yourself first. :( I'd be surprised if there
weren't better ways, but this is one possible approach:
#!/usr/bin/perl
use strict;
use warnings;
my ($chunk, @chunks);
open FH, 'logfile' or die $!;
while (<FH>) {
if (/^\S/) {
push @chunks, $chunk if $chunk;
$chunk = '';
}
$chunk .= $_;
}
close FH;
push @chunks, $chunk;
# print chunks that include the domain fake.com
print grep { /\@fake\.com/ } @chunks;
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Thu, 9 Oct 2003 00:05:33 -0500
From: "len v" <lv@yahoo.com>
Subject: Re: EBCDIC-ASCII Conversation
Message-Id: <A06hb.1716$5M.41894@dfw-read.news.verio.net>
"Alan J. Flavell" <flavell@ph.gla.ac.uk> wrote in message
news:Pine.LNX.4.53.0310061859150.31525@ppepc56.ph.gla.ac.uk...
> On Mon, 6 Oct 2003, Reinhard Burgmann wrote:
>
> > I have to convert a EBCDIC-File into an ASCII-Code in perl.
Unfortunately
> > part's of the files are in packed format I have to do this in perl.
>
> Clarification, please. Are you saying that these data records contain
> "packed decimal" fields? Then a mere character code conversion from
> EBCDIC to ASCII is not going to help. You need to know the format of
> your records (i.e which ranges contain packed-decimal), and unpack
> those into signed decimal format before continuing.
>
> Presumably Perl can do that with an appropriate unpack() template, but
> it's not something I've had reason to try (I was fresh out of IBM
> mainframes around the time that I first met Perl, and anyway, in
> scientific work we hardly ever had to deal with packed-decimal data in
> practice).
Try Convert::IBM390.pm using the umpackeb() subroutine
http://search.cpan.org/~grommel/Convert-IBM390-0.15/IBM390.pm
Len
------------------------------
Date: Thu, 9 Oct 2003 10:37:44 +0100
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: EBCDIC-ASCII Conversation
Message-Id: <Pine.LNX.4.53.0310091036240.6452@ppepc56.ph.gla.ac.uk>
On Thu, 9 Oct 2003, len v wrote:
> Try Convert::IBM390.pm using the umpackeb() subroutine
>
> http://search.cpan.org/~grommel/Convert-IBM390-0.15/IBM390.pm
Makes sense to me - thanks for pointing it out. I particularly liked
this comment at the end:
| BUGS
|
| None, of course. What do you think this is -- Unix?
------------------------------
Date: Thu, 09 Oct 2003 07:40:58 +0200
From: Kurt Kronschnabl <kurt.kronschnabl-nospam@ica-intercom-akademie.de>
To: Peter@PSDT.com
Subject: Re: How To activate command line history in debugger?
Message-Id: <3F84F4EA.7000607@ica-intercom-akademie.de>
Peter Scott wrote:
>>Hello Peter.
> My news server spasmed and dropped this thread from its spool, and I didn't
> see any reply to my emails to you. Install Term::ReadKey as root with
>
> perl -MCPAN -e shell
> CPAN> install Term::ReadKey
> CAPAN> q
>
> and email me if that doesn't fix the problem.
>
ok, here my reply from 10/01/03 once again:
Hello Peter.
As already told, there is no "ReadKey.pm" in a Knoppix and Suse 8.2
installation. ReadLine is available in both distries. But only under
Suse it works.
Here the results for ReadKey:
knoppix@p01kno:~$ perl -MTERM::ReadKey -e 0
Can't locate TERM/ReadKey.pm in @INC (@INC contains: /etc/perl
/usr/local/lib/perl/5.8.0 /usr/local/share/perl/5.8.0 /usr/lib/perl5
/usr/share/perl5 /usr/lib/perl/5.8.0 /usr/share/perl/5.8.0
/usr/local/lib/site_perl .).
BEGIN failed--compilation aborted.
knoppix@p01kno:~$ perl -dle 'print $INC{"Term/ReadKey.pm"}'
Loading DB routines from perl5db.pl version 1.19
Editor support available.
Enter h or `h h' for help, or `man perldebug' for more help.
main::(-e:1): print $INC{"Term/ReadKey.pm"}
DB<1> c
Debugged program terminated. Use q to quit or R to restart,
use O inhibit_exit to avoid stopping after program termination,
h q, h R or h O to get additional info.
DB<1>
knoppix@p01kno:~$ perl -MCPAN -le 'print $INC{"Term/ReadKey.pm"}'
knoppix@p01kno:~$
> Are you sure that root doesn't have a
> different path causing it to run a different perl?
Yes, very shure. Under root it is the same effect.
And here the results for ReadLine:
knoppix@p01kno:~$ perl -dle 'print $INC{"Term/ReadKey.pm"}'
Loading DB routines from perl5db.pl version 1.19
Editor support available.
Enter h or `h h' for help, or `man perldebug' for more help.
main::(-e:1): print $INC{"Term/ReadKey.pm"}
DB<1> c
Debugged program terminated. Use q to quit or R to restart,
use O inhibit_exit to avoid stopping after program termination,
h q, h R or h O to get additional info.
DB<1> q
knoppix@p01kno:~$ perl -MCPAN -le 'print $INC{"Term/ReadKey.pm"}'
knoppix@p01kno:~$ perl -MTERM::ReadLine -e 0
Can't locate TERM/ReadLine.pm in @INC (@INC contains: /etc/perl
/usr/local/lib/perl/5.8.0 /usr/local/share/perl/5.8.0 /usr/lib/perl5
/usr/share/perl5 /usr/lib/perl/5.8.0 /usr/share/perl/5.8.0
/usr/local/lib/site_perl .).
BEGIN failed--compilation aborted.
knoppix@p01kno:~$ perl -dle 'print $INC{"Term/ReadLine.pm"}'
Loading DB routines from perl5db.pl version 1.19
Editor support available.
Enter h or `h h' for help, or `man perldebug' for more help.
main::(-e:1): print $INC{"Term/ReadLine.pm"}
DB<1> c
/usr/share/perl/5.8.0/Term/ReadLine.pm
Debugged program terminated. Use q to quit or R to restart,
use O inhibit_exit to avoid stopping after program termination,
h q, h R or h O to get additional info.
DB<1> q
knoppix@p01kno:~$ perl -MCPAN -le 'print $INC{"Term/ReadLine.pm"}'
knoppix@p01kno:~$
Hope this tells you more than me :=)
Best Regards, Kurt
------------------------------
Date: Thu, 9 Oct 2003 00:13:50 GMT
From: Said el-Hassan <ujyfjap@yjepv.org>
Subject: Re: i am frantically outer, so I smell you
Message-Id: <6f31a80b.fe8830ba@akiwhul.org>
<HTML><!What did Woodrow care the film throughout the glad fig?>
<!-- Copyright 2003 The Media Foundation. All Rights Reserved -->
<HEAD><TITLE>rethink the cool</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252"><LINK
title=unbrandamerica href="http://www.blackspotsneaker.org/img/01/style.css" type=text/css
rel=stylesheet><!-- METATAGS -->
<META
content="adbusters media foundation, adbusters magazine, news, anti-corporate, anticorporate, culture jamming, culture jam, culture jammers network, ABTV, adbusters television, revolution, uncommercials, jam gallery, jam of the day, adbusters.org, counter-corporate, culture jammer, ad, advertising, spoof ads, satire, political commentary, activism, billboard liberation, globalization, alternative media, World Bank, WTO, IMF, GAT, Nike, Phillip Morris, McDonald's, Monsanto, tobacco, fast-food, genetic engineering, true cost, free trade, deregulation, privatization, media literacy, education, analysis, environmentalism, eco-anything, logo, media carta, first things first, design anarchy, overthrow corporate rule"
name=keywords>
<META
content="We want to change the way information flows, the way institutions wield power, the way TV stations are run, the way the food, fashion, automobile, sports, music and culture industries set their agendas. Above all, we want to change the way we interact with the mass media and the way in which meaning is produced in our society."
name=description><!-- STYLE -->
<STYLE>#layer {
Z-INDEX: 2; LEFT: 465px; VISIBILITY: visible; WIDTH: 140px; POSITION: absolute; TOP: 216px; HEIGHT: 80px
}
BODY {
BACKGROUND: url(/navigation/navbar.gif) white repeat-x
}
</STYLE>
<SCRIPT language=JavaScript>
<!--
if (document.images) {
img1on = new Image(); img1on.src = "http://www.blackspotsneaker.org/buttons/01on.gif";
img2on = new Image(); img2on.src = "http://www.blackspotsneaker.org/buttons/02on.gif";
img3on = new Image(); img3on.src = "http://www.blackspotsneaker.org/buttons/03on.gif";
img4on = new Image(); img4on.src = "http://www.blackspotsneaker.org/buttons/04on.gif";
img5on = new Image(); img5on.src = "http://www.blackspotsneaker.org/buttons/05on.gif";
img6on = new Image(); img6on.src = "http://www.blackspotsneaker.org/buttons/06on.gif";
img7on = new Image(); img7on.src = "http://www.blackspotsneaker.org/buttons/logo1.gif";
img1off = new Image(); img1off.src = "http://www.blackspotsneaker.org/buttons/01.gif";
img2off = new Image(); img2off.src = "http://www.blackspotsneaker.org/buttons/02.gif";
img3off = new Image(); img3off.src = "http://www.blackspotsneaker.org/buttons/03.gif";
img4off = new Image(); img4off.src = "http://www.blackspotsneaker.org/buttons/04.gif";
img5off = new Image(); img5off.src = "http://www.blackspotsneaker.org/buttons/05.gif";
img6off = new Image(); img6off.src = "http://www.blackspotsneaker.org/buttons/06.gif";
img7off = new Image(); img7off.src = "http://www.blackspotsneaker.org/buttons/logo.gif";
}
function imgOn(imgName) {
if (document.images) {
document[imgName].src = eval(imgName + "on.src");
}
}
function imgOff(imgName) {
if (document.images) {
document[imgName].src = eval(imgName + "off.src");
}
}
// -->
</SCRIPT>
<!-- end STYLE -->
<!Otherwise the sauce in Katherine's tyrant might smell some raw shirts.>
<SCRIPT name="Popups">
function shoe_size()
{
window.open('http://www.blackspotsneaker.org/03/individual/chart.html','pop','width=650,height=400,menubar=no,scrollbars=yes,toolbar=no')
}
</SCRIPT>
<META content="MSHTML 6.00.2800.1170" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff><!-- NAVIGATION -->
<TABLE cellSpacing=0 cellPadding=0 width=750 bgColor=#000000 border=0>
<TBODY>
<TR vAlign=top>
<TD align=left width=180><A onmouseover="imgOn('img7');"
onmouseout="imgOff('img7')" href="http://adbusters.org/home"><IMG
height=30 alt=Adbusters src="http://www.blackspotsneaker.org/buttons/logo.gif" width=140 border=0
name=img7></A> </TD>
<TD noWrap align=left width=420>
<TABLE cellSpacing=0 cellPadding=0 width=570 border=0>
<TBODY>
<TR>
<TD align=left width=381><A onmouseover="imgOn('img1');"
onmouseout="imgOff('img1')"
href="http://adbusters.org/campaigns/"><IMG height=30 alt=Campaigns
src="http://www.blackspotsneaker.org/buttons/01.gif" width=74 border=0 name=img1></A><A
onmouseover="imgOn('img2');" onmouseout="imgOff('img2')"
href="http://adbusters.org/magazine/"><IMG height=30 alt=Magazine
src="http://www.blackspotsneaker.org/buttons/02.gif" width=69 border=0 name=img2></A><A
onmouseover="imgOn('img3');" onmouseout="imgOff('img3')"
href="http://adbusters.org/creativeresistance/"><IMG height=30
alt="Creative Resistance" src="http://www.blackspotsneaker.org/buttons/03.gif" width=127
border=0 name=img3></A><A onmouseover="imgOn('img5');"
onmouseout="imgOff('img5')"
href="https://secure.adbusters.org/orders/"><IMG height=30
alt=Orders src="http://www.blackspotsneaker.org/buttons/05.gif" width=70 border=0
name=img5></A></TD>
<TD align=right width=189><A onmouseover="imgOn('img6');"
onmouseout="imgOff('img6')"
href="http://adbusters.org/information/"><IMG height=30
alt=Information src="http://www.blackspotsneaker.org/buttons/06.gif" width=39 border=0
name=img6></A></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR><BR><!-- end NAVIGATION --><BR>
<TABLE cellSpacing=0 cellPadding=0 border=0>
<TBODY>
<TR>
<TD width=60></TD>
<TD class=px15 width=400><B><BR>This is a ground-breaking marketing scheme
to uncool Nike. If it succeeds, it will set a precedent that will
revolutionize capitalism. <BR></B></TD>
<TD align=right width=250></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=750 border=0>
<TBODY>
<TR>
<TD align=middle><BR><BR><IMG height=333 alt=""
src="http://www.blackspotsneaker.org/img/01/shoe05.jpg" width=712 border=0><BR><BR><BR><IMG
height=193 alt="" src="http://www.blackspotsneaker.org/img/01/phil_knigh_had_a_dream.gif" width=475
border=0><BR><BR><BR></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=750 border=0>
<TBODY>
<TR>
<TD></TD>
<TD class=px15 width=400><B>For years, Nike was the undisputed champion of
logo culture, its swoosh an instant symbol of global cool. Today, Phil
Knight's Nike is a fading empire, badly hurt by years of "brand damage" as
activists and culture jammers fought back against mindfuck marketing and
dirty sweatshop labor.<BR><BR>Now a final challenge. We take on Phil at
his own game - and win. We turn the shoes we wear into a counterbranding
game. The swoosh versus the anti-swoosh. Which side are you
on?<BR><BR>Adbusters has been doing R&D for more than a year, and
guess what? Making a shoe - a good shoe - isn't exactly rocket science.
With a network of supporters, we're getting ready to launch the
<I>blackSpot</I> sneaker, the world's first grassroots anti-brand. You can
help launch the <I>blackSpot</I> revolution.<BR><BR>THE BIG
QUESTION:<BR>Is it possible to take Phil Knight's billion-dollar marketing
momentum and, in a quick judo-like move, slap him onto the mat with the
power of his own PR thrust?<BR><BR><A
href="http://blackspotsneaker.org/02/">OUR KICK-ASS MARKETING
STRATEGY>><BR></A><BR></B></TD>
<TD align=left></TD></TR></TBODY></TABLE><BR><BR>
</BODY>
</HTML>
<!A lot of old active sauces will frantically scold the plates.>
------------------------------
Date: Thu, 09 Oct 2003 08:44:42 +0100
From: Salvador Fandino <sfandino@yahoo.com>
Subject: Re: Mail::POP3Client
Message-Id: <bm33lg$652$01$1@news.t-online.com>
Jeff Snoxell wrote:
> Hello,
>
> I'm trying to develop a script to do some Spam filtering for me. I've got my
> script running no problem. It connects to my pop box, scans and deletes
> emails, logs its activity etc.
I have already done one, you can get it from
http://yaspi.sourceforge.net
> Problem is, once the scan is completed, ALL my emails are marked as having
> been read, so when I subsequently download them with my mail client, they're
> not flagged up correctly.
do not download the full message, use "top" instead to retrieve the
headers and the first lines
> I've tried calling $client->unseen($i) for each message after I've finished
> with it; but this doesn't seem to do anything.
>
> Thanks for any help you can offer,
>
> Jeff Snoxell
> http://www.aetherweb.co.uk
>
>
------------------------------
Date: Thu, 09 Oct 2003 17:59:09 +1000
From: Sisyphus <kalinaubears@iinet.net.au>
Subject: Re: Mail::POP3Client
Message-Id: <3f851607$0$23601$5a62ac22@freenews.iinet.net.au>
Josef Möllers wrote:
>
> I'm doing the very same thing, but based on IMAP. There you can say
> $imap->Peek(1);
> to prevent the setting of the /Seen flag in the first place.
>
Not sure if that will work with Mail::POP3Client .... but it might. See
the section "IMAP COMPATIBILITY" near the end of the Mail::POP3Client
pod documentation.
Cheers,
Rob
--
To reply by email u have to take out the u in kalinaubears.
------------------------------
Date: Thu, 09 Oct 2003 03:29:46 GMT
From: "LaDainian Tomlinson" <go@away.spam>
Subject: Re: Newbie needs some help
Message-Id: <KC4hb.41545$5r1.26270@twister.southeast.rr.com>
"Helgi Briem" <HelgiBriem_1@hotmail.com> wrote:
<snip>
> open WANTED, $wanted or die "Cannot open $wanted:$!\n";
...
> close WANTED;
> open OUT, ">", $outfile
> or die "Cannot open $outfile for writing:$!\n";
...
> close OUT or die "Cannot close $outfile:$!\n";
> open INFO, $infofile or die "Cannot open $infofile:$!\n";
...
> close INFO;
Can I ask why you chose only to check the return value of close for OUT? Is
it because you're writing to a file rather than only reading from it? I can
see why a hung write might keep the file from closing properly, but could a
hung read not do the same for the other files?
Thanks for any clarification,
Brandan L.
--
bclennox AT eos DOT ncsu DOT edu
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.522 / Virus Database: 320 - Release Date: 9/29/2003
------------------------------
Date: 9 Oct 2003 03:41:41 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: Newbie needs some help
Message-Id: <slrnbo9m7l.ia9.sholden@flexal.cs.usyd.edu.au>
On Thu, 09 Oct 2003 03:29:46 GMT, LaDainian Tomlinson <go@away.spam> wrote:
> "Helgi Briem" <HelgiBriem_1@hotmail.com> wrote:
>
><snip>
>
>> open WANTED, $wanted or die "Cannot open $wanted:$!\n";
> ...
>> close WANTED;
>
>> open OUT, ">", $outfile
>> or die "Cannot open $outfile for writing:$!\n";
> ...
>> close OUT or die "Cannot close $outfile:$!\n";
>
>
>> open INFO, $infofile or die "Cannot open $infofile:$!\n";
> ...
>> close INFO;
>
> Can I ask why you chose only to check the return value of close for OUT? Is
> it because you're writing to a file rather than only reading from it? I can
> see why a hung write might keep the file from closing properly, but could a
> hung read not do the same for the other files?
A "hung read" will just cause the read to not return, and the script to
"freeze".
A failure to close a file open for reading is irrelevant from the point
of view of a script, and I can't think of a reason for such a failure to
occur (though there probably is, with something like NFS...).
A failure to close a file open for writing on the other hand is very
important. The data you have written to the file has possibly not been
written to the file after all. The disk could be full, for example.
Such data loss situations are important enough for a program to let
the user know in no uncertain terms that something has gone wrong.
--
Sam Holden
------------------------------
Date: 8 Oct 2003 23:26:10 -0700
From: viijv@thedifferenZ.com (Vijoy Varghese)
Subject: Question about comparing Remote image with Local one
Message-Id: <4c08aaff.0310082226.547ec7d6@posting.google.com>
Hello Group,
My final goal is to show a green/red gif image on my webpage when I am
available on yahoo chat. Yes for this I could have used the url
provided by yahoo
http://opi.yahoo.com/online?u=xxxx&m=g&t=2, where xxxx is my yahoo
userid. But the images yahoo print wont match with my webpage's
colors. So I want to display a custom one. Now I know some Perl and I
decided to give it a try.
I used the LWP module to get the image (either online image/ offline
image) from yahoo.
______
use LWP::UserAgent;
use LWP;
use CGI;
my $q=new CGI;
my $browser = LWP::UserAgent->new;
my @ns_headers = (
'User-Agent' => 'Mozilla/4.76 [en] (Win98; U)',
'Accept' => 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
image/png, */*',
'Accept-Charset' => 'iso-8859-1,*,utf-8',
'Accept-Language' => 'en-US',
);
my $url='http://opi.yahoo.com/online?u=vishnutp3&m=g&t=2';
$res = $browser->get($url, @ns_headers);
print $q->header(-header=>'text/html');
print $res->content;
______
Now, I have the image from yahoo through my script. Now what I want is
to see if the image is that of 'online_status' or 'offline_status'.
And according to that, display my custom 'online/offline' image.
For this, what I can do is to get the two images from yahoo, when my
id is offline and when my id is online and save it.
Then when ever the script is called, compare the real_time image from
yahoo to the ones saved and take the decision.
Now, my question is, Which is the best way to compare the remote image
with the one I have on my server?
Can I embbed the data of the image on my server to the perl program,
will this be efficient(because no read from file is required)? I tried
everything using trial and error methods, but seems like the
difference between 'ascii' and 'binary' mode is doing the trick and I
am not able to compare the image from remote computer(yahoo) and the
image on myserver.
Can some one guide me, or give me pointers to some online resource
which will help me to solve the problem with maximum efficiency?
Thankyou for all helps in advance,
Regards
Vijoy Varghese
------------------------------
Date: Thu, 9 Oct 2003 07:14:05 +0000 (UTC)
From: Neil Shadrach <neil.shadrach@corryn.com>
Subject: Re: Question about comparing Remote image with Local one
Message-Id: <3F8509CE.6030403@corryn.com>
Vijoy Varghese wrote:
> Can some one guide me, or give me pointers to some online resource
> which will help me to solve the problem with maximum efficiency?
Generate some sort of checksum from the two images and store that in your program for comparison?
perl -e 'use Digest::MD5; if ( open(my $h, "/tmp/online.gif") )
{ my $m=Digest::MD5->new; $m->addfile($h); print $m->hexdigest,"\n";}'
------------------------------
Date: Fri, 10 Oct 2003 10:44:11 +0100
From: JS <vervoom@hotmail.com>
Subject: regex to get OS from combined log
Message-Id: <bm3aml$ubo$1@cspc1n11.baplc.com>
Hi,
I have the following regex to pull the IP address and Operating System
from a log in combined logformat:
if (/^(\d*.\d*.\d*.\d*).*\((.*;.*;.*)\)"/){
$ip=$1;
($j1,$j2,$os,$j3)=split /;/,$2;
$os=~s/^\s//;
For the most part this works, but every now and again I get an OS with
characters on the end of it e.g Windows NT 5.1)" "CTG=1065689351
Can anyone help me fix the regex above please? Here's a an example lines
from the log just to show how difficult this is:
12.110.129.108 - u768912 [07/Oct/2003:00:02:07 +0000] "GET
http://www.anpe.fr/offres/unitary/menu_cand_offre.jsp;jse
ssionid=1B0v5E29JcsNTVJlJPuDyvAP3E4O8zs1aeCZAVqvtCp8CCxYcZCk!1647636474!-1062731341!10000!7002
HTTP/1.1" 200 1733 "h
ttp://www.anpe.fr/offres/index.html?option=1&zone=64D&submit=1"
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;
.NET CLR 1.0.3705)"
166.2.123.85 - u617856 [07/Oct/2003:00:04:30 +0000] "GET
http://www.toptable.co.uk/images/restaurant/small/1389.jpg
HTTP/1.1" 200 1926
"http://www.toptable.co.uk/details.cfm?bf=172,1296,1361,394,1472,1284,40,1389,1322,1229,829,941,1
163,1387,785,1295,701,1092&&bfh=133" "Mozilla/4.0 (compatible; MSIE
6.0; Windows NT 5.1; .NET CLR 1.0.3705)" "CFI
D=1218747;CFTOKEN=ca5a76%2Dbfd444bd%2Db2d4%2D4b80%2Da588%2Df24fdd8e1484"
13.59.16.245 - - [07/Oct/2003:00:08:57 +0000] "OPTIONS
http://161.2.67.76/ HTTP/1.0" 504 1548 "-" "Microsoft-WebDAV-
MiniRedir/5.1.2600"
12.32.34.43 - - [07/Oct/2003:00:10:41 +0000] "GET
http://www.nyc.com/web/website.nsf/Images/$file/header.gif HTTP/1.1" 200
1023 "http://www.nyc.com/web/website.nsf" "Mozilla/4.0 (compatible; MSIE
5.01; Windows 95)"
Thanks for any help.
JS.
------------------------------
Date: Thu, 09 Oct 2003 01:43:46 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Rookie: HTML::TableExtract test will not print
Message-Id: <3F84BBC3.9070907@rochester.rr.com>
sdfgsd wrote:
> Hello,
>
> This script will not generate any output within the foreach loop. No errors
> or anything. $te tests ok with a hash. I can't figure it out.
>
> My sample .html file consists of 1 table (depth = 0, count = 0). Using perl
> 5.8/Suse 8.0
>
> Thanks in Advance
> ===========================
> #!/usr/bin/perl
>
> use warnings;
> use strict;
> use HTML::TableExtract;
>
> my $target = "op2.html";
----------------^^^^^^^^
The above string is the "HTML" you are supplying to the parse() method
below. The parse method expects an HTML string, not a file name, so you
need to read the file. Something like:
my $target = "op2.html";
open IN,$target or die "Oops, can't open $target for read, $!";
{local $/;$target=<IN>} #slurp it
close IN;
> my $te;
> my $ts;
> my $row;
>
> if (-e $target) { print "File Exists\n"; }
>
> $te = new HTML::TableExtract( depth => 0, count => 0 );
> $te->parse($target);
>
> print "We are here\n";
>
> foreach $ts ($te->table_states) {
> print "Table found at ", join(',', $ts->coords), ":\n";
> foreach $row ($ts->rows) {
> print " ", join(',', @$row), "\n";
> }
> }
...
HTH.
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: Thu, 09 Oct 2003 02:00:33 GMT
From: "sdfgsd" <sdfg@sdg.com>
Subject: Re: Rookie: HTML::TableExtract test will not print
Message-Id: <5j3hb.81860$eS5.62860@twister.tampabay.rr.com>
(snipped)
> > Thanks in Advance
> > ===========================
> > #!/usr/bin/perl
> >
> > use warnings;
> > use strict;
> > use HTML::TableExtract;
> >
> > my $target = "op2.html";
>
> ----------------^^^^^^^^
>
> The above string is the "HTML" you are supplying to the parse() method
> below. The parse method expects an HTML string, not a file name, so you
> need to read the file. Something like:
>
> my $target = "op2.html";
> open IN,$target or die "Oops, can't open $target for read, $!";
> {local $/;$target=<IN>} #slurp it
> close IN;
Thanks! This worked. If it's not too much trouble, could you give me a
sentence or two on this construct:
==> {local $/;$target=<IN>}
I know this'll send me scrambling to the books.
> > my $te;
> > my $ts;
> > my $row;
> >
> > if (-e $target) { print "File Exists\n"; }
> >
> > $te = new HTML::TableExtract( depth => 0, count => 0 );
> > $te->parse($target);
> >
> > print "We are here\n";
> >
> > foreach $ts ($te->table_states) {
> > print "Table found at ", join(',', $ts->coords), ":\n";
> > foreach $row ($ts->rows) {
> > print " ", join(',', @$row), "\n";
> > }
> > }
> ...
>
>
> HTH.
> --
> Bob Walton
> Email: http://bwalton.com/cgi-bin/emailbob.pl
>
>
------------------------------
Date: 9 Oct 2003 03:29:18 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: Rookie: HTML::TableExtract test will not print
Message-Id: <slrnbo9lge.ia9.sholden@flexal.cs.usyd.edu.au>
On Thu, 09 Oct 2003 02:00:33 GMT, sdfgsd <sdfg@sdg.com> wrote:
>
> Thanks! This worked. If it's not too much trouble, could you give me a
> sentence or two on this construct:
>==> {local $/;$target=<IN>}
> I know this'll send me scrambling to the books.
Slurps the entire file into $target.
See "perldoc perlvar" and the section on $/ for information on why.
The block and local are used to limit the effect of the
change to $/ (it is set to undef by the local) to just the
read into $target.
--
Sam Holden
------------------------------
Date: Thu, 09 Oct 2003 07:11:00 +0200
From: Roger Johansson <no-email@home.se>
Subject: Search-replace in multiple files?
Message-Id: <76r9ovc5gd38km8510j533iatsuedbjq83@4ax.com>
I have been trying to learn more about regular expressions. I have
tried many programs and read a lot of help files.
I finally managed to use regexp in BK-Replace-em to change all the
<body background...> tags in a number of html files into a plain
<body>, for example. My first success with regexpressions!
Search expression, replace expression:
<[Bb][Oo][Dd][Yy][^>]*> <body>
I learned how to use the Tcl/Tk script visual_regexp.tcl to test
regular expressions.
Now I want to learn how to use perl to perform the same type of tasks,
replacing one expression with another in multiple files, for example
in all files in a certain directory.
I have installed ActivePerl 5.8 and have read pod files for many
hours. But I still cannot write a program for this kind of task in
perl. I am a total beginner in using perl.
Could somebody please show me how to write a perl script to change a
number of files with a regexp search and replace, like I did in
BK-Replacem?
I have read perlrequick and perlretut and I understand how to use
regular expressions, but how do I handle the directory and files, and
maybe I have to create loops to read in each file into a string,
etc..?
A practical example script would help a lot.
--
Roger J.
(My email address is a spam trap, do not use it)
(Use my real email address, if you know it.)
------------------------------
Date: Thu, 09 Oct 2003 07:16:40 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Search-replace in multiple files?
Message-Id: <bm2r22$hfnlm$1@ID-184292.news.uni-berlin.de>
Roger Johansson wrote:
> Now I want to learn how to use perl to perform the same type of
> tasks, replacing one expression with another in multiple files, for
> example in all files in a certain directory.
>
> I have installed ActivePerl 5.8 and have read pod files for many
> hours. But I still cannot write a program for this kind of task in
> perl. I am a total beginner in using perl.
http://learn.perl.org/
> but how do I handle the directory and files, and maybe I have to
> create loops to read in each file into a string, etc..?
Something like that.
http://learn.perl.org/
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Thu, 09 Oct 2003 17:07:25 +0900
From: ko <kuujinbo@hotmail.com>
Subject: Re: Search-replace in multiple files?
Message-Id: <bm353o$e35$1@pin3.tky.plala.or.jp>
Roger Johansson wrote:
[snip]
> Now I want to learn how to use perl to perform the same type of tasks,
> replacing one expression with another in multiple files, for example
> in all files in a certain directory.
If its a simple search/replace, you can do it with a one-liner from your
shell:
*nix:
perl -p -i.orig -e 's/SEARCH/REPLACE/g' *.html
WINDOWS (wrapped, but should be on one line):
perl -p -i.orig -e "BEGIN {@ARGV = map { glob } @ARGV }
s/SEARCH/REPLACE/g" *.html
These commands will do replacement on HTML files in the current
directory. In the second example, you need the BEGIN block because the
Windows shell doesn't do wildcard expansion. 'perlrun' will give you a
better idea of what you can do with the -i, -p, and -e command line
switches.
[snip]
> I have read perlrequick and perlretut and I understand how to use
> regular expressions, but how do I handle the directory and files, and
> maybe I have to create loops to read in each file into a string,
> etc..?
'perlsyn' will help you understand loops, among other things. The
perlfaqs are all good if you haven't read them already - 'perlfaq5' will
help with reading files, etc. No offense, but it usually takes a while
(messing around with them) to *really* understand regular expressions.
I've read 'perlrequick' and 'perlretut' a few times, and still have a
way to go...
HTH - keith
------------------------------
Date: Thu, 09 Oct 2003 03:56:18 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Segmentation Fault - core dumped. Do I have latest version ?
Message-Id: <20031008235631.6716b4c7.jwillmore@remove.adelphia.net>
On 7 Oct 2003 19:08:15 -0700
ghendry@iprimus.com.au (Glen Hendry) wrote:
> I am getting repeated seg faults and dumped cores on Solaris
> (version details below).
>
> The problem is difficult to trace with debug print statements and
> often dissapears completely when print statements (which resolve
> variables) are added. The problem also stops happening when we run
> in debugging mode. It is very frustrating.
>
> We do use the 'use blah' statement and some have said in recent
> posts that these can cause the problem.
>
> Any advice would be greatly appreciated. (My current solution is to
> run the program in production with -d switch ;-)
<snip>
> config_args='-Dcc=gcc -B/usr/ccs/bin/'
Are you sure this is where the gcc compiler is? It looks more like
the path to the compiler that comes with Solaris. It may not be the
source of the issue, but worth looking into.
<snip>
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
Larkinson's Law: All laws are basically false.
------------------------------
Date: Thu, 09 Oct 2003 04:13:39 GMT
From: "Joe Gottman" <jgottman@carolina.rr.com>
Subject: Switch and function prototypes
Message-Id: <Tf5hb.41682$5r1.15256@twister.southeast.rr.com>
I tried to compile the following code in my Perl program:
#!/usr/bin/perl
use strict;
use Switch;
sub testSwitch ($)
{
my $param = shift;
switch ($param) {}
}
I got the following error:
syntax error at test.pl line 9, near ") {"
syntax error at test.pl line 10, near "}"
Execution of test.pl aborted due to compilation errors.
Strangely, when I declared the function with no prototype, or replaced the
"$" with "$;", the program compiled fine. Does anyone have any idea why
this is happening?
Joe Gottman
------------------------------
Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re:
Message-Id: <3F18A600.3040306@rochester.rr.com>
Ron wrote:
> Tried this code get a server 500 error.
>
> Anyone know what's wrong with it?
>
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {
(---^
> dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
...
> Ron
...
--
Bob Walton
------------------------------
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 5638
***************************************