[17987] in Perl-Users-Digest
Perl-Users Digest, Issue: 147 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 26 03:10:31 2001
Date: Fri, 26 Jan 2001 00:05:11 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <980496310-v10-i147@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 26 Jan 2001 Volume: 10 Number: 147
Today's topics:
Code that could use a different approach, can you optim (Clinton A. Pierce)
Re: Code that could use a different approach, can you o <stephenk@cc.gatech.edu>
Re: Comparing multiple values <uri@sysarch.com>
Re: Comparing multiple values (Richard J. Rauenzahn)
Re: Comparing multiple values <krahnj@acm.org>
Re: database <jdf@pobox.com>
Re: Dealing with x1b character (Mark Jason Dominus)
Re: Error Message <jdf@pobox.com>
Re: Error Message <jdf@pobox.com>
Re: Form Processing - newbie question (David Efflandt)
Re: FreezeThaw. <jdf@pobox.com>
Re: FreezeThaw. <a565a87@my-deja.com>
Re: FreezeThaw. <a565a87@my-deja.com>
Re: FreezeThaw. <jdf@pobox.com>
Re: FreezeThaw. <a565a87@my-deja.com>
Re: Hash of hash of arrays problem <jdf@pobox.com>
How do you backspace(back delete) on console? (Monte Phillips)
Is Number of Params Limited? *Warning Newbie* <jamas@mindspring.com>
Re: Is Number of Params Limited? *Warning Newbie* (Mark Jason Dominus)
Re: Is Number of Params Limited? *Warning Newbie* (Dave Rustay)
Re: Is Number of Params Limited? *Warning Newbie* <callgirl@la.znet.com>
Know Perl? Help a poor hack out with if-else statement (EROTH001)
Re: Know Perl? Help a poor hack out with if-else state <wyzelli@yahoo.com>
merging 2 array columns... <projectobjects@earthlink.net>
OLE Module for AS Perl 5.6 on NT <w-woerlinger@ti.com>
Re: Script to "rotate" the chars in a string. <wyzelli@yahoo.com>
Re: Script to "rotate" the chars in a string. (Rafael Garcia-Suarez)
tab delimitated file <yukon_jach@yahoo.com>
Re: tab delimitated file <jdf@pobox.com>
Re: What's wrong with this script? <wyzelli@yahoo.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 26 Jan 2001 02:33:44 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Code that could use a different approach, can you optimize?
Message-Id: <cm5c6.254204$hD4.61487625@news1.rdc1.mi.home.com>
This is an N-file compare routine ripped from a piece of code laying around.
I'm NOT interested in optimizing or bumming the whole thing. That would
defeat a few other things that are going on elsewhere. Here's the code
sample:
use IO::File;
@files=qw( /tmp/logfile /tmp/logfile2 /tmp/logfile3 );
foreach(@files) {
push(@fhs, { val => "",
line => 0,
name => $_,
fh => new IO::File $_ });
}
while(@fhs>1) {
for my $file (@fhs) {
$file->{val}=$file->{fh}->getline();
$file->{line}=$.;
}
COMPARE:
my $ov=undef;
for ( 0..$#fhs ) {
if ( defined $ov and $ov ne $fhs[$_]->{val} ) {
print "Differed at ",
$fhs[$_]->{line}, " in ",
$fhs[$_]->{name}, "\n";
splice(@fhs, $_, 1);
goto COMPARE;
} else {
$ov=$fhs[$_]->{val};
}
}
}
The part I'm interested in is the while loop. Specifically, the
part that begins COMPARE. Yes, that's a goto. At the time it seemed
like a good idea. What I want to do is:
* compare multiple elements of @fhs
* splice out the ones that aren't the same as the others,
going from lowest index to highest.
So if [1] is the same as [2]
but [2] is not the same as [3]
splice out [3]. Continue by comparing [2] and (what was) [4]
BUT, if [1] is NOT the same as [2]
then splice out [2] ... then
continue comparisons with [1] and (what was) [3]....
I'm interested in any solutions that do the Right Thing to @fhs...
as described above. Suggestions?
--
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: Thu, 25 Jan 2001 21:49:41 -0500
From: Stephen Kloder <stephenk@cc.gatech.edu>
Subject: Re: Code that could use a different approach, can you optimize?
Message-Id: <3A70E5C5.10F84556@cc.gatech.edu>
"Clinton A. Pierce" wrote:
> This is an N-file compare routine ripped from a piece of code laying around.
> I'm NOT interested in optimizing or bumming the whole thing. That would
> defeat a few other things that are going on elsewhere. Here's the code
> sample:
>
>
<code snipped>
> The part I'm interested in is the while loop. Specifically, the
> part that begins COMPARE. Yes, that's a goto. At the time it seemed
> like a good idea. What I want to do is:
>
> * compare multiple elements of @fhs
> * splice out the ones that aren't the same as the others,
> going from lowest index to highest.
> So if [1] is the same as [2]
> but [2] is not the same as [3]
> splice out [3]. Continue by comparing [2] and (what was) [4]
> BUT, if [1] is NOT the same as [2]
> then splice out [2] ... then
> continue comparisons with [1] and (what was) [3]....
>
> I'm interested in any solutions that do the Right Thing to @fhs...
> as described above. Suggestions?
>
It looks like you're comparing all files to the first one. Why do you want to do it
in this manner?
--
Stephen Kloder | "I say what it occurs to me to say.
stephenk@cc.gatech.edu | More I cannot say."
Phone 404-874-6584 | -- The Man in the Shack
ICQ #65153895 | be :- think.
------------------------------
Date: Fri, 26 Jan 2001 03:12:27 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Comparing multiple values
Message-Id: <x7snm7uhut.fsf@home.sysarch.com>
>>>>> "DC" == Damian Conway <damian@cs.monash.edu.au> writes:
DC> "TA" == Tore Aursand <tore@extend.no> writes:
TA> In article <94pocs$osn$1@nnrp1.deja.com>, datastar@my-deja.com says...
>> >> ...but what if I want to test if $somevar equals 3,4,8 or 9?
DC> I'm late to this thread, so I'm not sure if anyone has yet suggested:
DC> use Quantum::Superpositions;
DC> if ($somevar == any(3,4,8,9)) {
DC> ...
DC> }
we all did in an alternate universe. you are the only one who did it in
this one.
:-)
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: 26 Jan 2001 00:02:40 GMT
From: nospam@hairball.cup.hp.com (Richard J. Rauenzahn)
Subject: Re: Comparing multiple values
Message-Id: <980467359.941979@hpvablab.cup.hp.com>
Tore Aursand <tore@extend.no> writes:
>In article <94pocs$osn$1@nnrp1.deja.com>, datastar@my-deja.com says...
>> ...but what if I want to test if $somevar equals 3,4,8 or 9?
>
>if ($number =~ /[1|2|3|4]/) {
> ...
>}
Umm.. no,
$ perl
$number = '40';
if ($number =~ /[1|2|3|4]/) {
print "$number is 1, 2, 3 or 4\n";
}
__END__
40 is 1, 2, 3 or 4
$
You want $number =~ /^[1|2|3|4]$/) {
Rich
--
Rich Rauenzahn ----------+xrrauenza@cup.hp.comx+ Hewlett-Packard Company
Technical Consultant | I speak for me, | 19055 Pruneridge Ave.
Development Alliances Lab| *not* HP | MS 46TU2
ESPD / E-Serv. Partner Division +--------------+---- Cupertino, CA 95014
------------------------------
Date: Fri, 26 Jan 2001 06:55:42 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Comparing multiple values
Message-Id: <3A71205D.96B7D73F@acm.org>
"Richard J. Rauenzahn" wrote:
>
> Tore Aursand <tore@extend.no> writes:
> >In article <94pocs$osn$1@nnrp1.deja.com>, datastar@my-deja.com says...
> >> ...but what if I want to test if $somevar equals 3,4,8 or 9?
> >
> >if ($number =~ /[1|2|3|4]/) {
> > ...
> >}
>
> Umm.. no,
>
> $ perl
> $number = '40';
>
> if ($number =~ /[1|2|3|4]/) {
> print "$number is 1, 2, 3 or 4\n";
> }
>
> __END__
> 40 is 1, 2, 3 or 4
> $
>
> You want $number =~ /^[1|2|3|4]$/) {
BZZZZT! wrong answer.
$ perl -e '$number = "|"; if ($number =~ /^[1|2|3|4]$/) { print "$number
is 1, 2, 3 or 4\n"; }'
| is 1, 2, 3 or 4
John
------------------------------
Date: 25 Jan 2001 21:16:23 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: database
Message-Id: <ae8ft5vs.fsf@pobox.com>
Julien Quint <julien.quint@imag.fr> writes:
> The French translation of "Learning Perl" (the Lama Book)
No, no. The Lama book is "The Art of Happiness : A Handbook for
Living".
;)
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
Oui, je sais qu'on dit "lama" en Français.
------------------------------
Date: Fri, 26 Jan 2001 02:26:06 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Dealing with x1b character
Message-Id: <3a70e03e.2509$3e5@news.op.net>
Keywords: Jurassic, cavemen, long, plumb
In article <94q8le$952$1@nnrp1.deja.com>, <hparks@my-deja.com> wrote:
>Some debugging showed the program was exiting when an escape
>character (hex 1B) was encountered.
Are you sure the character was 1B? Windows file reads normally exit
when they encounter character 1A, not 1B.
In any event, my first suggestion would be to add
binmode(INFILE);
binmode(OUTFILE);
just after you open the input and output files. This may disable the
exiting behavior you described. At the very least, it is much easier
to try than the other suggestion in this thread so far.
>I don't mind RTFM if someone will point me
>to the right manual. The environment is WinNT4.
Definitely check out the section on 'binmode' in the 'perlfunc'
manual. Even if it doesn't solve today's problem, you will probably
need it sooner or later.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: 25 Jan 2001 21:31:23 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Error Message
Message-Id: <1ytrt56s.fsf@pobox.com>
"Dustin" <dfreeman@rathis.com> writes:
> I'm very new to Perl/cgi programming and I am getting an error with a
> recently acuirred script .
You have "acquired" a program, which implies that you haven't yourself
*written* it. Unless you yourself speak at least a limited dialect of
programmer-talk, it will be hard for us to help you fix whatever's
wrong.
> I'm running Apache web server on my local machine for testing
> purposes then transfering them to a WinNt server. The error i'm
> getting is "couldn't spawn child process:" I have know idea what
> this is telling me.
Windows and Unix are drastically different in the way they manage the
creation of processes communications between those processes. A
script written for Unix that makes use of the fork() command (that's a
Perl language function, which creates a new process by calling the C
standard library fork() function) will most likely fail when run in
Windows, even though the Windows version of perl now emulates fork().
Your program might need to be redisigned, at least in part, to use the
Win32-specific process-management tools that come with ActivePerl.
If you're in a hurry, you'll have to either hire someone, or convince
someone with more expertise than yourself to come and fix it for you
for free. This newsgroup is good at helping people learn more about
Perl; it's not so good at consulting jobs, at least not en masse. :)
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: 26 Jan 2001 01:29:59 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Error Message
Message-Id: <bssusu54.fsf@pobox.com>
Jonathan Feinberg <jdf@pobox.com> writes:
> Windows and Unix are drastically different in the way they manage the
> creation of processes communications between those processes. A
^^^
and
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Fri, 26 Jan 2001 04:24:46 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Form Processing - newbie question
Message-Id: <slrn971uve.fe5.efflandt@efflandt.xnet.com>
On Fri, 26 Jan 2001 00:05:13 GMT, paanwa <paanwa@hotmail.com> wrote:
>I am trying to take form data from checkboxes and write it to a text file.
>Here are the rules I have been given:
>A maximum of 5 checkboxes may be submitted (this is screened via
>javascript).
>A total of 5 entries in the data file must be submitted even if less than 5
>checks have been selected by the user.
>
>Here is an example of what must occur if only 3 checks are submitted:
>(note the csv formatting)
>
>print FILE "\"$in{'check1'}\","
>print FILE "\"$in{'check2'}\","
>print FILE "\"$in{'check3'}\","
>print FILE "\"\","; #blank field
>print FILE "\"\","; #blank field - this makes a total of 5 entries.
I think you forgot some semi-colons. You could write this as:
for ($i = 1; $i < 6; $i++) {
print FILE '"', ($in{'check'.$i}) ? $in{'check'.$i} : '', '",';
}
One other comment is that you would be better off using the currently
supported CGI module included with Perl5 instead of the antiquated perl4
cgi-lib.pl. For more info type: perldoc CGI
Although this question is Perl specific, general CGI questions should be
posted to a *.cgi newsgroup.
--
David Efflandt efflandt@xnet.com http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: 25 Jan 2001 21:35:38 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: FreezeThaw.
Message-Id: <wvbjrqf9.fsf@pobox.com>
Rob <a565a87@my-deja.com> writes:
> I have Win NT 4, and the MLDBM module I want to build seems to want
> FreezeThaw and/or Storable, both of which I subsequently downloaded
> from CPAN.
It may be that you have a reason to build your own perl for Win32. If
you don't have a reason, then just get the ActiveState perl
distribution. Run the "ppm" utility that comes with it, and type
"install MLDBM" at the prompt. That will save you a great deal of
time, aggravation, and hair.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Fri, 26 Jan 2001 05:04:00 GMT
From: Rob <a565a87@my-deja.com>
Subject: Re: FreezeThaw.
Message-Id: <94r0ft$tlq$1@nnrp1.deja.com>
Jonathan,
Thank you very much for responding to my post.
Yeah, I made a conscious decision to build from the Win32 source
because the last time I was thinking about playing with Apache and
mod_perl (about a year ago), the ActiveState was a no-no for that
combination. So now, while I've read recently that binary may in fact
now be compatible with mod_perl, I didn't want to take any chances.
I've had success running the 5.6.0 CPAN Win32 build from source, and I
also built from the mod_perl source (the Apache 1.3.14 I downloaded and
am running is binary).
But right now I'm in the process of building Apache::ASP from source.
That's where this problem I posted has arisen from (Apache::ASP wants
some extraneous modules). Just can't get beyond this point with the
MLDBM module build (one of those modules).
If nobody has suggestions to work around the aforementioned, there's
been mention in the perl Makefile.PL debug information that gets thrown
back in my face about some kind of automatic CPAN.PL or something like
that that would offer to configure this prospective MLDBM build with
whatever exactly it needs. I threw in the towel and attempted to try
it with this MLDBM thingy, but the CPAN script eventually started
asking for an FTP proxy and an HTTP proxy which it asked if I'd like to
use before it could produce results, and I don't know what to tell the
interpreter as far as what are my FTP and and/or HTTP proxies. All I
knows is I'm on a 56K POTS connection to my ISP two towns over. What
should I say is my FTP proxy?
Or what else should I do about this MLDBM build?
Thanks again,
-Rob
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 26 Jan 2001 05:16:35 GMT
From: Rob <a565a87@my-deja.com>
Subject: Re: FreezeThaw.
Message-Id: <94r17f$u60$1@nnrp1.deja.com>
Also, since it's really an MLDBM issue (the build just stops at the
FreezeThaw.t area for some reason even though I built and installed
FreezeThaw with no problem), maybe I should also e-mail an inquiry
about this to the module's creator, Gurusamy Sarathy (who noted in the
accompanying docs that feedback is welcome. Although technically this
isn't really feedback but a petition for information about how to build
this from the source given the problems I'm incurring.).
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 26 Jan 2001 01:12:46 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: FreezeThaw.
Message-Id: <k87isuxt.fsf@pobox.com>
Rob <a565a87@my-deja.com> writes:
> All I knows is I'm on a 56K POTS connection to my ISP two towns
> over. What should I say is my FTP proxy?
You have no proxies. I'm not familiar with the menu you're going
through (although it's reminiscent of the configuration for libnet),
but I expect you can just leave those answers blank.
> Or what else should I do about this MLDBM build?
I wish I could tell you. My best answer is to install a Unix-like OS
and watch everything go much easier. :/
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Fri, 26 Jan 2001 07:33:39 GMT
From: Rob <a565a87@my-deja.com>
Subject: Re: FreezeThaw.
Message-Id: <94r98k$41t$1@nnrp1.deja.com>
Jonathan,
Thanks. I'll keep pluggin' away at it.
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 25 Jan 2001 21:52:46 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Hash of hash of arrays problem
Message-Id: <ofwvrpmp.fsf@pobox.com>
lou@visca.com (Lou Hevly) writes:
> However, when I make the values of %data into array refs, so as to be
> able to push more data onto them later, I get a reference to the
> *same* hash as my %domains hash values:
>
> my %data = (
> du_w => ['Disk Usage: Web'],
> du_m => ['Disk Usage: Mail'],
> tot_du => ['Total Disk Usage'],
> );
Now $data{du_w} contains a reference to an anonymous array, right?
That reference is essentially a pointer to a memory location (for the
purposes of this explanation, that's true enough). When you copy
%data into a new anonymous hash, you're not constructing new anonymous
arrays; you're copying those pointers into the new hash.
%data = ( key => [anonymous array at location 1492BEEF] );
$href = { %data };
# $href->{key} now contains [anonymous array at location 1492BEEF]
Another way to think of it: you havent put instructions to build new
anonymous arrays into that hash; you've simply put the anonymous
arrays themselves.
I hope this helps!
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Fri, 26 Jan 2001 06:17:05 GMT
From: montep@hal-pc.org (Monte Phillips)
Subject: How do you backspace(back delete) on console?
Message-Id: <3a7115d0.48260615@news.hal-pc.org>
Backspace print using \b is fine except I need to backspace on the
display screen. Print a character then backspace over it and print
another character on the same spot.
------------------------------
Date: Thu, 25 Jan 2001 21:09:19 -0500
From: Max <jamas@mindspring.com>
Subject: Is Number of Params Limited? *Warning Newbie*
Message-Id: <3A70DC4E.D7EFF03D@mindspring.com>
This is about my fifth script.
After read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
And spliting $buffer into %pairs
Is there a limit to the number of elements in %pairs ?
My form is suppose to return 9 products, but only returns 7
Some of the $keys are close in spelling, but no dupilicates.
--
CGI, ASP, PHP, Oh' my,
CGI, ASP, PHP, Oh' my
John M. Smith
------------------------------
Date: Fri, 26 Jan 2001 02:12:29 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Is Number of Params Limited? *Warning Newbie*
Message-Id: <3a70dd0d.24a7$85@news.op.net>
In article <3A70DC4E.D7EFF03D@mindspring.com>,
Max <jamas@mindspring.com> wrote:
>Is there a limit to the number of elements in %pairs ?
No.
>My form is suppose to return 9 products, but only returns 7
>Some of the $keys are close in spelling, but no dupilicates.
Your program has a bug.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: 26 Jan 2001 02:44:43 GMT
From: drus3113@cs.com (Dave Rustay)
Subject: Re: Is Number of Params Limited? *Warning Newbie*
Message-Id: <20010125214443.12089.00001275@ng-fl1.news.cs.com>
I would strongly suggest, to sho away those bugs, to use CGI.pm. It's much
easier and much more efficient. simple use.
use CGI qw/param/;
my $var = param("var");
OR you can use an object
use CGI;
my $var = new CGI;
$var2 = $var->param("var");
It's much better than all that other mumbo jumbo. Use it!.
------------------------------
Date: Thu, 25 Jan 2001 20:28:13 -0800
From: Kira <callgirl@la.znet.com>
Subject: Re: Is Number of Params Limited? *Warning Newbie*
Message-Id: <3A70FCDD.3341987C@la.znet.com>
Max wrote:
(some snippage)
> After read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> And spliting $buffer into %pairs
> Is there a limit to the number of elements in %pairs ?
> My form is suppose to return 9 products, but only returns 7
Do yourself a favor and post your home-grown
read and parse routine. Either you have a
problem with your routine or you are only
receiving seven key/value pairs from your
form action. It would help, as well, to give
a * brief * description of your form action.
Post your code so people can look it over.
Godzilla!
------------------------------
Date: 26 Jan 2001 03:14:14 GMT
From: eroth001@aol.com (EROTH001)
Subject: Know Perl? Help a poor hack out with if-else statement
Message-Id: <20010125221414.01973.00001040@ng-fp1.aol.com>
Hello,
Im a newbie to writing perl. I dont know the proper syntax required to do this
but Im trying to add a new variable into an already existing if-else statement.
First the background information:
This is from www.bignosebird.com, NOMODOMO subscribe.cgi e-mail script -for
anyone who may be already using it. Ive linked it to formmail which then
e-mails to autoresponders which send out confirmations back to the subscriber ,
and an e-mail to me too.
Currently the statement in the script, with surrounding script lines, looks
like this:
sub thank_you
{
if ($action eq "unsubscribe")
{ $whichaction = "removed from";}
else { $whichaction = "added to";}
print "Content-type: text/html\n\n";
print <<__END_THANKS__;
BODY BGCOLOR="etc etc etc...........
I want to also make the statement affect a new variable called: $confirmation
if ($action eq "unsubscribe")
{ $whichaction = "removed from" and $confirmation =
"youre_removed";}
else { $whichaction = "added to" and $confirmation =
"youre_subscribed";}
OK. my question is: what is the proper way to write this so it works. since Im
just taking shots in the dark, and Im starting to become one with the 500
server error.
Thanking you in advance,
eroth001@aol.com
------------------------------
Date: Fri, 26 Jan 2001 13:15:30 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Know Perl? Help a poor hack out with if-else statement
Message-Id: <qp6c6.11$Gf5.4045@vic.nntp.telstra.net>
This has been answered several times on both Perl and CGI newsgroups.
Anything you didn't understand about any of those answers? Or didn't you
read them?
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: Fri, 26 Jan 2001 07:34:58 GMT
From: "dkh" <projectobjects@earthlink.net>
Subject: merging 2 array columns...
Message-Id: <CM9c6.463$k%3.61862@newsread1.prod.itd.earthlink.net>
I am using Data::Table pm to map one table to another and would like to
combine 2 columns together, but it does not have that method. Could someone
give a hash or something to do so...
$phonearray1= $pretable->col (17);
$phonearray1= $pretable->col (18);
------------------------------
Date: Fri, 26 Jan 2001 08:48:35 +0100
From: "wiwo" <w-woerlinger@ti.com>
Subject: OLE Module for AS Perl 5.6 on NT
Message-Id: <94ra1h$a2d$1@tilde.csc.ti.com>
Is there a module compareable to Win32::OLE for AS Perl 5.6 running on NT?
Regards,
Willi
------------------------------
Date: Fri, 26 Jan 2001 12:39:06 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Script to "rotate" the chars in a string.
Message-Id: <iT5c6.9$Gf5.3860@vic.nntp.telstra.net>
"James Kufrovich" <eggie@REMOVE_TO_REPLYsunlink.net> wrote in message
news:slrn971d6r.emp.eggie@melody.mephit.com...
> Hi.
G'day
> I just put together a small script (at the bottom there) that will
> rotate the characters in a string (supplied on the command line) and print
> the resulting string out, both forwards and backwards. In other words,
> giving the program the string "funky" will produce the following output:
>
Here is an alternative approach, where you feed the sub the string and the
direction.
Successive calls to the sub rotate one further letter.
print &rotate ('funky', 'forward');
sub rotate { # gimme a word and a direction (forward or backward)
my @letters = split //,shift;
my $direction = shift;
push @letters,(shift @letters) if $direction eq 'forward';
unshift @letters,(pop @letters) if $direction eq 'backward';
return (join '',@letters);
}
Wyzelli (just havin fun)
--
#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: Fri, 26 Jan 2001 07:50:56 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Script to "rotate" the chars in a string.
Message-Id: <slrn972b40.i8a.rgarciasuarez@rafael.kazibao.net>
James Kufrovich wrote in comp.lang.perl.misc:
>
> I just put together a small script (at the bottom there) that will
> rotate the characters in a string (supplied on the command line) and print
> the resulting string out, both forwards and backwards. In other words,
> giving the program the string "funky" will produce the following output:
Another alternative approach, uses substitutions :
#!/usr/local/bin/perl -l
$_ = shift;
my $n = length;
for my $i (1..$n) { print; s/^(.)(.*)/$2$1/ }
$_ = join '', reverse split //;
for my $i (1..$n) { print; s/^(.)(.*)/$2$1/ }
--
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: Thu, 25 Jan 2001 22:02:32 -0700
From: "Bier" <yukon_jach@yahoo.com>
Subject: tab delimitated file
Message-Id: <t7214aafkj1jd7@corp.supernews.com>
I want to pass a tab delimitated file to a Perl program, and am unsure of
how to proceed.
The file is made up of many rows each containing several columns of data, of
varying length. The first row contains the column headings. Only certain
columns of are interest, for example columns 1, 2, 4, 6, and 9. Starting at
the second row I want read the appropriate columns and assign each to a
particular variable. The data will processed and passed to another file. The
program would then proceed with the third row and so forth.
I would like to learn how to read only the desired columns starting on the
second row.
Any help would be appreciated.
Thanks
B
--
My life is being cursed by a Big Purple Dinosaur.....
------------------------------
Date: 26 Jan 2001 01:25:57 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: tab delimitated file
Message-Id: <g0i6subu.fsf@pobox.com>
"Bier" <yukon_jach@yahoo.com> writes:
> The file is made up of many rows each containing several columns of data, of
> varying length. The first row contains the column headings. Only certain
> columns of are interest, for example columns 1, 2, 4, 6, and 9. Starting at
> the second row I want read the appropriate columns and assign each to a
> particular variable. The data will processed and passed to another file. The
> program would then proceed with the third row and so forth.
>
> I would like to learn how to read only the desired columns starting on the
> second row.
Hello, Bier.
I'm glad to try and help you, but I'm concerned that maybe you don't
actually speak any Perl at all, and that therefore the best you could
do would be to copy and paste my code, without understanding how it
works. I'll provide some pointers, but I hope you'll take the time to
buy, read, and work through the exercises in the book "Learning Perl".
If you're in a hurry, you might have to hire someone else for now to
make sure you've got a robust program that does what you want. As you
learn more yourself, you'll be able to make changes to the program,
and then perhaps create your own.
To skip the first line of the file, simply read a line of data using
the filehandle operator, and throw away the result. For example...
# throw away a line
scalar <>;
Then to split each line of input by tabs, keeping only certain
columns, you'll use the split() function in combination with a list
slice and a list assignment.
while (<>) {
chomp;
($foo, $bar, $baz) = (split /\t/)[0, 1, 3];
}
Then you can process those variables however you like, and use the
print() function to put whatever you like into another file.
I hope this helps.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Fri, 26 Jan 2001 13:10:48 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: What's wrong with this script?
Message-Id: <3l6c6.10$Gf5.4108@vic.nntp.telstra.net>
"Dan" <kkk@elrancho.com> wrote in message
news:94pq50$a5e$1@news.kolumbus.fi...
<snip>
Aside from the things that mark has pointed out, it would appear that you
are printing two headers,...
> #!/usr/local/bin/perl
> print ("Content-type: text/html\n\n");
Here
> use CGI qw(:standard);
> my $c = new CGI;
>
> ### READ PARAMETER i ###
>
> if($c->param())
> {
> $id = $c->param('i');
> }
>
> print header;
And Here.
> print start_html('wavetable.net - add plugin');
> print (start_form,
<snip>
You probably don't need the first one.
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: 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 V10 Issue 147
**************************************