[15891] in Perl-Users-Digest
Perl-Users Digest, Issue: 3304 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 9 18:05:47 2000
Date: Fri, 9 Jun 2000 15:05:31 -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: <960588330-v9-i3304@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 9 Jun 2000 Volume: 9 Number: 3304
Today's topics:
Re: Accessing CC using Sendmail <methos495@earthlink.net>
backquote error output <kjell@wpi.edu>
Re: backquote error output (Brandon Metcalf)
Re: backquote error output <sariq@texas.net>
Re: backquote error output (Gary E. Ansok)
Re: backquote error output (Brandon Metcalf)
Re: backquote error output <Jonathan.L.Ericson@jpl.nasa.gov>
Re: backquote error output <you.will.always.find.him.in.the.kitchen@parties>
Best Perl Accessory? <bholowko@colorsavvy.com>
Re: Best Perl Accessory? (Clinton A. Pierce)
Re: Chomp problem (Craig Berry)
Re: Chomp problem (Clinton A. Pierce)
Re: Chomp problem <lr@hpl.hp.com>
Re: Chomp problem <methos495@earthlink.net>
dividing a string into array..? happyhippi@my-deja.com
Re: dividing a string into array..? <care227@attglobal.net>
Re: dividing a string into array..? <mikecard@my-deja.com>
Re: dividing a string into array..? <sariq@texas.net>
Re: dividing a string into array..? (Craig Berry)
Re: Dumb question.. How to prompt the user and get the (Bart Lateur)
Re: Encrypting / decrypting. <godzilla@stomp.stomp.tokyo>
Re: Encrypting / decrypting. <bkennedy@hmsonline.com>
Re: Encrypting / decrypting. <godzilla@stomp.stomp.tokyo>
Re: Encrypting / decrypting. <methos495@earthlink.net>
Re: Encrypting / decrypting. (David H. Adler)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 09 Jun 2000 19:25:07 GMT
From: methos <methos495@earthlink.net>
Subject: Re: Accessing CC using Sendmail
Message-Id: <39414576.1E5EAFBC@earthlink.net>
Personally I don't use extrernal programs when I can avoid them.
You can do this with external Mail packages for Perl like SendMail.pm or
SMTP.pm,
but what I would advise in this case is this:
There is a command called sendmail.
The man page for that program says that you can include the cc or bcc as
part of the message, as you have done for the "To", "From", "Subject",
etc...
So you may want that.
Of course you may be using sendmail already...
If that's the case, then just re-read the man page.
You might have missed it.
It's easy to miss.
under the -t option
cheers,
--
- Methos -
"Blaming the Internet for societies problems is like blaming paper for
bad poetry"
- anonymous -
Raphael Pirker wrote:
> Hi Guys,
>
> I want to have the option to send CC E-mails to myself through perl.
> Basically the code I have is:
>
> open(MAIL,"|$mailprog -t");
>
> print MAIL "To: $recipient\n";
> print MAIL "From: $from\n";
> print MAIL "Subject: $subject\n";
> if ($mail_cc ne "false") {
> print MAIL ""; # How do I write a CC address?
> };
>
> Hope you get what I mean. Please advise!
>
> Raphael
------------------------------
Date: Fri, 09 Jun 2000 20:30:02 GMT
From: Charles Knutson <kjell@wpi.edu>
Subject: backquote error output
Message-Id: <sk2kuar3h5117@corp.supernews.com>
I am writing a perl script that performs various system calls in UNIX
through the use of backquotes. However some of my system calls are failing
and I cannot figure out a way to capture the error message inside a
variable. I don't have access to a terminal because this is being run
as a cgi script. Here is an example:
$error = `chmod 755 my.file`;
print "$error\n";
This just prints the carriage return. Any insight as to how to approach
this problem would be greatly appreciated.
--
Posted via CNET Help.com
http://www.help.com/
------------------------------
Date: 9 Jun 2000 21:10:06 GMT
From: bmetcalf@baynetworks.com (Brandon Metcalf)
Subject: Re: backquote error output
Message-Id: <8hrmfe$5t4$1@spinner.corpeast.baynetworks.com>
kjell@wpi.edu writes:
> I am writing a perl script that performs various system calls in UNIX
> through the use of backquotes. However some of my system calls are failing
> and I cannot figure out a way to capture the error message inside a
> variable. I don't have access to a terminal because this is being run
> as a cgi script. Here is an example:
>
> $error = `chmod 755 my.file`;
> print "$error\n";
>
> This just prints the carriage return. Any insight as to how to approach
> this problem would be greatly appreciated.
$error = `chmod 755 my.file 2>&1`;
Brandon
------------------------------
Date: Fri, 09 Jun 2000 16:14:51 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: backquote error output
Message-Id: <39415E4B.E155D82@texas.net>
Charles Knutson wrote:
>
> I am writing a perl script that performs various system calls in UNIX
> through the use of backquotes. However some of my system calls are failing
> and I cannot figure out a way to capture the error message inside a
> variable. I don't have access to a terminal because this is being run
> as a cgi script. Here is an example:
>
> $error = `chmod 755 my.file`;
> print "$error\n";
1) Ensure that the system calls you use are not available natively in
Perl.
perldoc perlfunc
2) perldoc -f system
perldoc perlop
3) Familiarize yourself with Perl's documentation.
perldoc perldoc
perldoc perl
- Tom
------------------------------
Date: 9 Jun 2000 21:18:51 GMT
From: ansok@alumni.caltech.edu (Gary E. Ansok)
Subject: Re: backquote error output
Message-Id: <8hrmvr$lu6@gap.cco.caltech.edu>
In article <sk2kuar3h5117@corp.supernews.com>,
Charles Knutson <kjell@wpi.edu> wrote:
>I am writing a perl script that performs various system calls in UNIX
>through the use of backquotes. However some of my system calls are failing
>and I cannot figure out a way to capture the error message inside a
>variable. I don't have access to a terminal because this is being run
>as a cgi script. Here is an example:
>
>$error = `chmod 755 my.file`;
>print "$error\n";
>
>This just prints the carriage return. Any insight as to how to approach
>this problem would be greatly appreciated.
1) Why not use Perl's built-in chmod function?
chmod 0755, 'my.file' or warn "Error chmoding 'my.file': $!";
Note that the 0 in 0755 is important! See perldoc -f chmod.
2) Since you've already said this is to run on Unix, you could use
$error = `chmod 755 my.file 2>&1`
The 2>&1 says to send stderr to wherever stdout is going -- see man sh.
3) If you want a more general solution, check out IPC::Open3.
-- Gary Ansok ansok at alumni.caltech.edu
------------------------------
Date: 9 Jun 2000 21:50:07 GMT
From: bmetcalf@baynetworks.com (Brandon Metcalf)
Subject: Re: backquote error output
Message-Id: <8hroqf$6v1$1@spinner.corpeast.baynetworks.com>
ansok@alumni.caltech.edu writes:
> 2) Since you've already said this is to run on Unix, you could use
>
> $error = `chmod 755 my.file 2>&1`
2>&1 works on nt as well.
Brandon
------------------------------
Date: Fri, 09 Jun 2000 14:12:23 -0700
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: backquote error output
Message-Id: <39415DB7.C8F80FBD@jpl.nasa.gov>
Charles Knutson wrote:
> $error = `chmod 755 my.file`;
> print "$error\n";
>
> This just prints the carriage return. Any insight as to how to approach
> this problem would be greatly appreciated.
First read the qx section of perlop to understand what backquotes are
used for. Then read the system section of perlfunc for a better way to
execute a system command when you aren't capturing stdout. Next read
the chmod section of perlfunc for a better way to change the permissions
of a file without creating a child process or breaking portability.
After that, read the $! section of perlvar to see how to get a useful
error message when chmod fails. Remember, perldoc is your friend.
Jon
--
Knowledge is that which remains when what is
learned is forgotten. - Mr. King
------------------------------
Date: Sat, 10 Jun 2000 10:05:34 +1200
From: "Tintin" <you.will.always.find.him.in.the.kitchen@parties>
Subject: Re: backquote error output
Message-Id: <960588231.971335@shelley.paradise.net.nz>
"Charles Knutson" <kjell@wpi.edu> wrote in message
news:sk2kuar3h5117@corp.supernews.com...
> I am writing a perl script that performs various system calls in UNIX
> through the use of backquotes. However some of my system calls are failing
> and I cannot figure out a way to capture the error message inside a
> variable. I don't have access to a terminal because this is being run
> as a cgi script. Here is an example:
>
> $error = `chmod 755 my.file`;
> print "$error\n";
>
> This just prints the carriage return. Any insight as to how to approach
> this problem would be greatly appreciated.
Ask yourself the question, "Should I really be writing this as a shell
script if I'm doing a lot of system calls?"
I've seen a few examples of Perl and C programs that only consisted
system("foo1");
system("foo2");
.
.
etc
Of course, the other question you should ask is "Does Perl have an inbuilt
way of performing the system call I'm using?"
------------------------------
Date: Fri, 9 Jun 2000 14:53:04 -0400
From: "Boris Holowko" <bholowko@colorsavvy.com>
Subject: Best Perl Accessory?
Message-Id: <39413c6f_1@news.siscom.net>
What is anyone's opinion on the next best thing to download after you've
downloaded perl, like for example, Perl Studio, Visual Perl,
Pound-Bang-Perl, Activestate Perl Development Kit, etc...??? I am just
curious!
thanks...
-jared
------------------------------
Date: Fri, 09 Jun 2000 21:33:31 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: Best Perl Accessory?
Message-Id: <Lod05.104102$h01.826784@news1.rdc1.mi.home.com>
[Posted and mailed]
In article <39413c6f_1@news.siscom.net>,
"Boris Holowko" <bholowko@colorsavvy.com> writes:
> What is anyone's opinion on the next best thing to download after you've
> downloaded perl, like for example, Perl Studio, Visual Perl,
> Pound-Bang-Perl, Activestate Perl Development Kit, etc...??? I am just
> curious!
A few hours to read the documentation.
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours!
clintp@geeksalad.org for details see http://www.geeksalad.org
"If you rush a Miracle Man,
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: Fri, 09 Jun 2000 18:25:31 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Chomp problem
Message-Id: <sk2dkr3oh5192@corp.supernews.com>
W Kemp (bill.kemp@wire2.com) wrote:
: >crufy
:
: sorry for wastin spce- but pls define the above if it isn't a typo
It's likely a typo for "crufty", a common piece of hacker (in the original
sense) slang meaning "old, ugly, slapdash, poorly designed, needlessly
complex". See for example:
http://www.tuxedo.org/~esr/jargon/html/entry/crufty.html
--
| Craig Berry - http://www.cinenet.net/users/cberry/home.html
--*-- "You live in Los Angeles, and you are going to Reseda; we are
| all in some way or another going to Reseda someday, to die."
- Soul Coughing
------------------------------
Date: Fri, 09 Jun 2000 18:41:38 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: Chomp problem
Message-Id: <CTa05.104073$h01.825301@news1.rdc1.mi.home.com>
[Posted and mailed]
In article <960564476.10146.0.nnrp-01.c3ad6973@news.demon.co.uk>,
"W Kemp" <bill.kemp@wire2.com> writes:
>>crufy
>
> sorry for wastin spce- but pls define the above if it isn't a typo
No typo. From the Jargon File:
crufty: /kruhf'tee/ adj. [very common; origin unknown; poss. from `crusty'
or `cruddy'] 1. Poorly built, possibly over-complex. The canonical example
is "This is standard old crufty DEC software". In fact, one fanciful
theory of the origin of `crufty' holds that was originally a mutation
of `crusty' applied to DEC software so old that the `s' characters were
tall and skinny, looking more like `f' characters. 2. Unpleasant,
especially to the touch, often with encrusted junk. Like spilled coffee
smeared with peanut butter and catsup. 3. Generally unpleasant.
4. (sometimes spelled `cruftie') n. A small crufty object (see frob);
often one that doesn't fit well into the scheme of things. "A LISP
property list is a good place to store crufties (or, collectively,
random cruft)."
This term is one of the oldest in the jargon and no one is sure of
its etymology, but it is suggestive that there is a Cruft Hall at
Harvard University which is part of the old physics building; it's
said to have been the physics department's radar lab during WWII.
To this day (early 1993) the windows appear to be full of random
techno-junk. MIT or Lincoln Labs people may well have coined the
term as a knock on the competition.
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours!
clintp@geeksalad.org for details see http://www.geeksalad.org
"If you rush a Miracle Man,
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: Fri, 9 Jun 2000 13:02:35 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Chomp problem
Message-Id: <MPG.13aaed35c17191f898ab59@nntp.hpl.hp.com>
In article <87ya4fkml0.fsf@limey.hpcc.uh.edu> on 09 Jun 2000 08:31:23 -
0500, Tony Curtis <tony_curtis32@yahoo.com> says...
> >> On Fri, 9 Jun 2000 12:42:21 +0100,
> >> "Damian (-*-)" <damian@amorphous.co.uk> said:
>
> > while ($fileline = <HIFILE>) {
> ^^^^^^^^^^^^^^^^^^^^^
> -w and "use strict" would tell you there is a bug
> waiting to happen here
No. Since perl 5.005, the 'defined' is implicit.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 09 Jun 2000 20:22:44 GMT
From: methos <methos495@earthlink.net>
Subject: Re: Chomp problem
Message-Id: <394152F7.7C70E616@earthlink.net>
As far as I can tell chomp is a perl5 function...
What you may want to do is check to make sure the version of perl you're using
is perl5 as opposed to perl4
See if you get the same problem using chop.
It would be a good test.
I'm not claiming to know the anser here, just tests on how to resolve it.
--
- Methos -
"Blaming the Internet for societies problems is like blaming paper for
bad poetry"
- anonymous -
"Damian (-*-)" wrote:
> Hi There,
>
> Does anyone have infomation about problems with chomp() ? I developed a
> script locally (NT4 / Apache / ActivePerl) that worked fine with the lines :
>
> # Read all lines in ...
> while ($fileline = <HIFILE>)
> {
> # Remove trailing EOL char ...
> chomp($fileline);
>
> # Anything left to use ?
> if (length($fileline) != 0)
> {
> $inTable[$entryCount++] = $fileline;
> }
> }
>
> which basically reads lines from a file, storing them after stipping the end
> of line character. When I tried this on our live server (BSDi / Apache / and
> Perl V5.005_03 built for i386-bsdos by Larry Wall), I get the following
> errors :
>
> "chomp" may clash with future reserved word at
> /usr/local/etc/httpd/cgi-bin/jeghitable.pl line 46.
> syntax error in file /usr/local/etc/httpd/cgi-bin/jeghitable.pl at line 46,
> next 2 tokens "chomp("
> Execution of /usr/local/etc/httpd/cgi-bin/jeghitable.pl aborted due to
> compilation errors
>
> So what is so wrong with chomp($fileline) on this setup ? Or how can I
> replace it with something that strips trailing whitespace / EOL characters ?
>
> TIA
>
> Damian (-*-)
------------------------------
Date: Fri, 09 Jun 2000 19:08:50 GMT
From: happyhippi@my-deja.com
Subject: dividing a string into array..?
Message-Id: <8hrfbk$cvl$1@nnrp1.deja.com>
Hola!
I've decided to make a game where a player guesses letters from some
unknown word and after all tries to guess the whole word. Unfortunately
it seems to be harder job than I first imagined cause I dunno how to
show current situation to player; like this:
the word is "detournement"
First, the player can see: "____________"
Player guesses letter "e"
What she sees next would be: "_e_____e_e__"
and so on..
I thought that tr/// -function should solve the problem but according to
my handbook it doesn't support variables in it. (of course i tried it
too..)
Now it came in to my mind that I should divide the word into an array,
each letter into it's own element; like:
@array[0] = "d";
@array[1] = "e";
@array[2] = "t";
and so on..
I don't have an idea how to divide the word, any help..?
Keep it in your mind that the word to be guessed is a variable..
otherwise this would be an easy one.. ;)
The rest of the program is almost finished..
thank you
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 09 Jun 2000 15:33:34 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: dividing a string into array..?
Message-Id: <3941468E.CEF37225@attglobal.net>
happyhippi@my-deja.com wrote:
>
> Hola!
perldoc -f split
as in @array = split(//, $word);
------------------------------
Date: Fri, 09 Jun 2000 20:00:55 GMT
From: mike cardeiro <mikecard@my-deja.com>
Subject: Re: dividing a string into array..?
Message-Id: <8hrida$fft$1@nnrp1.deja.com>
In article <8hrfbk$cvl$1@nnrp1.deja.com>,
happyhippi@my-deja.com wrote:
> Hola!
> Now it came in to my mind that I should divide the word into an array,
> each letter into it's own element; like:
>
> @array[0] = "d";
> @array[1] = "e";
> @array[2] = "t";
> and so on..
>
> I don't have an idea how to divide the word, any help..?
my @array = split //, 'detournement';
mike cardeiro
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 09 Jun 2000 15:28:25 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: dividing a string into array..?
Message-Id: <39415369.82187061@texas.net>
happyhippi@my-deja.com wrote:
>
> Hola!
>
> I've decided to make a game where a player guesses letters from some
> unknown word and after all tries to guess the whole word. Unfortunately
> it seems to be harder job than I first imagined cause I dunno how to
> show current situation to player; like this:
>
> the word is "detournement"
> First, the player can see: "____________"
> Player guesses letter "e"
> What she sees next would be: "_e_____e_e__"
> and so on..
>
> I thought that tr/// -function should solve the problem but according to
> my handbook it doesn't support variables in it. (of course i tried it
> too..)
Actually, you *can* use a variable, but you must wrap the expression in
eval (as documented in perlop). Many people around here (including
myself) strongly discourage using 'eval EXPR' when there is a reasonable
alternative. So forget I suggested it.
Use 's///g'.
perldoc perlop
> Now it came in to my mind that I should divide the word into an array,
> each letter into it's own element; like:
>
> @array[0] = "d";
> @array[1] = "e";
> @array[2] = "t";
> and so on..
perldoc -q @array
> I don't have an idea how to divide the word, any help..?
perldoc -f split
But there's no reason to use it.
You should really read:
perldoc perldoc
perldoc perl
to familiarize yourself with the documentation.
- Tom
------------------------------
Date: Fri, 09 Jun 2000 21:22:12 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: dividing a string into array..?
Message-Id: <sk2o042dh51153@corp.supernews.com>
happyhippi@my-deja.com wrote:
: I've decided to make a game where a player guesses letters from some
: unknown word and after all tries to guess the whole word. Unfortunately
: it seems to be harder job than I first imagined cause I dunno how to
: show current situation to player; like this:
[snip]
Fun one. Here's my approach:
#!/usr/bin/perl -w
# wordguess - guess a randomly chosen word letter by letter
# Arguments: Files containing possible words to guess, one per line.
# Default is /usr/dict/words if no args are provided.
# Craig Berry (20000609)
use strict;
push @ARGV, '/usr/dict/words' unless @ARGV;
print "Choosing a word...\n";
my $word;
rand $. < 1 and m/^[a-z]{3,}$/i and $word = $_ while <>;
print "Word chosen.\n";
chomp $word;
$word = lc $word;
my @chars = split //, $word;
my %guessed;
while (1) {
my $show = join '', map { exists $guessed{$_} ? $_ : '_' } @chars;
print("Done.\n"), last unless $show =~ /_/;
print 'Guessed: ', join(' ', sort keys %guessed), "\n",
"Word : $show\n",
'Enter a letter or your word guess: ';
chomp(my $try = lc <STDIN>);
print("Correct!\n"), last if $try eq $word;
print("Nope.\n"), next if length $try > 1;
$guessed{$try}++;
}
--
| Craig Berry - http://www.cinenet.net/users/cberry/home.html
--*-- "You live in Los Angeles, and you are going to Reseda; we are
| all in some way or another going to Reseda someday, to die."
- Soul Coughing
------------------------------
Date: Fri, 09 Jun 2000 19:49:52 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Dumb question.. How to prompt the user and get the input.
Message-Id: <394249e3.396009@news.skynet.be>
Matt King wrote:
>I guess Perl does have a native way of doing this. It's just a matter of
>using what's in the docs, and a bit of guess work.
Heh. Cutely put, but a sour point, actually. I think I'll call it
"Ilya's gripe" from now on. ;-)
--
Bart.
------------------------------
Date: Fri, 09 Jun 2000 11:37:42 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Encrypting / decrypting.
Message-Id: <39413976.A26AFCA3@stomp.stomp.tokyo>
Ben Kennedy wrote:
> So, next time you post, ask yourself this:
> "Will my post provoke a strong reaction in this newsgroup,
> resulting in yet another flame war?"
This is amongst the best of hypocritical
statements I have read within this group.
* stupefied *
Godzilla!
------------------------------
Date: Fri, 09 Jun 2000 19:59:27 GMT
From: "Ben Kennedy" <bkennedy@hmsonline.com>
Subject: Re: Encrypting / decrypting.
Message-Id: <z0c05.243657$Tn4.2209337@news1.rdc2.pa.home.com>
Godzilla! <godzilla@stomp.stomp.tokyo> wrote in message
news:39413976.A26AFCA3@stomp.stomp.tokyo...
> Ben Kennedy wrote:
>
> > So, next time you post, ask yourself this:
>
> > "Will my post provoke a strong reaction in this newsgroup,
> > resulting in yet another flame war?"
>
> This is amongst the best of hypocritical
> statements I have read within this group.
>
> * stupefied *
Please... I have treated you better and more respectful than nearly everyone
who responds to you, and you call me a hypocrite? I'm just trying to
explain why people react to you the way they do. In fact, I'm trying to
help you and this group. I am trying to provoke a rational discussion, not
a flame war. If you are not willing to have such a discussion, then you are
acting as badly as you claim the rest of the group does. If you would stop
reacting to what people say and start responding, you'd be better off.
Perhaps you do provoke people out of malicious intent or boredom, but I'm
still willing to give you the benefit of the doubt.
So, try responding (not reacting) to this: I don't see why you feel like
posting your advice to this newsgroup, when the majority of readers consider
it bad (regardless of whether it is good advice or not). If you post advice
that you know is going to get flamed, why not just send the message directly
to the poster and save us all a lot of time and energy?
If you can answer the above statement in a clear and rational manor, you
could start a discussion that would get to the heart of the issue.
--Ben Kennedy
------------------------------
Date: Fri, 09 Jun 2000 13:34:26 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Encrypting / decrypting.
Message-Id: <394154D2.34672B02@stomp.stomp.tokyo>
Ben Kennedy wrote:
> Godzilla! <godzilla@stomp.stomp.tokyo> wrote in message
> news:39413976.A26AFCA3@stomp.stomp.tokyo...
> > Ben Kennedy wrote:
(snipped)
There is no legitimate reason for you
to consistently and constantly troll
and harass me. I will ask you to stop
trolling and harassing me.
Godzilla!
------------------------------
Date: Fri, 09 Jun 2000 20:49:46 GMT
From: methos <methos495@earthlink.net>
Subject: Re: Encrypting / decrypting.
Message-Id: <3941594B.31553B45@earthlink.net>
Here's something to try...
A single line to display in Hex, but not change the real string.
If I understood your post correctly:
-----------------
if ($sample =~ m%^[0-9]+$%) {
printf (STDOUT "Encoded Sample Is: %lx\n\n", $sample);
}
else {
print "Encoded Sample Is: $sample\n\n";
}
------------------
replace the print with this, and that shoudl be golden.
--
- Methos -
"Blaming the Internet for societies problems is like blaming paper for
bad poetry"
- anonymous -
Matt King wrote:
> Hi, I like your example, however, it just doesn't give me the output I
> need/want.
> Using your script, I converted 11 and got 31311. I would like it better if
> that was shown in a hex number (like AF for example). I have tried making
> some changes to script to get that, but I have yet to get it working. Can
> you help me out with that (also the decoder needs to work the same, but in
> reverse)?
>
> Thanks. Matt
>
> Godzilla! <godzilla@stomp.stomp.tokyo> wrote in message
> news:393FCF9F.6312ADFA@stomp.stomp.tokyo...
> > Matt King wrote:
> >
> > > Hi. I need a way to encrypt and decrypt a small string
> > > (between 8 and 16 chars). I have looked on CPAN, but all
> > > I find are add-in modules. I need something small...
> >
> > > ...so that the file is a 'stand alone' file and can be
> > > moved from PC to PC without installing anything...
> >
> > > I would like some type of encryption that can't easly be
> > > broken and doesn't make the encrypted string more then
> > > double the orginal length...
> >
> > > Can one of you please help me out with this?
> >
> >
> >
> > Funny, encryption and modules, yet again...
> >
> >
> > I love these type of questions. Just takes a bit of old
> > fashion imagination Matt. Not doubling your original
> > string length using HEX as you suggest, clearly is
> > quite impossible. HEX doubles a string, inherently.
> > Would you mind double length plus one?
> >
> > This test script and results below, affords encoding
> > and decoding based on four basic principles:
> >
> > Encode based on a random ROT-13 variation.
> > Reverse a string.
> > HEX encode.
> > Append a decode key.
> >
> >
> > I have limited this to two ROT-13 variations
> > to keep it a simple example. You can develop
> > as many ROT-13 variations as you like and key
> > them to a random number generator.
> >
> > Reversing your string adds a 'frustration' factor.
> >
> > HEX, not all that secure but befuddles those who
> > are not familiar with HEX encoding; a bit more
> > frustration for those with idle hands.
> >
> > Your Green Hornet Magic Key, a random number,
> > can be prepended or appended to your string
> > then extracted for decoding.
> >
> > However, there is another slick trick you
> > may employ, one of dozens of variations.
> > You could include a random substring, slice
> > up your string, glue it together backwards,
> > sidewards, upside down, whatever and, the
> > reverse for decoding. Easy enough to do
> > by generating a random number for a substring
> > start position or a substring character count,
> > or both! A random substring number could also
> > be used to conceal your decode number or numbers
> > well within a string.
> >
> > You might even consider adding a number to each
> > of your HEX numbers, or multiply, divide...
> > Lots and lots of 'stuff' you can do.
> >
> > How complicated you make this is only limited
> > by your imagination and how much work you are
> > willing to give this methodology.
> >
> > Naturally this method can be cracked but would
> > be rather frustrating. This method is not intended
> > for absolute high level security but may well
> > meet your needs for casual encoding, as a stand
> > alone method with no need for any modules. Your
> > security with this method relies on frustration,
> > not on high level eighty-bagillion key encryption
> > requiring a ten gigabyte module taking forty-seven
> > hours to run and complete.
> >
> > Otherwords, it's stand-alone and portable.
> >
> > Have fun with this, should you decide to
> > use something similar to this. If you wish
> > to test this code of mine, it is quite
> > portable and will run under any Perl 4
> > or Perl 5 version, no problems. This code
> > is ready to run on your server.
> >
> > Godzilla!
> >
> >
> > "Imagination is more important than knowledge."
> >
> > - Albert Einstein
> >
> >
> >
> > SAMPLE PRINTED RESULTS
> > ______________________
> >
> > Input Sample Is:
> > Green Hornet Secret Decoder Ring
> >
> > Encoded Sample Is:
> > 7a67624b206b787768767857206d786b76784c206d78676b6841206778786b5a1
> >
> > Decoded Sample Is:
> > Green Hornet Secret Decoder Ring
> >
> >
> > SAMPLE PRINTED RESULTS
> > ______________________
> >
> > Input Sample Is:
> > Green Hornet Secret Decoder Ring
> >
> > Encoded Sample Is:
> > 6e75705920796c6b766a6c4b20616c796a6c5a20616c7579764f20756c6c794e0
> >
> > Decoded Sample Is:
> > Green Hornet Secret Decoder Ring
> >
> >
> >
> > TEST SCRIPT
> > ___________
> >
> > #!/usr/local/bin/perl
> >
> > print "Content-Type: text/plain\n\n";
> >
> > $sample = "Green Hornet Secret Decoder Ring";
> >
> > print "Input Sample Is:
> > $sample\n\n";
> >
> >
> > ## Encode:
> >
> > local ($random_key) = int(rand(2));
> >
> > if (!($random_key))
> > {
> > srand;
> > $random_key = int(rand(2));
> > }
> >
> > if ($random_key == 0)
> > { $sample =~ tr/a-zA-Z/h-za-gH-ZA-G/; }
> >
> > elsif ($random_key == 1)
> > { $sample =~ tr/a-zA-Z/t-za-sT-ZA-S/; }
> >
> > else
> > { print "Random Key Generation Failed"; exit; }
> >
> > $sample = reverse ($sample);
> >
> > $sample =~ s/(.)/sprintf('%02x',ord($1))/ge;
> >
> > $sample = join ("", $sample, $random_key);
> >
> > print "Encoded Sample Is:
> > $sample\n\n";
> >
> >
> > ## Decode:
> >
> > $random_key = chop ($sample);
> >
> > $sample =~ s/([0-9A-Fa-f]{2})/sprintf("%c",hex($1))/ge;
> >
> > $sample = reverse ($sample);
> >
> > if ($random_key == 0)
> > { $sample =~ tr/h-za-gH-ZA-G/a-zA-Z/; }
> >
> > elsif ($random_key == 1)
> > { $sample =~ tr/t-za-sT-ZA-S/a-zA-Z/; }
> >
> > else
> > { print "Random Key Generation Failed"; exit; }
> >
> > print "Decoded Sample Is:
> > $sample\n\n";
> >
> > exit;
------------------------------
Date: 9 Jun 2000 21:11:29 GMT
From: dha@panix.com (David H. Adler)
Subject: Re: Encrypting / decrypting.
Message-Id: <slrn8k2nc1.t5n.dha@panix6.panix.com>
I find it informative that, in answer to this:
> So, try responding (not reacting) to this: I don't see why you feel
> like posting your advice to this newsgroup, when the majority of
> readers consider it bad (regardless of whether it is good advice or
> not). If you post advice that you know is going to get flamed, why
> not just send the message directly to the poster and save us all a
> lot of time and energy?
> If you can answer the above statement in a clear and rational manor,
> you could start a discussion that would get to the heart of the
> issue.
> --Ben Kennedy
"Godzilla" replied (quoted *in full*):
On Fri, 09 Jun 2000 13:34:26 -0700, Godzilla!
<godzilla@stomp.stomp.tokyo> wrote:
>Ben Kennedy wrote:
>
>> Godzilla! <godzilla@stomp.stomp.tokyo> wrote in message
>> news:39413976.A26AFCA3@stomp.stomp.tokyo...
>> > Ben Kennedy wrote:
>
>(snipped)
>
>There is no legitimate reason for you
>to consistently and constantly troll
>and harass me. I will ask you to stop
>trolling and harassing me.
>
>Godzilla!
Fascinating.
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"Cracking keys to free the world from web/cgi questions!"
- my contribution to the Perl Mercenaries United motto.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 3304
**************************************