[22049] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4271 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Dec 16 18:06:04 2002

Date: Mon, 16 Dec 2002 15: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, 16 Dec 2002     Volume: 10 Number: 4271

Today's topics:
    Re: cgi and perl on windows 98 ? <mckenzie@bigmultimedia.com>
    Re: cgi and perl on windows 98 ? <mckenzie@bigmultimedia.com>
        CGI/perl problem with reading and writing user files (Michael Mays)
    Re: editing files <mgjv@tradingpost.com.au>
    Re: extract dir name from file path <bart.lateur@pandora.be>
    Re: extract dir name from file path <jurgenex@hotmail.com>
    Re: Freing Unused Memory in Perl <nospam@nospam.com>
    Re: Hashing several million rows of data ctcgag@hotmail.com
    Re: Hashing several million rows of data <ddunham@redwood.taos.com>
    Re: Help with Assignment of Split Value from STDIN to H <shondell@cis.ohio-state.edu>
        help:  perl script to make all DNA sequence Nmers? (isen)
    Re: help:  perl script to make all DNA sequence Nmers? <camerond@mail.uca.edu>
    Re: help:  perl script to make all DNA sequence Nmers? <camerond@mail.uca.edu>
        How to reference multiple keys from a hashref? <ddunham@redwood.taos.com>
    Re: How to reference multiple keys from a hashref? <barryk2@SPAM-KILLER.mts.net>
    Re: How to reference multiple keys from a hashref? <uri@stemsystems.com>
    Re: How to reference multiple keys from a hashref? <pinyaj@rpi.edu>
    Re: How to reference multiple keys from a hashref? <ddunham@redwood.taos.com>
    Re: In place edit with $^I and multiple files, keeping  <krahnj@acm.org>
        Invoke a browser every 2 hours ...how? <kalyanramcvs@rediffmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 16 Dec 2002 13:54:18 CST
From: "Bruce McKenzie" <mckenzie@bigmultimedia.com>
Subject: Re: cgi and perl on windows 98 ?
Message-Id: <xmqdnb4Qxt0oA2agXTWc3g@comcast.com>

Eric,

I agree with the IndigoPerl recommendation. It's a first rate package. There
was a bug in the config. file in the version I got for Win 98-- for some
reason it failed to set the server up on Port 80  -- change line 237 of the
config file if this happens to you.

There are some pretty good Perl/email tutorials in the about.com perl
classes http://perl.about.com/library/p101/bl_p101class.htm?PM=ss12_perl.

I recommend Simon Tneoh Chee-Boon's perl module SendMail.pm (not to be
confused with the "real" sendmail)
http://www.tneoh.zoneit.com/perl/SendMail/2.0/  Finally, if you want to do
all your testing locally, you'll need a local mail server. I use ArgoSoft
plus (shareware); I think freeware version would work as well. Setting it up
is simple but not easy (i.e., only a few options, but the documentation is
confusing). Fortunately, the people in their forums are very helpful.
http://www.argosoft.com/applications/mailserver/

Bruce


Eric Osman wrote:
> I've got both a quick request, and then more questions
> that are more specific:
>
> The quick request:  on my windows 98 system, what
>                    (hopefully free or shareware) do
>                    I need to install in order to test
>                    CGI scripts before putting them
>                    up on an actual web host
>
>
>
> The more specific questions:
>
> o        Using "mailto:" url pointer, can I make it
>          actually SEND an email, or will user always
>          be left in their email client and they have
>          to click the send button themselves
>
> o        What I'm really trying to implement is to have
>          a filled-out-form on an html page be sent
>          through email when SUBMIT button is pressed.
>
>          For this purpose, if I can't use "mailto:",
>          should I be using CGI ?
>
> o        If CGI, is there one package I can install
>          on my windows 98 to test this ?  Or do
>          I have to install a separate web server piece
>          AND cgi-perl interpretation piece AND
>          some sort of procmail piece to send the
>          actual email ?
>
> By the way, I know html and java and javascript well,
> plus unix shell scripting.  I'm new to CGI
> and PERL however, and fairly new to running web
> server software.  However, I have run apache tomcat
> java servlet software before.  (Maybe that will
> support all this stuff ?  Do you know ?)
>
> Thanks for any info to help me get going here.  I'm
> basically trying to figure what I need to install
> on my windows 98 system to develop and test perl
> cgi scripts called from html.
>
> Thanks.
>
> /Eric
>
> HOW TO POST to comp.infosystems.www.authoring.cgi:
> http://www.thinkspot.net/ciwac/howtopost.html



-- 
PLEASE NOTE: comp.infosystems.www.authoring.cgi is a
SELF-MODERATED newsgroup. aa.net and boutell.com are
NOT the originators of the articles and are NOT responsible
for their content.

HOW TO POST to comp.infosystems.www.authoring.cgi:
http://www.thinkspot.net/ciwac/howtopost.html



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

Date: Mon, 16 Dec 2002 13:59:24 CST
From: "Bruce McKenzie" <mckenzie@bigmultimedia.com>
Subject: Re: cgi and perl on windows 98 ?
Message-Id: <zTCdnZ92JcrqImagXTWcrg@comcast.com>

Eric,

I agree with the IndigoPerl recommendation. It's a first rate package. There
was a bug in the config. file in the version I got for Win 98-- for some
reason it failed to set the server up on Port 80  -- change line 237 of the
config file if this happens to you.

There are some pretty good Perl/email tutorials in the about.com perl
classes http://perl.about.com/library/p101/bl_p101class.htm?PM=ss12_perl.

I recommend Simon Tneoh Chee-Boon's perl module SendMail.pm (not to be
confused with the "real" sendmail)
http://www.tneoh.zoneit.com/perl/SendMail/2.0/  Finally, if you want to do
all your testing locally, you'll need a local mail server. I use ArgoSoft
plus (shareware); I think freeware version would work as well. Setting it up
is simple but not easy (i.e., only a few options, but the documentation is
confusing). Fortunately, the people in their forums are very helpful.
http://www.argosoft.com/applications/mailserver/

Bruce


Eric Osman wrote:
> I've got both a quick request, and then more questions
> that are more specific:
>
> The quick request:  on my windows 98 system, what
>                    (hopefully free or shareware) do
>                    I need to install in order to test
>                    CGI scripts before putting them
>                    up on an actual web host
>
>
>
> The more specific questions:
>
> o        Using "mailto:" url pointer, can I make it
>          actually SEND an email, or will user always
>          be left in their email client and they have
>          to click the send button themselves
>
> o        What I'm really trying to implement is to have
>          a filled-out-form on an html page be sent
>          through email when SUBMIT button is pressed.
>
>          For this purpose, if I can't use "mailto:",
>          should I be using CGI ?
>
> o        If CGI, is there one package I can install
>          on my windows 98 to test this ?  Or do
>          I have to install a separate web server piece
>          AND cgi-perl interpretation piece AND
>          some sort of procmail piece to send the
>          actual email ?
>
> By the way, I know html and java and javascript well,
> plus unix shell scripting.  I'm new to CGI
> and PERL however, and fairly new to running web
> server software.  However, I have run apache tomcat
> java servlet software before.  (Maybe that will
> support all this stuff ?  Do you know ?)
>
> Thanks for any info to help me get going here.  I'm
> basically trying to figure what I need to install
> on my windows 98 system to develop and test perl
> cgi scripts called from html.
>
> Thanks.
>
> /Eric
>
> HOW TO POST to comp.infosystems.www.authoring.cgi:
> http://www.thinkspot.net/ciwac/howtopost.html

passme



-- 
PLEASE NOTE: comp.infosystems.www.authoring.cgi is a
SELF-MODERATED newsgroup. aa.net and boutell.com are
NOT the originators of the articles and are NOT responsible
for their content.

HOW TO POST to comp.infosystems.www.authoring.cgi:
http://www.thinkspot.net/ciwac/howtopost.html



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

Date: 16 Dec 2002 14:19:23 -0800
From: mmays@temple.edu (Michael Mays)
Subject: CGI/perl problem with reading and writing user files
Message-Id: <9a4b565a.0212161419.6fbd2a7c@posting.google.com>

Greetings.

Here is my current programming environment:
OS: Unix
Server: Apache 2.x running as www (user w/ no permissions)
Perl: Perl 5.8
User Authentication: LDAP server

I am trying to write a cgi program, in perl that will switch 
permissions to the user that logs in. Basically I am writing a mail 
client. First thing the program does is throw the user to a login 
page. The user authenticates off of our LDAP database. Once they 
log in, I want to allow them access to their INBOX as well as other 
mail folders. (all which are under their home directory).

I've looked at all the perl books I have and searched the internet, 
but have been unable to find a useful answer. 

What I was trying to do was have the program run setuid root and then 
change the effective uid ($<) to be equal to the users. I don't know 
if this is the right idea, but either way, I'm sure all of you know 
that it is not very easy nor recommended to have a cgi-script have 
root permissions. How then can I have it execute as the user after 
they log in. This has to be a problem that has been tackled 
before...I just can't seem to locate the answer.

Thanks.

Mike


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

Date: Mon, 16 Dec 2002 21:40:07 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: editing files
Message-Id: <slrnavsi5d.865.mgjv@verbruggen.comdyn.com.au>

On Mon, 16 Dec 2002 09:21:00 -0600,
	Tad McClellan <tadmc@augustmail.com> wrote:
> Richard Cross <richard.cross@NOPSPAM.freeserve.com> wrote:

>> Now I want to write something in Perl to make this easier for anyone else 
>> to accomplish.  Is there an easy way of being able to read a file in Perl 
>> such that each line is exactly 16 bytes long and can easily be separated 
>> into bytes' hex values.  
> 
> 
> The concept of "lines" is only applicable to text files.
> 
> Binary files do not have "lines", so you must have meant "records"
> or some such.
> 
>    perldoc -f read

I would also mention C<pack> and C<unpack> here, as the OP might need
those to get to the actual values, depending on what is actually
stored in the 16 bytes they want to read.

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


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

Date: Mon, 16 Dec 2002 16:05:17 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: extract dir name from file path
Message-Id: <fttrvuooj6n1siq77dt0h4bs54hpac7hgr@4ax.com>

Naran Hirani wrote:

>I have a fully qualified path name to a file which may or may not have
>an extension
>- all I would like to do is strip away the file name so I am left with
>just the dir path to
>this file.  What is the simplest RE that will achieve this for me?

	($dir) = /(.*)\//;

If there are other separation characters than the slash, you can either
use them instead, or use a character class. For example, for
DOS/Windows:

	($dir) = /(.*)[\/\\]/;


And then there's the more portable solution, using the module
File::Basename, which even works properly on exotic OSes like VMS. From
the synopsis:

        use File::Basename;
        $dirname = dirname($fullname);

-- 
	Bart.


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

Date: Mon, 16 Dec 2002 16:10:11 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: extract dir name from file path
Message-Id: <DVmL9.25798$_S2.19613@nwrddc01.gnilink.net>

Naran Hirani wrote:
> I'm sure there is a very simple solutions to this but I can't seem to
> work it out :-)
> I have a fully qualified path name to a file which may or may not have
> an extension
> - all I would like to do is strip away the file name so I am left with
> just the dir path to
> this file.  What is the simplest RE that will achieve this for me?

Why would you want to use a regular expression?
    use File::Basename;
has beautiful functions to disect file names and is even compatible.

jue




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

Date: Mon, 16 Dec 2002 12:17:56 -0800
From: "Tan D Nguyen" <nospam@nospam.com>
Subject: Re: Freing Unused Memory in Perl
Message-Id: <atlc9q$81c2$1@ID-161864.news.dfncis.de>


"Sébastien Cottalorda" <spp@monaco377.com> wrote in message
news:3dfda8ab$0$11833$626a54ce@news.free.fr...
> I all,
>
> Here is my configuration.
> (Perl 5.6.0 on Linux RedHat 2.4.18-3)
>
> I've a perl program that contains, during a certain time, some records in
a
> %HASH table (size about 7 Mo).
>
> Then, when the user has finished to work with, the program delete the hash
> table with %HASH=();
>
> The problem:
> - At the begining of the perl program (the %HASH is created but not
> used=empty), the size reserved by the OS for the perl program represent
> some ko.
> - When the %HASH table is used (with all records), the memory reserved
grows
> up to 7Mo.
> - During all the life of the perl program, the Memory size reserved by the
> OS for the program is still about 7Mo even if the %HASH table is deleted.
>
> Is there a way to free the OS reserved memory, I've some old PC that are
> able to use temporarily 7Mo for that program, but I would not like the
perl
> program to use 7Mo of RAM (64Mo on the PC) during its entire life.
>
> If somebody as a clue?
>
> Thanks in advance.
>
> Sébastien

This question often comes up on this newsgroup. If you do a search, you'll
find plenty of answers for it.
In short, No - you can't return the memory back to the system until your
process exits.
Please be aware that many OSes implements memory management this way, no
matter what kind of language your program is written in, you can't release
memory back to the OS after using.




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

Date: 16 Dec 2002 17:43:07 GMT
From: ctcgag@hotmail.com
Subject: Re: Hashing several million rows of data
Message-Id: <20021216124307.674$gZ@newsreader.com>

tconti@hotmail.com (T Conti) wrote:
> Howdy:
>
> I am writing a script to preprocess a large file of data.  The files
> could get up to 4 million rows.  I want to ensure that each row in the
> file is unique based on a key column as defined by the key colum (i.e.
> column 2 should be unique).  The key column 2 will be between 20 - 100
> bytes of ascii characters.  I imagine that as more data is loaded into
> a hash its search performance degrades.

Nope.*  That's why hashes are very useful (and probably why they are
included in Perl).

* Except that once your computer runs out of memory and starts swapping,
the performance will get much, much worse.

> I thought of using multiple
> hashes to implement this. I was just wondering if anyone had any input
> on what is a good input for the optimal use of hashes for a large
> volume of data.

Pre-allocating buckets will give you a small performance increase
(keys %hash=1_000_000).

You could tie the hash to disk if it gets too large.  But before doing
that I would see if the unix utils could get the job done.  What do you
want to do if they are not unique?  Throw an error?

my @errors = qx[ awk '{print $2}' big_file |sort|uniq -d ];
die "Found duplicate entries for @errors" if @errors;


Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

Date: Mon, 16 Dec 2002 19:14:02 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: Hashing several million rows of data
Message-Id: <_BpL9.290$TK1.29284444@newssvr21.news.prodigy.com>

Dave Tweed <dtweed@acm.org> wrote:
> In the default case, this is true only if lookups vastly outnumber stores.
> But things aren't quite that simple for the OP's problem, determining
> uniqueness, which involves just one lookup and one store per record.

> Perl creates a hash with a certain number of "buckets", and whenever the
> number of keys exceeds the number of buckets, the number of buckets is
> doubled and the items are redistributed. This makes the execution time
> O(log N) on the number of stores.

But doubling occurs less and less often as objects are inserted.  That
allows the increased cost of the doubling to be amortized across the
insertions that do not cause doubling.  So the process may still be
O(1).  

I don't know perl's hash insertion scheme in particular, but just
because it has to occasionally redistribute the items in O(n) time
doesn't force the insertion time to be greater than O(1)

-- 
Darren Dunham                                           ddunham@taos.com
Unix System Administrator                    Taos - The SysAdmin Company
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >


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

Date: 16 Dec 2002 14:06:46 -0500
From: Ryan Shondell <shondell@cis.ohio-state.edu>
Subject: Re: Help with Assignment of Split Value from STDIN to Hash Values (As Arrays)
Message-Id: <xcwr8chzsu1.fsf@psi.cis.ohio-state.edu>

Rod <palladium#@spinn.net> writes:

> "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de> wrote in
> news:athf8f$scn$1@nets3.rz.RWTH-Aachen.DE: 
> 
> > Also sprach Joe Blow:
> 
> Sprached.

I think there's a little misunderstanding here. Sprach means 'spoke'
in German, not 'ditch your pseudonym'. :-)

-- 
Ryan Shondell <shondell@cis.ohio-state.edu>


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

Date: 16 Dec 2002 11:11:34 -0800
From: isen@molbio.mgh.harvard.edu (isen)
Subject: help:  perl script to make all DNA sequence Nmers?
Message-Id: <d7a1c97b.0212161111.7d6c5552@posting.google.com>

does anyone have a perl script to make all possible DNA sequence Nmers
(and put in an array preferably) when given N as an input?  Please
reply by email (sindriATmacDOTcom) if possible.

Thank-you,
Tom Isenbarger
Harvard University


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

Date: Mon, 16 Dec 2002 13:35:56 -0600
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: help:  perl script to make all DNA sequence Nmers?
Message-Id: <3DFE2B1C.9050106@mail.uca.edu>

isen wrote:

> does anyone have a perl script to make all possible DNA sequence Nmers
> (and put in an array preferably) when given N as an input?  


perldoc -q permute

> Please reply by email (sindriATmacDOTcom) if possible.


Ask it here, read it here.


Cameron

-- 
Cameron Dorey
Associate Professor of Chemistry
University of Central Arkansas
Phone: 501-450-5938
camerond@mail.uca.edu



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

Date: Mon, 16 Dec 2002 13:45:41 -0600
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: help:  perl script to make all DNA sequence Nmers?
Message-Id: <3DFE2D65.6030607@mail.uca.edu>

Cameron Dorey wrote:

> isen wrote:
> 
>> does anyone have a perl script to make all possible DNA sequence Nmers
>> (and put in an array preferably) when given N as an input?  
> 
> 
> 
> perldoc -q permute
> 
>> Please reply by email (sindriATmacDOTcom) if possible.
> 
> 
> 
> Ask it here, read it here.


Of course, looking over the answer, you could either have (1) a very 
long seed for your string (4*N), chop off your answers at N mers and get 
rid of duplicates, or (2) set up an array of N-long seed arrays 
containing unique numbers of each base and run each one through the 
routine. (2) should be much, much faster (factor: 
#permutations/#combinations or something similar).

Cameron

-- 
Cameron Dorey
Associate Professor of Chemistry
University of Central Arkansas
Phone: 501-450-5938
camerond@mail.uca.edu



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

Date: Mon, 16 Dec 2002 18:34:11 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: How to reference multiple keys from a hashref?
Message-Id: <D0pL9.1189$ZO.187@newssvr16.news.prodigy.com>

I'd like to reference multiple keys simultaneously from a hashref, but I
haven't found anything about this in the docs.

If it weren't a ref, I'd use a hash slice..

%hash = (alpha => "first", bravo => "second", charlie => "third");
@items = @hash{"alpha", "charlie"};

But instead, I have a ref
$hashref = \%hash;

I tried a few forms hoping...

@items = $hashref->{"alpha", "charlie"};
@items = @hashref->{"alpha", "charlie"};
@items = @$hashref->{"alpha", "charlie"};

But none of them worked.  If this is possible, can someone show me the
syntax or point me to the docs that I've missed?

Thanks!

-- 
Darren Dunham                                           ddunham@taos.com
Unix System Administrator                    Taos - The SysAdmin Company
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >


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

Date: Mon, 16 Dec 2002 13:12:29 -0600
From: godzilla <barryk2@SPAM-KILLER.mts.net>
Subject: Re: How to reference multiple keys from a hashref?
Message-Id: <MPG.1867e19a4d17214d9896a7@news.mts.net>

[This followup was posted to comp.lang.perl.misc and a copy was sent to 
the cited author.]

In article <D0pL9.1189$ZO.187@newssvr16.news.prodigy.com>, Darren Dunham 
(ddunham@redwood.taos.com) says...
> I'd like to reference multiple keys simultaneously from a hashref, but I
> haven't found anything about this in the docs.
> 
> If it weren't a ref, I'd use a hash slice..
> 
> %hash = (alpha => "first", bravo => "second", charlie => "third");
> @items = @hash{"alpha", "charlie"};
> 
> But instead, I have a ref
> $hashref = \%hash;
> 
> I tried a few forms hoping...
> 
> @items = $hashref->{"alpha", "charlie"};
> @items = @hashref->{"alpha", "charlie"};
> @items = @$hashref->{"alpha", "charlie"};
> 
> But none of them worked.  If this is possible, can someone show me the
> syntax or point me to the docs that I've missed?
> 
> Thanks!
> 
> 

@items = map { $$hashref{$_} } ("alpha" , "charlie");

-- 
---------

Barry Kimelman
Winnipeg, Manitoba, Canada
email : bkimelman@hotmail.com


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

Date: Mon, 16 Dec 2002 19:25:12 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: How to reference multiple keys from a hashref?
Message-Id: <x7n0n5zrzb.fsf@mail.sysarch.com>

>>>>> "g" == godzilla  <barryk2@SPAM-KILLER.mts.net> writes:

i wouldn't use that nick if i were you. it was used by the resident
moron troll here.

  >> I'd like to reference multiple keys simultaneously from a hashref, but I
  >> haven't found anything about this in the docs.
  >> 
  >> If it weren't a ref, I'd use a hash slice..
  >> 

  g> @items = map { $$hashref{$_} } ("alpha" , "charlie");

you can slice with a ref just fine. map is overkill.

	@{$hash_ref}{ 'alpha', 'charlie' }

read my tutorial on hash slices

	http://tlc.perlarchive.com/articles/perl/ug0001.shtml

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Mon, 16 Dec 2002 14:30:12 -0500
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
To: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: How to reference multiple keys from a hashref?
Message-Id: <Pine.SGI.3.96.1021216142910.455077A-100000@vcmr-64.server.rpi.edu>

[posted & mailed]

On Mon, 16 Dec 2002, Darren Dunham wrote:

>I'd like to reference multiple keys simultaneously from a hashref, but I
>haven't found anything about this in the docs.

Anywhere you'd use the NAME of the hash, put the hash ref in.

>$hashref = \%hash;
>@items = @hash{"alpha", "charlie"};

Therefore:

  @items = @{$hashref}{"alpha", "charlie"};

or

  @items = @$hashref{"alpha", "charlie"};

-- 
Jeff Pinyan            RPI Acacia Brother #734            2003 Rush Chairman
"And I vos head of Gestapo for ten     | Michael Palin (as Heinrich Bimmler)
 years.  Ah!  Five years!  Nein!  No!  | in: The North Minehead Bye-Election
 Oh.  Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)



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

Date: Mon, 16 Dec 2002 19:38:19 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: How to reference multiple keys from a hashref?
Message-Id: <LYpL9.266$Qs5.44784770@newssvr14.news.prodigy.com>

Jeff 'japhy' Pinyan <pinyaj@rpi.edu> wrote:
> [posted & mailed]

> On Mon, 16 Dec 2002, Darren Dunham wrote:

>>I'd like to reference multiple keys simultaneously from a hashref, but I
>>haven't found anything about this in the docs.

> Anywhere you'd use the NAME of the hash, put the hash ref in.

>>$hashref = \%hash;
>>@items = @hash{"alpha", "charlie"};

> Therefore:

>   @items = @{$hashref}{"alpha", "charlie"};

Duh, yes.  For some reason I was too concerned about trying to continue
using the arrow operator.  Obviously, that's not necessary at all for
this case.

Thank you.

-- 
Darren Dunham                                           ddunham@taos.com
Unix System Administrator                    Taos - The SysAdmin Company
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >


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

Date: Mon, 16 Dec 2002 22:00:36 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: In place edit with $^I and multiple files, keeping SOME originals.
Message-Id: <3DFE4CC4.A0FF1C2F@acm.org>

qanda wrote:
> 
> Hi all, in line with previous posts I have this ...
> 
> #!/usr/bin/perl -w
> 
> use diagnostics -verbose;
> use warnings;

Using the -w switch and both the diagnostics and warnings pragmas is a
bit redundant.


> use strict;
> 
> extract_recs();
> 
> sub extract_recs {
>     open( RECA, ">reca.out" ) or die "Can't open reca.\n";
>     open( RECB, ">recb.out" ) or die "Can't open recb.\n";
> 
>     # In place edit by <> construct.
>     local $^I = '.orig';
>     local @ARGV = glob("abc*.dat");
> 
>     # For each file.
>     while ( <> )
>     {
>         # Ingore blank lines.
>         next if /^\s+$/;
> 
>         # Split records into fields.
>         my @type = split( /,/, $_, -1 );
> 
>         # Save valid type A records.
>         if( $type[2] eq 'A' && $type[5] ) {
>             print RECA;
>         }
>         # Save valid type B records.
>         elsif( $type[2] eq 'B' && $type[5] ) {
>             print RECB;
>         }
>         else {
>             print;
>         }
> 
>         # Check something else in current file
>         # if OK do_action_1 then delete orig file
>         # else do_action_2 then keep orig file

        if ( eof ) {
            close ARGV;
            if ( something_else ) {
                do_action_1();
                unlink "$ARGV$^I" or warn "Cannot delete $ARGV$^I: $!";
            }
            else {
                do_action_2();
            }
        }


>     }
> }
> Example data in files ...
> 
> [snip]
> 
> First note I used a comma as the separator so it could be seen here,
> in fact it is a backspace or delete character.
> 
> I would like to test some condition within each file and depending on
> the result either remove or keep the original.  The above seems to
> work OK however I don't know how to reference the individual files.
> 
> One other query, since discovering the wonderful __DATA__ idea I use
> this for example data, can we replicate MULTIPLE files using this?

Yes you can.

http://search.cpan.org/author/DCONWAY/Inline-Files-0.60/



John
-- 
use Perl;
program
fulfillment


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

Date: Mon, 16 Dec 2002 16:48:20 -0500
From: "Kalyan C" <kalyanramcvs@rediffmail.com>
Subject: Invoke a browser every 2 hours ...how?
Message-Id: <atlhnr$k0t$1@hubcap.clemson.edu>

Group,

I've a question...

I am to simulate a web-user who periodically tries to visit some web-sites,
I could go for wget, but, I'm more interested in the browser based
statistics like latencies associated with rendering the html etc. I would
like to use the standard browsers viz., Netscape and Internet Explorer for
my purposes.

To summarize:
I would like to visit some web-sites periodically, say every 2 hours,
without my actually being in front of the system. That is, invoke the
browser (whatever that happens to be, Netscape or IE) every 2 hours with a
specific URL.

Is there some way, I can do this ?

Hope, I'm clear this time and Hope, I'm not bugging you...

Thanks,
¬KalC




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

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


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