[22210] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4431 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 20 09:05:53 2003

Date: Mon, 20 Jan 2003 06: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)

Perl-Users Digest           Mon, 20 Jan 2003     Volume: 10 Number: 4431

Today's topics:
    Re: A Good Perl Developing Enviroment (Kevin Cline)
    Re: Arrays. What don't I get? <wkrempa@erols.com>
    Re: Arrays. What don't I get? <barbr-en@online.no>
    Re: Arrays. What don't I get? <flavell@mail.cern.ch>
    Re: Creating standalone application <goldbb2@earthlink.net>
    Re: Data Form to Email Changes (Grayson Bathgate)
    Re: Data Form to Email Changes (Grayson Bathgate)
    Re: Day of the month redirection - revised <spamfilter@cheiron-it.nl>
    Re: hard (Kevin Cline)
    Re: hard <jurgenex@hotmail.com>
    Re: hard news@roaima.freeserve.co.uk
    Re: How are named unary operators that take $_ created? <ubl@schaffhausen.de>
    Re: How can a SMTP mail be deleted from a Unix mailbox  lvirden@yahoo.com
        Is anyone using Perl 6 yet? (Sara)
    Re: is it printf/sprintf that ############ fills this # <istink@real.bad.com>
    Re: is it printf/sprintf that ############ fills this # (Damian James)
        little-endian convert to big endian <bma@hotmail.com>
    Re: little-endian convert to big endian <josef.moellers@fujitsu-siemens.com>
    Re: little-endian convert to big endian (Anno Siegel)
    Re: little-endian convert to big endian <josef.moellers@fujitsu-siemens.com>
        split composite hash key into sub key fields. (qanda)
    Re: split composite hash key into sub key fields. <mgjv@tradingpost.com.au>
    Re: split composite hash key into sub key fields. <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
    Re: split composite hash key into sub key fields. <tassilo.parseval@post.rwth-aachen.de>
    Re: split composite hash key into sub key fields. <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
        Taint check problem (again) <md0nilhe@mdstud.DIESPAMchalmers.se>
    Re: Taint check problem (again) <nobull@mail.com>
    Re: Taint check problem (again) (Helgi Briem)
        using expect <tombrooks.nospam@hotmail.com>
    Re: Why is order of REs important? <krahnj@acm.org>
        your sig [was: "Re: Is logic in regular expression poss <bik.mido@tiscalinet.it>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 19 Jan 2003 21:23:11 -0800
From: kcline17@hotmail.com (Kevin Cline)
Subject: Re: A Good Perl Developing Enviroment
Message-Id: <ba162549.0301192123.7b8b731e@posting.google.com>

genericax@hotmail.com (Sara) wrote in message news:<776e0325.0301190841.634bce0c@posting.google.com>...
> "A. Fuentes" <alvarof2@hotmail.com> wrote in message news:<iz4W9.43403$aG4.2586200@twister.austin.rr.com>...
> > Fellow Perl Netters:
> > 
> > I have a newbie question:
> > 
> > What would be a good Perl Developing Enviroment for
> > managing and developing Perl projects?
> > (Visual Developer Studio-like)
> > 
> > Any suggestions will be appreciated.
> > 
> > Thanks in advance,
> > 
> > A. Fuentes
> > 512-297-9937
> 
> Some people "emacs" an environment. It runs in Perlmode, and you can
> open various windows to do OS and compiling tasks. I like it for
> editing and the syntax highlighting is nice, but I still just go to an
> eterm for everything else, probably out of my own ignorance of the
> power of emacs.

Just M-x shell and M-x perldb.


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

Date: Mon, 20 Jan 2003 07:15:01 -0500
From: wrk <wkrempa@erols.com>
To: tadmc@augustmail.com
Subject: Re: Arrays. What don't I get?
Message-Id: <3E2BE844.5D3AB9C3@erols.com>

Thanks Tad,

I also think anno overlooked the fact that I posted a snip from the Cookbook
to confirm what Tina was saying.

Bill

Tad McClellan wrote:

> wrk <wkrempa@erols.com> wrote:
> > Anno Siegel wrote:
> >> Tina Mueller  <usenet@tinita.de> wrote in comp.lang.perl.misc:
> >> > wrk <wkrempa@erols.com> wrote:
>
> [snip stuff from the Cookbook about foreach aliasing]
>
> >> That was my reaction too, until I realized that the entire posting
> >> (excepting the first line) is quoted from the Cookbook.
>
> I think Anno must have overlooked the part that said it was
> from the Cookbook.
>
> >> This clown
> >> did about everything wrong that can be wrong in a Usenet posting,
>
> I don't know what that was about.
>
> wrk did only 2 "bad things" that I can see...
>
> > Why don't you educate me and tell  me what was wrong with my posting .
>
> 1) lines too long
>
> 2) top-posting
>
> For other things to avoid, see:
>
>       http://mail.augustmail.com/~tadmc/clpmisc.shtml
>
> > I made it clear
> > that the text was from the "Perl Cookbook" which I cut and pasted
> > from "The Perl CD
> > Bookshelf.
>
> Anno must have overlooked that part.
>
> --
>     Tad McClellan                          SGML consulting
>     tadmc@augustmail.com                   Perl programming
>     Fort Worth, Texas



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

Date: Mon, 20 Jan 2003 13:24:36 +0100
From: Kåre Olai Lindbach <barbr-en@online.no>
Subject: Re: Arrays. What don't I get?
Message-Id: <d3qn2v8a42shnngeirgdru8sl66gc4stqs@4ax.com>

On Mon, 20 Jan 2003 07:15:01 -0500, wrk <wkrempa@erols.com> wrote:

>Tad McClellan wrote:
>
>> wrk <wkrempa@erols.com> wrote:

[snip]

>> wrk did only 2 "bad things" that I can see...
>>
>> > Why don't you educate me and tell  me what was wrong with my posting .
>>
>> 1) lines too long
>>
>> 2) top-posting

!!  ;-)

>> For other things to avoid, see:
>>
>>       http://mail.augustmail.com/~tadmc/clpmisc.shtml

>> > I made it clear
>> > that the text was from the "Perl Cookbook" which I cut and pasted
>> > from "The Perl CD
>> > Bookshelf.
>>
>> Anno must have overlooked that part.

>Thanks Tad,
>
>I also think anno overlooked the fact that I posted a snip from the Cookbook
>to confirm what Tina was saying.
>
>Bill

I just rearranged some of it to show what's make Mr McClellan, and
many others more happy when you thanks somebody.

Another thing, when one goes through the post one wants to answer, and
tries to quote and snipp correctly, one often has to read through
everything more carefully to get it right, and then one often gets to
understand the questions better ;-)

-- 
mvh/Regards
Kåre Olai Lindbach


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

Date: Mon, 20 Jan 2003 13:41:46 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Arrays. What don't I get?
Message-Id: <Pine.LNX.4.40.0301201340070.15976-100000@lxplus071.cern.ch>

On Jan 20, wrk FuQuToPed:

> Thanks Tad,

If you mean to thank Tad, don't spit in his face at the same time.

http://mail.augustmail.com/~tadmc/clpmisc.shtml

The killfile awaits.



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

Date: Mon, 20 Jan 2003 00:16:25 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Creating standalone application
Message-Id: <3E2B8629.126B74D6@earthlink.net>

Daby wrote:
> 
> Are there any free tools for doing this, or cheap ones :)? I`ve come
> across PerlApp which is part of the $190 ActiveState PDK. I wanted to
> have a play with it but unforunately I already have a version the PDK
> installed to use the debugger and the trial license has expired -
> although the visual debugger stil works

Well, although I haven't implemented it, I have an idea of how one might
go about doing this....

The basic idea is as follows:
   6/ Name this compiled program "perl.sfx"
   7/ Zip up a file called "main.pl" and all the modules it requires
into a file named foo.zip.
   8/ Now do: cat perl.sfx foo.zip > foo.exe
   9/ You're done!  Run foo.exe.

   1/ Create an embedded perl interpreter.  Make sure that you
initialize it so that XS libraries which have been statically linked
will load properly later on.
   2/ Open a filehandle to the program's own file.  Obviously, this
would require your program have read access to itself.  Seek to the end
of the program data.  Using knowledge of the 'zip' file format, scan
through the file, obtaining filenames, offsets, etc. and store this into
a perl hash.
   3/ Set the interpreter's @INC to a single coderef.  This coderef will
be called with two arguments -- the first one will be the coderef
itself, and the second will be a filename.  If the filename doesn't
exist in the hash, return undef.  If it *does* exist in the hash, use
the offset info, and the filehandle from step 2, to create a perl
filehandle with an appropriate* perlio layer for unzipping the data.
   4/ Evaluate the perl code "exit( do 'main.pl' ? 1 : 0 )"
   5/ Compile the program, *statically* (NOT dynamically) linking it any
XS libraries that the modules you plan to use will need.


Once you've create perl.sfx, with a "reasonable" set of statically
linked XS modules (Cwd.pm, IO::Socket, ....), you can keep reusing it,
without recompiling, with various different zip files.

[*] Due to the peculiar semantics of dup()ing a filedescriptor, if each
filehandle is made from a dup() of the one from step 2, then each will
need to keep track of it's own offset into the fd, and lseek() there
just before every read, and then update it's privately kept offset. 
You'll probably end up with something like PerlIO::subfile, but with
offset tracking and lseek()ing added.  To do the unzipping, use
PerlIO::gzip (make sure to statically link the XS part).

-- 
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r  coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);


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

Date: 20 Jan 2003 03:49:26 -0800
From: gbathgate2000@yahoo.com (Grayson Bathgate)
Subject: Re: Data Form to Email Changes
Message-Id: <e89f00b6.0301200349.470e85fb@posting.google.com>

> You may find this to be a bad idea, as it could easily be abused for
> harrassment or spamming.

Yeah that's true.  So does anyone know how to add the #1 to the
program?

As for the #2 does anyone know if there is any way to fix an online
web form so that when printed it shows all the stuff that has been
typed in?  That's the actual problem we are having


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

Date: 20 Jan 2003 03:50:04 -0800
From: gbathgate2000@yahoo.com (Grayson Bathgate)
Subject: Re: Data Form to Email Changes
Message-Id: <e89f00b6.0301200350.398e6484@posting.google.com>

Oh and what diff does it make what "information" it is getting.  Duh.


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

Date: Mon, 20 Jan 2003 12:22:51 +0100
From: "Frank Maas" <spamfilter@cheiron-it.nl>
Subject: Re: Day of the month redirection - revised
Message-Id: <3e2bdc0c$0$126$e4fe514c@dreader5.news.xs4all.nl>


"Ralph" <ralph@beseenmg.com> schreef in bericht
news:58772576.0301172357.b6f81ae@posting.google.com...
> Please help - I'm a rookie. I'm searching for a script that will
> redirect visitors of my website to a specific page depending on the
> day of the month and uses the clock on my server to determine the
> date. I found a free javascript that does this but it uses the clock
> on the visitor's computer. I've been told javascripts can't be
> modified to read from my server and that I need a perl script. I'm
> running a Windows 2000 server.

I doubt that you'll need a (Perl) script for this. Using Server Side Include
(or SSI; use a search engine to get information about it) will bring you
what you want.

--Frank




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

Date: 19 Jan 2003 21:28:47 -0800
From: kcline17@hotmail.com (Kevin Cline)
Subject: Re: hard
Message-Id: <ba162549.0301192128.f9bb8e4@posting.google.com>

"J rgen Exner" <jurgenex@hotmail.com> wrote in message news:<GwfW9.12036$xx4.7579@nwrddc01.gnilink.net>...
> Abigail wrote:
> > KT (kennedyel_5000@yahoo.com) wrote on MMMCDXXVII September MCMXCIII
> > in <URL:news:6495f466.0301180044.7fa4eca3@posting.google.com>:
>  [...]
> >>>  that mean. when A is online. then a program send A's ip address to
> >>>  B's email account.
> >
> > Well, it depends what you mean by "online". The most logical way is to
> > modify whatever program brings the computer of A in the state of
> > "being online" (a script from /etc/init.d, perhaps), and to have it
> > send a message to B.
> 
> Not necessarily. That would send a message when the computer 'goes online'.
> But what about broadband connections which are permanently online? Or
> multiuser systems? Or LANs? Or if user A logs out and user C logs on to the
> same computer. Is A still online?
> 
> There is no relation between a computer being online and a user being
> online.
> 
> Of course you are quite right: the question is rather vague and it is hard
> to guess what the OP meant.

No, I think it's pretty easy to guess.  The OP wants to run a server but
has no fixed IP address and doesn't want to pay $100+/month to get one.
So instead he wants to write a script that will determine an IP address
for his computer and mail it to the client machine.


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

Date: Mon, 20 Jan 2003 08:03:46 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: hard
Message-Id: <C3OW9.25304$xx4.16428@nwrddc01.gnilink.net>

Kevin Cline wrote:
> "J rgen Exner" <jurgenex@hotmail.com> wrote in message
> news:<GwfW9.12036$xx4.7579@nwrddc01.gnilink.net>...
> No, I think it's pretty easy to guess.  The OP wants to run a server
> but has no fixed IP address and doesn't want to pay $100+/month to
> get one. So instead he wants to write a script that will determine an
> IP address for his computer and mail it to the client machine.

Possible. But why did he ask about a user A and a user B. In your scenario
he would have a computer and user, not a user and a user.

Maybe he's trying to implement some authentication system for IM based on IP
addresses. Who can tell?

jue




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

Date: Mon, 20 Jan 2003 09:33:33 +0000
From: news@roaima.freeserve.co.uk
Subject: Re: hard
Message-Id: <dpfg0b.mc.ln@moldev.cmagroup.co.uk>

Kevin Cline <kcline17@hotmail.com> wrote:
> No, I think it's pretty easy to guess.  The OP wants to run a server but
> has no fixed IP address and doesn't want to pay $100+/month to get one.
> So instead he wants to write a script that will determine an IP address
> for his computer and mail it to the client machine.

That sounds like it's related to a DDNS update client for for one of the
many dynamic dns providers "out there". I use DynDNS and know there are
several Perl scripts available via http://clients.dyndns.org/. YMMV for
other providers.

Chris
-- 
@s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}


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

Date: Mon, 20 Jan 2003 12:00:50 +0100
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: How are named unary operators that take $_ created?
Message-Id: <b0go54$pmv$1@news.dtag.de>

J. Romano wrote:
>    Do you have any other ideas how to construct a Perl function that
> behaves like a named unary operator and operates on $_ by default?

Well, you could disable the prototype for function calls with a 
parameter list using the & prefix:

use strict;
use warnings;

sub unary() {
	my $para = defined $_[0] ? $_[0] : $_;
	print "via $para\n";
}

$_ = "dollar underscore";

unary;
&unary("parameter list");

# This is very ugly.
Or you could ignore the number of paras completely using a @ proto:

use strict;
use warnings;

sub unary(@) {
	my $para = defined $_[0] ? $_[0] : $_;
	print "via $para\n";
}

$_ = "dollar underscore";

unary;
unary "parameter list";

# This is highly dangerous in terms of parsing.


Why do you want to do this anyway? Did you read Tom's "Perl Prototypes 
Considered Harmful"?

Bye,
->malte


-- 
srand 108641088; print chr int rand 256 for qw<J A P H>



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

Date: 20 Jan 2003 13:25:44 GMT
From: lvirden@yahoo.com
Subject: Re: How can a SMTP mail be deleted from a Unix mailbox by a script?
Message-Id: <b0gtco$d3v$1@srv38.cas.org>


According to Markus Elfring <Markus.Elfring@web.de>:
:This request's subject is the deletion of messages in the file "mbox".

:The deletion can be performed manually by typing the letter "d" with a
:following message number inside the programmes "mail". (This step can
:be performed by a script, too.)
:
:I encounter the difficulty to scroll through all exististing messages
:by a command to find the right number for the message that should be
:deleted. I am looking for an efficient algorithm.

I don't believe that the format that the physical storage of mail messages
within a file is documented in a standard.  Neither, unfortunately, is
the protocol for interacting with such a file.  This leaves one wanting
to do things with the box in a quandry.  First, one has no guaranteed way
of knowing how the messages are stored - are they merely a series of 
messages appended one to another, with perhaps some sort of initial line
indicating something about the message (the most frequent case in open source
software at least)?  Does the format consist, instead of seperator lines,
of the software making use of some particular header (under System V, some
mailers make use of a content-length header to determine where the end of a
msg occurred)?  Or does the file format consist of some sort of lead in
index?  Or, as is the case for some user mail agent packages, does each message
become stored in its own file?

The second problem is even worse, in my opinion.  That is the factor of file
locking.  Each mail program is free to (and appears to) make use of what
its author(s) deem as most useful file locking.  Of course, if one's
mail files are on NFS, then some file locking schemes are less successful
than others.  But if an additional utility to, say, delete messages, were
to be written, the author needs to account for the locking styles of ANY
program which might update that box, so as not to lose messages.

If the above two problems were solvable, then the method to 'delete'
a message would be to write to a new file all the messages before, and after,
the message in question to a file.  The author would probably open the
original file for exclusive access, read in the data and write out the 
remaining messages to a new file, then somehow rename the two files in
a way that would minimize the window one might lose a message.

It is a non-trivial task to do right.

:3.2 The file can always be written (without the deleted contents) to a
:new version. The updated version replaces the old one. Is this
:applicable if you think about speed?

Unfortunately, there are no options, at least on Unix and given the
above restrictions.

Besides storing each message in a seperate file, another option might be
to store emails in a database (ala Outlook, etc.)

-- 
Tcl - The glue of a new generation.  <URL: http://wiki.tcl.tk/ >
Even if explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.
<URL: mailto:lvirden@yahoo.com > <URL: http://www.purl.org/NET/lvirden/ >


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

Date: 20 Jan 2003 05:16:38 -0800
From: genericax@hotmail.com (Sara)
Subject: Is anyone using Perl 6 yet?
Message-Id: <776e0325.0301200516.12d38faf@posting.google.com>

I'm considering replacing one of my boxes running 5.x with 6. That
will only be for experimenting and learning however, no plans to
migrate any production code, even though at OSCON the talk on that
topic indicated the migration was pretty straightforward in many
cases.

At any rate, what kind of popularity is it enjoying?

Was it hard to install / configure?

Are you using it in production or just testing/playing?

Once installed, are you using it pretty much LIKE Perl 5.x, or are you
using the new functionality?

Are you finding proiductivity enhancements with it? 

What was it like migrating old code to 6?

Did you go to 6, then go BACK to 5.x after problems?


Thanks. I'm pretty surprized that 6 appeared to be a big event at
OSCON last July, yet I almost never see it mentioned here. I know the
team worked hard to put it out (I was even on it for awhile), and I
also believe it addressed many shortcomings and nuisences found in
5.x. I want to get it installed here and maybe try to start getting
some production ported over. I'd love to hear your comments.

Cheers, 
Gx


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

Date: Mon, 20 Jan 2003 01:32:38 -0500
From: istink <istink@real.bad.com>
Subject: Re: is it printf/sprintf that ############ fills this ###############
Message-Id: <3E2B9806.C826DCFA@real.bad.com>

i think it was something like
formatted
<<<<<<<<<<<<<
|||||||||||
>>>>>>>>>>>>>

but I forgot what that's called and how to properly use it.

Tad McClellan wrote:
> 
> istink <istink@real.bad.com> wrote:
> >
> >  could it be printf/sprinf or some other formater that does this
> >
 ....
> 
> No. Unless you give us some indication of how to determine
> where to place the interior strings.
> 
> Or maybe you meant "centered" but just messed up the example?
>


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

Date: 20 Jan 2003 07:04:01 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: is it printf/sprintf that ############ fills this ###############
Message-Id: <slrnb2n7r0.qni.damian@puma.qimr.edu.au>

On Mon, 20 Jan 2003 01:32:38 -0500, istink said:
>Tad McClellan wrote:
>> 
>> istink <istink@real.bad.com> wrote:
>> >  could it be printf/sprinf or some other formater that does this
>....
>> No. Unless you give us some indication of how to determine
>> where to place the interior strings.
>> Or maybe you meant "centered" but just messed up the example?
>>
>i think it was something like
>formatted
><<<<<<<<<<<<<
>|||||||||||
>>>>>>>>>>>>>>
>
>but I forgot what that's called and how to properly use it.

You are thinking of Perl's formats. See the perlform man page
for details. 

--damian


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

Date: Mon, 20 Jan 2003 20:02:53 +0800
From: "bin" <bma@hotmail.com>
Subject: little-endian convert to big endian
Message-Id: <b0gohe$2h9s$1@justice.itsc.cuhk.edu.hk>

Is there any script can convert little endian ASCII file to Big-endian file?

Thanks a lot!

bin




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

Date: Mon, 20 Jan 2003 13:08:20 +0100
From: Josef =?iso-8859-1?Q?M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: little-endian convert to big endian
Message-Id: <3E2BE6B4.C94F46F9@fujitsu-siemens.com>

bin wrote:

> Is there any script can convert little endian ASCII file to Big-endian =
file?
> =

> Thanks a lot!

What on earth is a "little endian ASCII file"?
Do you have an example?

-- =

Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett


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

Date: 20 Jan 2003 12:09:16 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: little-endian convert to big endian
Message-Id: <b0gotc$ep5$1@mamenchi.zrz.TU-Berlin.DE>

bin <bma@hotmail.com> wrote in comp.lang.perl.misc:
> Is there any script can convert little endian ASCII file to Big-endian file?

What is a "little endian ASCII" file?  The little/big endian distinction
applies to binary files.

If your file is actually binary, use unpack with a little endian format,
then re-pack in big endian.  The exact format letters you need would
depend on the size of the numbers involved.

Anno


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

Date: Mon, 20 Jan 2003 13:38:09 +0100
From: Josef =?iso-8859-1?Q?M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: little-endian convert to big endian
Message-Id: <3E2BEDB1.F5A06041@fujitsu-siemens.com>

Anno Siegel wrote:
> =

> bin <bma@hotmail.com> wrote in comp.lang.perl.misc:
> > Is there any script can convert little endian ASCII file to Big-endia=
n file?
> =

> What is a "little endian ASCII" file?  The little/big endian distinctio=
n
> applies to binary files.

Better yet: "applies to multi-byte values."

> If your file is actually binary, use unpack with a little endian format=
,
> then re-pack in big endian.  The exact format letters you need would
> depend on the size of the numbers involved.

Since this is a perl newsgroup, bin might want to look at

- binmode and
- pack/unpack (n and N vs v and V)

Josef
-- =

Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett


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

Date: 19 Jan 2003 23:14:15 -0800
From: fumail@freeuk.com (qanda)
Subject: split composite hash key into sub key fields.
Message-Id: <62b4710f.0301192314.3525cf8a@posting.google.com>

Hi all

I have a hash with keys made from several fields, for example

my %f1_keys;
 ...
$f1_keys{$f2,$f3,$f5} = $rec;

The sub key fields (f2, f3, f5) are lost after reading each record. 
Once the hash has been built how can I reference the 3 fields of the
key.  I need to do this AFTER the hash has been built.

Thanks.


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

Date: Mon, 20 Jan 2003 18:47:59 +1100
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: split composite hash key into sub key fields.
Message-Id: <slrnb2nadf.7m2.mgjv@martien.heliotrope.home>

On 19 Jan 2003 23:14:15 -0800,
	qanda <fumail@freeuk.com> wrote:
> Hi all
> 
> I have a hash with keys made from several fields, for example
> 
> my %f1_keys;
> ...
> $f1_keys{$f2,$f3,$f5} = $rec;
> 
> The sub key fields (f2, f3, f5) are lost after reading each record. 
> Once the hash has been built how can I reference the 3 fields of the
> key.  I need to do this AFTER the hash has been built.

You're using, probably unwittingly, a rather obscure and not recommended
part of Perl, the multidimensional hash emulation. See the $; ($SUBSEP)
variable in the perlvar documentation for some more information. This
should also give you the hint that using split with the $; variable
would get you back your fields from the key.

foreach my $key (%f1_keys)
{
    # Be paranoid, $; might contain metacharacters
    my @fields = split /\Q$;/, $key;
    # ...
}

However, do consider using a real multidimensional hash instead of this.
This approach has some potential problems that you need to be aware of,
before deciding to use it.

Martien
-- 
                        | 
Martien Verbruggen      | Useful Statistic: 75% of the people make up
                        | 3/4 of the population.
                        | 


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

Date: Mon, 20 Jan 2003 09:02:15 +0100
From: Koos Pol <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
Subject: Re: split composite hash key into sub key fields.
Message-Id: <newscache$rb609h$hxc$1@news.emea.compuware.com>

qanda wrote (Monday 20 January 2003 08:14):

> Hi all
> 
> I have a hash with keys made from several fields, for example
> 
> my %f1_keys;
> ...
> $f1_keys{$f2,$f3,$f5} = $rec;


This is gibberish. What are trying to do?


> The sub key fields (f2, f3, f5) are lost after reading each record.
> Once the hash has been built how can I reference the 3 fields of the
> key.


By now, I have tried to come up with some explainations and solutions for 
you, but I remain unclear on your real problem. Please give us a data 
sample and a clear description of what it is you are trying to achieve.


> I need to do this AFTER the hash has been built.
> 
> Thanks.


You could do some homework by reading:
perldoc -f keys
perldoc perlvar  (and skim for the word "slice")

-- 
KP



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

Date: 20 Jan 2003 08:15:16 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: split composite hash key into sub key fields.
Message-Id: <b0gb6k$8q6$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Koos Pol:

> qanda wrote (Monday 20 January 2003 08:14):
> 
>> Hi all
>> 
>> I have a hash with keys made from several fields, for example
>> 
>> my %f1_keys;
>> ...
>> $f1_keys{$f2,$f3,$f5} = $rec;
> 
> 
> This is gibberish. What are trying to do?

It isn't actually gibberish. It is just very old: This idiom dates back
to long gone Perl4 days where it was used to emulate multidimensional
hashes. $; is used in conjunction with the above.

> You could do some homework by reading:
> perldoc -f keys
> perldoc perlvar  (and skim for the word "slice")

'perldoc perldsc' might be more suitable for the OP.

Tassilo
-- 
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;


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

Date: Mon, 20 Jan 2003 10:02:15 +0100
From: Koos Pol <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
Subject: Re: split composite hash key into sub key fields.
Message-Id: <newscache$r3909h$zxc$1@news.emea.compuware.com>

Tassilo v. Parseval wrote (Monday 20 January 2003 09:15):

> Also sprach Koos Pol:
> 
>> qanda wrote (Monday 20 January 2003 08:14):
>> 
>>> Hi all
>>> 
>>> I have a hash with keys made from several fields, for example
>>> 
>>> my %f1_keys;
>>> ...
>>> $f1_keys{$f2,$f3,$f5} = $rec;
>> 
>> 
>> This is gibberish. What are trying to do?
> 
> It isn't actually gibberish. It is just very old: This idiom dates back
> to long gone Perl4 days where it was used to emulate multidimensional
> hashes. $; is used in conjunction with the above.


Hmm... I've tried some variations on $rec (href, aref, scalar) and inspected 
%f1_keys with Data::Dumper. And %f1_keys just contained... well... 
gibberish :-) 


</study mode>
(And after Tad made clear that I also need to brush up my version 8 RE's 
(some other thread) I'll ignore the request to backlearn Perl4 :-).
<study mode>  # yes, I deliberately reversed them :-)


Cheers,
-- 
KP



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

Date: Mon, 20 Jan 2003 10:51:40 +0100
From: henrik nilsson <md0nilhe@mdstud.DIESPAMchalmers.se>
Subject: Taint check problem (again)
Message-Id: <3E2BC6AC.501@mdstud.DIESPAMchalmers.se>

Hello

Although my cgi Perl script works fine without the -T switch, I cannot 
get it to work when -T is on.

The following line generates the message "Insecure $ENV{PATH} when 
running with -T ...":

open (PROG, "|$oldprogram > /dev/null"); # error msg points here
print PROG "13\n";
etc.

The program is old and cannot be called with any switches, hence I have 
to print them to the program while it is running. I direct the screen 
output to my grandmother's cabin and collect the program outdata (a 
file) before I close PROG.


$oldprogram is hardcoded in the very beginning of the script:

$oldprogram = "/home/henrik/oldprogram.exe";

I collect three "html form" items, all of which I untaint.

What should I do to get rid of that error message?

I *have* read the help files.

Thanks for your time,

Henrik



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

Date: 20 Jan 2003 12:31:14 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Taint check problem (again)
Message-Id: <u9znpw9f59.fsf@wcl-l.bham.ac.uk>

henrik nilsson <md0nilhe@mdstud.DIESPAMchalmers.se> writes:

> The following line generates the message "Insecure $ENV{PATH} when
> running with -T ...":

> $oldprogram = "/home/henrik/oldprogram.exe";
 
> open (PROG, "|$oldprogram > /dev/null"); # error msg points here
> print PROG "13\n";

> What should I do to get rid of that error message?

Why not simply undef($ENV{PATH}) since you are not using it?

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Mon, 20 Jan 2003 13:47:47 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Taint check problem (again)
Message-Id: <3e2bfdf0.1421130677@news.cis.dfn.de>

On Mon, 20 Jan 2003 10:51:40 +0100, henrik nilsson
<md0nilhe@mdstud.DIESPAMchalmers.se> wrote:

>Although my cgi Perl script works fine without the -T switch, I cannot 
>get it to work when -T is on.
>
>The following line generates the message "Insecure $ENV{PATH} when 
>running with -T ...":

undef $ENV{PATH};

-- 
Regards, Helgi Briem
helgi AT decode DOT is


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

Date: Mon, 20 Jan 2003 00:25:39 -0500
From: "Thomas Brooks" <tombrooks.nospam@hotmail.com>
Subject: using expect
Message-Id: <g-OcnRPj8rnJFbajXTWcqA@comcast.com>

I am trying to use expect to run passwd to change a user password. Not
trying to run this via WWW... just to automate a script that I execute as
root.

Here is what I have:
=====================
#!/usr/bin/perl -w
use Expect;

$account  = $ARGV[0];
$password = $ARGV[1];

$setpwd = Expect->spawn("/usr/bin/passwd $account");

$setpwd->expect(undef, "New password: ");

print $setpwd "$password\n";

$setpwd->expect(undef, "Retype new password: ");

print $setpwd "$password\r";

$setpwd->soft_close();



and this is what happens:
============================
[root@secure tmp]# perl test6.pl testuser testpw
Changing password for user testuser
New password: testpw



and it just sits there.. does nothing. Any ideas? redhat 7.2

thanks





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

Date: Mon, 20 Jan 2003 13:55:57 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Why is order of REs important?
Message-Id: <3E2BFFA1.A31220C@acm.org>

Tad McClellan wrote:
> 
> Andrej Hocevar <root@siol.net> wrote:
> >
> >       if (/^From /) {
> >               s/^/0From: /;
> >       }
> 
> There is no need to match before you substitute:
> 
>    s/^From /0From: /;
> 
> will do the same thing as your whole if there.

I think you mean that this will do the same thing:

    s/^(?=From )/0From: /;

:-)


John
-- 
use Perl;
program
fulfillment


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

Date: Mon, 20 Jan 2003 10:50:41 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: your sig [was: "Re: Is logic in regular expression possible?"]
Message-Id: <vs1l2vk7uvvbk752tuu62b99cg3p1hnolf@4ax.com>

On 16 Jan 2003 12:45:52 GMT, Abigail <abigail@abigail.nl> wrote:

>perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'

great!!


Michele
-- 
>It's because the universe was programmed in C++.
No, no, it was programmed in Forth.  See Genesis 1:12:
"And the earth brought Forth ..."
- Robert Israel on sci.math, thread "Why numbers?"


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

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 4431
***************************************


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