[21833] in Perl-Users-Digest
Perl-Users Digest, Issue: 4037 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 28 11:05:49 2002
Date: Mon, 28 Oct 2002 08:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 28 Oct 2002 Volume: 10 Number: 4037
Today's topics:
Re: backticks/system command <smurch@no.spam>
HTML Text Substitution CGI <groovers@netvigator.com>
Re: Newbie Q:Help! (Perl Networking) <nobull@mail.com>
Re: Overloading and recursion; how to turn '""' overloa <nobull@mail.com>
Re: Overloading and recursion; how to turn '""' overloa <heather710101@yahoo.com>
Perl How to Program Ch 5, Ch 6, Ch 8 Help (PeteA)
Re: Perl How to Program Ch 5, Ch 6, Ch 8 Help (Helgi Briem)
Re: Perl How to Program Ch 5, Ch 6, Ch 8 Help <bernard.el-hagin@DODGE_THISlido-tech.net>
PERL, WIN32, and the Registry (John)
Re: PERL, WIN32, and the Registry <nobull@mail.com>
Re: Printing formatted text to a non-PostScript Printer <un1@bluewin.ch>
Re: Printing formatted text to a non-PostScript Printer <d.adamkiewicz@i7.com.pl>
Re: Replacing string in binary file <cingram@pjocsNOSPAMORHAM.demon.co.uk>
Re: significance of 42 for perl, any?!? <dave@junkbox.uk.sun.com>
Re: significance of 42 for perl, any?!? (Tad McClellan)
Re: significance of 42 for perl, any?!? <dover@nortelnetworks.com>
Strange Performance Thing <un1@bluewin.ch>
system() and shell "metacharacters" <smurch@no.spam>
Re: Value in array with loop (Tad McClellan)
Win32 performance data collection (Pumpkin)
Re: Win32 performance data collection <Thomas.Kratz@lrp.de.nospam>
Re: Wow <fatcat01010@yahoo.co.uk>
Re: Wow <fatcat01010@yahoo.co.uk>
Re: Wow <nobull@mail.com>
Re: Wow <fatcat01010@yahoo.co.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 28 Oct 2002 14:21:03 GMT
From: Stan Murch <smurch@no.spam>
Subject: Re: backticks/system command
Message-Id: <jJbv9.147772$La5.496012@rwcrnsc52.ops.asp.att.net>
> OK, I guess I should follow up with a bit more info. I just
> uninstalled v5.6.0
> build 623 and reinstalled v5.6.1 build 633. The above command doesn't
> work with
> the newer version of Perl. While I still had the older version
> installed I was
> able to use perl2exe to make a functional executable of the program
> I've been
> working on.
>
> So, all those commands at the top of this post work with v5.6.1 b633
> but you
> can't make a functional executable with perl2exe. None of those
> commands work
> with 5.6.0 b623.
Take a look at the ActivePerl change log
(http://aspn.activestate.com/ASPN/Perl/Products/ActivePerl/Changes.html).
You'll see that in build 630 they introduced a new feature ("system()
and backticks behave more sanely with regard to whitespace ..."). This
is probably the root of your version problems.
-Stan
------------------------------
Date: Mon, 28 Oct 2002 21:51:22 +0800
From: "Craig Dovey" <groovers@netvigator.com>
Subject: HTML Text Substitution CGI
Message-Id: <apjfd3$5df2@imsp212.netvigator.com>
Hi
I want to have a database with various quotations in it. eg Hi [_____] how
are you. OR Thanks [_____] see you again. These quotations will be on an
HTML page, and the reader can enter their name in to a field, the page will
then reopen with their name substituted into the phrase. Does anyone know
where I could find a script to help me do this, as my CGI skills are not
very hot. I would assume I'll have to use SQL database if I have many
quotes.
Thanks
------------------------------
Date: 28 Oct 2002 12:18:36 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Newbie Q:Help! (Perl Networking)
Message-Id: <u9adky4uzn.fsf@wcl-l.bham.ac.uk>
Rahul <rshringa@austin.ibm.com> writes:
> Subject: Newbie Q:Help! (Perl Networking)
"Newbie", "Q:", "Help", "Perl" and particularly "!" are redundant in
your subject line. Redundant words in subject lines serve only to
bias people against you.
What's left is a one word subject line "Networking".
As it happens your question is not related to networking but you could
not have known that.
Please try to be more descriptive. If in doubt try this simple test.
Imagine you had done a search before you posted. Next imagine you
found a thread with your subject line. Would you have been able to
recognise it as the same subject?
> I am new to Perl....I have tried perldoc...but don't see any of that doc
> helping me.
>
> I think, I am missing something here...though I haven't been able to
> find out. I am writing a simple Client/Server program using Perl.
If you are trying to make a simple program why are you using the far
from simple low-level socket interface not the simple IO::Socket
interface?
> everything works out fine until I try sending back data from the Server
> to the Client.
So perhaps you should take a close look at the line that does that.
> print Client "$username.\n" || die "Can't print to client:$!";
You have an operator precedence problem. Try...
( print Client "$username.\n" ) || die "Can't print to client:$!";
Or...
print Client "$username.\n" or die "Can't print to client:$!";
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 28 Oct 2002 12:17:19 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Overloading and recursion; how to turn '""' overloading off?
Message-Id: <u9d6pu4v1s.fsf@wcl-l.bham.ac.uk>
Da Witch <heather710101@yahoo.com> writes:
> In <3DB9B6B7.41801E4A@earthlink.net> Benjamin Goldberg <goldbb2@earthlink.net> writes:
> >use vars ($stringify_recursion);
> >sub stringify {
> > return $_[0] if $stringify_recursion;
> > local $stringify_recursion = 1;
> > "Just call me $_[0]";
> >}
>
> Cool!
Huh?
Benjamin's untested code doesn't help at all there's still an infinite recusrion.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Mon, 28 Oct 2002 13:18:24 +0000 (UTC)
From: Da Witch <heather710101@yahoo.com>
Subject: Re: Overloading and recursion; how to turn '""' overloading off?
Message-Id: <apjdf0$61u$1@reader1.panix.com>
In <u9d6pu4v1s.fsf@wcl-l.bham.ac.uk> Brian McCauley <nobull@mail.com> writes:
>Da Witch <heather710101@yahoo.com> writes:
>> In <3DB9B6B7.41801E4A@earthlink.net> Benjamin Goldberg <goldbb2@earthlink.net> writes:
>> >use vars ($stringify_recursion);
>> >sub stringify {
>> > return $_[0] if $stringify_recursion;
>> > local $stringify_recursion = 1;
>> > "Just call me $_[0]";
>> >}
>>
>> Cool!
>Huh?
>Benjamin's untested code doesn't help at all there's still an infinite recusrion.
I tested it (fixing the typo in the "use vars" line) before posting my
reply, and it worked as advertised.
h
------------------------------
Date: 28 Oct 2002 05:18:56 -0800
From: pallia@hotmail.com (PeteA)
Subject: Perl How to Program Ch 5, Ch 6, Ch 8 Help
Message-Id: <2965ae60.0210280518.762c5701@posting.google.com>
I am looking for some help for a few examples from Deitel's Perl How
to Program book. The problems that I am looking for help on are Ch 5
#7 and #8, Ch 6 #5 and #9, and Ch 8 #6 and #7. IF you have any ideas
or solutions you would not mind sharing let me know. Thanks
------------------------------
Date: Mon, 28 Oct 2002 13:31:36 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Perl How to Program Ch 5, Ch 6, Ch 8 Help
Message-Id: <3dbd3bc9.1073916229@news.cis.dfn.de>
On 28 Oct 2002 05:18:56 -0800, pallia@hotmail.com (PeteA)
wrote:
>I am looking for some help for a few examples from Deitel's Perl How
>to Program book. The problems that I am looking for help on are Ch 5
>#7 and #8, Ch 6 #5 and #9, and Ch 8 #6 and #7. IF you have any ideas
>or solutions you would not mind sharing let me know. Thanks
This is beyond ridiculous.
Have a quick look at the Posting Guidelines for
the comp.lang.perl.misc newssgroup at
http://mail.augustmail.com/~tadmc/clpmisc.shtml
For more information about netiquette in general, see
the "Netiquette Guidelines" at:
http://andrew2.andrew.cmu.edu/rfc/rfc
Come back when you have some code and run
into problems.
--
Regards, Helgi Briem
helgi AT decode DOT is
A: Top posting
Q: What is the most irritating thing on Usenet?
- "Gordon" on apihna
------------------------------
Date: Mon, 28 Oct 2002 13:53:52 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Perl How to Program Ch 5, Ch 6, Ch 8 Help
Message-Id: <slrnarqg7d.15m.bernard.el-hagin@gdndev25.lido-tech>
In article <2965ae60.0210280518.762c5701@posting.google.com>, PeteA
wrote:
> I am looking for some help for a few examples from Deitel's Perl How
> to Program book. The problems that I am looking for help on are Ch 5
> #7
while (1) {
^@&^($&#* = @;
}
#8 is a little trickier. You can try this:
sub number_8 {
return 666;
}
> Ch 6 #5
die if 1;
> and #9
die unless 0;
> and Ch 8 #6 and #7.
Those are easy. I'm sure you can manage if you just think about it a
little. Here's a hint:
perldoc perl
> IF you have any ideas
> or solutions you would not mind sharing let me know. Thanks
You're quite welcome.
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'
------------------------------
Date: 28 Oct 2002 04:46:05 -0800
From: tkd-texan@attbi.com (John)
Subject: PERL, WIN32, and the Registry
Message-Id: <d73d8f.0210280446.3693a882@posting.google.com>
Hello,
I'm writing a scrit that obtained the registry keys and print the keys
out. The code looks like:
#!/usr/bin/perl -w
use Win32::TieRegistry ( Delimiter=>"/" );
use strict;
my $Registry;
my $tips;
$tips=
$Registry->{"HKEY_LOCAL_MACHINE/Software/Microsoft
/"}->
{"Windows/CurrentVersion/Explorer/Tips/"}
or die "Can't find the Windows tips:
$^E\n";
foreach( keys %$tips )
{
print "$_: ", $tips->{$_}, "\n";
}
When I execute the code, I receive the messages:
D:\Source\perl>example1.pl
Can't find the Windows tips:
The system cannot find the file specified
Please help.
TIA
------------------------------
Date: 28 Oct 2002 12:53:56 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: PERL, WIN32, and the Registry
Message-Id: <u9smyq3esb.fsf@wcl-l.bham.ac.uk>
tkd-texan@attbi.com (John) writes:
> use Win32::TieRegistry ( Delimiter=>"/" );
> use strict;
> my $Registry;
> my $tips;
> $tips=
> $Registry->{"HKEY_LOCAL_MACHINE/Software/Microsoft
> /"}->
> {"Windows/CurrentVersion/Explorer/Tips/"}
> or die "Can't find the Windows tips:
> $^E\n";
In the above code the lexical varible $Registry does not contain
anything special - it's just a plain undefined scalar.
You probably wanted to use the package variable $Registry that is
exported by Win32::TieRegistry.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Mon, 28 Oct 2002 14:16:28 +0100
From: Sven <un1@bluewin.ch>
Subject: Re: Printing formatted text to a non-PostScript Printer
Message-Id: <un1-E8A3AB.14162828102002@zinews.unizh.ch>
In article <3DBCD39F.5A8DFD66@getnet.net>,
Matt Stoker <stokerm@getnet.net> wrote:
> For the case of PostScript printers, PostScript::Simple appears adequate
> for my needs. However, several locations where I would like to use the
> script do not have access to a PostScript printer. What are my options
> for a non-PostScript solution?
How about creating the report with PostScript::Simple and then
converting it (if necessary) with Ghostscript?
Sven
------------------------------
Date: Mon, 28 Oct 2002 15:19:58 +0100
From: Darek Adamkiewicz <d.adamkiewicz@i7.com.pl>
Subject: Re: Printing formatted text to a non-PostScript Printer
Message-Id: <3DBD478E.9010006@i7.com.pl>
Matt Stoker wrote:
> I have a perl script that generates a text-based report. I would like
> to print out (on a printer) the report with some simple formatting.
> Ideally, I would like to be able to control the font and font-size, as
> well as specify bold or italic print. In addition I would like some
> capability for positioning the text, so as to enable me to generate
> tables.
>
See Win32::NPRG module
>
> Finally, I'll be working primarily on Windows98 systems and I understand
> that there may be some API's in the OS that are useful in printing
> formatted text. If this is so, can anyone point me to where I might
> find information about the API's and how to access them from perl?
I think all you need you'll find in code snippet below - it uses
Win32::NPRG module (Win32::Wingraph is part of this package) and
Win32::API.
Regards
Darek
=========================
#!perl -w
use strict;
# Win32::API GDI printer test code
use ExtUtils::testlib;
use Win32::Wingraph;
use Win32::NPRG qw(drawmatrix);
use Win32::API;
my $PrintDialog = new Win32::API('comdlg32', 'PrintDlg', ['P'], 'N');
my $GlobalLock = new Win32::API('kernel32', 'GlobalLock', ['N'], 'N');
my $GlobalFree = new Win32::API('kernel32', 'GlobalFree', ['N'], 'N');
my $GetDeviceCaps = new Win32::API('gdi32', 'GetDeviceCaps', ['N','N'],
'N');
my $GetTextMetrics = new Win32::API('gdi32', 'GetTextMetrics',['N','P'],
'N');
my $StartDoc = new Win32::API('gdi32', 'StartDoc', ['N', 'P'] , 'N');
my $StartPage = new Win32::API('gdi32', 'StartPage', ['N'], 'N');
my $TextOut = new Win32::API('gdi32', 'TextOut',['N','I','I','P','I'], 'N');
my $EndPage = new Win32::API('gdi32', 'EndPage', ['N'], 'N');
my $EndDoc = new Win32::API('gdi32', 'EndDoc', ['N'], 'N');
my $GetLastError = new Win32::API('kernel32', 'GetLastError', [],'N');
my $FormatMessage = new Win32::API('kernel32',
'FormatMessage',['N','P','N','N','P','N','P'],'N');
sub ShowError {
my $function = shift;
my $message = " " x 1024;
$FormatMessage->Call(0x1000, 0, $GetLastError->Call(), 0,$message,
1024, 0);
$message =~ s/\s+$//;
print "$function: $message\n";
exit;
}
# user dialog to select printer
# page setup dialog selected since pages, selection and copies are not
used here
# paper size and orientation shown instead
my $pd = pack("Lx16Lx42", 66, 0x140);
# pd_size, flags = RETURNDC | PRINTSETUP
$PrintDialog->Call($pd) or die "Cancelled\n";
# get device mode and device context
my ($devmode, $dc) = unpack("x8Lx4L", $pd);
# this part is just to print a notice line
# and to practice mucking with pointers in structures
# otherwise, examining devmode is not needed for GDI
# devmode is a handle to movable global memory
my $handle = $devmode;
# get actual memory pointer
unless ($devmode = $GlobalLock->Call($handle)) {ShowError('GlobalLock')};
# get perl to use long integer as a pointer
# and retrieve the printer relevant part of the devmode structure
$devmode = unpack('P104', pack('L', $devmode));
# release the global memory
unless ($GlobalFree->Call($handle) == 0) {ShowError('GlobalFree')};
# these strings are blank padded
my ($devicename, $orient, $duplex, $formname) =
unpack('A32x12Sx16Sx6A32', $devmode);
$orient = ('Portrait', 'Landscape')[--$orient];
$duplex = ('', 'Duplex')[$duplex > 1];
print "Printing to $devicename on $formname paper, $orient $duplex\n";
my $dc = new Win32::Wingraph(device=>"$devicename", desc=>'test',
orientation=>'$orient') or die; #orientation=>'Landscape',
$dc->SetPen(3);
# "font, size, codepage" - the third argument is Windows font codepage
# if you don't supply this it'll be set to russian !!!,
# 0-westerneuropean, 238-polish, I don't know the hungarian ;(
$dc->SetFont("Times New Roman Bold, 12, 0");
$dc->TextOut(70, 180, "Blah blah blah");
$dc->MoveTo(70, 200);
$dc->LineTo(270, 200);
print "Start\n";
my $rp=new NPRG(dc=>$dc);
$rp->{'atbreak'} = sub {
$rp->pushq({font=>'Times, 6, 0', opt=>'R',
border=>'B',value=>'Very wisdom report about something '.$rp->pagenum(),
width=>980});
$rp->pushq({height=>20, value=>' ', width=>100});
$rp->pushq({font=>'Arial italic, 16, 0',
opt=>'-L',border=>'TBLR', value=>"Some header", width=>300, brush=>220},
{font=>'Courier Bold, 12, 0',
opt=>'-C',border=>'TBLR', value=>"Another header", width=>250, brush=>220},
{value=>\&NPRG::drawmatrix, width=>400,
matrix=>[
[ {font=>'Arial Bold Italic,
12',value=>'Month', border=>'TBLR', opt=>'C'}],
[
{font=>'Times New
Roman,8',value=>'I', border=>'TBLR', opt=>'-C'},
{font=>'Times New
Roman,8',value=>'II', border=>'TBLR', opt=>'-C'},
{font=>'Times New
Roman,8',value=>'III', border=>'TBLR', opt=>'-C'},
{font=>'Times New
Roman,8',value=>'IV', border=>'TBLR', opt=>'-C'},
],
[
{font=>'Times New
Roman,7',value=>'I', border=>'TBLR', opt=>'-C'},
{font=>'Times New
Roman,7',value=>'II', border=>'TBLR', opt=>'-C'},
{font=>'Times New
Roman,7',value=>'III', border=>'TBLR', opt=>'-C'},
{font=>'Times New
Roman,7',value=>'IV', border=>'TBLR', opt=>'-C'},
{font=>'Times New
Roman,7',value=>'V', border=>'TBLR', opt=>'-C'},
{font=>'Times New
Roman,7',value=>'VI', border=>'TBLR', opt=>'-C'},
{font=>'Times New
Roman,7',value=>'VII', border=>'TBLR', opt=>'-C'},
{font=>'Times New
Roman,7',value=>'VIII', border=>'TBLR', opt=>'-C'},
{font=>'Times New
Roman,7',value=>'IX', border=>'TBLR', opt=>'-C'},
{font=>'Times New
Roman,7',value=>'X', border=>'TBLR', opt=>'-C'},
{font=>'Times New
Roman,7',value=>'XI', border=>'TBLR', opt=>'-C'},
{font=>'Times New
Roman,7',value=>'XII', border=>'TBLR', opt=>'-C'},
]
],
}
);
$rp->pushq({width=>950, height=>3, brush=>0});
$rp->flushq();
print "Here\n";
};
$rp->flushq();
print "End\n";
------------------------------
Date: Mon, 28 Oct 2002 13:35:23 -0000
From: "Clyde Ingram" <cingram@pjocsNOSPAMORHAM.demon.co.uk>
Subject: Re: Replacing string in binary file
Message-Id: <apjecs$4er$1$830fa79f@news.demon.co.uk>
People,
"Jürgen Exner" <jurgenex@hotmail.com> wrote in message
news:HCIu9.29759$wm6.1038@nwrddc01.gnilink.net...
> David K. Wall wrote:
> > develop@gistenson.com wrote:
> >
> >> Tassilo,
> >> You said that I should get rid of the develop@gistenson.com. I'll
> >> look into how to do this and take care of it, if it poses a problem.
> >
> > What he said was "Also sprach develop@gistenson.com:". Note that
> > Tassilo's email address is in Germany. "also sprach" is roughly
> > equivalent to "thus spoke".
>
> I guess develop is neither a fan of classic music nor of science fiction
> movies. Otherwise he would have recognized the words.
>
> Not that this has anything to do with Perl, of course ;-)
>
> jue
The reference to classical music should have reminded me of Richard Strauss
(long forgotten.) The point about science fiction also puzzled me. (Never
knew the sunrise link to 2001 - A Space Odyssey.)
But a quick query to Google thew up lots of good stuff, about "Also Sprach
Zarathustra.". For those with german as rusty as mine, or none at all, the
clearest summary is probably:
http://www.americansymphony.org/dialogues_extensions/99_2000season/2000_03_0
8/strauss.cfm
which neatly pulls together Nietzsche, Strauss, Zarathustra, Kubrick.
German speakers will appreciate the Gutenburg Project at
http://gutenberg.spiegel.de/nietzsch/zara/also.htm
Regards,
Clyde
------------------------------
Date: 28 Oct 2002 13:46:32 GMT
From: Dave Peacock <dave@junkbox.uk.sun.com>
Subject: Re: significance of 42 for perl, any?!?
Message-Id: <apjf3o$2gi$1@new-usenet.uk.sun.com>
In article <5nspru8r8t9fodp8gnv32p1eshr4h9lbgl@4ax.com>, Michele Dondi wrote:
> I noticed that Benjamin Goldberg's japh sig uses the number 42 at some
> point, while it could have been anything else. Now, even if I can't
> find any example at the moment, I seem to recall that 42 arises
> frequently in such contexts... is there any particular significance of
> 42 for perl or is it just my impression?
You need to read "Hitch Hikers Guide to the Galaxy" by Douglas Adams.
You will then recognise a great many things you see on the Internet,
in science journals, etc. Babelfish? ;-)
------------------------------
Date: Mon, 28 Oct 2002 06:46:26 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: significance of 42 for perl, any?!?
Message-Id: <slrnarqcd2.2k8.tadmc@magna.augustmail.com>
Michele Dondi <bik.mido@tiscalinet.it> wrote:
> is there any particular significance of
> 42 for perl
Not for Perl in particular, but for all fans of
"The Hitchhiker's Guide to the Galaxy":
http://www.chapel42.com/life/
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 28 Oct 2002 10:00:39 -0600
From: "Bob Dover" <dover@nortelnetworks.com>
Subject: Re: significance of 42 for perl, any?!?
Message-Id: <apjmrr$fce$1@bcarh8ab.ca.nortel.com>
"Michele Dondi" wrote...
> Is there any particular significance of 42 for perl or is it just my impression?
Its the answer to the question about Life, the Universe, and Everything. We
don't know what the question is, but when we do, its answer will be 42.
------------------------------
Date: Mon, 28 Oct 2002 14:23:35 +0100
From: Sven <un1@bluewin.ch>
Subject: Strange Performance Thing
Message-Id: <un1-55FE50.14233528102002@zinews.unizh.ch>
Hi folks,
I've posted this a couple of days ago with no response. You'd help me a
big deal if you copy/paste the below script, try it on your box and post
the result. Please post as well the Perl version (perl -v), kernel
version (uname -a) and distribution (like RedHat 8) along with it. I'm
particularly interested in people using RedHat 8 as I do.
Thank you for your help! Sven
=== === === Original Posting "Slow File Read and Regex === === ===
I experience a strange behaviour ever since I upgraded from Perl 5.6.1
to 5.8.0.
I'm reading a file line by line and checking every line againts a regex.
The performance drops a lot if you use /i to make the regex case
insensitive. Then again if you don't read from a file but cruise an
array, there's no difference.
Here's a little test script to illustrate this:
------------------------------------------------------------------------
#!/usr/bin/perl
# Create Sample File (sample.txt) and Array (@sample)
$line = "xxxxxxxxxxABCDxxxxxxxxxx\n";
@sample = ();
open(SAMPLE,'>sample.txt');
for (my $i=0;$i<20000;$i++) {
push @sample, $line;
print SAMPLE $line;
}
close(SAMPLE);
# Test
print "1) Time Case Insensitive Regex from File\n";
open(SAMPLE,'sample.txt');
$cnt = 0;
$go = time;
while (<SAMPLE>) { $cnt++ if /ABCD/; }
print "$cnt found in ".(time-$go)." secs\n\n";
close(SAMPLE);
print "2) Time Case Insensitive Regex from RAM\n";
$cnt = 0;
$go = time;
for ($i=0;$i<20000;$i++) {
$_ = $sample[$i];
$cnt++ if /ABCD/;
}
print "$cnt found in ".(time-$go)." secs\n\n";
print "3) Time Case Sensitive Regex from File\n";
open(SAMPLE,'sample.txt');
$cnt = 0;
$go = time;
while (<SAMPLE>) { $cnt++ if /ABCD/i; } # added /i to regex
print "$cnt found in ".(time-$go)." secs\n\n";
close(SAMPLE);
print "4) Time Case Sensitive Regex from RAM\n";
$cnt = 0;
$go = time;
for ($i=0;$i<20000;$i++) {
$_ = $sample[$i];
$cnt++ if /ABCD/i; # added /i to regex
}
print "$cnt found in ".(time-$go)." secs\n\n";
------------------------------------------------------------------------
As you see, test 1 and 3 are completely identical (but adding the /i)
and the same goes for 2 and 4.
Now see the output on my linux box:
1) Time Case Insensitive Regex from File
20000 found in 0 secs
2) Time Case Insensitive Regex from RAM
20000 found in 0 secs
3) Time Case Sensitive Regex from File
20000 found in 26 secs
4) Time Case Sensitive Regex from RAM
20000 found in 0 secs
What's going on at test 3 there? I'm really out of clues.
To give you an impression of my linux box: It's an old i586 operated by
RedHat 8.0 (which includes Perl 5.8.0 built for i386-linux-thread-multi)
on Kernel 2.4.18-17.8.0. The box is not running X, has only 128MB RAM
but is hardly ever swapping and most of the time >98% idle.
Thanks for any hint!!
Sven
------------------------------
Date: Mon, 28 Oct 2002 14:14:39 GMT
From: Stan Murch <smurch@no.spam>
Subject: system() and shell "metacharacters"
Message-Id: <jDbv9.142622$zE6.493465@rwcrnsc51.ops.asp.att.net>
Could someone explain please why this is not a bug in Perl (5.8.0, solaris):
% perl -e 'die $! if system ":"'
No such file or directory at -e line 1.
It seems to me that system's understanding of "shell metacharacters"
doesn't extend to recognizing ":" as the first word. True, colon isn't
technically a metacharacter but system() is still breaking its promise
to behave the same as the shell would when taking the fast (no shell) route.
Stan
------------------------------
Date: Mon, 28 Oct 2002 08:45:47 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Value in array with loop
Message-Id: <slrnarqjcr.2k8.tadmc@magna.augustmail.com>
reggie <reggie_nospam@reggieband.com> wrote:
> I need to find whether a value exists inside an array.
But your code below does not try to find whether a value
exists inside an array.
> Please, before you refer me to an FAQ consider the whole problem.
I figure this is the FAQ you're talking about:
"How can I tell whether a list or array contains a certain element?
It appears you have found at least one FAQ that is relevant to
what you want to do, but it is unclear if you have seen others
that are also relevant...
> I am getting the contents of a url then regexp for urls.
^^^^^^^^^^^^^^^
There are modules that will do that for you already, as
mentioned in the answer to this FAQ:
perldoc -q url
"How do I extract URLs?"
(the answer is better in the 5.8.0 version of the std docs.)
See also:
http://search.cpan.org/author/BDFOY/HTML-SimpleLinkExtor-0.72/
Your code will return things that are NOT links
<!--
Fix the URL before uncommenting this:
<a href="somethin">
-->
and miss things that ARE links:
<A href="somethin">
<a href = "somethin">
<a
href="somethin">
<a name="Something" href="somethin">
> I then add these
> urls to an array
You are adding them to a hash, not to an array.
> to keep a loop going (to loop through all values). I need
> to make sure the value is not inside the array before I try and add it (so
> the same page does not get searched more than once).
Have you seen the FAQ about that part?
How can I remove duplicate elements from a list or array?
> Problem is, if I do it with a hash,
> it only loops through values existant in
> the hash when the for loop is entered.
> my $base = 'http://www.server.com'; # base site
Note no slash at the end.
> $uris{'index.php'} = 1;
Note no slash at the beginning.
> foreach (keys %uris) {
> $content = get ($base . $_); # get is from LWP::Simple
So one of the URLs that it will try to get is:
http://www.server.comindex.php
Is this your real code?
> Any ideas on an eloquent solution?
That depends on what the problem really is. :-)
If you want to check/follow links, then consider using modules
as components rather than reinventing (possibly poorly) wheels.
If you are working on nothing more than a "learning exercise",
then continue rolling your own.
You can avoid the problem by rethinking your algorithm (ie.
redesigning your program).
Use an array as a queue of "links to follow" an a hash that
records "links already followed". Something like (untested):
while ( my $page = shift @todo ) {
# fetch the web page...
foreach my $link ( something_that_finds_links($content) ) {
push @todo, $link unless $seen{$link}++;
}
}
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 28 Oct 2002 03:23:54 -0800
From: supercyberedu@yahoo.com.ar (Pumpkin)
Subject: Win32 performance data collection
Message-Id: <ff537f34.0210280323.479a271@posting.google.com>
Hello,
I am really new at perl, so I need some help
I need to log nt4 performance monitor data being collected by command
line, to a log file.
I read about this perl module accessing win32 api ( I think that was
the name ) written by aldo ( an italian guy ).
has anybody used it before ?
Specifically I need to get the currentconnections and currenisapi
connection request.
any example would be great.
thanks.
------------------------------
Date: Mon, 28 Oct 2002 13:39:17 +0100
From: "Thomas Kratz" <Thomas.Kratz@lrp.de.nospam>
Subject: Re: Win32 performance data collection
Message-Id: <3dbd3709.0@juno.wiesbaden.netsurf.de>
"Pumpkin" <supercyberedu@yahoo.com.ar> wrote in
news:ff537f34.0210280323.479a271@posting.google.com...
> Hello,
> I am really new at perl, so I need some help
> I need to log nt4 performance monitor data being collected by
command
> line, to a log file.
> I read about this perl module accessing win32 api ( I think that was
> the name ) written by aldo ( an italian guy ).
> has anybody used it before ?
>
> Specifically I need to get the currentconnections and currenisapi
> connection request.
>
> any example would be great.
>
> thanks.
Use Win32::Perflib (included in the libwin module collection) to get
the performance counters. The example in the pod should be enough to
get you started.
Thomas
------------------------------
Date: Mon, 28 Oct 2002 12:30:39 +0000 (UTC)
From: "Brian" <fatcat01010@yahoo.co.uk>
Subject: Re: Wow
Message-Id: <apjale$8uo$1@venus.btinternet.com>
Advice received with thanks.
"ebchang" <echang@netstorm.net> wrote in message
news:Xns92B4E38E267E8echangnetstormnet@207.106.92.86...
> "Brian" <fatcat01010@yahoo.co.uk> wrote in
> <aphjsb$k0f$1@knossos.btinternet.com>:
>
> >Sorry.
> >I was refering to a posting on the 25th "Before I buy this book" Would
> >have helped if I replied ti the corect thread.
> >Oh well
>
> Effective quoting, especially not top-posting, is important too - see
> http://www.geocities.com/ResearchTriangle/Lab/6882/nquote.html for a
start.
>
> >"Jürgen Exner" <jurgenex@hotmail.com> wrote in message
> >news:dpUu9.9827$FS5.4110@nwrddc04.gnilink.net...
> >> Brian wrote:
> >>> I'm new to this news group and new to Perl. I'm hoping to learn a
> >>> bit from you guys while I'm here. Just read this thread.
> >>
> >> Which thread? Your posting does not link to any other thread.
>
>
------------------------------
Date: Mon, 28 Oct 2002 12:30:39 +0000 (UTC)
From: "Brian" <fatcat01010@yahoo.co.uk>
Subject: Re: Wow
Message-Id: <apjalf$8uo$2@venus.btinternet.com>
"ebchang" <echang@netstorm.net> wrote in message
news:Xns92B4E38E267E8echangnetstormnet@207.106.92.86...
> "Brian" <fatcat01010@yahoo.co.uk> wrote in
> <aphjsb$k0f$1@knossos.btinternet.com>:
>
> >Sorry.
> >I was refering to a posting on the 25th "Before I buy this book" Would
> >have helped if I replied ti the corect thread.
> >Oh well
>
> Effective quoting, especially not top-posting, is important too - see
> http://www.geocities.com/ResearchTriangle/Lab/6882/nquote.html for a
start.
>
> >"Jürgen Exner" <jurgenex@hotmail.com> wrote in message
> >news:dpUu9.9827$FS5.4110@nwrddc04.gnilink.net...
> >> Brian wrote:
> >>> I'm new to this news group and new to Perl. I'm hoping to learn a
> >>> bit from you guys while I'm here. Just read this thread.
> >>
> >> Which thread? Your posting does not link to any other thread.
>
>
------------------------------
Date: 28 Oct 2002 12:34:35 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Wow
Message-Id: <u9wuo23fok.fsf@wcl-l.bham.ac.uk>
In response to being advised not to top-post "Brian" <fatcat01010@yahoo.co.uk> top-posts:
> Advice received with thanks.
Like, duh!
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Mon, 28 Oct 2002 15:09:05 +0000 (UTC)
From: "Brian" <fatcat01010@yahoo.co.uk>
Subject: Re: Wow
Message-Id: <apjjug$7dq$1@knossos.btinternet.com>
"Brian McCauley" <nobull@mail.com> wrote in message
news:u9wuo23fok.fsf@wcl-l.bham.ac.uk...
> In response to being advised not to top-post "Brian"
<fatcat01010@yahoo.co.uk> top-posts:
>
> > Advice received with thanks.
>
> Like, duh!
Okay.
------------------------------
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 4037
***************************************