[22685] in Perl-Users-Digest
Perl-Users Digest, Issue: 4906 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 28 14:06:05 2003
Date: Mon, 28 Apr 2003 11:05:07 -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 Mon, 28 Apr 2003 Volume: 10 Number: 4906
Today's topics:
books from beginner to guru - reading order (qanda)
Re: books from beginner to guru - reading order <matthew@weierophinney.net>
Re: books from beginner to guru - reading order <ubl@schaffhausen.de>
Re: books from beginner to guru - reading order <News@LearnQuick.Com>
Re: Curses and perl5.8 <goldbb2@earthlink.net>
Re: Dumping hash after sort <TruthXayer@yahoo.com>
Re: Errors running Randal and Damian's Parse::RecDescen (J. H.)
Re: Get PID from process started by "system" - how? <goldbb2@earthlink.net>
grep problem <psmahesh@miel.mot.com>
Hash memory consumption <mhunter@celeste.net.berkeley.edu>
Re: hashes in scalar context? ctcgag@hotmail.com
Re: if (grep ...) is failing... <mhunter@celeste.net.berkeley.edu>
Re: if (grep ...) is failing... <mhunter@celeste.net.berkeley.edu>
Newbie cannot compile :( (ibits)
Re: perl hash - help request <goldbb2@earthlink.net>
Re: perl hash - help request (Anno Siegel)
Re: Regex greediness question ctcgag@hotmail.com
setting a variable from a line in a file <jts43@cornell.edu>
Re: setting a variable from a line in a file <peter_wilson@mail.com>
Re: setting a variable from a line in a file <bigj@kamelfreund.de>
Re: Test::Harness annoyance <kalinabears@hdc.com.au>
Re: Unnecessary Calls to the Server? <markvalls.spambox@dnainternet.net>
Re: Unnecessary Calls to the Server? <goldbb2@earthlink.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 28 Apr 2003 08:23:43 -0700
From: fumail@freeuk.com (qanda)
Subject: books from beginner to guru - reading order
Message-Id: <62b4710f.0304280723.7b2e33a4@posting.google.com>
Hi all
Would you be able to give me a list of books and the reading order
that a programmer would need to learn Perl, from the basics through to
advanced topcs. Keep in mind the objective is to learn the skills to
develop large scale applications in the future. By large-scale I mean
applications wrote by several developers over serveral months,
possibly years - once they have read the books of course :) Assume
the applications are mainly back-end server data processors, possibly
with simple command-line/Tk front-ends.
I know there is an FAQ and a critique page by Tom Christiansen but I
can't find a recommended reading order. For example I think the Llama
is an excellent starting point, however the Camel straight after that
is simply too much. I'm looking for a list of books (maybe 3-6,
however many are required) and their reading order; here's a few I
know about (in no paricular order), would someone be able to give me a
shortlist (using these and/or other good books)?
Programming Perl
Perl Cookbook
Learning Perl
Perl: Programmers Companion
Advanded Perl Programming
Effective Perl Programming
Mastering Perl/Tk
Could anyone also recommend a good book or source of reference that
details large scale Perl development as mentioned above?
Thanks in advance.
------------------------------
Date: Mon, 28 Apr 2003 15:32:14 GMT
From: Matthew Weier O'Phinney <matthew@weierophinney.net>
Subject: Re: books from beginner to guru - reading order
Message-Id: <slrnbaqibu.e2n.matthew@kavalier.weierophinney.net>
* qanda <fumail@freeuk.com>:
> Would you be able to give me a list of books and the reading order
> that a programmer would need to learn Perl, from the basics through to
> advanced topcs. Keep in mind the objective is to learn the skills to
> develop large scale applications in the future. <snip> Assume
> the applications are mainly back-end server data processors, possibly
> with simple command-line/Tk front-ends.
>
<snip>
> here's a few I know about (in no paricular order), would someone be
> able to give me a shortlist (using these and/or other good books)?
>
> Programming Perl
I love this book -- it's what I originally bought to learn Perl. I later
bought Learning Perl, which was a much gentler, though also less
thorough, introduction. However, if you want *all* of the core elements
and ideas of perl at your fingertips, you *can't* go wrong with this
one.
> Perl Cookbook
> Learning Perl
Great introduction to basic perl concepts -- a good programmer can go
through it in a few hours and have the rudiments down well.
> Perl: Programmers Companion
> Advanded Perl Programming
I don't reference this book as much as Programming Perl -- but I think
that's because it's so well written, I've internalized many of the
concepts. I would *never* have understood references, objects, or ties
without it. While it is written well, it also engages some very complex
concepts, and takes a bit more time to traverse. I highly recommend this
as a concurrent study with the Camel book.
> Effective Perl Programming
> Mastering Perl/Tk
>
> Could anyone also recommend a good book or source of reference that
> details large scale Perl development as mentioned above?
Honestly, I'd look through some of the larger modules on CPAN and study
them, getting an idea of how they were designed.
--
Matthew Weier O'Phinney
matthew@weierophinney.net
http://matthew.weierophinney.net
------------------------------
Date: Mon, 28 Apr 2003 17:59:14 +0200
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: books from beginner to guru - reading order
Message-Id: <b8jm9k$ho4$1@news.dtag.de>
qanda wrote:
> Could anyone also recommend a good book or source of reference that
> details large scale Perl development as mentioned above?
100%, no way around, must have:
Object Oriented Perl
by Damian Conway
------------------------------
Date: Mon, 28 Apr 2003 18:03:09 GMT
From: "Herb Martin" <News@LearnQuick.Com>
Subject: Re: books from beginner to guru - reading order
Message-Id: <x1era.40164$DX.1760325@twister.austin.rr.com>
Agreed.
Add: Mastering Regular Expressions (another O'Reilly book)
While not technically a "Perl" book since it covers, compares,
and contrasts Regexes from several languages and systems,
it covers Perl well and offers the most depth on Regexes.
--
Herb Martin
Try ADDS for great Weather too:
http://adds.aviationweather.noaa.gov/projects/adds
------------------------------
Date: Mon, 28 Apr 2003 12:10:01 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Curses and perl5.8
Message-Id: <3EAD5259.BFBFEFED@earthlink.net>
"Eric J. Roode" wrote:
>
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
>
> "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de> wrote in
> news:b8isft$hv1$1@nets3.rz.RWTH-Aachen.DE:
>
> > Also sprach Benjamin Goldberg:
> >
> >> That should be either:
> >>
> >> if (Perl_sv_isa(aTHX_ sv, "Curses::Window")) {
> >>
> >> Or:
> >>
> >> if (sv_isa(sv, "Curses::Window")) {
> >>
> >> You shouldn't use the Perl_ version without having aTHX_ in front
> >> of the first argument.
> >
> > Thread context, I see. I never ever had a perl with any of the two
> > thread-flavors compiled in so I got too used to the idea that
> > aTHX_ and pTHX_ were empty #defines for me.
>
> So what does that mean for people who have this compilation error?
>
> If they have threading enabled, they should manually change the line
> in error to the first line above; if they don't, they should manually
> change it to the second above?
Actually, since there is a line in one of the headers:
#define sv_isa(a,b) Perl_sv_isa(aTHX_ a,b)
They are equivilant. So you could use either. However, a bare sv_isa
is clearer (and it's more consistant with the other code in Curses).
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Mon, 28 Apr 2003 10:55:23 -0700
From: TruthXayer <TruthXayer@yahoo.com>
Subject: Re: Dumping hash after sort
Message-Id: <3EAD6B0B.967CE573@yahoo.com>
"Tassilo v. Parseval" wrote:
>
> Please don't top-post. Before you do anything, halt and read
> <http://www.xs4all.nl/~wijnands/nnq/nquote.html>, Q7 in particular.
Thanks for the NG guideline, will keep it in mind.
>
> Also sprach TruthXayer:
>
> > Thanks Tassilo, but somehow I can't get it to work even
> > for a simple sort by value. I could work around by sorting
>
> If I run the above with warnings enabled, I get
> Use of uninitialized value in numeric comparison (<=>) at dump.pl line 12.
> And indeed, there's again this 'b' instead of '$b' type in a
> hash-subscript. Didn't we just recently had this in another thread?
Thanks for the keen eye, fixing that solved the problem,
Will turn on warnings and
strict for testing :) It worked for the simple testcase(on
one level hash) I had tried. But on expansion it failed
again :(
use strict;
use Data::Dumper;
$Data::Dumper::Sortkeys = \&my_filter2;
my %hash = (
"A" => {
ratio => 34
},
"B" => {
ratio => 75
},
"C" => {
ratio => 21
},
);
print Dumper ( \%hash );
sub my_filter2 {
my ($hash) = shift;
# return an array ref containing the hash keys
to dump
# in the order that you want them to be dumped
return [ sort { $hash->{$b}->{ratio} <=>
$hash->{$a}->{ratio} } (keys %$hash) ];
}
>
> Tassilo
------------------------------
Date: 28 Apr 2003 10:17:10 -0700
From: loopy1@ureach.com (J. H.)
Subject: Re: Errors running Randal and Damian's Parse::RecDescent examples
Message-Id: <6d0c93f5.0304280917.665e9d99@posting.google.com>
Randal is absolutely right. Mea culpa.
Thank you to Anno and Randal for posting.
After making Anno's changes (and putting in
some single quotes here and there to make
Perl happy), here is a working version of
Damian's tutorial:
#! /usr/bin/perl -w
use vars qw( %base %man @try_again );
use Parse::RecDescent;
sub Parse::RecDescent::choose { $_[1 + int rand $#_]; }
$abbott = new Parse::RecDescent <<'EOABBOTT';
Interpretation:
ConfirmationRequest
| NameRequest
| BaseRequest
ConfirmationRequest:
Preface(s?) Name /[i']s on/ Base
{ (lc $::man{$item[4]} eq lc $item[2])
? "Yes"
: "No, $::man{$item[4]}\'s on $item[4]"
}
| Preface(s?) Name /[i']s the (name of the)?/
Man /('s name )?on/ Base
{ (lc $::man{$item[6]} eq lc $item[2])
? "Certainly"
: "No. \u$item[2] is on " . $::base{lc $item[2]}
}
BaseRequest:
Preface(s?) Name /(is)?/
{ "He's on " . $::base{lc $item[2]} }
NameRequest:
/(What's the name of )?the/i Base "baseman"
{ $::man{$item[2]} }
Preface: ...!Name /\S*/
Name: Name12 | /I Don't Know/i
Name12: /Who/i | /What/i
Base: 'first' | 'second' | 'third'
Man: 'man' | 'guy' | 'fellow'
EOABBOTT
$costello = new Parse::RecDescent <<'EOCOSTELLO';
Interpretation:
Meaning {'prev'}
{ $thisparser->{'prev'} = $item[1] }
| { choose(@::try_again) }
Meaning:
Question
| UnclearReferent
| NonSequitur
Question:
Preface Interrogative /[i']s on/ Base
{ choose ("Yes, what is the name of the guy on $item[4]?",
"The $item[4] baseman?",
"I'm asking you! $item[2]?",
"I don't know!") }
| Interrogative
{ choose ("That's right, $item[1]?",
"What?",
"I don't know!") }
UnclearReferent:
"He's on" Base
{ choose ("Who's on $item[2]?",
"Who is?",
"So, what is the name of the guy on $item[2]?"
) }
NonSequitur:
( "Yes" | 'Certainly' | /that's correct/i )
{ choose("$item[1], who?",
"What?",
@::try_again) }
Interrogative: /who/i | /what/i
Base: 'first' | 'second' | 'third'
Preface: ...!Interrogative /\S*/
EOCOSTELLO
%man = ( first => "Who", second => "What", third => "I Don't Know" );
%base = map { lc } reverse %man;
@try_again =
(
"So, who's on first?",
"I want to know who's on first!",
"What's the name of the first baseman?",
"Let's start again. What's the name of the guy on first?",
"Okay, then, who's on second?",
"Well then, who's on third?",
"What's the name of the fellow on third?",
);
$costello->{'prev'} = $line = "Who's on first?";
while (1)
{
print " ", $line, "\n" and sleep 1;
$line = $abbott->Interpretation($line);
print " ", $line, "\n" and sleep 1;
$line = $costello->Interpretation($line);
}
------------------------------
Date: Mon, 28 Apr 2003 12:18:01 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Get PID from process started by "system" - how?
Message-Id: <3EAD5439.298C552F@earthlink.net>
Tony wrote:
> Rudolf Polzer wrote:
[snip]
> > You use the same 'play' program I know? Then my ForkAndExec
> > routine from the previous posting will just work fine for you.
[snip]
> I do not quite get what is hapening below...it looks like a
> variation of the above with the fork within it.
>
> How would you play the list of files remembering that the
> main program still needs to run checking for new events
> to handle? Or is the suggestion below a "second fork"
> to be used after a first fork?
By using exec(), instead of system(), a second fork is avoided.
> Where do the %pids come from? (Only the forked process ID
> as far as I can see).
The %pids hash is filled in by the StartFile subroutine. It's keys are
devices (possibly always "/dev/output" ... in which case there would be
at most one key, and at most one stored pid), and it's values are
process ids.
> Killing the forked perl process will not kill the play process...
Because of the exec(), the forked process is no longer a perl process,
but is a play process directly. Thus, you are killing the play process,
not a perl process.
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Mon, 28 Apr 2003 21:20:12 +0530
From: P S Mahesh <psmahesh@miel.mot.com>
Subject: grep problem
Message-Id: <3EAD4DB3.5E924B63@yahoo.com>
Hi folks,
I am reading an input from an rlogin process from a device. I run a
couple of commands and I get the output from them, I am able to do that
perfectly through perl. Now the problem is that I have to grep the
output that I get from those commands line by line and search for a
couple of strings. If I find them in the instream that I get. I flush
the instream and run another command to get another bunch of lines.
So far I have failed to grep properly the list of fixed terms from the
instream that I get line by line. Can anyone help me to figure this out.
I need to grep a line for a couple of characters.
I tried the following. The problem is the output is a table and I am
reading it row by row where one of the columns might contain AAA or
BBBB.
if ( grep /AAAA/BBBBB/CCCC $currentline)
{
discard line
}
else
print line
------------------------------
Date: Mon, 28 Apr 2003 17:41:57 +0000 (UTC)
From: Mike Hunter <mhunter@celeste.net.berkeley.edu>
Subject: Hash memory consumption
Message-Id: <slrnbaqpue.rj.mhunter@celeste.net.berkeley.edu>
Hey everybody,
I have a script that ends up using a lot of memory when I shove lots of
data into a hash. I followed a suggestion on this group to try pack'ing
values to be stored instead of storing array references, but it hasn't
helped much.
My question is: Is there any way to reduce the consumption of the hash
data structure itself? Is there any OS dependance on this size?
Thanks,
Mike
------------------------------
Date: 28 Apr 2003 16:59:06 GMT
From: ctcgag@hotmail.com
Subject: Re: hashes in scalar context?
Message-Id: <20030428125905.883$HA@newsreader.com>
Andras Malatinszky <nobody@dev.null> wrote:
> The perldata man page tells me this:
>
> "If you evaluate a hash in scalar context, it returns false if the hash
> is empty. If there are any key/value pairs, it returns true; more
> precisely, the value returned is a string consisting of the number of
> used buckets and the number of allocated buckets, separated by a slash.
> This is pretty much useful only to find out whether Perl's internal
> hashing algorithm is performing poorly on your data set. For example,
> you stick 10,000 things in a hash, but evaluating %HASH in scalar
> context reveals "1/16", which means only one out of sixteen buckets has
> been touched, and presumably contains all 10,000 of your items. This
> isn't supposed to happen."
>
> Is there a realistic situation when evaluating a hash in scalar context
> may be useful? Anyone ever used this feature?
Yes and Yes. I was building a hash keyed to vendors catalog numbers,
which contained an internal check-sum. I was getting abysmal performance,
and discovered the hash was only using 4/8 buckets to store over 60,000
things. I preallocated 100,000 buckets and get back the performance I
expected. This was on Perl 5.004 or 5.005. I've never seen this
problem under 5.6, which uses a better hashing fucntion, but I still
routinely check the bucket usage on large hashes (Once bitten, twice shy.)
> On a slightly different track: what are these "buckets"? Are they
> documented somewhere? Is it useful to know about them?
Sure and sure. Look in an algorithms book for hashing.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service New Rate! $9.95/Month 50GB
------------------------------
Date: Mon, 28 Apr 2003 17:34:52 +0000 (UTC)
From: Mike Hunter <mhunter@celeste.net.berkeley.edu>
Subject: Re: if (grep ...) is failing...
Message-Id: <slrnbaqph5.r6.mhunter@celeste.net.berkeley.edu>
On 28 Apr 2003 05:34:05 -0700, pdqd wrote:
> Hi Friends,
> -
> I am using the following program which uses grep command to check
> whether a substring is found in a string. But i am getting wrong
> answer. Could someone tell me what is wrong in the code below?
> -----------
> #!/usr/local/bin/perl -w
>
> my $text = "f dfdf flwower fdfd ";
>
> if (grep $text,"flower" ) {
> print("correct\n");
> }
> else {
> print("Wrong\n");
> }
>
> exit 0;
> ----------------
Try =~
Mike
------------------------------
Date: Mon, 28 Apr 2003 17:38:09 +0000 (UTC)
From: Mike Hunter <mhunter@celeste.net.berkeley.edu>
Subject: Re: if (grep ...) is failing...
Message-Id: <slrnbaqpna.re.mhunter@celeste.net.berkeley.edu>
On Mon, 28 Apr 2003 17:34:52 +0000 (UTC), Mike Hunter wrote:
> On 28 Apr 2003 05:34:05 -0700, pdqd wrote:
> > Hi Friends,
> > -
> > I am using the following program which uses grep command to check
> > whether a substring is found in a string. But i am getting wrong
> > answer. Could someone tell me what is wrong in the code below?
> > -----------
> > #!/usr/local/bin/perl -w
> >
> > my $text = "f dfdf flwower fdfd ";
> >
> > if (grep $text,"flower" ) {
> > print("correct\n");
> > }
> > else {
> > print("Wrong\n");
> > }
> >
> > exit 0;
> > ----------------
>
> Try =~
I should add that "grep" is mainly for arrays in perl...I've been confused
on this point many times :(
------------------------------
Date: 28 Apr 2003 10:44:13 -0700
From: one2katwo@yahoo.com (ibits)
Subject: Newbie cannot compile :(
Message-Id: <a317f43d.0304280944.3ff965e0@posting.google.com>
I had some questions about my program. I can't compile/run the program
because of some errors. Can anyone please take a look at my program
and direct me to make the appropriate corrections.
# /usr/bin/perl -w
# cgi script with cgi.pm
#use strict;
use CGI;
my $query = new CGI;
my $name = new CGI;
my $meaning = new CGI;
my $letter = new CGI;
print "WELCOME TO NAZIA'S PERSONALITY GAME!!!";
print $query->header(),
$query->start_html("LEVEL1: NAME, LEVEL2: BIRTHDATE, LEVEL3:
COLOR, LEVEL4: PLACEofBIRTH, LEVEL5: HEIGHT, LEVEL6: comingSoon"),
$query->p("NAME?"),
$query->p("Please enter the first letter of your name:"),
$query->textfield(-letter=>'letter');
$query->param;
$letter = param;
print $query->submit(letter=>'letter',
onClick=>computePersonality);
$query->end_html;
#uses the first letter of the name to compute the meaning of the name
function computePersonality(letter){
#print $letter;
$query->start_html("level 1 - YOUR PERSONALITY BY NAME");
if($letter eq "a"){
print $query->p("A - You can be very quiet when you have something on
your mind.");
}
elsif($letter eq "b"){
print $query->p("B - You are always cautious when it comes to meeting
new people.");
}
else{
print $query->p("Invalid input! Please revisit the page to try
again!");
}
$query->end_html;
}
------------------------------
Date: Mon, 28 Apr 2003 12:05:31 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: perl hash - help request
Message-Id: <3EAD514B.5BE4AC63@earthlink.net>
kz15 wrote:
>
> Anno Siegel wrote:
> > Michael Budash <mbudash@sonic.net> wrote in comp.lang.perl.misc:
> >
> > [...]
> >
> >
> >> $early++ if ("$iy$im$id" lt "$ry$rm$rd");
> >> $on++ if ("$iy$im$id" eq "$ry$rm$rd");
> >> $late++ if ("$iy$im$id" gt "$ry$rm$rd");
> >
> >
> > ...or in one line:
> >
> > ${ ( \ ( $early, $on, $late))
> > [ 1 + ( "$iy$im$id" cmp "$ry$rm$rd")] ++;
You're missing a "}" between "]" and "++".
> > :)
> >
> > Anno
>
> COOOOL!
>
> and now the translation?
my @item_refs = \( $early, $on, $late );
my $item_idx = 1 + ("$iy$im$id" cmp "$ry$rm$rd");
my $item_ref = $item_refs[$item_idx];
${ $item_ref }++;
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: 28 Apr 2003 16:53:28 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: perl hash - help request
Message-Id: <b8jma8$1b6$1@mamenchi.zrz.TU-Berlin.DE>
Michael Budash <mbudash@sonic.net> wrote in comp.lang.perl.misc:
> In article <b8iqk4$bl2$1@mamenchi.zrz.TU-Berlin.DE>,
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
>
> > Michael Budash <mbudash@sonic.net> wrote in comp.lang.perl.misc:
> >
> > [...]
> >
> > > $early++ if ("$iy$im$id" lt "$ry$rm$rd");
> > > $on++ if ("$iy$im$id" eq "$ry$rm$rd");
> > > $late++ if ("$iy$im$id" gt "$ry$rm$rd");
> >
> > ...or in one line:
> >
> > ${ ( \ ( $early, $on, $late))[ 1 + ( "$iy$im$id" cmp "$ry$rm$rd")] ++;
> >
> > :)
> >
> > Anno
>
> _someone_ has too much time on their hands! or perhaps has forgotten how
> annnoying it is to be handed code like this to maintain... but it IS
> cool!!
...and here I thought I was being reader-friendly by not writing
${ ( \ ( $late, $on, $early))[ "$iy$im$id" cmp "$ry$rm$rd"]} ++;
(Typo corrected thanks to Benjamin Goldberg)
Anno
------------------------------
Date: 28 Apr 2003 17:52:45 GMT
From: ctcgag@hotmail.com
Subject: Re: Regex greediness question
Message-Id: <20030428135245.646$vT@newsreader.com>
genericax@hotmail.com (Sara) wrote:
> "Tman" <nerdy1@snet.net> wrote in message
> news:<Z8Rpa.1172$Hg4.279561317@newssvr10.news.prodigy.com>...
> > Am I misunderstanding something here?
> >
> > C:\Temp>perl -de 1
> > .....
> > DB<1> p "aaaaaabaaaaa" =~ /a(.*?b.*?)a/
> > aaaaab
> >
>
> in a regex, would
>
> /(something)*?/
>
> ever be any different than
>
> /(something)*/
>
> Wouldn't both match zero-many sometings?
Yes and no. Both would match, meaning return true, for zero-many
somethings (in a scalar context).
The difference is what get's stuck into the $1 variable.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service New Rate! $9.95/Month 50GB
------------------------------
Date: Mon, 28 Apr 2003 12:05:57 -0400
From: "J. Todd Slack" <jts43@cornell.edu>
Subject: setting a variable from a line in a file
Message-Id: <b8jjfd$2ie$1@news01.cit.cornell.edu>
Hi,
In a file I have a list of files that I need to work with.
like:
index.html
pro.html
about.html
I want to do something like
while (...) {
$file = line from the file I just opened
open(File, $file);
....
}
and have that open up index.html, then pro.html, etc
but I am not sure how?
Thoughts?
-Jason
------------------------------
Date: Mon, 28 Apr 2003 16:44:18 +0000 (UTC)
From: "Peter Wilson" <peter_wilson@mail.com>
Subject: Re: setting a variable from a line in a file
Message-Id: <b8jlp2$cr0$1@hercules.btinternet.com>
"J. Todd Slack" <jts43@cornell.edu> wrote in message
news:b8jjfd$2ie$1@news01.cit.cornell.edu...
> Hi,
>
> In a file I have a list of files that I need to work with.
>
> like:
>
> index.html
> pro.html
> about.html
>
> I want to do something like
>
> while (...) {
> $file = line from the file I just opened
> open(File, $file);
> ....
>
> }
>
> and have that open up index.html, then pro.html, etc
>
> but I am not sure how?
>
> Thoughts?
>
> -Jason
>
open(filelist,$list_of_files_filename)
while(<filelist>)
{
chomp;
open(htmlfile,$_);
while(<htmlfile>)
{
....
}
}
Pete
------------------------------
Date: Mon, 28 Apr 2003 17:54:23 +0200
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: setting a variable from a line in a file
Message-Id: <pan.2003.04.28.15.54.21.632205@kamelfreund.de>
J. Todd Slack wrote at Mon, 28 Apr 2003 12:05:57 -0400:
> In a file I have a list of files that I need to work with.
>
> like:
>
> index.html
> pro.html
> about.html
>
> I want to do something like
>
> while (...) {
> $file = line from the file I just opened
> open(File, $file);
> ....
>
> }
>
> and have that open up index.html, then pro.html, etc
>
> but I am not sure how?
>
> Thoughts?
2 ideas:
1) set the @ARGV variable and work with the magic <> operator:
open FILE_WITH_LIST_OF_OTHER_FILES, $filename or die $!;
chomp( my @file = <FILE_WITH_LIST_OF_OTHER_FILES> );
@ARGV = @file;
while (<>) {
# now $_ loops over all lines from all files
}
2) do it explicitly:
while (<FILE_WITH_LIST_OF_OTHER_FILES>) {
open OTHER_FILE, $_ or die $!;
while (<OTHER_FILE>) {
# now $_ loops over the lines of OTHER_FILE
}
close OTHER_FILE;
}
[untested]
Best Wishes,
Janek
------------------------------
Date: Tue, 29 Apr 2003 01:15:55 +1000
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: Test::Harness annoyance
Message-Id: <3ead46a3$0$21278@echo-01.iinet.net.au>
"Sisyphus" <kalinabears@hdc.com.au> wrote in message
news:3eacc729$0$21262@echo-01.iinet.net.au...
>
> "James E Keenan" <jkeen@concentric.net> wrote in message
> news:b8grm6$em@dispatch.concentric.net...
>
> <snip>
> >
> > Am perplexed too.
> >
> >
>
> I've got a PII laptop with AS build 633 (5.6.1), and a PIII desktop with
AS
> build 626 (5.6.1). (They both also have 5.8 builds, but for the moment I'm
> looking at the 5.6.1 builds only.)
> Both machines have identical Win 2k operating systems.
> On the laptop, Test::Harness behaviour is as desired - producing no
> superfluous blank lines. On the desktop, however, I get those useless and
> annoying blank lines.
>
> On both machines I've run scandeps.pl (which comes with Module::ScanDeps)
on
> Test\Harness.pm, and on Test.pm.
>
> I've then checked the version numbers of the fifty-odd modules that
scandeps
> finds - and they're the same on both machines.
>
> This leaves me thinking that it's possibly something in the different
> patchlevel between builds 626 and 633.
>
> Or its explained in terms of the difference between PII and PIII ......
time
> to warm up the soldering iron ?
> :-)
>
> Looks like it's time for me to turf it into the (already overflowing)
> "too-hard basket" ....... unless anyone has any ideas on how/where to
> proceed ?
>
> In case people don't properly understand what I'm talking about:
> On the laptop, 'nmake test' will output something like this:
> t/test_01................... ok
> t/test_02................... ok
>
> On the desktop, 'nmake test' will output something like this:
> t/test_01................... ok
>
>
> t/test_02................... ok
>
> where the actual number of blank lines between the test_01 result and the
> test_02 result is equal to the number of tests that test_02 performs.
>
> On both machines, I'm getting the incremental counter while the tests are
> being conducted. That parts ok - it's just that, on the desktop, each time
> the counter increments, a new (blank) line is printed to the screen.
>
> I can probably, as James suggests, use the 'verbose' switch to have that
> line print the result of the test - but that's not what I want - I simply
> don't want that line at all (as per the laptop).
>
Ha !! Really not a perl problem - at least the solution has nothing to do
with perl.
Turns out that the (cmd.exe) console on my laptop is 80 characters wide, and
on my desktop it's only 75 characters wide.
Test::Harness defines a variable:
$blank = ' ' x 77;
So, on the laptop 'print "$blank\r";' returns the cursor to its original
starting position, but on the desktop the same command advances the cursor
down the screen by one line.
Setting the desktop console to 80 chars wide fixes the problem.
Cheers,
Rob
------------------------------
Date: Mon, 28 Apr 2003 18:53:30 +0300
From: Marko Vallius <markvalls.spambox@dnainternet.net>
Subject: Re: Unnecessary Calls to the Server?
Message-Id: <qcvvn-1i9.ln1@sethlans.mine.nu>
On Mon, 28 Apr 2003 14:54:19 GMT, Topspin wrote:
> Inside the script, I log to a text file each time the script is
> executed and completed. When users call the scripts that return other
> file types, the script correctly logs a "hit". When users request a
> PDF (via the PDF script), the script often logs 2 or 3 hits.
That's IE for you (or rather some versions of IE with Acrobat Reader
plugin). Microsoft calls it a feature:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q293792
--
Marko Vallius # http://iki.fi/markvall/
------------------------------
Date: Mon, 28 Apr 2003 13:47:00 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Unnecessary Calls to the Server?
Message-Id: <3EAD6914.134F1A19@earthlink.net>
Marko Vallius wrote:
>
> On Mon, 28 Apr 2003 14:54:19 GMT, Topspin wrote:
> > Inside the script, I log to a text file each time the script is
> > executed and completed. When users call the scripts that return
> > other file types, the script correctly logs a "hit". When users
> > request a PDF (via the PDF script), the script often logs 2 or 3
> > hits.
>
> That's IE for you (or rather some versions of IE with Acrobat Reader
> plugin). Microsoft calls it a feature:
>
> http://support.microsoft.com/default.aspx?scid=kb;EN-US;q293792
So for those versions of IE which generate 3 requests in a row, you can
solve the problem by detecting when the userAgent is "contype", and
remove the prior entry from that client from the log, and to treat that
particular request as a HEAD instead of as a GET, *and* don't log that
particular request.
That would reduce 3 requests down to one request, and decrease the cost
of the middle request.
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
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 4906
***************************************