[13197] in Perl-Users-Digest
Perl-Users Digest, Issue: 607 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 20 22:07:14 1999
Date: Fri, 20 Aug 1999 19: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 Fri, 20 Aug 1999 Volume: 9 Number: 607
Today's topics:
Re: Attn: CRAP (was Re: voting system pealse advise) (Neko)
Re: Do something with the 1st Nth of a Hash <makkulka@cisco.com>
Re: Do something with the 1st Nth of a Hash (Larry Rosler)
Re: Error message (David Efflandt)
Re: Finding the last occurance of a match/reg exp (Larry Rosler)
Re: Help with variables in a for loop with varaibles (Larry Rosler)
How to distinguish strings 'A|\\|B|' from 'A|\B|' ? holmberg@NoSpam.net
modules not located in /usr/lib/perl5 <nead@neadwerx.com>
Re: modules not located in /usr/lib/perl5 (David Efflandt)
Re: new to perl and a bit stupid <webmaster@chatbase.com>
Re: newbie CGI question re CGI.pm <webmaster@chatbase.com>
Oops: meant how distinguish 'A|\\|B|' from 'A|\|B|' holmberg@NoSpam.net
Re: Parse ANSI X12N 837 claim files <makarand_kulkarni@my-deja.com>
Re: Perl regex matching problem (in a Java env) moc.cnioro@sfd.strip.this.and.reverse
Re: processing html on the fly part 2 <flavell@mail.cern.ch>
Re: replacing @, /, . etc, in POST method (David Efflandt)
Re: Request for Comments: www.perl.com (Alan Barclay)
Re: Request for Comments: www.perl.com <revjack@radix.net>
Re: Request for Comments: www.perl.com <revjack@radix.net>
Re: Shell vs Perl (Neko)
Re: Shell vs Perl (Larry Rosler)
Re: What are valid characters in hash keys (Larry Rosler)
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 21 Aug 1999 01:09:38 GMT
From: tgy@chocobo.org (Neko)
Subject: Re: Attn: CRAP (was Re: voting system pealse advise)
Message-Id: <7pku8i$ijt$1@216.39.141.200>
On Fri, 20 Aug 1999 16:03:23 -0700, lr@hpl.hp.com (Larry Rosler) wrote:
>In article <7pkivn$32p$1@216.39.141.200> on 20 Aug 1999 21:57:11 GMT,
>Neko <tgy@chocobo.org> says...
>> On 20 Aug 1999 08:08:55 GMT, sholden@pgrad.cs.usyd.edu.au (Sam Holden) wrote:
>>
>> >On Fri, 20 Aug 1999 00:49:36 -0700, Larry Rosler <lr@hpl.hp.com> wrote:
>...
>> >> ({
>> >> add_topic => \&add_topic,
>> >> showvote => \&showvote,
>> >> others => \&others,
>> >> vote => \&vote,
>> >> results => \&results,
>> >> delete => \&delete,
>> >> }->{$FORM{action})->();
>> >
>> >eval "&$FORM{action}()";
>> >
>> >Why use a hash when you have got the symbol table I say ;)
>>
>> Or if the prospect of running unknown code through eval() scares you:
>>
>> $FORM{action}->();
>
>At least the 'eval' form makes it through "use strict 'refs';"
Do you really believe passing 'use strict' but failing -T is better than the
reverse? Especially in this case where it is a CGI script?
>And both of these approaches assume that the names of the subroutines
>are the same as the values of $assFORM{action}, which isn't necessary in
>general.
The hash dispatch does likewise. It blindly assumes that $FORM{action} is
the name of a hash key, which also isn't necessary in general. The real
difference is that the hash will let you limit what code will run -- not all
subroutines are up for grabs.
--
Neko | tgy@chocobo.org | Will hack Perl for a moogle stuffy! =^.^=
------------------------------
Date: Fri, 20 Aug 1999 17:08:36 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: Do something with the 1st Nth of a Hash
Message-Id: <37BDEE04.AB9F27F4@cisco.com>
[ Mesarchm wrote:
> How can I print out the 1st Nth values of a hash?
We cannot talk about the first N values of a hash as the keys are
not having any order. If you want the first N values using the first N
keys ( after a sort ) do a splice.
%h=( a=>1, d=>2, c=>3, e=>4, z=>5, h=>6, k=>7, j=>8, x=>9, y=>10 ) ;
@first_5 = ( sort keys %h)[ 1..5] ;
print join ' ', @first_5 ;
You will need the code block after sort if the sort you need is not
alphabetic.
By default the sort is alphabetic.
--
------------------------------
Date: Fri, 20 Aug 1999 17:52:19 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Do something with the 1st Nth of a Hash
Message-Id: <MPG.1227981fffa1f37989e8b@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <37BDEE04.AB9F27F4@cisco.com> on Fri, 20 Aug 1999 17:08:36 -
0700, Makarand Kulkarni <makkulka@cisco.com> says...
> [ Mesarchm wrote:
>
> > How can I print out the 1st Nth values of a hash?
>
> We cannot talk about the first N values of a hash as the keys are
> not having any order. If you want the first N values using the first N
> keys ( after a sort ) do a splice.
You mean a slice, not a splice.
> %h=( a=>1, d=>2, c=>3, e=>4, z=>5, h=>6, k=>7, j=>8, x=>9, y=>10 ) ;
> @first_5 = ( sort keys %h)[ 1..5] ;
> print join ' ', @first_5 ;
I think you are spending far too much time answering questions fast and
far too little time testing what you post. You might find testing the
code to be a valuable way of improving your Perl skills. Posting
without testing (or clearly indicating UNTESTED) is simply
irresponsible.
Perl is not Fortran. Array indexes start with 0, not 1.
In any case, the answer to this question -- sorting by *values* -- can
be found in the FAQ, perlfaq5: "How do I sort a hash (optionally by
value instead of key)?", followed by a correct slice.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 21 Aug 1999 01:25:21 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Error message
Message-Id: <slrn7rs080.11k.efflandt@efflandt.xnet.com>
On Fri, 20 Aug 1999 19:29:00 GMT, Teacher Guy <habfan2@my-deja.com> wrote:
>Hello! I have an error message that reads, "Premature end of script
>headers". I have +100 lines of code and one dumb error. Can someone
>help.
Wrong newsgroup (should be in *.authoring.cgi). Your error could happen
for so many reasons that no one could venture a guess. I can't tell you
how many times I forgot a quote or nested ) or ;
It is best to run the script from the shell (telnet) as ./scriptname.cgi
to get more complete error messages before even attempting to run it on
the web. One reason I run Linux is so I can test everything completely
before uploading it. Very helpful for sites that only have ftp access.
And even for sites with only ftp access, I wrote a webshell that can
run shell commands. See http://cgi-help.virtualave.net/pub/webshell.txt
--
David Efflandt efflandt@xnet.com http://www.xnet.com/~efflandt/
http://www.de-srv.com/ http://cgi-help.virtualave.net/
------------------------------
Date: Fri, 20 Aug 1999 17:39:46 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Finding the last occurance of a match/reg exp
Message-Id: <MPG.1227952ce314b683989e8a@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <7pkh8b$egu$1@nnrp1.deja.com> on Fri, 20 Aug 1999 21:27:53
GMT, marcza@my-deja.com <marcza@my-deja.com> says...
> O.k. I can find the last occurance of a match by using a loop
> similar to:
>
> $string = "One table two table three table forth table";
> while ($string =~ /(\w+)\s+table\b/g) {
> }
>
> But can find the word directly before the last occurnace of a
> match without a loop - just with a reg expression ?
$string =~ /.*\b(\w+)\s+table\b/ and print "$1\n";
And that's spelled 'fourth', though I think you mean 'four' to go with
'One', 'two', and 'three'.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 20 Aug 1999 17:25:26 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Help with variables in a for loop with varaibles
Message-Id: <MPG.122791cf63eeba6f989e89@nntp.hpl.hp.com>
In article <37BDCEB8.2BA2CCE@cisco.com> on Fri, 20 Aug 1999 14:55:04 -
0700, Makarand Kulkarni <makkulka@cisco.com> says...
> [ Adam Berns wrote:
> > What I have is a for loop that looks like this:
> > for ($temp=1; $temp <= $nofields; $temp++) {
> > if ($FORM{'eventid.$temp.guest'} ne "") {
No interpolation.
> > $FORM{'eventid.$temp.guest'}++;
> > $FORM{eventid.$temp.cost} = $FORM{eventid.$temp.cost} *
Barewords.
> > $FORM{'eventid.$temp.guest'};
> > $FORM{'eventid.$temp.guest'}--;
> > }
> > }
> >
> > What I want to happen is thsy yhr $temp is replaced by a number. SO that when
> > ran, I would get something like this:
>
> The following statement $FORM{'eventid.$temp.guest'}++; ends up
> creating a new key in the hash %FORM. The correct way to do this
> is $FORM{'eventid'.$temp.'guest'}++ so that value for $temp is substituted.
You've lost the dots in the desired hash key. Just use double-quotes
instead of single-quotes.
$FORM{"eventid.$temp.guest"}++
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 21 Aug 1999 01:13:00 GMT
From: holmberg@NoSpam.net
Subject: How to distinguish strings 'A|\\|B|' from 'A|\B|' ?
Message-Id: <37bdf7e8.31505799@news.tiac.net>
Hi,
Is it even possible to distinguish these two strings as read from a file?
Problem is, I have database dumps with fields distinguished by '|', but the '|'
is also present as a literal as '\|' and so should not be treated as a field
separator, and worse, escaped backslashes are present
(there are even cases where 'A|\\|B' is present, which is a fragment with
a field contains only a '\' in escaped form; and this is distinguished from
'A|\|B' which is one field ending with 'A', and the next starting with
'\|B' (that is, the '\' is in escaped form). A variety of techniques would
work if it were possible to treat the characters in these input strings
as straight characters (no interpolation at all), but that doesn't seem
possible.
To illustrate the problem, the strings below are not distinguished, and
I haven't been able to find a way to distinguish them because interpolation
of '\\' hits before I can do anything. Is there any way to turn off
interpolation in a local context?
# Sample showing failure to distinguish strings - these produce
# the same results:
printf "length %d %s %s\n",length('A|\|C|'),'A|\|C|',quotemeta('A|\|C|');
printf "length %d %s %s\n",length('A|\\|C|'),'A|\|C|',quotemeta('A|\\|C|');
What is desirable is when splitting (these are being read from a file) is to get
the following splits:
'A|\|C|' splits into ('A','\|C') (2 components)
'A|\\|C|' splits into ('A','\\','C') (3 components)
Now how can that be done within Perl given that these two strings
appear so fundamentally indistinguishable?
Carl
Antispam address: In order to reply, change NoSpam to tiac.
------------------------------
Date: 21 Aug 1999 00:34:13 GMT
From: "Nick Downey" <nead@neadwerx.com>
Subject: modules not located in /usr/lib/perl5
Message-Id: <01beeb6c$bcbf94e0$73463d80@r52h83>
I have written my own set of modules.
The modules do not serve purpose enough to warrant installation in the
default perl path, and since I am not the system administrator I can't
simply 'put them there anyway'.
/doc_root/modules/ <all my modules are here>
/doc_root/someotherdir/ <I would like to use the modules here>
myscript.pl:
#!/usr/bin/perl -w
use strict;
push @INC, '/doc_root/modules';
use MyModule1;
use MyModule2;
./myscript.pl
Can't locate MyModule1.pm in @INC (@INC contains: <the above addition is
NOT here>, blah, blah blah)
------------------------------
Date: 21 Aug 1999 01:36:41 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: modules not located in /usr/lib/perl5
Message-Id: <slrn7rs0t9.11k.efflandt@efflandt.xnet.com>
On 21 Aug 1999 00:34:13 GMT, Nick Downey <nead@neadwerx.com> wrote:
>I have written my own set of modules.
>
>The modules do not serve purpose enough to warrant installation in the
>default perl path, and since I am not the system administrator I can't
>simply 'put them there anyway'.
>
>/doc_root/modules/ <all my modules are here>
>
>/doc_root/someotherdir/ <I would like to use the modules here>
>
>myscript.pl:
>
>#!/usr/bin/perl -w
>
>use strict;
>
>push @INC, '/doc_root/modules';
This will not work. It needs to be in @INC during preprocessing before
the script is run. Instead try the correct way which unshifts it to the
front of @INC during preprocessing:
use lib '/doc_root/modules';
>use MyModule1;
>use MyModule2;
>
>./myscript.pl
>
>Can't locate MyModule1.pm in @INC (@INC contains: <the above addition is
>NOT here>, blah, blah blah)
--
David Efflandt efflandt@xnet.com http://www.xnet.com/~efflandt/
http://www.de-srv.com/ http://cgi-help.virtualave.net/
------------------------------
Date: Fri, 20 Aug 1999 18:03:47 -0700
From: TRG Software: Tim Greer <webmaster@chatbase.com>
Subject: Re: new to perl and a bit stupid
Message-Id: <37BDFAF3.65C9BFD9@chatbase.com>
Paul Glidden wrote:
>
> perl does have a getline function though.
>
> open FILEHANDLE , "filename" || die;
^^
You'll probably want to use an "or", rather then the "||" (logical or)
there.
<SNIP>
--
Regards,
Tim Greer : webmaster@chatbase.com | software@linkworm.com
The ChatBase: http://www.chatbase.com | 250,000+ hits daily Worldwide!
TRG Software: http://www.linkworm.com | CGI scripts in Perl/C, & more.
Unix/NT/Novell Administration, Security, Web Design, ASP, SQL, & more.
Freelance Programming & Consulting, Musician, Martial Arts, +Sciences.
------------------------------
Date: Fri, 20 Aug 1999 17:58:20 -0700
From: TRG Software: Tim Greer <webmaster@chatbase.com>
Subject: Re: newbie CGI question re CGI.pm
Message-Id: <37BDF9AC.AD12AF9F@chatbase.com>
either Jana or John wrote:
>
<SNIP>
> #!/user/bin/perl -w
^^^^^^^^^^^^^^
Should be:
#!/usr/bin/perl
> use CGI qw(:standard);
> my $echoline = param("anecho");
> print header, start_html("Yes, there is an echo!"), h1("You typed");
> if ($echoline) {
> print q($echoline);
> } else {
> print q("You didn't type anything.");
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
There's no reason to use q() here, unless you want it print the double
quotes. :-)
<SNIP>
--
Regards,
Tim Greer : webmaster@chatbase.com | software@linkworm.com
The ChatBase: http://www.chatbase.com | 250,000+ hits daily Worldwide!
TRG Software: http://www.linkworm.com | CGI scripts in Perl/C, & more.
Unix/NT/Novell Administration, Security, Web Design, ASP, SQL, & more.
Freelance Programming & Consulting, Musician, Martial Arts, +Sciences.
------------------------------
Date: Sat, 21 Aug 1999 01:20:32 GMT
From: holmberg@NoSpam.net
Subject: Oops: meant how distinguish 'A|\\|B|' from 'A|\|B|' ?
Message-Id: <37bdfe8d.33206244@news.tiac.net>
Hi,
Its getting too late. See prior message.
Carl
Antispam address: In order to reply, change NoSpam to tiac.
------------------------------
Date: Sat, 21 Aug 1999 00:02:24 GMT
From: Makarand Kulkarni <makarand_kulkarni@my-deja.com>
Subject: Re: Parse ANSI X12N 837 claim files
Message-Id: <7pkqaa$kte$1@nnrp1.deja.com>
[In article <scottle-1908991748490001@ddsl1-17.ddsl.mr.net>,
scottle@stribmail.com (Scott Erickson) wrote:
>I am having difficulty figuring out how to correctly parse an ANSI
>X12N 837 file. Basically, I want to verify that a received 837 has the
>correct ..{snipped..}
I just want to give you a pointer here.
FreeMed is a freely available health management software. Details
on FreeMed can be found at www.FreeMed.com. If you post
your query on the mailing list they have -- someone on the mailing
list might be able to help you or point you in the right direction.
--Makarand
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 20 Aug 1999 17:42:13 -0700
From: moc.cnioro@sfd.strip.this.and.reverse
Subject: Re: Perl regex matching problem (in a Java env)
Message-Id: <7pksl5$5pn$1@chewie.savarese.org>
In article <7phnvs$n95$1@nntp.Stanford.EDU>,
zeadeATboink.stanford.edu <spammers_suck@[127.0.0.1]> wrote:
>More complications: I'm doing this in Java code using OROMatcher and
>PerlTools from ORO software (http://www.quateams.com/oro/). So while I'm
>able to use full Perl5 regluar expressions, I can't say use s///e, where I
>could actually evaluate perl code in a substitution or other nifty Perl
>tricks. Using Perl directly isn't an option.
Hi Micah,
You need to use the Substitution interface in OROMatcher 1.1. It allows
you to execute arbitrary code in a substitution.
daniel
------------------------------
Date: Sat, 21 Aug 1999 02:19:36 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: processing html on the fly part 2
Message-Id: <Pine.HPP.3.95a.990821015010.13072A-100000@hpplus03.cern.ch>
On Fri, 20 Aug 1999, Larry Rosler wrote:
(quoting me)
> > When the _browser_ retrieves a document from the server, it does it by
> > means of a URL. That URL defines (by means of its hierarchical
> > components, separated by "/") a logical hierarchy. It (the browser)
> > neither knows nor cares which directory of the server's local file
> > system contains it.
> >
> > When the resultant document contains relative URLs, the browser resolves
> > those URLs by reference to the "base URL" of the document which contains
> > them, and that is the whole issue that seemed to be under discussion in
> > the previous thread.
>
> Yes. But the "base URL" is the server's web root directory,
Let me try again at this. I really should xpost and f'up to
c.i.w.a.cgi, but its moderation procedures prevent that from working, so
I'm just setting f'up.
The "base URL" isn't the server's _anything_ directory: it's a URL.
> which has
> nothing whatever to do with the cgi-bin directory, which the poster
> described as being treated 'as the starting directory to find images and
> reference all the paths in the web page.'
>
> To which you responded "Of course."
OK, in detail:
I have been considering the situation where the successful execution of
a CGI script results in a status-200 response and a body which is, say,
an HTML document. (I.e I disregard redirections and other less-likely
responses).
So, as far as the browser is concerned, it sent a request URL something
like, let's say for illustration:
http://some.server/cgi-bin/some.script/some/path?some-query
Which (you and I know, but the browser doesn't know or care) has
invoked a CGI script in order to generate the response document.
As far as the browser ("client") is concerned, it presented a URL,
got a 200 status, and an HTML document.
This _is_ the URL of the response document, and any relative URLs in
the response will be resolved by the browser relative to _this_ URL.
Now, I must admit I had at first ignored the case where that
extra /some/path was non-null, and fell in with agreeing that the
relative URLs would be resolved relative to http://some.server/cgi-bin/
And yes, OK, I also fell in with referring loosely to that as a
"directory". However, now that the discussion as gone this far, I think
I have to insist on calling it a URL path. The _browser_ has no
knowledge of "directories" on the server: that is a private matter as to
how the server establishes its mapping between URL paths and directories
(or data bases, or whatever it keeps its web stuff in).
So, in the frequent situation where the /some/path is null, yes, and the
conventional URL path to the script is /cgi-bin/ for example, the
relative URLs of images etc. will indeed be resolved relative to the URL
path of /cgi-bin/ - which was what I understood the original questioner
to be saying.
------------------------------
Date: 21 Aug 1999 01:47:23 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: replacing @, /, . etc, in POST method
Message-Id: <slrn7rs1ha.11k.efflandt@efflandt.xnet.com>
On Fri, 20 Aug 1999 13:00:58 -0400, Patrick Tully <pmt@top.mitre.org> wrote:
>Hi,
> I wrote a cgi program that collects some user data, such as email
>address, url and more. The problem is, is that when i get back the
>data, all the @,./ etc. charactore are replaced by %NUMBER. Is there
>any easy way to replace these %NUMBERS with the original charactors? Am
>i doing something wron? I know i could substitute the charactor back in
>for every single charactor, but i would imagine there is a simpler way?
>Please let me know... Thanks,
perldoc CGI
If you use the CGI module it will do all the converting for you along with
simple ways to print headers, forms, file upload and more.
--
David Efflandt efflandt@xnet.com http://www.xnet.com/~efflandt/
http://www.de-srv.com/ http://cgi-help.virtualave.net/
------------------------------
Date: Sat, 21 Aug 1999 01:00:27 GMT
From: gorilla@elaine.drink.com (Alan Barclay)
Subject: Re: Request for Comments: www.perl.com
Message-Id: <935197461.933546@elaine.drink.com>
In article <7pjoal$5mo$1@news.NERO.NET>,
John Stanley <stanley@skyking.OCE.ORST.EDU> wrote:
>In article <Pine.HPP.3.95a.990820141043.20918E-100000@hpplus03.cern.ch>,
>Alan J. Flavell <flavell@mail.cern.ch> wrote:
>>What the heck do you think you mean, "sites designed specifically with
>>lynx in mind". If a site is designed _for_ the WWW, then Lynx is not
>>excluded.
>
>That is not true. There is a big difference between designing a hot web
>site and doing it with text browsers in mind. The number of sites
>that do nothing at all without having javascript in yor browser are
>growing every day, and forgetting to have ALT text for images is common.
>So is the use of an imagemap as the only navigation method.
>
This is a form letter I send off to several websites a week.
>>
>>Please make your website more accessable for blind users.
>>
>>This is what Lynx (A text based browser often used by blind users) sees
>>for [insert URL]
>>
>> [Insert lynx -dump of URL]
>>
>> As you can see, your webpage isn't readable when used in this way.
>>
>> Enababling pages for Lynx doesn't neccessarily mean a lot of extra
>> work. For each image, remember to give a meaningful ALT tag. If
>> you use javascript or imagemaps, then give an alternative naviagition
>> method as well. If you're using frames, then give meaningful NOFRAMES
>> content.
>>
>> Many content management systems even allow you to give a text only
>> view without any additional work, and as a bonus, this view of your
>> site is ideal for use by the growing band of people using PDA's
>> and palm computers to surf the web while on the road.
>>
>>For an example of a very good site for blind users, please look at
>>http://news.bbc.co.uk/text_only.htm, which is just as attractive &
>>easy to use for the blind as the 'normal' version is for the sighted.
>>
>>Lynx can be downloaded from lynx.browser.org, information on
>>designing pages for blind users can be read at
>>http://www.hicom.net/~oedipus/weave.html#dawp and
>>http://www.w3.org/WAI/References/
>>
It usually gets back a 'sorry, we never thought of that' letter, and I
have seen improvements to some of the sites I've complained to.
While the 'Upgrade to Netscape or IE' excuse sort of works for those who
can, I think we should always remember that there are people who cannot,
and we shouldn't exclude them.
------------------------------
Date: 21 Aug 1999 01:24:48 GMT
From: revjack <revjack@radix.net>
Subject: Re: Request for Comments: www.perl.com
Message-Id: <7pkv50$elh$1@news1.Radix.Net>
Keywords: Hexapodia as the key insight
mike cardeiro explains it all:
:the biggest problem i've encountered is some (not all) of the
:documentation is not formatted to fit any screen...so you end up with
:that pesky little horizontal scroll bar at the bottom and have to scroll
:left to right for every line you read...YUCK
This is also my only real gripe - the <PRE> text can get long, and it
suffers from being already indented by the dual-column table structure of
the site.
I also have this problem with web design where I work, where we have
hundreds of pages of government-generated 80-column text that we just
parrot on the web. The solution for wide preformatted content is to have
not one but two standard page templates; the first, like the perl.com
homepage, with a 20:80 ratio of navigation:content, and a second template
that just brands the site at top and bottom, with no tables around the
content:
+-----------------------------------------------+
| |
| BRAND/BANNER |
| |
+-----------------------------------------------+
NAV NAV NAV NAV NAV NAV NAV NAV NAV NAV
<P>regular text here</P>
<PRE>
Preformatted text here
</PRE>
<P>regular text here</P>
<P>etc.</P>
NAV NAV NAV NAV NAV NAV NAV NAV NAV NAV
+-----------------------------------------------+
| BRAND/BANNER |
+-----------------------------------------------+
It looks like most if not all of the preformatted code on www.perl.com is
already 80 columns of fewer, so giving it as much screen real estate as
possible should make for a reasonable browsing experience for most
clients.
It's nice to bring a site together under one unifying template, but it
won't break the paradigm much to have two. People will still know where
they are and what's around them.
------------------------------
Date: 21 Aug 1999 01:31:57 GMT
From: revjack <revjack@radix.net>
Subject: Re: Request for Comments: www.perl.com
Message-Id: <7pkvid$hkj$1@news1.Radix.Net>
Keywords: Hexapodia as the key insight
revjack explains it all:
:It looks like most if not all of the preformatted code on www.perl.com is
:already 80 columns of fewer,
s/of fewer/or fewer/;
------------------------------
Date: 21 Aug 1999 00:31:18 GMT
From: tgy@chocobo.org (Neko)
Subject: Re: Shell vs Perl
Message-Id: <7pks0m$ijt$0@216.39.141.200>
On Fri, 20 Aug 1999 22:02:33 GMT, mcafee@waits.facilities.med.umich.edu (Sean
McAfee) wrote:
>In article <7pkh1j$e79$1@nnrp1.deja.com>, <kcounts@my-deja.com> wrote:
>>The system administrator at my workplace doesn't believe
>>that a Perl program can be written to mimic the functionality of the
>>below shell script and still keep as simple as the shell script.
>
>>!#/usr/bin/ksh
>>if [ "$1" = "" ]
>> then sort -t: +2n -3 /etc/passwd
>>else
>> grep "[:/]$1[:/]" /etc/passwd | sort -t: +2n -3
>>fi
>
>>He says it took him a page and a half in Perl.
>>I know it can be more efficient.
>
>#!/usr/local/bin/perl
>
>@lines = do { local @ARGV = '/etc/passwd'; <> };
>@lines = grep m|[:/] $ARGV[0] [:/]|x, @lines if $ARGV[0] ne "";
>print map { $_->[0] }
> sort { $a->[1] <=> $b->[1] or $a->[2] cmp $b->[2] }
> map { [ $_, (split /:/)[2,0] ] } @lines;
>
>I imagine it looks complicated to a beginner, but an intermediate to
>advanced programmer ought to be able to apprehend it pretty quickly.
Not that the system administrator is necessarily a beginner in Perl, but
compared to his ksh script, he may still find that too complicated. If so,
then perhaps the following will meet his criterion for simplicity.
#!/usr/bin/perl
print @ARGV
? `grep "[:/]$ARGV[0]\[:/]" /etc/passwd | sort -t: +2n -3`
: `sort -t: +2n -3 /etc/passwd`;
--
Neko | tgy@chocobo.org | Will hack Perl for a moogle stuffy! =^.^=
------------------------------
Date: Fri, 20 Aug 1999 18:10:10 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Shell vs Perl
Message-Id: <MPG.12279c4910077852989e8c@nntp.hpl.hp.com>
In article <7pks0m$ijt$0@216.39.141.200> on 21 Aug 1999 00:31:18 GMT,
Neko <tgy@chocobo.org> says...
> On Fri, 20 Aug 1999 22:02:33 GMT, mcafee@waits.facilities.med.umich.edu (Sean
> McAfee) wrote:
>
> >In article <7pkh1j$e79$1@nnrp1.deja.com>, <kcounts@my-deja.com> wrote:
> >>The system administrator at my workplace doesn't believe
> >>that a Perl program can be written to mimic the functionality of the
> >>below shell script and still keep as simple as the shell script.
> >
> >>!#/usr/bin/ksh
> >>if [ "$1" = "" ]
> >> then sort -t: +2n -3 /etc/passwd
> >>else
> >> grep "[:/]$1[:/]" /etc/passwd | sort -t: +2n -3
> >>fi
...
> Not that the system administrator is necessarily a beginner in Perl, but
> compared to his ksh script, he may still find that too complicated. If so,
> then perhaps the following will meet his criterion for simplicity.
>
> #!/usr/bin/perl
>
> print @ARGV
> ? `grep "[:/]$ARGV[0]\[:/]" /etc/passwd | sort -t: +2n -3`
> : `sort -t: +2n -3 /etc/passwd`;
Sure. Why not let the commands do the printing?
#!/usr/bin/perl
system(@ARGV ? qq{grep "[:/]$ARGV[0]\[:/]" /etc/passwd |
sort -t: +2n -3} :
: 'sort -t: +2n -3 /etc/passwd');
You may be trying to be funny, but I look in vain for a smiley. Your
program may be written using Perl syntax, but it is a shell program
nonetheless.
The issue is not the language syntax but the level of discourse.
The operators in a shell program are commands; the operands are
(typically) files. Try doing arithmetic on shell variables some time,
and you will see that it is not natural or pleasant.
The operators in a Perl program are C-like operators and functions; the
operands are (typically) numbers, strings, arrays and hashes. There are
really very few Perl operations that deal directly with files as
operands (other than to open them in order to read or write their
contents).
Your program consists of command invocations, so it is a shell program
in Perl clothing. It proves nothing about the capabilities of Perl.
Sean's program does.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 20 Aug 1999 17:12:25 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: What are valid characters in hash keys
Message-Id: <MPG.12278ec785f4446989e88@nntp.hpl.hp.com>
In article <37BDC174.E4E3132F@cajunbro.com> on Fri, 20 Aug 1999 20:58:28
+0000, Mark McCoy <mcking@cajunbro.com> says...
> Roger Musson wrote:
> >
> > $hash{key}='some_value';
> >
> > What are the valid characters for 'key'
> >
> > I can't find any reference to this anywhere, all examples use
> > alphanumeric.
...
> I believe it is the same as for the variable names themselves, no
> "@$%[]{}<>()..." (unless you want to spend the whole time escaping the reserved
> characters)
There are no reserved characters.
> Stick with alphanumeric and you will be ok.
Yes, you will, but you are totally wrong about this. Absolutely any
string will do, including even the null string "".
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 99)
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. Due to their sizes, neither the Meta-FAQ nor
the FAQ are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq" from
almanac@ruby.oce.orst.edu.
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 V9 Issue 607
*************************************