[18580] in Perl-Users-Digest
Perl-Users Digest, Issue: 748 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 23 18:06:43 2001
Date: Mon, 23 Apr 2001 15:05:16 -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: <988063515-v10-i748@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 23 Apr 2001 Volume: 10 Number: 748
Today's topics:
Re: Calling an ASP from a Perl CGI <jmoon@uab.edu>
Re: Calling an ASP from a Perl CGI <flavell@mail.cern.ch>
CGI.pm | WWW::Search WWW::SearchResults <acarl@slip.net>
Re: CGI.pm | WWW::Search WWW::SearchResults (Randal L. Schwartz)
Cryptofish - A crytographic tool <djsyntax@crazydj.de>
Re: Debugging <webmaster@webdragon.unmunge.net>
Re: Debugging <elaine@chaos.wustl.edu>
easy newbie Question <adam.braa@portalplayer.com>
Re: easy newbie Question (Rudolf Polzer)
Re: easy newbie Question <bart.lateur@skynet.be>
Re: Getting a list of modules currently installed <webmaster@webdragon.unmunge.net>
Re: Getting character codes <flavell@mail.cern.ch>
Re: Getting character codes <iltzu@sci.invalid>
Re: Good editor for perl (---Pete---)
Re: Good editor for perl <dirkvandemoortel@ThankS-NO-SperM.hotmail.com>
Re: Good editor for perl <simon@super-simon.com>
Re: Good editor for perl (Webmaster)
Re: Good editor for perl (Webmaster)
Re: Good editor for perl <newspost@coppit.org>
Re: Good editor for perl <newspost@coppit.org>
Help with double hash of arrays (Jake Peters)
Re: Help with double hash of arrays (Tad McClellan)
Re: Help with my feedback script <dennis.kowalsk@daytonoh.ncr.com>
Re: Help with my feedback script <uri@sysarch.com>
Re: HTML Template Module <jboes@nexcerpt.com>
Re: Infinate loop <iltzu@sci.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 23 Apr 2001 15:39:08 -0500
From: "Jim" <jmoon@uab.edu>
Subject: Re: Calling an ASP from a Perl CGI
Message-Id: <9c23tc$hun$1@SonOfMaze.dpo.uab.edu>
> I have to call a page at the enf of a Perl CGI (in the specific
> case is an ASP, but I think HTML is the same).
>
> How can I do?
This javascript will redirect a browser to the desired ASP.
(Write an HTML header first.)
print "<SCRIPT LANGUAGE=\"JavaScript\"><!--\n";
print "window.location.href=\"YourASPName.asp\"\n";
print "//-->\n";
print "</SCRIPT>\n";
Jim
------------------------------
Date: Mon, 23 Apr 2001 22:54:01 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Calling an ASP from a Perl CGI
Message-Id: <Pine.LNX.4.30.0104232240440.16191-100000@lxplus003.cern.ch>
On Mon, 23 Apr 2001, Jim hammered another nail into the reputation
enjoyed by jeopardists usenetwide by blurting out:
> This javascript will redirect a browser to the desired ASP.
Don't be silly.
Use an HTTP redirect initiated in the usual way from the script (see
CGI.pm documentation for an easy recipe).
> (Write an HTML header first.)
Nope.
> print "<SCRIPT LANGUAGE=\"JavaScript\"><!--\n";
> print "window.location.href=\"YourASPName.asp\"\n";
> print "//-->\n";
> print "</SCRIPT>\n";
And that Perl (about the only thing on-topic here) is a mess. Never
heard of here-documents?
Sigh
------------------------------
Date: Mon, 23 Apr 2001 21:45:09 GMT
From: Carl Arrechea <acarl@slip.net>
Subject: CGI.pm | WWW::Search WWW::SearchResults
Message-Id: <Fn1F6.2$8b4.77@news2.dnvrcoidc.firstworld.net>
Can anyone direct me to a Perl script that uses CGI.pm to send
keywords to WWW::Search and WWW:SearchResults?
Reply also to channel@ibiblio.org
Roger Jacques
------------------------------
Date: 23 Apr 2001 14:56:02 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: CGI.pm | WWW::Search WWW::SearchResults
Message-Id: <m14rvfi8lp.fsf@halfdome.holdit.com>
>>>>> "Carl" == Carl Arrechea <acarl@slip.net> writes:
Carl> Can anyone direct me to a Perl script that uses CGI.pm to send
Carl> keywords to WWW::Search and WWW:SearchResults?
Yes. http://www.stonehenge.com/merlyn/WebTechniques/col44.html
is such an example. Check nearby for other ideas as well.
Carl> Reply also to channel@ibiblio.org
No. Come here for the answer.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Tue, 24 Apr 2001 00:00:48 +0200
From: "Bastian Ballmann" <djsyntax@crazydj.de>
Subject: Cryptofish - A crytographic tool
Message-Id: <20010424.000047.1626276121.1764@Syntaxerror.crazydj.de>
Hi @ll.
Does anyone of you need a crypthographic tool using the blowfish
algorythm?
You can find my version at http://www.crazydj.de
Maybe this could be a little chance to forget my smstool, because it will
never be written. And if I should says the truth I only wanted to write
this tool to bomb the exgirlfriend of one of my best friends. If you
believe it or not, the project is canceld 'cause I have recognized that
it was a fault.
So happy crypting out there!!!
Perl is phun :-)
Greetingz
Bastian Ballmann
------------------------------
Date: 23 Apr 2001 20:12:40 GMT
From: "Scott R. Godin" <webmaster@webdragon.unmunge.net>
Subject: Re: Debugging
Message-Id: <9c22bo$rgp$1@216.155.32.16>
In article <rYUE6.1740$QV4.134993@www.newsranger.com>,
jaime <nospam@newsranger.com> wrote:
| Does anyone know of a book that gives examples
| on how to use Perl's debugger?
you might start with
perldoc perldebug
as there's a lot of info in perldebug.pod. :)
| Is there a GUI debugger available anywhere?
This I have no answer for.
--
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw";
# ( damn spammers. *shakes fist* take a hint. =:P )
------------------------------
Date: Mon, 23 Apr 2001 20:46:45 GMT
From: "Elaine Ashton" <elaine@chaos.wustl.edu>
Subject: Re: Debugging
Message-Id: <Vw0F6.7884$m17.166158@news2.nokia.com>
"jaime" <nospam@newsranger.com> wrote in message
news:rYUE6.1740$QV4.134993@www.newsranger.com...
> Does anyone know of a book that gives examples
> on how to use Perl's debugger?
http://www.perldebugged.com/
> Is there a GUI debugger available anywhere?
ptkdb is one of several.
http://world.std.com/~aep/ptkdb/
e.
------------------------------
Date: Mon, 23 Apr 2001 12:31:46 -0700
From: "aDAM" <adam.braa@portalplayer.com>
Subject: easy newbie Question
Message-Id: <3ae48324_1@news.nwlink.com>
im am learning perl and wonder if somone can answer these 2Q's for me.
1. when would you use a "\n" over a "\r"?
2. how would i make the following line appear on its own line?
<print 'I a new line after this statement';>
------------------------------
Date: Mon, 23 Apr 2001 22:03:50 +0200
From: eins@durchnull.de (Rudolf Polzer)
Subject: Re: easy newbie Question
Message-Id: <slrn9e92l6.pu3.eins@www42.t-offline.de>
aDAM <adam.braa@portalplayer.com> wrote:
> im am learning perl and wonder if somone can answer these 2Q's for me.
>
> 1. when would you use a "\n" over a "\r"?
Whenever possible.
> 2. how would i make the following line appear on its own line?
> <print 'I a new line after this statement';>
print "I a new line after this statement\n";
or, if you want single quotes:
print 'I a new line after this statement' . "\n";
--
#!/usr/bin/perl -W -- WARNING: This will print 22,307 bytes! <strictsafe!>
use strict;for(my$y=-1;$y<1;$y+=.1){for(my$x=-1.9;$x<.4;$x+=.03){print'+';
my$X=my$Y=0;for(0..99){($X,$Y)=($X*$X-$Y*$Y+$x,2*$X*$Y+$y);print"\b "if$X*
$X+$Y*$Y>9;}}print"\n"};print''.reverse"\nHPAJ \a!rezloP .R yb torblednaM"
------------------------------
Date: Mon, 23 Apr 2001 20:35:31 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: easy newbie Question
Message-Id: <tb49etk792aec1ooh9frt0qm4kjdtd8qhl@4ax.com>
aDAM wrote:
>1. when would you use a "\n" over a "\r"?
Always. "\r" is something you hardly ever want. Er... except for
filtering them out. And I use "\r" if I want to generate Mac files on a
PC. (A Mac uses chr(13) for line endings.)
In summary: "\n" is what you want, "\r" is the other one. And Perl on a
PC will automatically convert the single character "\n" into the duo CR
and LF. Unless you applied binmode() on the output file handle.
--
Bart.
------------------------------
Date: 23 Apr 2001 18:33:08 GMT
From: "Scott R. Godin" <webmaster@webdragon.unmunge.net>
Subject: Re: Getting a list of modules currently installed
Message-Id: <9c1sh4$e7b$0@216.155.32.16>
In article <2RYE6.3013$Ln6.230693@news2-win.server.ntlworld.com>,
"Stuart Moore" <stumo@bigfoot.com> wrote:
| Is there a way to get a list of all currently available modules from within a
| Perl script? I haven't had any luck searching for one, but it may just be me
| being more massive per unit volume.
|
| Stuart
You could use something along the lines of this: sorry for the b0rked
linewrapping enforced by my newsreader -- you should be able to figure
out what's what, though (I tried to fix it somewhat). This merely tells
you what files you already HAVE and how the version numbers compare to
that which is on CPAN.
It could be easily modified to show those modules which you do NOT have
installed but exist on CPAN, but that's another ball of wax too. :) This
isn't exactly what you're looking for but it's close enough that it can
be easily munged into what you need.
#!/usr/bin/perl -w
# visualized and created by Scott R. Godin, 12/30/2000
# last update April 23, 2001
# e-mail print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw";
# web http://www.webdragon.net/
######
use strict;
# *** uncomment if you have Storable installed and want to use it,
# and also see below
#use Storable 0.604; # ***storable
use File::Spec 0.82;
use CPAN 1.59;
# current version 1.59. cpan> install CPAN ...
# do NOT install Bundle::CPAN!!!
use constant USE_SAVEFILE => 1;
# set to 0 if you don't want the output redirected to a file.
my $savefile =
File::Spec->catfile( File::Spec->curdir(), 'ModuleCheck.txt' );
my $storefile =
File::Spec->catfile( File::Spec->curdir(), 'installed_modules.stor' );
sub checkmodule () {
my %installed_modules = ();
print "Checking Modules...Please stand by.. the cursor will spin for
a minute or so.\n";
print "GO get some coffee! You Deserve it! :-D\n";
for my $mod (CPAN::Shell->expand("Module","/./")){
next unless $mod->inst_file;
# MakeMaker convention for undefined $VERSION:
$installed_modules{ $mod->id } =
[ (($mod->inst_version eq "undef") ? '' : $mod->inst_version),
(($mod->cpan_version eq "undef") ? '' : $mod->cpan_version),
];
}
# store \%installed_modules, $storefile; # ***storable
print "Done and stored.\n\n";
return \%installed_modules; # ***non-storable
}
sub readstored (;$) {
my $ref = shift; # ***non-storable
# my $ref = retrieve($storefile) or die "$!"; # ***storable again
my $last = '';
# otherwise let user direct it to a file if they so choose,
# via ./moduletest.plx > outputfile.txt
if (USE_SAVEFILE) {
print "Now retrieving Module data; output sent to $savefile\n";
open STDOUT, ">$savefile" or die "$!";
}
print "Listing all Installed Modules and Versions where
available...\n\n";
foreach (sort {uc($a) cmp uc($b)} keys %{$ref}) {
/^(\w+)\:{0,2}.*$/;
my $this = $1;
print "-" x 87, "\n" if ($last ne $this);
printf "Installed Module: %-35s", $_, ",";
printf " Version: %-9s", $ref->{$_}[0], ",";
printf " CPAN: %-10s", $ref->{$_}[1];
print "\n";
$last = $this;
}
}
# if the storefile already exists, use it to save time. delete it to
re-run the check.
if (-e $storefile) {
# this part uses Storable, but gets ignored if you don't have it
print "Using existing .stor file for brevity.\nDelete '$storefile'
and re-run the script to if you wish to update.\n\n";
readstored;
} else {
my $ref = checkmodule; # ***non-storable
readstored($ref); # ***non-storable
# checkmodule; # ***storable
# readstored; # ***storable
}
exit 0;
__END__
it should be pretty obvious what to swap around with the comments, but
just in case : If you have Storable.pm installed, uncomment all the
lines marked ***storable and comment out all the lines marked
***non-storable. :)
HTH
--
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw";
# ( damn spammers. *shakes fist* take a hint. =:P )
------------------------------
Date: Mon, 23 Apr 2001 22:24:25 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Getting character codes
Message-Id: <Pine.LNX.4.30.0104232213520.16191-100000@lxplus003.cern.ch>
On Mon, 23 Apr 2001, Rudolf Polzer wrote:
> Sorry, I meant DOS-437 (or the OEM charset) with ASCII and the Windoze
> charset with ANSI.
Aha, now we're getting somewhere.
> > US-ASCII is a subset (i.e positions 0 to 127) of _all_ of these
> > 8-bit codings.
>
> Perhaps I learnt too much bullsh*t from some word processors that
> called 437 'ASCII' and the Windoze charset 'ANSI'.
Sounds like it: it's true that I've heard CP-437 referred to as
"extended ASCII", but since the other codings under discussion have
ASCII as a subset too, that doesn't seem very useful terminology.
> Perhaps I did too
> much Win32 coding using oemtoansi functions.
Well, referring to "the" Windoze coding is still not quite the answer,
since there's more than one of them. At any given time, the
Windows-1252 code is the Latin-1 Windows coding, but they have changed
it now and again (most recently by adding the euro sign). And there
are nine or ten other "Windows" codings registered from 1250 upwards
(and apparently referred to in certain MS documentation as "ANSI
codings", in spite of the lack of any such published American National
standards).
(I don't know why the ANSI doesn't complain about this widespread
misattribution, but that would take us even more off-topic).
anyhow, no offence meant. Character coding is confusing enough.
------------------------------
Date: 23 Apr 2001 20:43:05 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Getting character codes
Message-Id: <988058389.7389@itz.pp.sci.fi>
In article <bs04et82nf641eva1depmma8cb750edp86@4ax.com>, Abe Timmerman wrote:
>On 21 Apr 2001 16:15:37 -0500, logan@cs.utexas.edu (Logan Shaw) wrote:
>>
>> That's sort of silly, but not nearly silly enough, I think. If you do
>> this:
>>
>> $mapping = join ("", map (chr, 0 .. 255));
>>
>> Then you can use
>>
>> $code = index($mapping, $character);
>>
>> and
>>
>> $character = $mapping[$code];
>
>Now were did @mapping spring into existence?
>Did you perhaps want:
>
> my $mapping = join "", my @mapping = map { chr } 0..255;
No, no, no, no, no! _Obviously_ he wants this:
use Tie::CharArray;
tie my @mapping, 'Tie::CharArray', $mapping;
Of course, he could've just used Tie::CharArray::Ord instead..
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla / Kira -- do not feed the troll.
------------------------------
Date: Mon, 23 Apr 2001 18:48:06 GMT
From: bogus@erol.com (---Pete---)
Subject: Re: Good editor for perl
Message-Id: <3ae4772d.101356896@news.earthlink.net>
On Mon, 23 Apr 2001 16:08:42 +0200, "Super-Simon"
<simon@super-simon.com> wrote:
>I'm searching for a good, fast editor with syntax highlighting for perl
>(CGI) for use under Windows 2000 / Windows 98 (I use windowz only for
>editing scripts, scripts runs on Linux-server). It has to be free (I'm a
>poor student ;-)
-------
I recommend the "Visual Perl IDE", an integrated development
environment for writing and debugging perl scripts under Windows.
This program is written with Delphi 5 and Perl, and it is OpenSource,
distributed under Mozilla Public License !
And here are the key features:
-Perl Syntax Coloring
-Script lines with syntax errors will be highlighted in editor window.
-Insertion and deletion of breakpoints with one mouse click.
-View and edit of variables in a hierarchical watch tree.
-Hint evaluation: Variables under the mouse cursor will be evaluated
and shown as hint.
If you want to download or get further information about
Visual Perl IDE, or if you just want to see some screenshots,
visit either site...
http://www.lost-sunglasses.de
http://visual-perl.sourceforge.net
PS: I have no connection with the author, I recently downloaded
this program and liked it. The current version is free.
---pete---
------------------------------
Date: Mon, 23 Apr 2001 19:16:52 GMT
From: "Dirk Van de moortel" <dirkvandemoortel@ThankS-NO-SperM.hotmail.com>
Subject: Re: Good editor for perl
Message-Id: <Ec%E6.17524$ii.1977328@afrodite.telenet-ops.be>
"Tom Scheper" <tom@power.net.uk> wrote in message news:mfe8etstel9d38mp8vrtasqo2351sulv2c@4ax.com...
> On Mon, 23 Apr 2001 16:08:42 +0200, "Super-Simon"
> <simon@super-simon.com> shed a beam of light on us:
>
> >Hi all,
> >
> >I'm searching for a good, fast editor with syntax highlighting for perl
> >(CGI) for use under Windows 2000 / Windows 98 (I use windowz only for
> >editing scripts, scripts runs on Linux-server). It has to be free (I'm a
> >poor student ;-)
UltraEdit is quite good for perl (and as a general replacement for Notepad).
Dirk Vdm
------------------------------
Date: Mon, 23 Apr 2001 21:28:47 +0200
From: "Super-Simon" <simon@super-simon.com>
Subject: Re: Good editor for perl
Message-Id: <9c1vkt$inj$1@news1.xs4all.nl>
Really good, and free!!!!!!!
I think I'm going to use this! Thanks for suggesting!
Grtz,
Super-Simon
"---Pete---" <bogus@erol.com> wrote in message
news:3ae4772d.101356896@news.earthlink.net...
> On Mon, 23 Apr 2001 16:08:42 +0200, "Super-Simon"
> <simon@super-simon.com> wrote:
>
> >I'm searching for a good, fast editor with syntax highlighting for perl
> >(CGI) for use under Windows 2000 / Windows 98 (I use windowz only for
> >editing scripts, scripts runs on Linux-server). It has to be free (I'm a
> >poor student ;-)
> -------
> I recommend the "Visual Perl IDE", an integrated development
> environment for writing and debugging perl scripts under Windows.
>
> This program is written with Delphi 5 and Perl, and it is OpenSource,
> distributed under Mozilla Public License !
>
> And here are the key features:
>
> -Perl Syntax Coloring
>
> -Script lines with syntax errors will be highlighted in editor window.
>
> -Insertion and deletion of breakpoints with one mouse click.
>
> -View and edit of variables in a hierarchical watch tree.
>
> -Hint evaluation: Variables under the mouse cursor will be evaluated
> and shown as hint.
>
> If you want to download or get further information about
> Visual Perl IDE, or if you just want to see some screenshots,
> visit either site...
> http://www.lost-sunglasses.de
> http://visual-perl.sourceforge.net
>
>
> PS: I have no connection with the author, I recently downloaded
> this program and liked it. The current version is free.
> ---pete---
>
------------------------------
Date: Sat, 21 Apr 2001 22:04:33 GMT
From: webmasterDELETETHIS@webmeeters.net (Webmaster)
Subject: Re: Good editor for perl
Message-Id: <3ae203d3.75701476@pubnews.netcom.net.uk>
On Mon, 23 Apr 2001 16:08:42 +0200, "Super-Simon" <simon@super-simon.com> wrote:
>Hi all,
>
>I'm searching for a good, fast editor with syntax highlighting for perl
>(CGI) for use under Windows 2000 / Windows 98 (I use windowz only for
>editing scripts, scripts runs on Linux-server). It has to be free (I'm a
>poor student ;-)
CuteHTML which comes with CuteFTP is pretty darn good, from whatever I've seen
so far.
--
"Unix is not designed for desktop applications, period."
- Frans Bouma, comp.sys.ibm.pc.demos, Oct 28,2000.
------------------------------
Date: Sat, 21 Apr 2001 22:09:13 GMT
From: webmasterDELETETHIS@webmeeters.net (Webmaster)
Subject: Re: Good editor for perl
Message-Id: <3ae204b9.75931043@pubnews.netcom.net.uk>
On Mon, 23 Apr 2001 18:48:06 GMT, bogus@erol.com (---Pete---) wrote:
>I recommend the "Visual Perl IDE", an integrated development
>environment for writing and debugging perl scripts under Windows.
...talking of which, what are some good LINUX Perl editors? Yeah, I know what it
sounds like :), but emacs is too bloated, nedit just sucks, gedit scrolls
slooooooowly and the windows takes ages to drag, I want CuteHTML for Linux. Is
that possible? :)
Thanks,
SMF,
Webmaster.
--
http://www.webmeeters.net
- For forming international Virtual Companies from all talented professionals
from around the Net.
------------------------------
Date: Mon, 23 Apr 2001 15:45:32 -0400
From: David Coppit <newspost@coppit.org>
Subject: Re: Good editor for perl
Message-Id: <Pine.SUN.4.33.0104231542520.25541-100000@mamba.cs.Virginia.EDU>
On 23 Apr 2001, Anno Siegel wrote:
> > Looks nice, but it's shareware and I can't find the syntax highlighting....
>
> Is this supposed to imply syntax hilighting is a good thing?
Is this supposed to imply syntax hilighting is a bad thing?
Don't insult someone because their preferences are not yours.
{
$a = reformat<<" EOF";
This is
a block of
text to be reformatted.
EOF # Oops. 3 spaces instead of 2.
}
--
David
------------------------------
Date: Mon, 23 Apr 2001 17:10:23 -0400
From: David Coppit <newspost@coppit.org>
Subject: Re: Good editor for perl
Message-Id: <Pine.SUN.4.33.0104231708320.28452-100000@mamba.cs.Virginia.EDU>
On Sat, 21 Apr 2001, Webmaster wrote:
> On Mon, 23 Apr 2001 18:48:06 GMT, bogus@erol.com (---Pete---) wrote:
>
> >I recommend the "Visual Perl IDE", an integrated development
> >environment for writing and debugging perl scripts under Windows.
>
> ...talking of which, what are some good LINUX Perl editors? Yeah, I
> know what it sounds like :), but emacs is too bloated, nedit just
> sucks, gedit scrolls slooooooowly and the windows takes ages to
> drag, I want CuteHTML for Linux. Is that possible? :)
It's already been mentioned, but the time spent learning vim is time
well-spent. Nearly every *NIX platform has vi already, and vim is
available for nearly every platform. Unlimited undo, syntax
highlighting, macro recording etc. make it my choice.
--
David
------------------------------
Date: 23 Apr 2001 20:56:06 GMT
From: jacobp@cubit.seas.upenn.edu (Jake Peters)
Subject: Help with double hash of arrays
Message-Id: <9c24t6$f93$1@netnews.upenn.edu>
Hi,
I am trying to build a double hash of arrays, such as the following:
$somehash{key1}{key2} = @somearray;
when I print out $somehash{key1}{key2} I get the number of elements in @somearray, so I
believe that what is being stored into the double has is simply the scalar number of
elements in the array. How can I actually get something where there is an array in the
double hash, so I can do the following:
$somehash{key1}{key2}[3] = 4;
or
pop $somehash{key1}{key2};
Thanks,
Jake
--
-------------
Jake Peters
jacobp@seas.upenn.edu
jacobp@wharton.upenn.edu
Send E-mail to my mobile phone: phone@jake.net
(100 character limit)
------------------------------
Date: Mon, 23 Apr 2001 16:30:35 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Help with double hash of arrays
Message-Id: <slrn9e947b.mpv.tadmc@tadmc26.august.net>
Jake Peters <jacobp@cubit.seas.upenn.edu> wrote:
>
>I am trying to build a double hash of arrays, such as the following:
>
> $somehash{key1}{key2} = @somearray;
perldoc perlreftut
>How can I actually get something where there is an array in the
>double hash, so I can do the following:
>
> $somehash{key1}{key2}[3] = 4;
$somehash{key1}{key2} = \@somearray; # take reference to array
or if you want a COPY instead:
$somehash{key1}{key2} = [ @somearray ]; # make ref to anon array
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 23 Apr 2001 15:30:51 -0400
From: "Dennis Kowalski" <dennis.kowalsk@daytonoh.ncr.com>
Subject: Re: Help with my feedback script
Message-Id: <3ae48324$1@rpc1284.daytonoh.ncr.com>
I would suggest you do something like this
Assume the the new comment is in $comment
open(TMP,">tmp");
print TMP "$comment\n"
open(REAL,"realname");
while (<REAL>)
{
print TMP;
}
close REAL;
close TMP;
unlink("realname");
rename("tmp","realname");
newuser <newuser@nospam.slip.net> wrote in message
news:HUIE6.254$oV6.322@news1.dnvrcoidc.firstworld.net...
> Hello,
> I have received lots of great help in the past in this newsgroup and
> would like if some can help me out with this problem that I am having.
> Currently this script which I got help from is a feedback script where
> people when visiting a webpage can make their comments. Right now it works
> but when a person types their comments they go to the bottom of the list
and
> what I would like that they go on the top of list. See example
> Existing
> 4/3/01 Very nice webpage
> 4/21/01 Webpage needs more work
>
> What I would like
> 4/21/01 Webpage needs more work
> 4/3/01 Very nice webpage
>
>
> #!/usr/bin/perl
>
> require 'cgi-lib.pl';
> &ReadParse(*in);
>
> #for testing:
> #$in{'name'} = "Joe";
> #$in{'address'} = "joe\@bazooka.com";
> #$in{'body'} = "Hi jim,\n\nHow the heck are you? :)\n\nSincerely, Joe";
>
> print "Content-type: text/html\n\n";
> print "<HTML><HEAD>\n";
> print "<TITLE>Post Results</TITLE>\n";
> print "</HEAD><BODY>\n";
>
> $date=`date`;
> chop($date); # trim \n
> $file="feedback.html";
> $tmp="/tmp/me-feedback.tmp";
> #$tmp=~s/\//@/g; # make a unique tmp file name from the path
> #$tmp="/tmp/$tmp";
> if ( !$in{'comments'} || !$in{'performance'} || !$in{'username'} ||
> !$in{realname)
> {
> &err("You haven't filled in all the the fields.\nBack up and try
> again.");
> }
>
> $text=$in{'body'};
> $text=~s/\r/ /g;
> $text=~s/\n\n/<P>/g;
> $text=~s/\n/ /g;
> $text=~s/<P><P>/<P>/g;
>
> #for testing:
> #$date = "June 1996";
>
> for($count=0;-f "$tmp"; $count++)
> {
> sleep(1);
> &err("TMP file in use, giving up!") if ($count > 4);
> }
>
> open(TMP, ">$tmp") || &err("Can't open file.");
> open(FILE, "<$file") || &err("Can't open file $file: $!");
>
> while(<FILE>)
> {
> if (/<!--LASTDATE-->/)
> {
> print TMP "<!--LASTDATE--> $date \n";
> } elsif (/<!--FEEDBACK-->/)
> {
> print TMP "<!--FEEDBACK-->\n";
> $feedback++;
> } elsif (/<!--POINTER-->/)
> {
> print TMP "<HR>";
> print TMP "<B>$in{'name'} \n";
> print TMP "<A HREF=\"mailto:$in{'address'}\">$in{'address'}</A>
> </B>$date\n";
> print TMP "<P>$text\n<!--POINTER-->\n";
> } else
> {
> print TMP $_;
> } # copy lines
> }
>
> if (! defined $feedback)
> {
> &err("not a Feedback file!");
> }
>
> open (TMP,"<$tmp")|| &err("Can't open tmp file.");
> open (FILE,">$file")|| &err("Can't open file $file: $!");
> print FILE <TMP>;
> #while(<TMP>)
> # {
> # print FILE$_;
> # }
> close(FILE);
> close(TMP);
> unlink "$tmp";
>
> print "<H1>Thank you!</H1>";
> print "<P>Your comment has been added to the ";
> print "<A HREF=\"feedback.html\">feedback</A>\n";
> print "</BODY></HTML>\n";
>
>
> sub err
> {
> local($msg)=@_;
> print "$msg\n";
> close FILE;
> close TMP;
> unlink "$tmp";
> print "</BODY></HTML>\n";
> exit;
> }
>
>
>
------------------------------
Date: Mon, 23 Apr 2001 20:04:03 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Help with my feedback script
Message-Id: <x7r8yjids6.fsf@home.sysarch.com>
>>>>> "n" == newuser <newuser@nospam.slip.net> writes:
n> Hello,
n> I have received lots of great help in the past in this newsgroup and
n> would like if some can help me out with this problem that I am having.
n> Currently this script which I got help from is a feedback script where
n> people when visiting a webpage can make their comments. Right now it works
n> but when a person types their comments they go to the bottom of the list and
n> what I would like that they go on the top of list. See example
n> Existing
n> 4/3/01 Very nice webpage
n> 4/21/01 Webpage needs more work
n> What I would like
n> 4/21/01 Webpage needs more work
n> 4/3/01 Very nice webpage
n> #!/usr/bin/perl
n> require 'cgi-lib.pl';
n> &ReadParse(*in);
use CGI is a much better choice.
n> print "Content-type: text/html\n\n";
n> print "<HTML><HEAD>\n";
n> print "<TITLE>Post Results</TITLE>\n";
n> print "</HEAD><BODY>\n";
use a here doc or CGI.pm's header function.
n> $date=`date`;
localtime
n> if ( !$in{'comments'} || !$in{'performance'} || !$in{'username'} ||
n> !$in{realname)
applying de morgan's law:
unless( $in{'comments'} && $in{'performance'} && $in{'username'} &&
$in{realname)
n> $text=$in{'body'};
n> $text=~s/\r/ /g;
n> $text=~s/\n\n/<P>/g;
n> $text=~s/\n/ /g;
n> $text=~s/<P><P>/<P>/g;
clean that up by reordering and combining:
$text =~ s/\n\n/<P>/g ;
$text =~ tr/\r\n/ /s ;
$text =~ s/<P><P>/<P>/g ;
and learn to use whitespace.
n> for($count=0;-f "$tmp"; $count++)
n> {
n> sleep(1);
n> &err("TMP file in use, giving up!") if ($count > 4);
n> }
ouch! -f isn't atomic with regards to a later open. there are many
better ways to do a lock file.
n> while(<FILE>)
n> {
n> if (/<!--LASTDATE-->/)
n> {
n> print TMP "<!--LASTDATE--> $date \n";
n> } elsif (/<!--FEEDBACK-->/)
n> {
n> print TMP "<!--FEEDBACK-->\n";
n> $feedback++;
n> } elsif (/<!--POINTER-->/)
n> {
n> print TMP "<HR>";
n> print TMP "<B>$in{'name'} \n";
n> print TMP "<A HREF=\"mailto:$in{'address'}\">$in{'address'}</A>
n> </B>$date\n";
n> print TMP "<P>$text\n<!--POINTER-->\n";
use a here doc
n> } else
n> {
n> print TMP $_;
$_ is redundant there.
n> } # copy lines
n> }
i don't know the exact format of that file but if you just print your
new entry before the old stuff it would do what you want.
n> open (TMP,"<$tmp")|| &err("Can't open tmp file.");
n> open (FILE,">$file")|| &err("Can't open file $file: $!");
n> print FILE <TMP>;
n> #while(<TMP>)
n> # {
n> # print FILE$_;
n> # }
n> close(FILE);
n> close(TMP);
n> unlink "$tmp";
that whole mess canbe replaced with rename.
n> print "<H1>Thank you!</H1>";
n> print "<P>Your comment has been added to the ";
n> print "<A HREF=\"feedback.html\">feedback</A>\n";
n> print "</BODY></HTML>\n";
use here docs
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info: http://www.sysarch.com/perl/OOP_class.html
------------------------------
Date: Mon, 23 Apr 2001 16:36:58 -0400
From: Jeff Boes <jboes@nexcerpt.com>
Subject: Re: HTML Template Module
Message-Id: <3AE4926A.6C90190E@nexcerpt.com>
Me wrote:
>
> "Priscilla Daniel" <pdaniel8@ford.com> wrote in
> <9bmsbc$len2@eccws12.dearborn.ford.com>:
>
> > Could anyone please tell me how I could use html templates in my
> > code.
>
> use HTML::Template;
Look! It's another self-answering question!
--
Jeff Boes vox 616.226.9550
Database Engineer fax 616.349.9076
Nexcerpt, Inc. jboes@nexcerpt.com
------------------------------
Date: 23 Apr 2001 20:37:27 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Infinate loop
Message-Id: <988057765.6867@itz.pp.sci.fi>
In article <9bs416$a9s$1@mamenchi.zrz.TU-Berlin.DE>, Anno Siegel wrote:
>
>To select a set of keys from a hash %h so that there is a unique value
>associated with each key, just do this:
>
> %h = reverse %h;
> %h = reverse %h;
Besides the warning already given by Anno about using this with large
DBM hashes, the idiom above is also a bad idea unless all your hash
values are strings (or numbers, which will be stringified).
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla / Kira -- do not feed the troll.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 748
**************************************