[19033] in Perl-Users-Digest
Perl-Users Digest, Issue: 1228 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 2 00:05:32 2001
Date: Sun, 1 Jul 2001 21: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)
Message-Id: <994046706-v10-i1228@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 1 Jul 2001 Volume: 10 Number: 1228
Today's topics:
Re: cant modify $_[x] ???? (Eric Bohlman)
Co-Creator of UseNet, Jim Ellis had passed on... (John LYC)
Re: Code Review Needed! <redsquirreldesign@yahoo.com>
Re: Code Review Needed! (Randal L. Schwartz)
Re: command line news posting tools <rookswood@suburbian.com.au>
Re: File parsing/split question (Garry Williams)
Re: How I can use CVS? (Garry Williams)
Re: ImageMagick installation (Martien Verbruggen)
New babies to Perl - FREE Documentation Require <kvwong@singnet.com.sg>
Newbie - Need large font <sprenger@rahul.net>
Re: Newbie - Need large font (Logan Shaw)
Re: Newbie - Need large font <junk@mytechsolutions.com>
Re: Newbie - Need large font <r1ckey@home.com>
Re: Open or Die - is die the only choice? <wyzelli@yahoo.com>
Re: Regexp problem (Eric Bohlman)
Re: Scanning a file in CGI <wyzelli@yahoo.com>
Re: Scanning a file in CGI <wyzelli@yahoo.com>
Re: Selling Scripts (Tony L. Svanstrom)
Re: Selling Scripts <somewhere@in.paradise.net>
Some fun with obfuscation, LOGO Japhing (Clinton A. Pierce)
Re: Storing a hash in a DBM file - example wanted. (Garry Williams)
Re: stripping Underscores (Zur Aougav)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 1 Jul 2001 22:55:45 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: cant modify $_[x] ????
Message-Id: <9ho9ph$qfm$1@bob.news.rcn.net>
[posting this because it's for the benefit of quite a few lurkers]
Tina Mueller <tinamue@zedat.fu-berlin.de> wrote:
> the only thing which made me say "isn't this a discussion group?"
> was "your explanation did more harm than good".
> okay, maybe i took it too seriously, and you misunderstood my
> answer.
The reason a lot of regulars here get touchy when someone posts an
incorrect explanation is that there are a lot of people reading this group
who, if they come across something that *appears* to solve their problem,
will simply grab it and stop reading further. While you've indicated a
definite interest in learning, not everyone has such a good attitude; some
people just want code they can cut and paste without having to learn
anything.
The upshot of all this is that there's a lot of superstitious Perl code
out there, code that may "work" under ideal conditions, but that falls
apart in situations the author didn't anticipate. For example, there are
*still* Web-based message-board scripts, written in Perl, that display the
current year as "19101" because the programmer guessed at how the
localtime() function worked rather than actually checking the
documentation. And much of this code was simply cut-and-pasted from
various sources, including this group, by people who didn't really
understand what the code was doing.
Unfortunately, because Perl doesn't have the kind of marketing force
behind it that say, Java or VB have, the existence of sloppy,
superstitious code leads to the creation of negative myths about Perl's
reliability, especially among People With Pointy Hair (PWPH). These myths
can make it politically difficult to use Perl in applications where it
really is the best choice of language. For example, the misuse of
localtime() led to lots of myths that Perl "wasn't Y2K ready."
Experienced Perl programmers, therefore, tend to react strongly to
anything that might propagate such myths. Bad code has a way of taking on
a life of its own.
Fortunately, there's a good way to avoid accidentally propagating
misinformation: *test* any code before posting it (in some circumstances
this isn't possible; in that case, clearly indicate that your code is
untested). And if you're uncertain about how a particular construct
works, *look it up* in Perl's extensive, *free* documentation rather than
guessing about it. Sure, you'll make mistakes sometimes--we all do--and
you'll get called on them, but if it's obvious that you've done your
homework, the tone of the correction will be gentle. Having your mistakes
pointed out to you is an *inevitable* part of being a programmer (remember
that it's often going to be the computer that does the pointing out) and
with the right attitude, you can become a better programmer (in this
field, there's *never* a point where one can stop learning) for it.
------------------------------
Date: 1 Jul 2001 19:47:14 -0700
From: jlee5@fedex.com (John LYC)
Subject: Co-Creator of UseNet, Jim Ellis had passed on...
Message-Id: <f2fd209e.0107011847.613f6887@posting.google.com>
Hi all,
Jim Ellis had passed on on thursday. He was one of the great people
behind Usenet. His presence and effort will be deeply remembered.
Read the cnet report:
http://news.cnet.com/news/0-1003-200-6417607.html?tag=st.ne.1003.saslnk.saseml
Best Regards,
John Lyc.
------------------------------
Date: Mon, 02 Jul 2001 01:10:52 GMT
From: "Dave Hoover" <redsquirreldesign@yahoo.com>
Subject: Re: Code Review Needed!
Message-Id: <wSP%6.102851$mG4.48827033@news1.mntp1.il.home.com>
John W. Krahn wrote:
> Dave Hoover wrote:
> > John W. Krahn wrote:
> > >
> > > From Soapbox.pm
> > >
> > > sub formatTerms {
> > > my $s = shift;
> > > my @search = $s->{param}{search} =~ /([\w']+)/g;
> >
> > This is very cool. I tested it and it obviously does what it needs to
do,
> > but I'm not sure how. Why did you use this rather than the split, is it
> > faster?
>
> Because Randal says so! :-)
That's good enough for me!
=====
Dave Hoover
"Twice blessed is help unlooked for." --Tolkien
http://www.redsquirreldesign.com/dave
------------------------------
Date: 01 Jul 2001 20:12:59 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Code Review Needed!
Message-Id: <m13d8gauro.fsf@halfdome.holdit.com>
>>>>> "John" == John W Krahn <krahnj@acm.org> writes:
>> > sub formatTerms {
>> > my $s = shift;
>> > my @search = $s->{param}{search} =~ /([\w']+)/g;
>>
>> This is very cool. I tested it and it obviously does what it needs to do,
>> but I'm not sure how. Why did you use this rather than the split, is it
>> faster?
John> Because Randal says so! :-)
John> This only extracts the strings you want while split can put a null
John> string in the first element.
My rule of thumb is:
when it's easier to talk about what you want to throw away, use split
when it's easier to talk about what you want to keep, OR you need to
have access in the "middle" of the locating, use m//g
Both are useful.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Mon, 02 Jul 2001 00:00:00 GMT
From: John Savage <rookswood@suburbian.com.au>
Subject: Re: command line news posting tools
Message-Id: <010702000100044.02Jul01$rookswood@suburbian.com>
>On 20 Jun 2001 23:58:19 -0300, * Tong * <sun_tong@users.sourceforge.net>
>wrote:
>
>> Please suggest a news posting tool that can be used from command
>> line, which has the function that like 'sendmail -t' (scanned
>> message for headers) TIA
inews -h <file
--
John Savage (for email, replace "ks" with "k" and delete "n")
------------------------------
Date: Sun, 01 Jul 2001 23:22:58 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: File parsing/split question
Message-Id: <slrn9jvc6h.pe1.garry@zfw.zvolve.net>
On Fri, 08 Jun 2001 13:57:51 GMT, Mark Riehl <mriehl@home.com> wrote:
> I've got a text file that has the following format:
>
> G 093 13:49:39.307 PPP FRAME-RX CRC=2CF0 OK
>
> I'd like to parse it and end up with each field in a separate variable
> delimited by space, colon, and period. I tried using the following:
>
> ($f1,$f2,$f3...) = split (' '|':','.', $_);
I think your questions would be answered, if you read the split()
manual page (in perlfunc).
> Question on split - can it support multiple delimiters?
Yes.
> If so, can you
> point me off to an example?
The first parameter to split is /PATTERN/, according to the manual
page. You have used an expression involving three strings. You want
a regular expression instead.
(Your expression is parsed as compute the bit-wise OR of " " with ":";
the comma operator then throws it away; finally, use "." as the
pattern. This matches *any* character in any string, so the fields
are all empty strings -- since each character of the string is a
delimiter. The manual page says that empty fields on the end are
thrown away. You now have all empty strings, so you end up with
undefined values for each of your variables in the list on the left
hand side of the assignment, since they are all thrown away.)
($f1,$f2,$f3...) = split /[ :.]/, $_;
This specifies a pattern that will match on any of blank, `:', or `.',
which is what you appear to want.
The second parameter will default to $_, so it can be left off
altogether.
($f1,$f2,$f3...) = split /[ :.]/;
> I haven't been able to find a good example so
> far.
See the manual page.
--
Garry Williams
------------------------------
Date: Sun, 01 Jul 2001 23:32:24 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: How I can use CVS?
Message-Id: <slrn9jvco8.pe1.garry@zfw.zvolve.net>
On Tue, 26 Jun 2001 12:31:32 +0300, Mauri Heinonen <mauri@netland.fi> wrote:
> How I can use CVS?
>
> I can't set CVSROOT, how I can do that?
1. See the perlvar manual page and check the %ENV explanation.
$ENV{CVSROOT} = "my cvsroot";
2. Assuming you're calling cvs using system (or backtics), see your
shell's (/bin/sh?) manual page to see how to set the environment for a
command.
$rc = system("CVSROOT='my cvsroot' cvs co module");
--
Garry Williams
------------------------------
Date: Mon, 02 Jul 2001 03:35:35 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: ImageMagick installation
Message-Id: <slrn9jvr07.4ot.mgjv@verbruggen.comdyn.com.au>
On Fri, 29 Jun 2001 16:55:24 GMT,
Lex <nospam@peng.nl> wrote:
>
> Now, I've never had much trouble with them, I would just like to know it
> their reply is reasonable.
>
> Does anybody know? Is ImageMagick so hard to install?
First of all: ImageMagick is not a Perl program, and really has
nothing to do with Perl. The Image::Magick Perl module is just an
interface to the ImageMagick set of tools and libraries. You'd be much
better off asking this question on the ImageMagick mailing list.
That said:
ImageMagick isn't hard to install at all. However... It uses a large
number of external programs and libraries to do the importing and
exporting of the various file formats. if your provider hasn't got
many of those installed, then the build will be either very spartan,
or maybe it won't even build if certain libraries arent available. I
don't know which platform your provider runs on, but depending on how
complete you want the installation to be, it can be quite a bit of
work.
On most platforms I've ever installed it on, it compiles without
troubles. all of these platforms were some variant of Unix or BSD.
For more information about how reasonable or unreasonable this all is,
I suggest you use the ImageMagick mailing list, where the amount of
expertise and experience with ImageMagick is likely to be higher.
Martien
--
Martien Verbruggen |
Interactive Media Division | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: Mon, 2 Jul 2001 10:28:10 +0800
From: "Kelvin Wong" <kvwong@singnet.com.sg>
Subject: New babies to Perl - FREE Documentation Require
Message-Id: <9holud$437$1@dahlia.singnet.com.sg>
Greeting all,
I'm a new babies in Perl Programming and does anyone know where can i get
the FREE documentation of learning Perl Programming?
Any suggested URL?
Thanks a lot! I appreciate your help!
Kelvin Wong
------------------------------
Date: 1 Jul 2001 23:42:39 GMT
From: Bob Sprenger <sprenger@rahul.net>
Subject: Newbie - Need large font
Message-Id: <9hochf$3qk$1@samba.rahul.net>
Keywords: font, screen
I am writing a flash-card program and need a large font to display
on the screen. Are there large fonts available in the perl4 or perl5
distributions ? If not would like a recommendation for software that
might be available from CPAN. Dosnt have to be fancy, just want the
screen text info legible from 4' to 5' away from display.
Many thanks for any advice.
--
Bob Sprenger
------------------------------
Date: 1 Jul 2001 20:02:19 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Newbie - Need large font
Message-Id: <9hoh6r$31s$1@charity.cs.utexas.edu>
Keywords: font, screen
In article <9hochf$3qk$1@samba.rahul.net>,
Bob Sprenger <sprenger@rahul.net> wrote:
>I am writing a flash-card program and need a large font to display
>on the screen. Are there large fonts available in the perl4 or perl5
>distributions ?
No, there aren't any fonts at all. Perl doesn't have a GUI. There are
GUI toolkits you can get to use with Perl, like Tk, but they certainly
don't come as part of the regular distribution. And anyway, if your
program is text-based, you'd have to rewrite it to have a GUI.
> If not would like a recommendation for software that
>might be available from CPAN. Dosnt have to be fancy, just want the
>screen text info legible from 4' to 5' away from display.
My suggestion is that you make whatever terminal window
you're using larger. If on Unix, you probably want to tweak
the configuration for xterm or something similar (dtterm?
eterm? there are many choices). If on Windows, there is
some way of making DOS windows' fonts larger, I think.
- Logan
--
my your his her our their _its_
I'm you're he's she's we're they're _it's_
------------------------------
Date: Sun, 1 Jul 2001 20:48:19 -0600
From: Jopa <junk@mytechsolutions.com>
Subject: Re: Newbie - Need large font
Message-Id: <PeR%6.1643$hs2.513779@news.uswest.net>
Logan Shaw wrote:
> In article <9hochf$3qk$1@samba.rahul.net>,
> Bob Sprenger <sprenger@rahul.net> wrote:
>>I am writing a flash-card program and need a large font to display
>>on the screen. Are there large fonts available in the perl4 or perl5
>>distributions ?
>
> No, there aren't any fonts at all. Perl doesn't have a GUI. There are
> GUI toolkits you can get to use with Perl, like Tk, but they certainly
> don't come as part of the regular distribution. And anyway, if your
> program is text-based, you'd have to rewrite it to have a GUI.
>
>> If not would like a recommendation for software that
>>might be available from CPAN. Dosnt have to be fancy, just want the
>>screen text info legible from 4' to 5' away from display.
>
> My suggestion is that you make whatever terminal window
> you're using larger. If on Unix, you probably want to tweak
> the configuration for xterm or something similar (dtterm?
> eterm? there are many choices). If on Windows, there is
> some way of making DOS windows' fonts larger, I think.
>
> - Logan
If your flash card prog will run on machines with a web browser you could
just use html output from your script and make the fonts whatever
size/fonts you want.
lynx would handle the font size (html) and the perl and output nicely on
any unix box.
Otherwise,
Here is a command to launch xterm with pre defined foreground, background
and font. note, this font may not be on your box.
xterm -fg gray -bg black -fn 10x20
In FreeBSD, I can get a list of available fonts with
xlsfonts
Anyway,
Good Luck.
Jopa
~~~~~`
------------------------------
Date: Mon, 02 Jul 2001 03:27:53 GMT
From: Rickey Ingrassia <r1ckey@home.com>
Subject: Re: Newbie - Need large font
Message-Id: <ZSR%6.7325$wr.35828@news1.frmt1.sfba.home.com>
Bob Sprenger <sprenger@rahul.net> on 1 Jul 2001 23:42:39 GMT wrote:
>I am writing a flash-card program and need a large font to display
>on the screen. Are there large fonts available in the perl4 or perl5
>distributions ? If not would like a recommendation for software that
>might be available from CPAN. Dosnt have to be fancy, just want the
>screen text info legible from 4' to 5' away from display.
>Many thanks for any advice.
>--
> Bob Sprenger
Try Figlet (google search) it will output large ASCII charactors like the
following (hope it looks OK in your viewer),
_____ _ _ _
| ___(_) __ _| | ___| |_
| |_ | |/ _` | |/ _ \ __|
| _| | | (_| | | __/ |_
|_| |_|\__, |_|\___|\__|
|___/
--
------------------------------
Date: Mon, 2 Jul 2001 10:41:37 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Open or Die - is die the only choice?
Message-Id: <MOP%6.19$sq2.988@vic.nntp.telstra.net>
"Gary" <gamtci@mpinet.net> wrote in message news:3B3DF426.19D4@mpinet.net...
> Every book I have shows "open or die". Isn't there any other way
> to determine if the open succeeded? I have been checking for
> existence using if (-f $file) first, but I'd still rather know the
> open succeeded.
open (IN, '<my/file/here') or errorhandler("Could not open File $!");
later...
sub errorhandler {
#do the approriate things about the error with the message and error
passed in ..
}
Wyzelli
--
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass it
around');
$d='$_$a$s$b$w';$e='$_$a$s$b';sub d{$h=shift;$h=~s/\$(\w+)/${$1}/g;return$h}
sub
e{return(shift!=1)?'s':''}for(reverse(1..100)){$s=e($_);$f=d($d);$g=d($e);
$c.="$f\n$g\n$t\n";$_--;$s=e($_);$e=d($d);$c.="$e\n\n";}print"$c*hic*";
------------------------------
Date: 1 Jul 2001 23:03:08 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Regexp problem
Message-Id: <9hoa7c$qfm$2@bob.news.rcn.net>
Jan Klaverstijn <jan@klaverstijn.nl> wrote:
> The ones from worrked as well Michael and John did not meet all of my
> requirements. I do wonder why Benjamin's
> $date = $1 if /^Date:\s(.+)(?:\s\(.+\))?/;
> doesn't work. It makes perfect sense to me. But the timezone between parens
> remains in $1. Could it be my perl installation? perl -V output folows.
Nope. It's because the first ".+" in the expression is greedy, and
everything that comes after it is optional. The regex engine will gobble
up everything after "Date: " and then find that it's in a position to
match the empty string, at which point it will declare "done." It won't
try to backtrack and shorten the first match, even if that would enable it
to capture the optional part.
------------------------------
Date: Mon, 2 Jul 2001 10:12:47 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Scanning a file in CGI
Message-Id: <RnP%6.9$sq2.870@vic.nntp.telstra.net>
"Joe Schaefer" <joe+usenet@sunstarsys.com> wrote in message
news:m3ofr7pg1h.fsf@mumonkan.sunstarsys.com...
> "Wyzelli" <wyzelli@yahoo.com> writes:
>
> > But try a 1-2 Mb file read and process with the line by line method
compared
> > to the read all into an array method, and you can often see signinficant
> > performance improvements, at the cost of system resources.
>
> Can you back this up? I just tested
>
> something() while <FILE>;
>
> against
>
> my @f = <FILE>;
> something() foreach @f;
Only that changing
while (<IN>){
#lots of different processing
}
to
@lines = <IN>;
for (@lines){
#same bunch of processing
}
Made a huge difference in a couple of cases.
The cases were where I read several files and build up hashes of data before
doing a whole bunch of processing and the script runtimes went from 10
minutes to less than a minute and disk activity dropped from continuous
activity to a couple of short blinks.
I can make an attempt to quantify it if it is really necessary, but I di
agree with Anno, in that we see it proposed as a fix for problems which have
nothing to do with the disk I/O performance.
This is not a 'guaranteed' performance improvement, and I do not advocate it
very often, and always with the caveats that memory consumption can go
through the roof.
Wyzelli
--
push@x,$_ for(a..z);push@x,' ';
@z='092018192600131419070417261504171126070002100417'=~/(..)/g;
foreach $y(@z){$_.=$x[$y]}y/jp/JP/;print;
------------------------------
Date: Mon, 2 Jul 2001 11:51:47 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Scanning a file in CGI
Message-Id: <yQQ%6.32$sq2.1199@vic.nntp.telstra.net>
"Wyzelli" <wyzelli@yahoo.com> wrote in message
news:RnP%6.9$sq2.870@vic.nntp.telstra.net...
> "Joe Schaefer" <joe+usenet@sunstarsys.com> wrote in message
> news:m3ofr7pg1h.fsf@mumonkan.sunstarsys.com...
> > "Wyzelli" <wyzelli@yahoo.com> writes:
> >
> > > But try a 1-2 Mb file read and process with the line by line method
> compared
> > > to the read all into an array method, and you can often see
signinficant
> > > performance improvements, at the cost of system resources.
> >
> > Can you back this up? I just tested
> >
> > something() while <FILE>;
> >
> > against
> >
> > my @f = <FILE>;
> > something() foreach @f;
>
> Only that changing
>
> while (<IN>){
> #lots of different processing
> }
>
> to
>
> @lines = <IN>;
> for (@lines){
> #same bunch of processing
> }
>
> Made a huge difference in a couple of cases.
It also occurred to me today, that another case where this can be useful is
where there is a lot of processing and the opening / closing of the file can
be time critical.
open file
while (<IN>){
#do stuff lots of times
}
close file
vs
open file
@lines = <IN>;
close file
for (@lines){
# do stuff lots of times
}
The second approach can give a significantly shorter window where the file
is open, particularly if multi user (with the appropriate locking
techniques - not shown) access is involved.
Once again, as with most programming, the user should be aware of the pros
and cons of any particular method.
Wyzelli
--
#Modified from the original by Jim Menard
for(reverse(1..100)){$s=($_!=1)? 's':'';print"$_ bottle$s of beer on the
wall,\n";
print"$_ bottle$s of beer,\nTake one down, pass it around,\n";
$_--;$s=($_==1)?'':'s';print"$_ bottle$s of beer on the
wall\n\n";}print'*burp*';
------------------------------
Date: Sun, 01 Jul 2001 23:08:03 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: Selling Scripts
Message-Id: <1evw8dz.17bbgal6j1t8yN%tony@svanstrom.com>
isterin <isterin@hotmail.com> wrote:
> "Misanthrope" <no@spam.net> wrote in message
> news:<Rbv%6.8953$eL5.958301@newsread1.prod.itd.earthlink.net>...
>
> > <tsee@gmx.net> wrote in message news:9hdka5$if2$07$1@news.t-online.com...
> > > "ffg" <john@trumpetweb.co.uk> schrieb im Newsbeitrag
> > > news:8or_6.4277$4i5.341643@news1.cableinet.net...
> > > In order to make it run, you need perms to be 555 or more.
> > Untrue.
>
> What's untrue. Maybe you want to explain why before you flaunt you ignorance.
The permissions, of course... it depends greatly on the server.
/Tony
--
the truth is dead, faith is gone, reality killed... ruled by the plastic
laws of modern life we're pushed towards the hell of personal doubt,
betrayal, hate, lust and murder... the now has become an illusion, a
paradise of a dead tomorrow... (c)2000-2001 tony@svanstrom.com
------------------------------
Date: Mon, 2 Jul 2001 09:32:16 +1000
From: "Tintin" <somewhere@in.paradise.net>
Subject: Re: Selling Scripts
Message-Id: <5rO%6.2$Id4.57401@news.interact.net.au>
"isterin" <isterin@hotmail.com> wrote in message
news:db67a7f3.0107011324.666b146b@posting.google.com...
> > > In order to make it run, you need perms to be 555 or more.
> >
> >
> > Untrue.
>
> What's untrue. Maybe you want to explain why before you flaunt you
ignorance.
The minimum perms needed on a Perl script is 500 (assuming it is owned by
the user who will run it).
In fact, you can even make it 400 if you invoke perl yourself, eg: perl
foo.pl
------------------------------
Date: Sun, 01 Jul 2001 23:17:59 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Some fun with obfuscation, LOGO Japhing
Message-Id: <HcO%6.150936$DG1.25088868@news1.rdc1.mi.home.com>
I was tinkering with a page-layout engine at work, bored out of my
mind, when I sketched out this JAPH. Yeah, it's bigger than a .sig
but it's fun. Save it to a file and run it. (It won't work fed to
stdin.)
Changing $s to another non-zero positive integer changes the scale.
#!/usr/bin/perl -w
$s=2;($p)=@m=(0,0,1,0);$/=\1;
sub t{@m[2,3]=(0,0);for$y(split//,$_[0]){for(2,3) {
$m[$_]+={n=>[-1,0],s=>[1,0],e=>[0,1],w=>[0,-1]}->{$y}->[$_-2];}}}
$SIG{__WARN__}=sub{$p=!$p};seek DATA,0,0;
for (qw( 6 se p 2 e 2 ne
2 n 5 p e 2 s
8 p n 6 ne 2 e
1 se 2 s 5 n 2 w 4 e 4
p e 2 s 3 p
n 8 e 4 se 1
s 2 sw 1 w 4 p
se 4 e 3 p n 8
s 4 e 4 n 4 s
7
)) { $_[0]=$_;tr/nsew//?&t:&f}
sub f{for(1..$_[0]*$s) {for(0,1){$m[$_]+=$m[$_+2]}if
($p){while(<DATA>){$t=$_;tr/\n\t //||last;}}$g[$m[0]][$m[1]]=$p?$t:" ";}}
for$i(0..20){for(0..60){print $g[$i][$_]||" ";}print"\n";}
__END__
Note, the JAPH in the middle is a ruse. It has little to do with the
output.
------------------------------
Date: Sun, 01 Jul 2001 23:51:14 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Storing a hash in a DBM file - example wanted.
Message-Id: <slrn9jvdri.pe1.garry@zfw.zvolve.net>
On Mon, 18 Jun 2001 16:59:30 +0530, Aman Patel <patelnavin@icenet.net> wrote:
> any one has ever used DBM files to store hashes ? i was looking for good
> examples, I have already read the documentation, but in vain for finding
> good examples.
This is a FAQ.
See the perlfaq8 manual page: "How can I capture STDERR from an
external command?". (perldoc -q stderr)
--
Garry Williams
------------------------------
Date: 1 Jul 2001 16:52:26 -0700
From: aougav@hotmail.com (Zur Aougav)
Subject: Re: stripping Underscores
Message-Id: <bccc87cc.0107011552.2ecabe86@posting.google.com>
"Banshee" <defont@nospam.iinet.net.au> wrote in message news:<3b3ea612$0$18438@echo-01.iinet.net.au>...
> Hi all,
>
> I have embedded some code into HTML to display a list of products from a
> flat file database. Most of the product categories have sub-categories which
> are as such, THING_blue, THING_red, etc...
> What I am trying to do is generate the product listing without listing all
> the product sub-categories, eg just THING.
>
> The code to generate the listing is below.
>
> If anyone can help in any way I would appreciate it.
>
> TIA,
> Malissa
>
> local(%db_ele,$sku,$category,%category_list);
> if (!($sc_db_lib_was_loaded =~ /yes/i))
> { &require_supporting_libraries (__FILE__, __LINE__, "$sc_db_lib_path"); }
> &capture_STDOUT;
> &get_prod_db_element($db{"product"},*db_ele);
> foreach $sku (keys %db_ele) {
> $category = $db_ele{$sku};
> $category_list{$category}++;
> }
> foreach $category (sort(keys %category_list)) {
> print "<a href=\"prog.cgi?cart_id=&product=",
> "$category\"><font class = \"Grey\">
> $category</font></a><br>\n";
> }
> &uncapture_STDOUT; }
Modify
$category = $db_ele{$sku};
$category_list{$category}++;
To
$category = $db_ele{$sku};
$category =~ s!\_.*$!!; # delete from _ till end of string
$category_list{$category}++; # $category is the main category
Zur
------------------------------
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 1228
***************************************