[20018] in Perl-Users-Digest
Perl-Users Digest, Issue: 2213 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 27 00:05:32 2001
Date: Mon, 26 Nov 2001 21: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)
Message-Id: <1006837510-v10-i2213@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 26 Nov 2001 Volume: 10 Number: 2213
Today's topics:
Re: 2D Array from Text File <bwalton@rochester.rr.com>
[OT] deja-vu all over again (was Re: A Perl Bug?) <joe+usenet@sunstarsys.com>
Re: A Perl Bug? <wyzelli@yahoo.com>
Re: A Perl Bug? (Logan Shaw)
Re: A Perl Bug? <jake@chaogic.com>
Re: ActivePerl Windows 2000 online documentation <r_larsen@image.dk>
BSDCon 2002 <mktgadm@usenix.org>
Re: Can I avoid 2 passes? (Logan Shaw)
Re: Can I avoid 2 passes? <krahnj@acm.org>
Re: Can I avoid 2 passes? <godzilla@stomp.stomp.tokyo>
Canceling Usenet Messages in a script (Chas Friedman)
Re: Canceling Usenet Messages in a script (Logan Shaw)
Re: Canceling Usenet Messages in a script (Logan Shaw)
Re: changing a html page for printing (Damian James)
Re: changing a html page for printing <jurgenex@hotmail.com>
Re: How do I implement non-blocking IO on Win32? <goldbb2@earthlink.net>
Re: How do I implement non-blocking IO on Win32? <goldbb2@earthlink.net>
Leading Zeroes <sunshine@brandeis.edu>
Re: Leading Zeroes <skuo@mtwhitney.nsc.com>
make subset of the search result <fly_no_spam@china.org>
Re: make subset of the search result (Logan Shaw)
making Links active (Blstone77)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 27 Nov 2001 02:33:21 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: 2D Array from Text File
Message-Id: <3C02FAEF.A8704EE4@rochester.rr.com>
Paul Wasilkoff wrote:
>
> I would like to generate a 2D array from a text file containing 2 lines -
> one line containing a 2 digit source code, and the other with corresponding
> descriptions for the codes. This way I can easily access the list of source
> codes and their descriptions at will.
>
> What is the best way of doing this?
>
> eg: file as follows:
>
> AA,BB,CC,DD
> Alpa Pub,Number Two,Tertiary Print,Forth Chapter
>
> How then would you display a list of source codes (AA,BB,CC,DD) and
> descriptions?
>
> PAW
@h=<DATA>=~/[^,\n]+/g and @h{@h}=<DATA>=~/[^,\n]+/g;
print "$_=>$h{$_}\n" for sort keys %h;
__END__
AA,BB,CC,DD
Alpa Pub,Number Two,Tertiary Print,Forth Chapter
--
Bob Walton
------------------------------
Date: 26 Nov 2001 23:21:14 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: [OT] deja-vu all over again (was Re: A Perl Bug?)
Message-Id: <m3667w6dz9.fsf_-_@mumonkan.sunstarsys.com>
"Jake Fan" <jake@chaogic.com> writes:
> You are missing the point. Let me quote my former thesis advisor whom
> you would consider God in his particular research area,
Please stop hijacking your own thread. You asked a very good
question, and your lack of interest in seeing it discussed and/or
resolved makes me wonder if you really didn't have some ulterior
motive in mind to begin with.
Over the past 5 years here, about 1 thread in every 2-300 posts to
clp.misc was about "netiquette" (compare with say c.l.scheme, where
it's only been discussed *once*, *ever*). Here's some rough figures
(google search on the year, and on the word "netiquette"- not
exactly scientific, but I wasn't aiming very high)
Year Number "netiquette" ratio
Posts thread t/p
--------------------------------------------------
96 4500 30 1 / 150
97 9960 15 1 / 640
98 12000 60 1 / 200
99 22800 85 1 / 268
00 25800 80 1 / 322
01 10300 40 1 / 257
So if you think this silly dialog about freedom of expression
and personal style hasn't been played out to death here, you
are badly mistaken. Stick to Perl and follow the groups'
conventions; don't make yourself the flavor of the week.
And if you meet Larry Wall on the road, ...
--
sub TIESCALAR {bless \$_[1]} sub STORE {${$_[0]}=$_[1]}$,=" ";$\=$/;$#Just=1;
tie $left,'main',-4; sub FETCH{${$_[0]}<0?${$_[0]}:$#[${$_[0]}++%4]}$Just[0]=
sub{$left,"\l$#[-++$_[0]]",$left&&$left.","}; @#=qw/Just Another Perl hacker/
;print ++$left, @{++$left} [$left++] -> ($left++) # some words on play
------------------------------
Date: Tue, 27 Nov 2001 11:21:31 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: A Perl Bug?
Message-Id: <yjCM7.12$HD3.142@vicpull1.telstra.net>
"Jake Fan" <jake@chaogic.com> wrote in message
news:9tu2gs$caa$1@Masala.CC.UH.EDU...
>
> Randal L. Schwartz <merlyn@stonehenge.com> wrote
>
<snip>
>
> > I'll answer your questions precisely and correctly and quickly
>
> Are you sure all your answers will be precise and correct? Or maybe I'm
> talking to a God indeed (see God Complex in an earlier post)?
>
If you realised who you were conversing with here, you would know that you
are not talking to God, but the next best thing. God would be Larry Wall.
(in a Perl context).
Wyzelli
--
push@x,$_ for(a..z);push@x,' ';
@z='092018192600131419070417261504171126070002100417'=~/(..)/g;
foreach $y(@z){$_.=$x[$y]}y/jp/JP/;print;
------------------------------
Date: 26 Nov 2001 20:05:00 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: A Perl Bug?
Message-Id: <9tuscc$r46$1@starbuck.cs.utexas.edu>
In article <9tt3g3$b1v$1@Masala.CC.UH.EDU>, Jake Fan <jake@chaogic.com> wrote:
>Heck, why computer at all, as paper and pencil used to
>be the standard, and still is in most part of the world... The point is,
>things change, and standards change accordingly. Standards are created to
>serve people, not restrict people.
They're created to serve people *by* restricting people.
>If their is a mass influx of new people
>who prefer not to do things the old way, is it possible that there is
>something not quite right with the standard (not intuitive, not convenient)?
It's possible, but that doesn't mean it's the case.
I find it difficult to believe that something about the nature of
reading and writing plain text posts has changed in such a way that a
quoting style which has been developed over (at least) 15 years is
suddenly not the right answer anymore. Really, I can only see four
changes to Usenet have happened in the last five years: (1) disk space
is cheaper, (2) networks are faster, (3) for-profit ISPs help support
the infrastructure (it's not all volunteer anymore), and (4) more
people are using it.
The only one of those things that really seems relavant to me is that
there are now people on Usenet whose text-editing skills (and/or
software) are so bad that they actually consider it a burden to
appropriately trim the quoted text before posting. If you're going to
not trim the quoted text, then top-posting seems to make sense because
otherwise the reader has to wade through huge amounts of crap to get to
part they want to read.
But since I have never seen any other reason for top posting and since
I can't condone posting to Usenet without proper trimming of quoted
material[1], that's not a justification of top-posting to me and I
can't see why top-posting should be considered.
>Perhaps we need to start considering upgrading the standard?
If it needs to be considered, it should be discussed in the appropriate
news.* newsgroups and then changed. Until it is changed, people should
respect the standard way of doing it. It's part of being a good
citizen in the Usenet community. Usenet operates on the principle that
people aren't going to take more than they give, and part of that is
voluntarily becoming familiar with how Usenet works and respecting
that.
- Logan
[1] E-mail is different. In e-mail, there's typically one person
who writes the message and one person (or just a few people)
who read the message. If it's more trouble for the author of
the message to trim it than it is for the reader to read it
backwards, then it's more efficient. But on Usenet, hundreds
of people read each message, so the only thing that makes
sense is for the author to spend a few extra seconds and save
the effort for those hundreds of people.
It used to be bad for this reason and because not trimming wastes
bandwidth. IMHO, the former is still a good enough reason even if
the latter isn't as big a deal anymore.
--
"In order to be prepared to hope in what does not deceive,
we must first lose hope in everything that deceives."
Georges Bernanos
------------------------------
Date: Mon, 26 Nov 2001 21:12:40 -0600
From: "Jake Fan" <jake@chaogic.com>
Subject: Re: A Perl Bug?
Message-Id: <9tv0c6$djn$1@Masala.CC.UH.EDU>
Wyzelli <wyzelli@yahoo.com> wrote in message
news:yjCM7.12$HD3.142@vicpull1.telstra.net...
> > > I'll answer your questions precisely and correctly and quickly
> >
> > Are you sure all your answers will be precise and correct? Or maybe I'm
> > talking to a God indeed (see God Complex in an earlier post)?
> >
> If you realised who you were conversing with here, you would know that you
> are not talking to God, but the next best thing. God would be Larry Wall.
> (in a Perl context).
You are missing the point. Let me quote my former thesis advisor whom you
would consider God in his particular research area, "every subject in
college in a struggle for everybody, students and professors alike." Larry
Wall is no doubt the Perl God. But if someday you could have a chat with
the guy, and ask him if he has precise and correct answers to every single
aspects of Perl, I will bet you good money that his answer will be "no".
Because Perl has evolved over the years from a one man's quest into a vastly
complex group effort. "The difference between a genius and an idiot is that
a genius knows his own limitations." (I am not saying that anybody in this
news group is an idiot).
Moreover, not that it's likely to happen, but if someday Larry Wall starts
to IMPOSE his own way of life (unrelated to Perl) on me (God Complex as in
one of my earlier posts), I would promptly ignore him just like the guy next
door. Personally, this statement holds true for me on every human being on
this planet, including my parents.
------------------------------
Date: Mon, 26 Nov 2001 11:13:39 +0100
From: "R. A. Larsen" <r_larsen@image.dk>
Subject: Re: ActivePerl Windows 2000 online documentation
Message-Id: <9tv2uj$eid$1@news.Stanford.EDU>
"Eric McDaniel" <ericm@vertical.com> wrote:
> I just installed the 630 build of ActivePerl for Windows 2000, and the
> online documentation seems to be a step backward. Before I start sounding
> like an ingrate, let me just state that I love the product and really
> appreciate what ActiveState is giving away for free.
[cut]
> Unless I am missing something obvious, in which case I'm sure all of you
> good people will set me straight, I am appealing to anyone who is listening
> at ActiveState to please restore the pre-build-630 html documentation for
> the next build.
I second that.
I have installed the 630 build and I have two different kind af HTML help
files:
D:\perl\Docs\ActivePerl.chm
and
D:\perl\html\perltoc.html
The first one is not updated when installing packages, but the help for e.g.
the standard packages works.
The latter *is* updated when installing packages, *but* only the help for the
newly installed packages can be used.
(Actually I never use the HTML help, as I like "perldoc" better ;) )
Regards, René
--
Using Virtual Access
http://www.vamail.com
------------------------------
Date: Mon, 26 Nov 2001 15:41:06 -0800
From: Ann Tsai <mktgadm@usenix.org>
Subject: BSDCon 2002
Message-Id: <mktgadm-A60DB4.15410626112001@reader.news.uu.net>
Keywords: USENIX, BSDCon, technical conference, research, system administration, security, Unix, Windows NT, Open Source, Tutorials, training, Invited talks, Refereed Papers, Distributed caching, embedded systems, Extensible operating, storage, kernel, BSD, resource management, virtual memory, personal digital assistants, device driver, LDAP, scalability, Client-server design development, DNS, free software, Operating systems design, Robotics and automation, CORBA, Intranet, Extranet, POSIX, software, hardware, Samba, FreeBSD, design, development, OpenBSD, NetBSD, Darwin, BSD/OS
Register by January 21, 2002 and SAVE!
http://www.usenix.org/events/bsdcon02
BSDCon 2002
February 11-14, 2002
Cathedral Hill Hotel - San Francisco, California, USA
Join the growing BSD community as we meet to explore the latest design
and implementation of BSD-based systems software at BSDCon. This years
program features keynote presentations by John Mashey of SenseiPartners
and Brett Halle of Apple Computer, as well as a unique collection of
refereed papers and invited talks covering a variety of topics,
including:
- MacOS X and Darwin
- Multiprocessing work for FreeBSD
- NetBSD work on the AMD x86-64
- Packet filtering and virtual private networks
- the continuing fight against spam
- vulnerabilities of wireless networks
- running a company based on open source software
In addition to exceptional content, BSDCon also features four
professional-level, educational tutorials. Practical and immediately
useful, these courses are an excellent way to improve the depth of your
knowledge about BSD and to stay current with the technology. BSDCon
offers the following tutorials:
* FreeBSD Kernel Internals, Part I and II
* System and Network Security
* Debugging Kernel Problems
* Porting BSD Applications to mac OS X
BSDCon's combination of technical tracks, invited talks, tutorials,
Birds-of-a-Feather sessions, and Work-in-Progress reports provide an
unparalleled opportunity for people of all experience levels to learn
from BSD experts, professionals with real world experience, and industry
leaders.
If you want to develop cutting-edge network applications, learn how to
use BSD as part of enterprise-grade solutions, or just meet the movers
and shakers of the BSD community, then BSDCon is the place to be!
=====================================================================
BSDCon 2002 is sponsored by USENIX, the Advanced Computing Systems
Association. www.usenix.org
=====================================================================
------------------------------
Date: 26 Nov 2001 20:13:32 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Can I avoid 2 passes?
Message-Id: <9tussc$r5n$1@starbuck.cs.utexas.edu>
In article <87y9l114x8.fsf@camel.tamu-commerce.edu>,
Dale Henderson <nilram@boisdarc.tamu-commerce.edu> wrote:
> So what's the difference between a hash and and associative array?
I don't know that there is a well-defined difference between them, but
if I had to come up with a definition, I'd say that an associative
array is a programming language concept and a hash is an algorithm for
implementing it.
There are other languages besides Perl[1] that have associative arrays,
and in theory they could use something other than a hash to implement
them (like a binary search tree). Really, a Perl implementation could
use something other than a hash as the implementation if it wanted to,
and if such a thing ever happened then the term "hash" would become
a bit (more?) of a misnomer.
- Logan
[1] Like awk, JavaScript, and I'm sure others, although I don't
know what they are.
--
"In order to be prepared to hope in what does not deceive,
we must first lose hope in everything that deceives."
Georges Bernanos
------------------------------
Date: Tue, 27 Nov 2001 02:20:44 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Can I avoid 2 passes?
Message-Id: <3C02F940.B2A99561@acm.org>
Drew Myers wrote:
>
> I'm writing a small perl program to parse the contents of a Unix
> /etc/passwd file into a hash. I'm using a split to separate the
> fields in /etc/passwd, but I actually just want to split the first one
> (the login name), and then dump the remaining fields into a scalar to
> form the value portion of the hash.
>
> #!/usr/bin/perl -w
> use strict;
>
> my $userlist = &BuildUserList();
>
> sub BuildUserList {
> open (EP,"</etc/passwd") || die "Can't fork open EP: $!\n";
> my %users = ();
> while (<EP>) {
> chomp;
> my ($user,$pass,$uid,$gid,$gecos,$home,$shell) = (split':');
> $users{$user} = join(':',$pass,$uid,$gid,$gecos,$home,$shell);
my ( $user, $other ) = split /:/, $_, 2;
$users{ $user } = $other;
> }
> close (EP) || die "Can't fork close EP: $!\n";
> return \%users;
> }
>
> Effectively, I'd like to combine the split and join statements above,
> but I'm not sure exactly how to do that, or if it's even a viable
> solution.
John
--
use Perl;
program
fulfillment
------------------------------
Date: Mon, 26 Nov 2001 19:57:28 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Can I avoid 2 passes?
Message-Id: <3C030F28.7EF2861F@stomp.stomp.tokyo>
Logan Shaw wrote:
> Dale Henderson wrote:
> > So what's the difference between a hash and and associative array?
> I don't know that there is a well-defined difference between them, but
> if I had to come up with a definition, I'd say that an associative
> array is a programming language concept and a hash is an algorithm for
> implementing it.
> There are other languages besides Perl[1] that have associative arrays,
> and in theory they could use something other than a hash to implement
> them (like a binary search tree). Really, a Perl implementation could
> use something other than a hash as the implementation if it wanted to,
> and if such a thing ever happened then the term "hash" would become
> a bit (more?) of a misnomer.
Well, well, one of you boys have actually added something intelligent.
* believed those boys would never arrive at this realization *
Here is code exemplifying use of a true associative array.
It is not as efficient as its equal in hash format. Still,
this might inspire some intelligent extrapolation regarding
efficiency of complex associative arrays and complex hashes.
#!perl
@Fruits = qw (apple plum grape orange);
$user_input = "Fruits";
print "@$user_input";
* not surprised none realized this earlier despite my previous examples of this *
What logical defining term would you tag to this array, @Menu?
@Menu = ("@Meat", "@Vegetables", "@Salads", "@Fruits");
$user_input = 2;
print "$Menu[$user_input]";
Godzilla!
------------------------------
Date: Tue, 27 Nov 2001 00:30:31 GMT
From: friedman@math.utexas.edu (Chas Friedman)
Subject: Canceling Usenet Messages in a script
Message-Id: <3c02dc1c.30090357@linux63.ma.utexas.edu>
I am writing some newsreading scripts using Net::NTTP.
Everything seems to work fine , but there is one thing I can't seem to
get right. Most newsreaders allow a poster to cancel a message; when
this is done it seems that a message is posted to the newsgroup (or
perhaps emailed?) with a subject of the form:
Cancel "message name". I can't seem to do this successfully in my
scripts although I've tried several ways. Does anyone on this group
know how to do this? (I realize this isn't exactly a Perl question,
although I thought perhaps there is some support for this in Net::NTTP
or another module, so I could read the code. Also, I'm guessing that
someone here has done this already.) Thanks for any info/comments!
chas friedman
------------------------------
Date: 26 Nov 2001 20:52:29 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Canceling Usenet Messages in a script
Message-Id: <9tuv5d$rar$1@starbuck.cs.utexas.edu>
In article <3c02dc1c.30090357@linux63.ma.utexas.edu>,
Chas Friedman <friedman@math.utexas.edu> wrote:
> I am writing some newsreading scripts using Net::NTTP.
>Everything seems to work fine , but there is one thing I can't seem to
>get right. Most newsreaders allow a poster to cancel a message; when
>this is done it seems that a message is posted to the newsgroup (or
>perhaps emailed?) with a subject of the form:
>Cancel "message name".
It's not the subject that does the magic.
> I can't seem to do this successfully in my
>scripts although I've tried several ways.
Read the FAQ at http://www.killfile.org/faqs/cancel.html . It will
tell you how to implement it and also tell you the DOs and DON'Ts of
cancelling.
- Logan
--
"In order to be prepared to hope in what does not deceive,
we must first lose hope in everything that deceives."
Georges Bernanos
------------------------------
Date: 26 Nov 2001 20:56:35 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Canceling Usenet Messages in a script
Message-Id: <9tuvd3$rcb$1@starbuck.cs.utexas.edu>
In article <9tuv5d$rar$1@starbuck.cs.utexas.edu>,
Logan Shaw <logan@cs.utexas.edu> wrote:
>Read the FAQ at http://www.killfile.org/faqs/cancel.html . It will
>tell you how to implement it and also tell you the DOs and DON'Ts of
>cancelling.
Oh, and I just discovered http://www.xs4all.nl/~rosalind/faq-care.html
which seems to have lots of good information.
- Logan
--
"In order to be prepared to hope in what does not deceive,
we must first lose hope in everything that deceives."
Georges Bernanos
------------------------------
Date: 27 Nov 2001 01:36:33 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: changing a html page for printing
Message-Id: <slrna05rha.pj0.damian@puma.qimr.edu.au>
On Mon, 26 Nov 2001 13:17:22 +0100, Lex Thoonen said:
>...
>How do I say in perl:
>
>look for <print> and </print> and make anything in between $result ?
>
m[<print>] .. m[</print>] and $result .= $_ while <>;
See `perldoc perlop`, and look for the paragraph beginning:
In a scalar context, ".." returns a booleans value...
HTH,
Cheers,
Damian
--
@:=grep!(m!$/|#!..$|),split//,<DATA>;@;=0..$#:;while($:=@;){$;=rand
$:--,@;[$;,$:]=@;[$:,$;]while$:;push@|,shift@;if$;[0]==@|;select$,,
$,,$,,1/80;print qq x\bxx((@;+@|)*$|++),@:[@|,@;],!@;&&$/} __END__
Just another Perl Hacker,### http://home.pacific.net.au/~djames.hub
------------------------------
Date: Mon, 26 Nov 2001 17:44:48 -0800
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: changing a html page for printing
Message-Id: <3c02f010$1@news.microsoft.com>
"Lex Thoonen" <lex@nospam.peng.nl> wrote in message
news:nec40ugf9apbtv8amfp4tndrk1p82a212s@4ax.com...
> How do I say in perl:
>
> look for <print> and </print> and make anything in between $result ?
You would use the HTML::Parser module
jue
------------------------------
Date: Mon, 26 Nov 2001 20:31:41 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: How do I implement non-blocking IO on Win32?
Message-Id: <3C02ECFD.AA20C289@earthlink.net>
Kevin Gould wrote:
[snip]
> $flags&= ~O_NONBLOCK if $nonblocking;
> $flags|+ O_NONBLOCK unless $blocking;
Is this a copy&paste error? Surely the second line there should be:
$flags |= O_NONBLOCK unless $blocking;
--
Klein bottle for rent - inquire within.
------------------------------
Date: Mon, 26 Nov 2001 20:34:58 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: How do I implement non-blocking IO on Win32?
Message-Id: <3C02EDC2.D937BE41@earthlink.net>
Kevin Gould wrote:
>
> I'm trying to write a parent/child script that will run as a service
> on Win32. I need the child to write data back to the parent, but the
> parent needs to perform other functions between polling for data from
> the child, so I need to do non-blocking IO. I'm using a routine from
> Lincoln Stein's excellent "Network Programming with Perl", but am
> having some trouble with the Fcntl module.
>
> It appears that Fcntl on Win32 doesn't implement what I need.
[snip]
> Can anyone suggest an alternate method for implementing non-blocking
> IO?
Yeah, sorta. Don't use try to it. Instead, use select or IO::Select,
etc to find out whether your sockets are readable, and use a timeout
[possibly a timeout of 0]. Then only attempt to read from those sockets
which have been indicated as being readable.
--
Klein bottle for rent - inquire within.
------------------------------
Date: Mon, 26 Nov 2001 20:26:24 -0500
From: "Joshua Sunshine" <sunshine@brandeis.edu>
Subject: Leading Zeroes
Message-Id: <9tupvl$ok0$1@new-news.cc.brandeis.edu>
Is there any way to force leading zeroes with the format command?
I know how to do it with printf, but I think the code is more readable with
format.
Any assistance is greatly appreciated.
-Josh Sunshine
------------------------------
Date: Mon, 26 Nov 2001 19:55:29 -0800
From: Steven Kuo <skuo@mtwhitney.nsc.com>
Subject: Re: Leading Zeroes
Message-Id: <Pine.GSO.4.21.0111261951420.28505-100000@mtwhitney.nsc.com>
On Mon, 26 Nov 2001, Joshua Sunshine wrote:
> Is there any way to force leading zeroes with the format command?
> I know how to do it with printf, but I think the code is more readable with
> format.
>
> Any assistance is greatly appreciated.
>
> -Josh Sunshine
If you find format easier to read, then you can use it -- you still need
to pair it with sprintf, however:
#! /usr/local/bin/perl
my $leading_zeros = sprintf("%05d",2);
my $ten_k = 10000;
format STDOUT =
SPRINTF: @<<<<
$leading_zeros
JUSTIFY: @####.##
$ten_k
.
write;
# VS.
printf "PRINTF: %05d\n", 2;
printf "JUSTIFY: %5.2f\n", $ten_k;
--
Cheers,
Steve
------------------------------
Date: Tue, 27 Nov 2001 02:10:04 GMT
From: qiang <fly_no_spam@china.org>
Subject: make subset of the search result
Message-Id: <0CCM7.34406$T67.10547165@news4.rdc1.on.home.com>
Hi, all
I 've seen some web search engine( like google ) that list search result
with a subset of the data ( like the first 30 items ) then have a button or
link to get more of the search hits.. but i don't know how to accomplish
it in perl.. can someone give me an idea or some .. since i know there are
always another way (for better ) to do .. :-)
thanks in advance !
Qiang
P.S prefer not to creat additional files to store the subset of search
result .. or if i have to , still love to hear it . excuse my picky ...
------------------------------
Date: 26 Nov 2001 21:48:24 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: make subset of the search result
Message-Id: <9tv2e8$rpv$1@starbuck.cs.utexas.edu>
In article <0CCM7.34406$T67.10547165@news4.rdc1.on.home.com>,
qiang <fly_no_spam@china.org> wrote:
>I 've seen some web search engine( like google ) that list search result
>with a subset of the data ( like the first 30 items ) then have a button or
>link to get more of the search hits.. but i don't know how to accomplish
>it in perl.. can someone give me an idea or some .. since i know there are
>always another way (for better ) to do .. :-)
The simplest way is to simply repeat the search every time your CGI (or
whatever) runs and show different parts of the results. Your "next 10
results" link would then pass a parameter to do the same query but
display a different part of it.
This may seem inefficient, but often searches are done against a
database, and some databases support a way of limiting query results.
For instance, MySQL allows you to do things like this:
select foo, bar
from mytable
where foo like "%mystring%"
limit 20,10
Here the "limit 20,10" will make it return only rows 21 through 30.
If you're doing that, you'll probably also want to do something
like this
select count(*)
from mytable
where foo like "%mystring%"
so that you actually know how many results there are.
You could get even fancier with the database-oriented approach by
creating a table in which to store temporary search results; you could
then have a bot that goes through and cleans old entries out of this
table every few minutes.
The other approach is to do the whole query all at once and store the
extra results somewhere. Storing them in a temporary file is not a
half bad idea, although you end up having to parse the temporary file
every time. In some cases, that won't actually speed anything up. You
could write a daemon to store temporary search results (and maybe even
to do the search for you) and allow your CGI (etc.) to retrieve them
through some sort of inter-process communication. Again, only in some
cases would that be a good idea.
- Logan
--
"In order to be prepared to hope in what does not deceive,
we must first lose hope in everything that deceives."
Georges Bernanos
------------------------------
Date: 27 Nov 2001 04:02:00 GMT
From: blstone77@aol.com (Blstone77)
Subject: making Links active
Message-Id: <20011126230200.29847.00001816@mb-fn.aol.com>
for (@message){
s/(\b\w{3}\.\w+\.(?:com|net|org|mil|etc).*\b)/\<a
href=\"$1\"\>$1\<\/a\>/i;
}
If I'm correct, this will make any link written in a message clickable. I have
two questions. Number one, how would I make this ignore links in message which
are already clickable. in other words, with the <a href= etc., already in it?
The number two question is, how would I make it make links clickable which
don't have www. attached to it. And also still catch those which do? Thanks for
any help.
------------------------------
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 2213
***************************************