[10237] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3830 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Sep 26 02:07:33 1998

Date: Fri, 25 Sep 98 23:00:17 -0700
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, 25 Sep 1998     Volume: 8 Number: 3830

Today's topics:
    Re: Bug in Net::FTP for ActivePerl? <gadget@bc.sympatico.ca>
    Re: capturing html to variable or file <samwang@freewwweb.com>
    Re: cat reese > /dev/null (was Re: Perl & Java - differ (I R A Aggie)
    Re: Does the $string contain "my_text"? (Steve Manes)
    Re: Hashes springing into existence [Was: more regex/pa (Tye McQueen)
    Re: help with removing leading zeros with reg-exp (Craig Berry)
    Re: help with removing leading zeros with reg-exp (Craig Berry)
        Internal Server Error (Premature end of script headers) <lampard@ticnet.com>
    Re: Internal Server Error (Premature end of script head <samwang@freewwweb.com>
    Re: NT 4 + PWS 4 vs PERL 5 + CGI <new_email@see.web.page>
    Re: passing parameters to local file on pc <samwang@freewwweb.com>
    Re: Perl version compatability (I R A Aggie)
    Re: Poll: How Did You Learn Perl? <stmatts@tig.com.au>
    Re: Poll: How Did You Learn Perl? <eashton@bbnplanet.com>
    Re: Poll: How Did You Learn Perl? <eashton@bbnplanet.com>
    Re: Poll: How Did You Learn Perl? grimel@icx.net
    Re: printing a two column sorted HTML table <ajohnson@gpu.srv.ualberta.ca>
        regex question <twei@nmsu.edu>
    Re: regex question <jdf@pobox.com>
    Re: regex question <ajohnson@gpu.srv.ualberta.ca>
    Re: Simple data encryption in Perl (I R A Aggie)
        The Third Annual Obfuscated Perl Contest (Jon Orwant)
    Re: Where to put cgi-lib.pl (Patrick Timmins)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Fri, 25 Sep 1998 20:32:12 -0700
From: Fred Richards <gadget@bc.sympatico.ca>
To: Eric Pan <pan@part.net>
Subject: Re: Bug in Net::FTP for ActivePerl?
Message-Id: <360C603C.9D41D005@bc.sympatico.ca>

I have gotten similar errors. IE: invalid file descriptor !!!

And when I looked at the debug list. I saw that it wasn't
reading my IP correctly...Ugh !!!

I found an old copy on 'ftplib.pl' and used that.
No problems with it.
It may be old, but it WORKS !!!

Bye.




------------------------------

Date: Fri, 25 Sep 1998 20:10:25 -0500
From: Sam Wang <samwang@freewwweb.com>
Subject: Re: capturing html to variable or file
Message-Id: <360C3F00.8953273E@freewwweb.com>

how do you mean capture it into a file? are you saying you want the perl
script to download a file thru http and save it to a server-side file?

get the LWP module from cpan. then:

use LWP::Simple qw(get);

open(FILE, 'NAME_OF_FILE_TO_WRITE.TO');
print FILE get('URL_OF_FILE_TO_GET');
close(FILE);

Mike Burnett wrote:

> I'm am using perl on a Windows NT Server.
>
> Could someone please provide the perl code to do the following:
>
>     open a URL, but instead of displaying the web page, capture the
>     HTML code in a variable or file
>
> Thanks.
>
> Mike Burnett
> mnb@ornl.gov



------------------------------

Date: Sat, 26 Sep 1998 00:32:01 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: cat reese > /dev/null (was Re: Perl & Java - differences and uses)
Message-Id: <fl_aggie-2609980032010001@aggie.coaps.fsu.edu>

In article <yRRO1.2136$Ge.6836178@ptah.visi.com>, George Reese
<borg@imaginary.com> wrote:

+ In comp.lang.java.programmer John Porter <jdporter@min.net> wrote:

+ : So I take it that by "a decade" you're just rounding 6 up to the
+ : nearest whole number of decades.
 
+ I have been programming for just shy of 8 years.  You can play all
+ sort of games with numbers you like, but it won't change the facts.

That 8 < 10? I like your logic, tho. Technically, I've been hacking
code for over 18 years now.  Round it up, and now its 20 years. Wait
6 months, do a rounding and get 21 years. Now round up again, and
suddenly its 25 years!

Hell, if I had done this when I first started, I'd have several hundred
years, if not several thousand years of programming experience!

James - I was wondering how one got 5 years of java experience...now I
        know...


------------------------------

Date: Sat, 26 Sep 1998 03:44:31 GMT
From: smanes@NOSPAM.HEREmagpie.com (Steve Manes)
Subject: Re: Does the $string contain "my_text"?
Message-Id: <362d6205.1211465751@news.panix.com>

On Thu, 24 Sep 1998 23:03:15 GMT, vbakke@atlas.otago.ac.nz wrote:

>Heres an example in quasi-perl:
>
>   if( $String contains "tea") {
>      print "Tea-time!\n";
>   }
>
>If $String contains the letters 't','e','a' (in this order), "Tea-time!\n"
>should be printed. How do I check if a string contains a given substring?

print "Tea-time" if $String =~ /tea/;

------------------[ http://www.magpie.com ]-----------=o&>o-------
Steve Manes        smanes [at] magpie.com       N'Yawk, N'Yawk


------------------------------

Date: 25 Sep 1998 14:26:27 -0500
From: tye@fumnix.metronet.com (Tye McQueen)
Subject: Re: Hashes springing into existence [Was: more regex/pattern substitution]
Message-Id: <6ugqp3$lim@fumnix.metronet.com>

) In comp.lang.perl.misc, tye@fohnix.metronet.com (Tye McQueen) writes:
) :But seriously, it would be nice to be able to prevent autovivication
) :so you can catch typos.  Why I just ran into one today.  I wrote:
) :
) :    @{$DiskInfo{PrtnSeq}}
) :
) :when I meant to write:
) :
) :    @{$DiskInfo{PartnSeq}}
) :
) :No error message and no way to get an error, just an C<undef>
) :silently turned into an empty array.  

Tom Christiansen <tchrist@mox.perl.com> writes:
) 
) That's because you were in an lvalue context, so you autovivified.
) As an rvalue, you'd have taken a fatal from strict.

And C<grep> provides an lvalue context even though I'm really
using it to grep [searching for matches, not changing things]
so my typo is not caught.

Even if there weren't so many lvalue contexts that are likely to
be used like rvalue contexts [C<for>, arguments to subroutines,
etc.], I'd still like the _option_ to have autovivifaction _always_
fail so I can catch my typos.  Catching typos only when I remember
to artificially induce rvalue contexts isn't really a big help.

Anyone agree or disagree?  Yes, I know I can always submit a patch,
but I'd like to get a feel for how it might be received before I go
try to write it.

Would it be okay to add C<use strict "vivify"> as long as C<use
strict> was still the same as C<use strict qw(vars refs subs)>?

I think that the one-sentence description of C<use strict "refs">
found in F<strict.pm> should be expanded based on what Tom has
said.  I doubt I'm qualified to do that.  Perhaps it is documented
elsewhere and just adding a pointer toward there would suffice.

Thanks for the comments,
-- 
Tye McQueen    Nothing is obvious unless you are overlooking something
         http://www.metronet.com/~tye/ (scripts, links, nothing fancy)


------------------------------

Date: 26 Sep 1998 05:03:46 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: help with removing leading zeros with reg-exp
Message-Id: <6uhsji$cir$1@marina.cinenet.net>

Joe Lundgren (jplundgren@micron.com) wrote:
: This is better than the solution I posted in many ways, but worse in
: one....
: 
: I used map in what amounted to a void context (shame, shame), but your
: (and Uri's) solutions would result in a value of '' for initial values
: of '000' and I don't think that's what the original poster was looking
: for....

Good point.  One could change my s/// as shown to fix this:

: Craig Berry wrote:
: > 
: >   foreach (@line_element[0..5]) {
: >     s/^0+//;

        s/^0+(?=\d)//;
or
        s/^0+(\d)/$1/;

I prefer the first variant, personally.

: > In 5.005 you can express that even *more* tersely, believe it or not. 
: 
: Gee, I guess it's a good thing that we aren't using 5.005 here yet. 
: Already, my coworkers (who don't use as Perl as much as I do) are
: complaining they have trouble with my regexs...allowing me to bury even
: more into it might result in my having to maintain *all* the code I
: write instead of most!   :)

Actually, this particular enhancement doesn't involve regexes.  It's the
long-awaited (by me) inclusion of foreach as a statement modifier, a la
if, while, and so forth:

  s/^0+(?=\d)// foreach (@line_element[0..5]);

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "Ripple in still water, when there is no pebble tossed,
       nor wind to blow..."


------------------------------

Date: 26 Sep 1998 05:14:01 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: help with removing leading zeros with reg-exp
Message-Id: <6uht6p$cir$2@marina.cinenet.net>

Abigail (abigail@fnx.com) wrote:
: Craig Berry (cberry@cinenet.net) wrote on MDCCCLI September MCMXCIII in
: <URL:news:6uggsd$avu$2@marina.cinenet.net>:
: ++ The idea is to use an array slice to pull out the @line_element members
: ++ you want to transform, iterating over them with $_ aliased to each array
: ++ member in turn.  The substitution then replaces any initial string of one
: ++ or more '0' characters with nothing.  Make sense?
: 
: No, because that doesn't gain anything.
: 
:     map {s/^0+//} @line_element [0 .. 5];

Evil!  Evil!  Map in void context!  Danger, Will Robinson! :)

And besides, that's not what I wrote.  My version (see up the thread a
ways) uses foreach, and does in fact work, thanks to foreach aliasing the
iteration variable to the members of the array (a sort of 'disguised
reference' is how I think of it).

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "Ripple in still water, when there is no pebble tossed,
       nor wind to blow..."


------------------------------

Date: 26 Sep 1998 04:06:33 GMT
From: "JD Lampard" <lampard@ticnet.com>
Subject: Internal Server Error (Premature end of script headers)
Message-Id: <98EAA94897203E01.377606EE6CA09818.BC8ED5F2EA6964C7@library-proxy.airnews.net>

When my script executes, or attempts to I am returned the following error:

Internal Server Error
Premature end of script headers

Important Info:
	-My Perl skills are limited--although growing.
	-My script worked previously, but the output to the browser wasn't very
pleasing, so I wanted to do some editing.
	-I got the error mentioned above afterwards.  So, I tried to "undo" my
editing.  No luck!
	-So, I deleted what I thought to be the problem area.  Still no luck!
	-I did some more deleting; I got no promising results.
	-I created a new script...

	#!/usr/bin/perl
	&PrintHeader
	sub PrintHeader {
		print "Content-type: text/html\n\n";
		print "test";
	}

	-Did it work???  Same f@#%ing error!!!

What's the deal?!

PS The script resides on an NT server w/Perl 5.005 (and ActiveWare for
Win32).  I do my editing on an NT box

Thanx a bunch for your help,
JD
lampard at ticnet.com


------------------------------

Date: Sat, 26 Sep 1998 00:09:42 -0500
From: Sam Wang <samwang@freewwweb.com>
Subject: Re: Internal Server Error (Premature end of script headers)
Message-Id: <360C7715.9D6856AA@freewwweb.com>

>         #!/usr/bin/perl
>         &PrintHeader; #<--- added semicolon.
>         sub PrintHeader {
>                 print "Content-type: text/html\n\n";
>                 print "test";
>         }

have you ever got any perl scripts to work?



------------------------------

Date: 25 Sep 1998 21:01:19 PDT
From: "Phlip" <new_email@see.web.page>
Subject: Re: NT 4 + PWS 4 vs PERL 5 + CGI
Message-Id: <6uhouf$qc1@journal.concentric.net>

droby@copyright.com wrote:

>Such a long list of responses that won't work!  Is this because you've
already
>tried them all, or do you just not like all those responses?

Allthough I might just "go with PERLis.DLL", the list indicates all the
research I did with www.dejanews.com before giving up and installing
Apache server on my notebook computer.

> Look at your server's error logs.  (Does PWS have error logs?)

I'm running WinNT Workstation; therefore it has an Error Log visible via
the Event Viewer

    "The service could not bind instance 1.  The data is the error
code."
        "0000: 40 27 00 00               @'.."

    "The service could not bind instance 1.  The data is the error
code."
        "0000: 40 27 00 00               @'.."

    "The script started from the URL '/hello.pl' with parameters
'in=wtf' has not responded within the configured timeout period.  The
HTTP server is terminating the script."

> Run your program from the command line and see what happens.

PERL promptly sez "Hello World".

> Show us some code.

It's PERL 5, build 316; the latest one from ActiveState.

The code looks a little bit like this (not my comments):

    # $in = <STDIN>;    # tried to get this to work with no success.
    $in = "Hello World";
    print "HTTP/1.0 200 OK\n"; print "Content-Type: text/html\n\n";
    print "<HTML>\n"; print "<HEAD>\n"; print
"<TITLE>dasfasd</TITLE>\n";
    print "</HEAD>\n";print "<BODY>\n";print "<H4>$in</H4>\n";
    print "<P>\n"; print "Your IP Address is $ENV{REMOTE_ADDR}.\n";
    print "<P>"; print "<H5>Have a nice day</H5>\n";
    print "</BODY>\n"; print "</HTML>\n";

That source started somewhere in MS's knowledge base.

I'm set to reinstall PWS right now then I'l be set to retest all these
options...

  --  Phlip                  (no replies - address munged)
======= http://users.deltanet.com/~tegan/home.html =======
  --  Have a :-) Day  --




------------------------------

Date: Fri, 25 Sep 1998 23:05:41 -0500
From: Sam Wang <samwang@freewwweb.com>
Subject: Re: passing parameters to local file on pc
Message-Id: <360C6814.25D236B8@freewwweb.com>

netscape uses file:///v%7C/blahblah for the address. don't know if that might
work. also parameter passing to a local file might not work, because the
environment variables might not be set properly. you could set yourself up as a
server, though.

Don Stierman wrote:

> I am trying to pass parameters from a web html page to a local perl
> script. I have not found a way for the local file to get the parameters.
> I have tried using CGI.pm, etc. The html code that I have tried is:
>
> <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
> <HTML><HEAD><TITLE>Diemapper</TITLE>
> </HEAD><BODY><P>
>
> *** 1st way ***
> <FORM METHOD="POST" ACTION="file:/v:/cgi-bin/diemap.pl"
> ENCTYPE="multipart/form-data">
> <INPUT NAME="file" VALUE="aaaa001Oo.txt"><P><INPUT TYPE="reset"><INPUT
> TYPE="submit" NAME="submit" VALUE="Run"><P>
>
> *** 2nd way ***
> <A
> HREF="file:/v:/username/d/dstierman/cgi-bin/diemap.pl?file=aaaa001Oo.txt">Run
> Diemap Editor (cgi)</A><P></BODY>



------------------------------

Date: Sat, 26 Sep 1998 00:22:09 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Perl version compatability
Message-Id: <fl_aggie-2609980022090001@aggie.coaps.fsu.edu>

In article <01bde8c5$5b251480$0100007f@quibhrgm>, "Ian Wilkinson"
<ian@no-spam.4site.co.uk> wrote:

+ When asked recently about upgrading to a more recent version of Perl, a
+ representative replied - "It has not been upgraded to avoid possible problems
+ with existing scripts".  I'm not in a position to argue about the merits of
+ that statement 

If it runs under 5.001, it should run under 5.004/5.005. AFAIK, anyway.
Go search the www.perl.com site for "Gotcha's".

If you want to obtain their undivided attention, tho, ask them if they
realize that 5.001 is CERTifably INsecure?

+ Also, is it possible for two or more flavours (sic) of Perl 5 to co-exist on
+ the same server - with scripts just 'requiring' the desired version?  Or could
+ this be handled in the shebang line?

Yes. For quite a while, we had a vendor installed v4.036, and a user installed
5.0* side-by-side, invoked via the proper shebang line.

James


------------------------------

Date: Sat, 26 Sep 1998 12:43:18 +1100
From: St Matthews Manly <stmatts@tig.com.au>
Subject: Re: Poll: How Did You Learn Perl?
Message-Id: <360C46AB.EAE@tig.com.au>

What a strange experience!

I've been away from the net for some years now.
I had a career change about 7 years ago, and at the
time was a convinced perl hacker. (I left computing
entirely).

It's so weird to, all of a sudden, jump back onto
the net (7 years later) and see the familiar perl names still
doing their best to support a wonderful language.
(And doing their best to deal with irritants).

I 1st learned Perl one day when dragging Perl 3 off
the net to see what it was all about. At the time
there was no camel book, I'm not sure if even there was
comp.lang.perl.

I learnt most of it from the man page.

Then once I discovered comp.lang.perl, Randal, Larry,
and Tom were the ones I paid attention to, and learnt
a great deal off them.

Once the camel book came out, there wasn't much
I picked up from it.

Recently, I went into a book store and saw a whole
range of books on perl! What a progression from the
early days.

What I would like to know more of, is the history
of Perl (the pink camel book didn't give enough).

Marty.


------------------------------

Date: Sat, 26 Sep 1998 04:33:56 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Poll: How Did You Learn Perl?
Message-Id: <360C6C46.FF123D75@bbnplanet.com>

St Matthews Manly wrote:

> What I would like to know more of, is the history
> of Perl (the pink camel book didn't give enough).

We're working on that :). Welcome back to the fray. 

e.

"All of us, all of us, all of us trying to save our immortal souls, some
ways seemingly more round-about and mysterious than others. We're having
a good time here. But hope all will be revealed soon."  R. Carver


------------------------------

Date: Sat, 26 Sep 1998 04:40:34 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Poll: How Did You Learn Perl?
Message-Id: <360C6DD5.B42933E3@bbnplanet.com>

Patrick Timmins wrote:

> I've even tried buying them from vending machines in busy places,
> and I still get an encrypted one everytime. It is a mystery to me,
> but I guess the Truth is out there, and I'll just have to keep
> checking more Snickers. But it *is* wreaking havoc on my formerly
> fine-tuned line-backer of a physique.

PSSSTTT! Dark Belgian Chocolate. Who needs men when you have belgian
chocolate? Encrypted? Nay, Listen to the Force Luke. Your tastebuds
should tell you what it is. Perl isn't as messed up as the X-Files.
Like, why haven't scully and mulder, well, ya know? ;)

e.

"All of us, all of us, all of us trying to save our immortal souls, some
ways seemingly more round-about and mysterious than others. We're having
a good time here. But hope all will be revealed soon."  R. Carver


------------------------------

Date: Fri, 25 Sep 98 23:47:30
From: grimel@icx.net
Subject: Re: Poll: How Did You Learn Perl?
Message-Id: <360c6527$1$tevzry$mr2ice@news.icx.net>

Randal Schwartz <merlyn@stonehenge.com> said:

>Edward> Being terribly bored one day, I wandered into the book store
>Edward> determined to learn some new computer skill.  I picked the
>Edward> "Learning Perl" at random from off the shelf and worked through it.

>Did you buy it first, or just read the entire thing there at the
>store?

I found "Learning Perl" on the 50% off table at the book store.  Bought
it because it was a (now) cheap O'Reilly Unix/programming book.  Threw
it on a book shelf for a few months, then faced with a boring repetitive
task started reading.  After about 20pgs I started the task (using the
index) 30min later I was done.  Now I'm hooked (I've got Perl for OS/2,
Win95/NT, and Linux).  It is a great book, I'll actually finish this
one; then the Camel, Panther, etc....

George


------------------------------

Date: Fri, 25 Sep 1998 22:06:38 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: printing a two column sorted HTML table
Message-Id: <360C5A3E.2DA5EE4F@gpu.srv.ualberta.ca>

Tom Tingdale wrote:
!
! Has anyone formatted a sorted list into a two column HTML table? The

no, but I've done similar things for multi-column LaTeX tables :-)

! script below creates a list of files from a directory and prints the
! list out into a two column table, however, I want the list to be in
! alphabetic order down the first column and then the next. I have
! tried splitting the array in the middle to stagger the output, but I
! haven't figured it out yet. Any ideas, solutions? Thanks in advance
! from your help.

[snip code which builds row sequential table]

a simple approach to printing a list in 2 columns (column
sequentially) is:

#!/usr/bin/perl -w
use strict;
my @list = qw/aaa bbb ccc ddd eee fff abc def abb add dad foo bar bad
              baz dud asd lsd xxx xyz qux/;
@list = sort @list;

my $n=int($#list/2)+1;
for(my $i=0;$i<$n;$i++){
    print "$list[$i] | ",($list[$i+$n]||''),"\n";
}
__END__

I've got a 'list_to_cols()' convenience function that would be
overkill for your purposes ... let me know if the above doesn't
suffice.

regards
andrew


------------------------------

Date: Fri, 25 Sep 1998 21:18:50 -0700
From: Tao Wei <twei@nmsu.edu>
Subject: regex question
Message-Id: <360C6B29.361151@nmsu.edu>

Hi there,

$var = "SRC=aaa.c bbb.c ccc.c \
ddd.c fff.c \
eee.c";
print "$var\n$1\n$2" if $var =~ m/^\w+=([^\n\\]*)(\\\n[^\n\\]*)*/;

Result is
SRC=aaa.c bbb.c ccc.c
ddd.c fff.c
eee.c
aaa.c bbb.c ccc.c

I do not understand why $2 is empty. Thanks in advance.

Tao Wei




------------------------------

Date: 26 Sep 1998 05:57:43 +0200
From: Jonathan Feinberg <jdf@pobox.com>
To: twei@nmsu.edu
Subject: Re: regex question
Message-Id: <m3emszcyq0.fsf@joshua.panix.com>

Tao Wei <twei@nmsu.edu> writes:

> $var = "SRC=aaa.c bbb.c ccc.c \
> ddd.c fff.c \
> eee.c";
> print "$var\n$1\n$2" if $var =~ m/^\w+=([^\n\\]*)(\\\n[^\n\\]*)*/;

> I do not understand why $2 is empty. Thanks in advance.

Because the the sequence backwhack-newline in a double-quoted string
is interpolated into a simple newline, and the backwhack disappears.
Did you notice that there's no backwhack when you print out $var?

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


------------------------------

Date: Fri, 25 Sep 1998 23:23:42 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: regex question
Message-Id: <360C6C4E.7E8613F3@gpu.srv.ualberta.ca>

Tao Wei wrote:
!
! Hi there,
! 
! $var = "SRC=aaa.c bbb.c ccc.c \
! ddd.c fff.c \
! eee.c";
! print "$var\n$1\n$2" if $var =~ m/^\w+=([^\n\\]*)(\\\n[^\n\\]*)*/;
! 
! Result is
! SRC=aaa.c bbb.c ccc.c
! ddd.c fff.c
! eee.c
! aaa.c bbb.c ccc.c
! 
! I do not understand why $2 is empty. Thanks in advance.

hmm, I don't see a backslash at the end of any of the
lines when you print out $var, neither does the regex
when you try to match a backslash followed by a "\n".
Since the backslash isn't escaping anything and it is 
not backslashed itself, it merely disappears off into
the sad void of unused escape characters.

regards
andrew


------------------------------

Date: Sat, 26 Sep 1998 00:18:06 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Simple data encryption in Perl
Message-Id: <fl_aggie-2609980018060001@aggie.coaps.fsu.edu>

In article <360c2137.36326227@news.supernews.com>,
mark-lists@webstylists.com (Mark Thompson) wrote:

+ Even a
+ simple offset routine (where all a's become b's, y's become z's and \47
+ becomes \48 would be acceptable in the instance we're looking at but I'm not
+ sure how to go about changing characters in this way (I know how to use tr///
+ but this is a bit beyond my knowledge.)

That's right up tr///'s alley:

#!/usr/bin/perl -w
#-- -*-perl-*-

$text=qq/I'm looking for a simple encryption routine for perl for 
information to go into a dbm file.  The only three requirements are that 
it doesn't make the dbm file size too big and that it's really simple to
implement (basically, as long as the data isn't in plain text format in 
the DBM file, it's alright) and that the encrypted data and unencrypted 
data are in a one-to-one relationship (using the same routine to encrypt 
the same data would give me the same encrypted data.
/;

($encrypt=$text)=~tr/A-Za-z/Q-ZA-Pq-za-p/;
print "$encrypt\n";

($decrypt=$encrypt)=~tr/Q-ZA-Pq-za-p/A-Za-z/;

print "$decrypt\n";


Which outputs ('encrypted'):

Y'c beeaydw veh q iycfbu udshofjyed hekjydu veh fuhb veh
ydvehcqjyed je we ydje q trc vybu.  Jxu edbo jxhuu hugkyhucudji qhu jxqj
yj teuid'j cqau jxu trc vybu iypu jee ryw qdt jxqj yj'i huqbbo iycfbu je
ycfbucudj (rqiysqbbo, qi bedw qi jxu tqjq yid'j yd fbqyd junj vehcqj yd
jxu TRC vybu, yj'i qbhywxj) qdt jxqj jxu udshofjut tqjq qdt kdudshofjut
tqjq qhu yd q edu-je-edu hubqjyedixyf (kiydw jxu iqcu hekjydu je udshofj
jxu iqcu tqjq mekbt wylu cu jxu iqcu udshofjut tqjq.

Wow. I couldn't have said that better myself... :)

James


------------------------------

Date: 25 Sep 1998 21:27:29 GMT
From: orwant@rising-sun.media.mit.edu (Jon Orwant)
Subject: The Third Annual Obfuscated Perl Contest
Message-Id: <ORWANT.98Sep25172729@rising-sun.media.mit.edu>


  The poor Third Obfuscated Perl Contest judges can now
  be put back into hibernation.  The contest is over, 
  and the winners are:

  Most Powerful: Clifford Adams, for an implementation
                 of two software munitions packed into
                 five lines.

  Most Creative: Stephane Payrard, for a Polyominos problem
                 solver.

  Best 'The Perl Journal': Jani Joki, for the implementation
                 and decryption of an 8-bit Feistel Network.

  Felix Gallo's inimitable writeup of the contest can be 
  found in the Perl Journal #11 and on the TPJ web site at 
  http://tpj.com/tpj/obfuscated.  

  Every entry from every category from every contest can
  be found there as well.  Them's good eatin'.

  Congratulations to the winners!  Your cash prizes and
  space-age trophies will arrive someday.

  -Jon

  ------------------------------------
  Jon Orwant            http://tpj.com
  Editor & Publisher, The Perl Journal

--


------------------------------

Date: Sat, 26 Sep 1998 04:24:51 GMT
From: ptimmins@netserv.unmc.edu (Patrick Timmins)
Subject: Re: Where to put cgi-lib.pl
Message-Id: <6uhqai$m6t$1@nnrp1.dejanews.com>

In article <1dfxg9y.19hbdpi5j2c61N@bay1-150.quincy.ziplink.net>,
  rjk@coos.dartmouth.edu (Ronald J Kimball) wrote:
> Patrick Timmins <ptimmins@netserv.unmc.edu> wrote:
>
> > > Besides, the web server has nothing to do with where Perl looks for
> > > an included script.  Perl looks for 'require'd files in the @INC
> > > array.  Exclusively.
> >
> > Yes, and the current directory (represented by '.') is always in @INC .
>
> What's your point?  It still has nothing to do with the web server, and
> everything to do with Perl.  Thus, it is a Perl question and not a CGI
> question.
[snip]

Jeepers! All I said was putting cgi-lib.pl in your cgi-bin instead of
somewhere else seems like the straight forward thing to do. Common
sense regarding where you put your scripts has nothing to do with Perl.
If you can put your calling perl script there, why not just put cgi-lib.pl
there has well? Steven Brenner (the creator of cgi-lib.pl) does, then uses:

require "./cgi-lib.pl";     # *See references below

to call it in to the original script. Why not do it the way the author
of the library recommends? You don't have to, but why not? The choice to
do it one way or another has nothing to do with Perl though!

I suppose we could go round and round about whether or not this is a Perl
question. All I know is that the volume on c.l.p.m. *is* relatively high,
and every Wednesday and Sunday Nathan Torkington makes a post to c.l.p.m.
titled:

*** FAQ: ANSWERS TO YOUR QUESTIONS! READ FIRST! Posted Twice Weekly ***

in which he says:

[snip]
2. comp.lang.perl.misc is for questions on the Perl language.  Try
comp.infosystems.www.authoring.cgi for questions on the CGI part of
CGI scripts.  The two leading blocks of reusable code for CGI purposes
are CGI.pm, at
	http://www.genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html
and cgi-lib.pl, at
	http://www.bio.cam.ac.uk/cgi-lib/
[snip]

I just referred the guy to a cgi newsgroup, the way Nate does twice
a week, and the squawking starts. Then, when I try to recommend that
the poor guy just do it the way the author recommends, (by putting it
in the cgi-bin), people start making stuff up like "He doesn't want to"
(even though he never said this, and actually probably does want to),
and then start chiming in with "Get off your high horse", or "What's
your point?".

Can't we all just get along? [snif ... snif ... wimper ... wimper]
(and try to keep the c.l.p.m. volume down while you're at it)

Patrick Timmins
$monger{Omaha}[0]

*(See  http://cgi-lib.stanford.edu/cgi-lib/ex/perl5/simple-form.cgi.txt
or other examples at the cgi-lib.pl homepage at
http://cgi-lib.stanford.edu/cgi-lib/)

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


------------------------------

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". 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". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 3830
**************************************

home help back first fref pref prev next nref lref last post