[12878] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 288 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 28 20:07:22 1999

Date: Wed, 28 Jul 1999 17:05:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 28 Jul 1999     Volume: 9 Number: 288

Today's topics:
    Re: [Summary] Korn Shell or Perl? (Michael Wang)
    Re: Any Suggestions? <sariq@texas.net>
    Re: Any Suggestions? <cassell@mail.cor.epa.gov>
    Re: Beginner needs help with a function (Tad McClellan)
        Book "Perl Annotated Archives" Good?Bad? (Gregg Silk)
    Re: DBM question (Eric Bohlman)
        Die process, Die! <raceE@yahoo.com>
    Re: Directory Listing with Size tjfreedog@my-deja.com
    Re: File maintenance algorithm required (Bart Lateur)
    Re: Filehandler... Can you email attachments??? <sariq@texas.net>
        Find::File -- skipping a directory? (J. Moreno)
    Re: Getting Height and Width of GIF/JPEG in PERL? (Eric Bohlman)
    Re: Getting Height and Width of GIF/JPEG in PERL? (Abigail)
    Re: Getting Height and Width of GIF/JPEG in PERL? (Abigail)
        help running Perl Scripts in win95 <mwhitley@superlink.net>
    Re: help running Perl Scripts in win95 <laurens@bsquare.com>
    Re: help w/command line argument <cassell@mail.cor.epa.gov>
        help with vars <tfiedler@ptd.net>
    Re: Help!! ---Database access in perl <cassell@mail.cor.epa.gov>
        how automatic assign a name to a hash <virtual.factory@turboline.be>
        How to copy a file to another name ? <factory@factory.co.kr>
    Re: How to find first occurance of white space... <sariq@texas.net>
        IEEE (NaN, Inf) iwelch@my-deja.com
        Looking for Free PERL based discussion forum <jnoviell@matrox.com>
    Re: NEWSFLASH: Supremes rule anti-advert-ware illegal (Andrew Johnson)
    Re: Pass by value or pass by reference? <keithmur@mindspring.com>
    Re: Pass by value or pass by reference? <keithmur@mindspring.com>
    Re: Pass by value or pass by reference? <cassell@mail.cor.epa.gov>
    Re: Pass by value or pass by reference? (Abigail)
    Re: Passing an Array into a HIDDEN FIELD <jeffp@crusoe.net>
        ref() return value... bhaskaracharya@my-deja.com
    Re: reg expression (Eric Bohlman)
    Re: Using regular expressions in $\ (Larry Rosler)
    Re: Variable in File name problems <cassell@mail.cor.epa.gov>
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: 28 Jul 1999 23:07:46 GMT
From: mwang@tech.cicg.ml.com (Michael Wang)
Subject: Re: [Summary] Korn Shell or Perl?
Message-Id: <7no2g2$617$1@news.ml.com>

Tom Christiansen  <tchrist@mox.perl.com> wrote:
>
>1) There is no such thing as a "Korn shell pipeline".  Get your
>   history straight.  David hardly invented it.  Do you even know
>   who did?
 
I concentrate on "Korn shell pipeline", whether other shells have 
pipeline or not is my concern, neither is that who invented it. 

>2) You're wrong about Perl.
>
>	$pwdinfo = `domainname` =~ /^(\(none\))?$/
>			? '< /etc/passwd'
>			: 'ypcat  passwd |';
>	open(PWD, $pwdinfo)   or die "can't open $pwdinfo: $!";
>	while (<PWD>) { ........... }
>
>    Yes, I could put the ?: in the open.
 
The ?: construct is very special case. It handles a if-else case, i.e.
either "local" or "yp". It can not handle a bit more 
generalization, eg, "local", "yp", "local-then-yp", and "yp-then-local",
as shown below in Korn Shell [since it can not be in Perl w/o the limitations
I mentioned in the summary]. 

$j="local yp" 
for i in $j
do
  if [[ $i == *local* ]]; then
    cat /etc/passwd
  elif [[ $i == *yp* ]]; then
    ypcat passwd
  fi
done | while read k; do ...; done

>3) You're an idiot, a troll, or both.  Die. 

People who don't have much to argue technically often resort to
personal attack. I won't degrade myself to that level. 
-- 
Michael Wang
http://www.mindspring.com/~mwang


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

Date: Wed, 28 Jul 1999 17:00:42 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: Any Suggestions?
Message-Id: <379F7D8A.3F3AAFDD@texas.net>

Steve Wagner wrote:
> 
> I am new to perl/cgi and have written the following code. Do you have any
> suggestions on how to restructure the code? 

perldoc CGI

- Tom


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

Date: Wed, 28 Jul 1999 16:33:11 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Any Suggestions?
Message-Id: <379F9337.C9C18466@mail.cor.epa.gov>

revjack wrote:
> 
> Eric The Read explains it all:
[snippety]
> :Ack!  Why roll your own CGI decoding routine (that doesn't properly
> :handle multiple values for a single key) when CGI.pm will do it for you?
> 
> It's funny - while looking for something else on the perl.com "Perl and
> CGI FAQ" a few minutes ago, I noticed this:
> 
>     Q2.1: Should I use the Perl CGI modules to code all
>     my CGI scripts? Isn't it easier to do it myself?
> 
>     It really depends on what you are trying to do. The
>     CGI modules should generally be used for heavy-duty
>     CGI scripts. For simple scripts, its is far easier
>     and quicker to roll your own or use CGI Lite (current
>     version is v1.62). If you really want, you can even
>     use the old Perl 4 cgi-lib.pl library.
> 
> "easier and quicker to roll your own". Hm.

Yes, and that's paragraph is not one I agree with in its entirety.
It's certainly true for Tom and Larry and Randal and The Other Larry
and a thousand other Perlites.  But they all know how to write it
*correctly*.  And they know not to delve into the junk code which
has metastatized all over the web.  There is nothing in the
"easier and quicker to roll your own" part which says:

"Assuming you know how to do this better than the incorrect Perl 
code which floats about the Internet, causing intermittent failures
of unsuspecting people's CGI programs."

There is nothing which provides a quick test for whether someone's
personal mutation of uri_escape() or uri_unescape() breaks on the
boundary cases.. or on every case.

But then, we can hardly stress-test every webpage on the planet, 
can we?

> Of course, you're right that the above cargo-cult code chunk has
> many flaws.

And it spreads painfully quickly too.  I'm suddenly reminded of a
quote from Another Tom:
"You can't catch me - I'm the wind, baby!"  - Tom Servo
 
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Wed, 28 Jul 1999 14:38:02 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Beginner needs help with a function
Message-Id: <aminn7.7bo.ln@magna.metronet.com>

Alec Kelingos (akelingos@petrosys-usa.com) wrote:

: I need a function to trim the first/last characters off a string if and
: only if these characters are a user defined character.


sub trimChr {
   my($str, $char) = @_;
   $char = quotemeta($char);

   $str =~ s/^$char//;
   $str =~ s/$char$//;

   return $str;
}


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 28 Jul 1999 22:41:33 GMT
From: greggsilk@aol.com (Gregg Silk)
Subject: Book "Perl Annotated Archives" Good?Bad?
Message-Id: <19990728184133.23018.00003512@ng-xa1.aol.com>

I see that Costco has "Perl Annotated Archives" by Martin Brown. I looked
pretty useful to me, but does anyone have opinions on its accuracy and quality?
Gregg


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

Date: 29 Jul 1999 00:02:10 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: DBM question
Message-Id: <7no5m2$dd@dfw-ixnews6.ix.netcom.com>

Bob Walton (bwalton@rochester.rr.com) wrote:
: from perlfunc regarding function each:
: 
: "... If you add
:      or delete elements of a hash while you're iterating
:      over it, you may get entries skipped or duplicated,
:      so don't."

This, BTW, is one place where the Camel is wrong; it claims that you're 
permitted to delete from, but not add to, a hash you're iterating over.



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

Date: Thu, 29 Jul 1999 00:00:58 GMT
From: "JME" <raceE@yahoo.com>
Subject: Die process, Die!
Message-Id: <_QMn3.109$Ga2.8231@news.cwix.com>

Hi all,

THE SETUP:
I've got a Perl script that uses CGI and DBI libraries.  It runs on an AIX
box running Perl version 5.004_04.  Clients execute it and it creates a
dynamic html page.  The traffic rate is about 3-4 hits per minute.  The page
is displayed completely and the script exits successfully.

THE PROBLEM:
Even though the script exits successfully, occasionally (say, 1 out of 30
times) the process still hangs out there.  If I execute a 'ps' command on
the command line, you can still see the process.

THE TEMPORARY FIX:
In the interim, while I try to debug this problem, I have a cron job that
runs hourly and kills process that have been out there too long.  It works,
but it is obviously not the best solution.

THE QUESTION:
Any ideas why a script would hang after it seemingly completes?  Obviously,
this is not a universal problem or you'd all be screaming about it.  I could
upgrade to the latest release of Perl, but I don't think that's the
problem -- my development box, which is Sun Solaris, also uses 5.004_04 but
does not have this problem.

Thank you all!

JME











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

Date: Wed, 28 Jul 1999 22:49:56 GMT
From: tjfreedog@my-deja.com
Subject: Re: Directory Listing with Size
Message-Id: <7no1ei$j97$1@nnrp1.deja.com>

This is not really a perl solution although it could easilly be
included into one. There is an NT resource kit utility called
DIRUSE.EXE that appears to do exactly what you want. You give it the
root path name and it will give you file statistic totals such as
number of files and sizes broken down by directory and/or sub-
directory. I use it to figure out which directory (and thereby which
user) is using up the most drive space.

Here is the usage info you get by calling DIRUSE /?
=====================
DIRUSE displays a list of disk usage for a directory tree(s). Version
1.20

DIRUSE [/S | /V] [/M | /K | /B] [/C] [/,] [/Q:# [/L] [/A] [/D] [/O]]
[/*] DIRS

/S      Specifies whether subdirectories are included in the output.
/V      Output progress reports while scanning subdirectories.  Ignored
if /S is specified.
/M      Displays disk usage in megabytes.
/K      Displays disk usage in kilobytes.
/B      Displays disk usage in bytes (default).
/C      Use Compressed size instead of apparent size.
/,      Use thousand separator when displaying sizes.
/Q:#    Mark directories that exceed the specified size (#) with a "!".
        (If /M or /K is not specified, then bytes is assumed.)
/L      Output overflows to logfile .\DIRUSE.LOG.
/A      Specifies that an alert is generated if specified sizes are
        exceeded. (The Alerter service must be running.)
/D      Displays only directories that exceed specified sizes.
/O      Specifies that subdirectories are not checked for specified size
        overflow.
/*      Uses the top-level directories residing in the specified DIRS
DIRS    Specifies a list of the paths to check.

Note:   Parameters can be typed in any order. And the '-' symbol can be
        used in place of the '/' symbol.

        Also, if /Q is specified, then return code is ONE if any
        directories are found that exceed the specified sizes.
        Otherwise the return code is ZERO.

Example: diruse /s /m /q:1.5 /l /* c:\users
=====================

Hope this helps

In article <379F2274.F239A71@trinite.co.uk>,
  Adrian Duncan <Adrian.Duncan@trinite.co.uk> wrote:
> Jason,
> cheers for the reply.
>
> I had thought of using dir /s, but this is quite slow.
> I would have to parse each line looking for a line
> that says Total Files and then take the size from the
> next line.
>
> Do you know of a more expedient method?
> Full specs below
> Cheers
> Adrian.
>
> Full Spec:
> I have 3 or more web servers.
> Each has a directory called webpages.
> I need to get a list of each directory under
> this directory and how much space it takes up,
> including any sub directories.  We need to do this
> to bill people for the amount of space that their
> web domain takes up.
>
>


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Wed, 28 Jul 1999 23:12:58 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: File maintenance algorithm required
Message-Id: <379f849b.2100112@news.skynet.be>

Roger Musson wrote:

>I need to add a line of data to the front of a file (i.e. not
>appending). The file is several thousand lines long and about 5mb file
>size.

Since everything in the file must move, there's no other way than to
rewrite the file. Sorry.

Why do you need that? To create a log file, latest events at the front?
Maybe you should try appending anyway, but in parallel creating an index
file, with the seek/tell value of each line. That way, it's easy to
find, say, the ten last lines in the main file, because every entry in
the index takes exactly 4 bytes, so all you need to do is read 40 bytes
from the end, to get the offset in the main file. Something like:

	open LOG,">>logfile.txt"; # or die...
	open INDEX,">>logfile.idx"; # or die...
	flock LOG, 2;
	flock INDEX, 2;
	binmode INDEX;
	print INDEX pack 'V', tell LOG;
	print LOG "Whatever you want\n";
	close INDEX; close LOG;

Read last 10 lines (if there are that many):

	open LOG,"logfile.txt"; # or die...
	open INDEX,"logfile.idx"; # or die...
	flock LOG, 2;
	flock INDEX, 2;
	binmode INDEX;
	seek INDEX, -40, 2 if -s INDEX > 40;
	read INDEX, $o, 4;
	seek LOG, unpack('V', $o), 0;
	while(<LOG>) {
		print;
	}

	Bart.


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

Date: Wed, 28 Jul 1999 17:03:47 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: Filehandler... Can you email attachments???
Message-Id: <379F7E43.9FF5F8F4@texas.net>

Peter Robichaud wrote:
> 
> thanks,
> 
> I was wondering if it was possible to send a file attachment out with a form
> generated email...

Try MIME::Lite

- Tom


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

Date: Wed, 28 Jul 1999 18:47:54 -0400
From: planb@newsreaders.com (J. Moreno)
Subject: Find::File -- skipping a directory?
Message-Id: <1dvo1hp.i0gtpb1svncdgN@roxboro0-0059.dyn.interpath.net>

Am, I missing something or is there no way to skip a directory when
using Find::File?

Please, someone tell me I'm missing something...

-- 
John Moreno


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

Date: 28 Jul 1999 23:27:23 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Getting Height and Width of GIF/JPEG in PERL?
Message-Id: <7no3kr$dd@dfw-ixnews6.ix.netcom.com>

I R A Darth Aggie (fl_aggie@thepentagon.com) wrote:
: On 27 Jul 1999 22:44:20 -0500, Abigail <abigail@delanet.com>, in
: <slrn7psv3n.3hu.abigail@alexandra.delanet.com> wrote:
: 
: + Don't forget, when it comes to the web, the evil character is Netscape,
: + way more than MS.
: 
: No, it is (was?) a constant contest to see who could do the most evil.

NS, though, got a substantial head start, especially with their 
broken-as-designed frames specification.  A good portion of CGI 
questions, and even Perl HTTP-client questions, are due to the 
poorly-though-out nature of that spec, which was implemented as-is 
*after* the problems were pointed out to NS, along with proposals for 
improvements.



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

Date: 28 Jul 1999 18:53:53 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Getting Height and Width of GIF/JPEG in PERL?
Message-Id: <slrn7pv5vj.4oo.abigail@alexandra.delanet.com>

I R A Darth Aggie (fl_aggie@thepentagon.com) wrote on MMCLVII September
MCMXCIII in <URL:news:slrn7pu168.gad.fl_aggie@thepentagon.com>:
$$ On 27 Jul 1999 22:44:20 -0500, Abigail <abigail@delanet.com>, in
$$ <slrn7psv3n.3hu.abigail@alexandra.delanet.com> wrote:
$$ 
$$ + Don't forget, when it comes to the web, the evil character is Netscape,
$$ + way more than MS.
$$ 
$$ No, it is (was?) a constant contest to see who could do the most evil.


Bollocks. Netscape managed to destroy the web even before MS had
developed their browser.



Abigail
-- 
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
             "\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
             "\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 28 Jul 1999 18:55:13 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Getting Height and Width of GIF/JPEG in PERL?
Message-Id: <slrn7pv624.4oo.abigail@alexandra.delanet.com>

Sean McAfee (mcafee@waits.facilities.med.umich.edu) wrote on MMCLVII
September MCMXCIII in <URL:news:jFEn3.2866$nB.428994@news.itd.umich.edu>:
!! In article <slrn7psv3n.3hu.abigail@alexandra.delanet.com>,
!! Abigail <abigail@delanet.com> wrote:
!! >Don't forget, when it comes to the web, the evil character is Netscape,
!! >way more than MS.
!! 
!! *blink*
!! 
!! You don't say.


Oh yes, I do. Let me say it again: the evilness of Jim Clark and Mark
Andreessen far outweights the evilness of Bill Gates.



Abigail
-- 
perl -wle '$, = " "; print grep {(1 x $_) !~ /^(11+)\1+$/} 2 .. shift'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Wed, 28 Jul 1999 18:22:14 EDT
From: Mark Whitley <mwhitley@superlink.net>
Subject: help running Perl Scripts in win95
Message-Id: <7nnvqm$2tl4$1@earth.superlink.net>

Help, I'm to young to Die!

 I am trying to run perl script forms inserted in HTML pages.
I am using both Visual Page 2.0 and Front Page 2000 for HTML.
Scrits were downloaded from net and I assume they work.
I would like to run them on my Windows 95 machine before loading to
Unix Web server. I have installed Active Perl V5. I have also installed
Perl_Win32 and PerlScript.
Perl runs the "Example.pl" program provided with Active Perl fine.

When I test the web pages on both Internet Explorer and Netscape
the script is opened so I assume the path is correct, but when it runs
I get

"Bad Command or File Name"  in a DOS window. Then any line in the
program with a Print statment is
printed then it terminates.

I have even tried running the example script "Excel1.pl".
It executes, starts Excel, loads, displays and terminates.

 If you can help I would greatly appreciate it.

Please respond by E-Mail

                                                mwhitley@superlink.net




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

Date: Wed, 28 Jul 1999 16:40:23 -0700
From: "Lauren Smith" <laurens@bsquare.com>
Subject: Re: help running Perl Scripts in win95
Message-Id: <7no4dp$jjl$1@brokaw.wa.com>

Mark Whitley wrote in message <7nnvqm$2tl4$1@earth.superlink.net>...
>I get "Bad Command or File Name"  in a DOS window. Then any line in the
>program with a Print statment is
>printed then it terminates.
>
I've been working on a God module for myself for some time now, and this
would be good place to try some functionality.

use God::Omniscience;
&FindProblem($no_information_given);

output:
There is a problem in your script.  Look for 'system()' commands or
backticked commands.  The source of your woes comes from such lines.

Well, that's what my God module is saying, I have to take it at face value.

>I have even tried running the example script "Excel1.pl".
>It executes, starts Excel, loads, displays and terminates.

Let me try again.

use God::Omniscience;
&WhatIsGoingOn($no_clue_as_to_what_is_supposed_to_happen);

output:
I have no idea.

*sigh*  Not all problems can be solved, it seems.

Lauren




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

Date: Wed, 28 Jul 1999 16:16:58 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: help w/command line argument
Message-Id: <379F8F6A.ECE8A568@mail.cor.epa.gov>

sn0brdr@yahoo.com wrote:
> 
> hi,
> 
> i'm a (perl) newbie w/a question re: command line argument.
> 
> what should i use to do:
>    progname   arg(s)
> 
> i was able to use Getopt::Std, but i'm trying to make this proggie
> easier for the end users so they don't have to memorize the switches.
> the ability to see output and error would be great.

Well, you can't make it totally transparent to the user.  The
user has to do *something* with his/her 'little gray cells'.
What I do is to write a here-doc which gets printed when a help
flag is typed [often -h or -? or /h or /? depending on the OS]
or when an incorrect set of options is specified.  The here-doc
has the short form of set of switches, so the user gets a little
screen of options and guidelines.  My usual model for this is the
subroutine 'usage' from Tom Christiansen's tcgrep program.

Alternatively, you can use Tk and put up a window with buttons
and menus which let the user pick and choose, correcting errors
as they go.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Wed, 28 Jul 1999 23:21:03 GMT
From: "ted fiedler" <tfiedler@ptd.net>
Subject: help with vars
Message-Id: <zfMn3.31$Q8.5285@nnrp1.ptd.net>

#!/usr/bin/perl
open(HEADER,"< oput/marriage");
while(<HEADER>) {
 if( /name ([\S\s\w]*)/) {
  $name=$1;
 }
 if( /account (\S*)/) {
  $account=$1;
 if( /balance (\S*)/) {
  $balance=$1;
   }
 print"$name,$account,$balance\n";
}


i have this reading a file that looks like this:

name joe blow
name john q public
account 123456
account 123456
balance 234.56
balance 3456.78

what am i doing wrong?  this doesnt work...



thanks
ted





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

Date: Wed, 28 Jul 1999 16:04:58 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Help!! ---Database access in perl
Message-Id: <379F8C9A.98D7FC72@mail.cor.epa.gov>

andrewfase@my-deja.com wrote:
> 
> I need some help please!!
> 
> I am designing a site for a computer company, and they want a online
> database of all there stock
> 
> The problem is that the table has 30000+ entries!!

That's not a problem for most databases.  But you probably
want to avoid trying it with MS Access.
 
> i was going to use Sprite to access it, but i am thinking the database
> is just to big for it.
> 
> Can anyone tell me what i could use??? and where to find tutorial's to
> use it (maybe MySql ???)
> 
> One last thing it has to be free!!!!!

There are now a host of free databases available.  Just look 
through the posting in this newsgroup.  MySQL is certainly an
option.

You may want to go to perl.com and look at the tutorials page
to find some tutorials that focus on DBI and sundry databases
which work with DBI.
 
> Thanks in advance!!!
> 
> please email andrew.fase@stud.umist.ac.uk

Please read it here in the newsgroup.  It's the polite, Usenet
way.  How else can anyone else profit by the answers you get?
Alternatively, how can you learn which answers are from idiots,
except by seeing experts correct them here?

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Thu, 29 Jul 1999 01:17:14 GMT
From: Pieter Van der Donckt <virtual.factory@turboline.be>
Subject: how automatic assign a name to a hash
Message-Id: <19990729.1171400@adsl1550.turboline.be>

--------------=_4D480021220808A2D178
Content-Description: filename="text1.txt"
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hi,

I am looking for a way to automate a nameassignment to a hash.
The problem is this:

I have an allround-cgi-script that generates different amounts of=20
key-value pairs.
I would put some of them in different hashes, but i never know how=20
many hashes i will need. So I need a way to name the hashes in an=20
automated way.

e.g.

$listcheck =3D 1;
$listtotal =3D 0;

sub check
  {
    $test =3D "list".$listcheck;
    if ($session->param("$test"))
      {
		%hash=3D(
			$test =3D> ($session->param("$test"))
			)
		@ses =3D ($session->param("$test"));
	    	$listcheck +=3D1;
	    	$listtotal +=3D1;
	    	&check;
      }
  }
&check;


%hash (in red) should get every loop another name (e.g.=20
%hash1,%hash2,....)
The problem is that i don't know how many loops there will be, because=20
a lot of different forms use the same cgi-script

Somebody who has an idea?


--------------=_4D480021220808A2D178
Content-Description: filename="text1.html"
Content-Type: text/html
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
	<TITLE>how automatic assign a name to a hash</TITLE>
	<META NAME=3D"GENERATOR" CONTENT=3D"StarOffice/5.1 (Linux)">
	<META NAME=3D"CREATED" CONTENT=3D"19990729;1554700">
	<META NAME=3D"CHANGEDBY" CONTENT=3D"Pieter Van der Donckt">
	<META NAME=3D"CHANGED" CONTENT=3D"19990729;2171400">
</HEAD>
<BODY>
<PRE>Hi,

I am looking for a way to automate a nameassignment to a hash.
The problem is this:

I have an allround-cgi-script that generates different amounts of
key-value pairs.
I would put some of them in different hashes, but i never know how many
hashes i will need. So I need a way to name the hashes in an automated
way.

e.g.

$listcheck =3D 1;
$listtotal =3D 0;

sub check
  {
    $test =3D &quot;list&quot;.$listcheck;
    if ($session-&gt;param(&quot;$test&quot;))
      {
		<FONT COLOR=3D"#ff3333">%hash</FONT>=3D(
			$test =3D&gt; ($session-&gt;param(&quot;$test&quot;))
			)
		@ses =3D ($session-&gt;param(&quot;$test&quot;));
	    	$listcheck +=3D1;
	    	$listtotal +=3D1;
	    	&amp;check;
      }
  }
&amp;check;


%hash (in red) should get every loop another name (e.g.
%hash1,%hash2,....)
The problem is that i don't know how many loops there will be, because
a lot of different forms use the same cgi-script

Somebody who has an idea?</PRE>
</BODY>
</HTML>

--------------=_4D480021220808A2D178--



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

Date: Thu, 29 Jul 1999 08:08:06 +0900
From: "Yeong Mo/Director Hana co." <factory@factory.co.kr>
Subject: How to copy a file to another name ?
Message-Id: <7no1ur$dad$1@news1.kornet.net>

How to copy a file to another name  in same directory ?

There is a file named aaa.txt

Now, I want to copy this file to bbb.txt through loading perl script from
web.
and give the new file chmod 777 permission.

If someone has a solution for this, please let me know.

Thanks in advance.








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

Date: Wed, 28 Jul 1999 17:02:43 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: How to find first occurance of white space...
Message-Id: <379F7E03.425DA704@texas.net>

cramey@my-deja.com wrote:
> 
> i have a string that i would like to shorten to the data before the
> first space,
> 
> ex.
> 
> 123456 don't want any of this text in string
> ^^^^^^
> need this

perldoc -f split

and/or maybe:

perldoc perlre

- Tom


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

Date: Wed, 28 Jul 1999 23:36:34 GMT
From: iwelch@my-deja.com
Subject: IEEE (NaN, Inf)
Message-Id: <7no462$kvh$1@nnrp1.deja.com>



Linux RH 6.0; Perl 5.005_03:

How do I get Perl to honor/deal with such values as NaN?  For example,
prtf gives me a warning that NaN is not numeric.

As it is the "missing code" in some data I am handling, it would be nice
to be able to use printf anyway...

/ivo welch


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Wed, 28 Jul 1999 18:35:40 -0400
From: Joe Novielli <jnoviell@matrox.com>
Subject: Looking for Free PERL based discussion forum
Message-Id: <379F859A.B85EBD3F@matrox.com>

Hi all,

Can anyone recommend a good perl (CGI) based discussion forum scripts.
FREE of course.

Something like O'reilly's WebBoard (see http://webtalk.us.dell.com/~1),
(not Matt Wright's WWWboard) .

Features my users desire are:
- open and close of messages and threads  with "+" or "-"
- and the option of having a full view of a meesage with threads.

Any hints would would be greatly appreciated. Thanks



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

Date: Wed, 28 Jul 1999 22:35:54 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: NEWSFLASH: Supremes rule anti-advert-ware illegal
Message-Id: <eBLn3.674$K%6.25728@news1.rdc2.on.home.com>

In article <379f67d1@cs.colorado.edu>,
 Tom Christiansen <tchrist@mox.perl.com> wrote:

[snip: spooky newsflash]

I heard a rumor (no names) that a major production company is making
this story into a movie --- initial leaks of the screenplay treatment
indicate a starring role for Michael Douglas as a power hungry
Cybercapitalist with the *unusual* twist that he is being stalked by
an elusive (possibly female) adversary on the internet.

I can't wait.

andrew


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

Date: Wed, 28 Jul 1999 16:12:55 -0500
From: "Keith G. Murphy" <keithmur@mindspring.com>
Subject: Re: Pass by value or pass by reference?
Message-Id: <379F7257.6EED6D11@mindspring.com>

"Eric L. Brine" wrote:
> 
> > is these operation pass the value (copy) or pass the reference (link)?
> 
> Both are possible, it's up to the function itself.

What?
> 
> =======
> e.g. 1:
> sub test {
>   my ($arg0, $arg1) = @_;          # Pass by value.
                                       ^^^^^^^^^^^^^
>   print($arg0, ' - ', $arg1, "\n");
> }
> $a = 1; $b = 2;
> test($a, $b);
> 
> Notice the copying from $_[0] to $arg0, and from $_[1] to $arg1.
[cut]
You're confusing the passing mechanism with what goes on in the function
code.
This all seems totally wrong to me.  I'm suprised no one else has
pointed it out by now.


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

Date: Wed, 28 Jul 1999 16:23:28 -0500
From: "Keith G. Murphy" <keithmur@mindspring.com>
Subject: Re: Pass by value or pass by reference?
Message-Id: <379F74D0.D642BB7A@mindspring.com>

Carfield Yim wrote:
> 
> I man using win32_perl, how can I do?

ActiveState?  It's got HTML documentation with it.  Just point your
browser to the right place.  

perldoc seems to work if you set your %PATH up right, but it still
doesn't seem to want to do perldoc perlsub.  It seems to handle the
module docs OK, though.  I just use the browser...

By the way, people will like it better if you place your answer *after*
the prior message, like I'm doing here.  I know Netscape Messenger
doesn't do that by default...
> 
> Abigail wrote:
> 
> > Carfield Yim (c8133594@comp.polyu.edu.hk) wrote on MMCLVII September
> > MCMXCIII in <URL:news:7nlo07$2l5$1@nnrp1.deja.com>:
> > ,, Thank for reply!!
> > ,,
> > ,, I know that perldoc is a great reference, but I don't know how to find
> > ,, the information I want, e.g.: If I want to find information about
> > ,, [return], How do I know perlfunc contain information of it?
> > ,, The only way is asking people at web? I think there should have some
> > ,, document can help me.
> >
> > But there is. There's 'man perltoc'. Granted, it's not as good as a
> > full blown index, but you could always use 'grep'.
> >
> > ,, I think that the main problem is I don't know most of the perl index
> > ,, definition.
> >
> > That's why there are 'man perl' and 'man perltoc'.
> >


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

Date: Wed, 28 Jul 1999 16:00:34 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Pass by value or pass by reference?
Message-Id: <379F8B92.32203C89@mail.cor.epa.gov>

Carfield Yim wrote:
> 
> I man using win32_perl, how can I do?
>
[my snip of Abigail's text up to here:]
> > But there is. There's 'man perltoc'. Granted, it's not as good as a
> > full blown index, but you could always use 'grep'.
> >
> > ,, I think that the main problem is I don't know most of the perl index
> > ,, definition.
> >
> > That's why there are 'man perl' and 'man perltoc'.

Let me put in a little aside before I answer your question.
Please, please, please follow the official guidelines for
posting in this newsgroup.  It will make everyone happier
with you, and that will improve your chances of getting helpful
answers.

Now, your question.  The simplest solution is to use the
'perldoc' program instead.  At a command prompt, type:

perldoc perltoc
perldoc perl

See how simple that is?  Your life will be a lot easier once
you learn to use all the Perl tools which come with a [proper]
Perl install.

Alternatively, there is a man for win32.  See the Perl Power
Tools [ http://language.perl.com/ppt/ ] for man and many other
useful unixisms, all in Perl.

There is also a perlman program written in Perl using the Tk
module to provide a graphical user interface like that of 
tkman.  It's out of "Advanced Perl Programming" and IIRC the
code is on the O'Reilly website.

Finally, on win32 boxes a proper install of ActiveState Perl
puts a shortcut on your Start Menu.  Clicking on that coughs
up an HTML documentation set in your favorite browser.  Those 
docs include the FAQ, the ActiveState FAQ, all the sections
people have reffed, and all the module docs as well.  Anything
you install using the ppm program should chuck its docs into
that HTML tree as well.  Convenient, huh?

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: 28 Jul 1999 18:56:44 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Pass by value or pass by reference?
Message-Id: <slrn7pv64v.4oo.abigail@alexandra.delanet.com>

Uri Guttman (uri@sysarch.com) wrote on MMCLVII September MCMXCIII in
<URL:news:x7iu74soui.fsf@home.sysarch.com>:
$$ >>>>> "A" == Abigail  <abigail@delanet.com> writes:
$$ 
$$   A> Uri Guttman (uri@sysarch.com) wrote on MMCLVII September MCMXCIII in
$$   A> <URL:news:x73dy9tfdc.fsf@home.sysarch.com>:
$$   A> .. 
$$   A> .. in any case, passing in an array and processing its elements by
$$   A> .. reference to modify them is usually not clear code and is probably
$$   A> .. better done by passing in a ref to the array and then modifying the
$$   A> .. elements.
$$ 
$$ 
$$   A> Why not? People do it with foreach() all the time. Why would be doing
$$   A> that in foreach() be clear code, but not when it's a sub?
$$ 
$$   A> Besides, how else is one going to make a sub similar to chop()?
$$ 
$$ use prototypes?


Uhm, only by giving it the most generic prototype Perl knows off: @



Abigail
-- 
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Wed, 28 Jul 1999 18:56:48 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Passing an Array into a HIDDEN FIELD
Message-Id: <Pine.GSO.4.10.9907281854080.22024-100000@crusoe.crusoe.net>

[posted & mailed]

> print $cgi->hidden(-name=>'theList' -default=>@theArray),

That does not work as you'd like.  Try doing:

( ..., -default => join "%%", @theArray )

> @theElems= $cgi->param('theList');

Then try:

@theElems = split /%%/, $cgi->param('theList');


The reason is, if @array = ('a','b','c'), then
	( -default => @array )
is really
	( -default => 'a',
	  'b', 'c'
	)

You can't store the array as an array reference either, because the
address of the array will not be the same from one process to the next.
So you need to create a temporary scalar (using join()) and then break up
the scalar (using split()).

-- 
jeff pinyan    japhy@pobox.com
japhy's little hole in the (fire) wall:   http://www.pobox.com/~japhy
perl stuff     japhy+perl@pobox.com
japhy's perl supposit^Wrepository:        http://www.pobox.com/~japhy/perl



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

Date: Wed, 28 Jul 1999 23:17:13 GMT
From: bhaskaracharya@my-deja.com
Subject: ref() return value...
Message-Id: <7no31j$k71$1@nnrp1.deja.com>

hi


my @array = qw ( 1 2 3);
$ref = ref (\@array);# returns ARRAY


##but...
$ref = ref (\( 1, 2, 3)); ## returns SCALAR

why is the ref() considering the array as in scalar context???
can some body explain this?

thanks


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 28 Jul 1999 23:21:53 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: reg expression
Message-Id: <7no3ah$dd@dfw-ixnews6.ix.netcom.com>

I.J. Garlick (ijg@connect.org.uk) wrote:
: The reason why Abigail, Tad, Tom, Larry, Uri and many others who have been
: here for years jump in with varying degrees of "rudeness" is simply for
: self preservation and the good of Perl. If they do what you propose a faq
: doesn't get answered corectly so some well meaning not-so-newbie comes
: along and says "oh good one I can answer". They then proceed to answer,
: badly.

Yes, it's been observed in other technical groups, especially the HTML 
ones, that when experienced people simply stay out of the discussion in 
response to FAQs, the remaining participants manage to generate "street 
knowledge" about the subject under discussion, much the way American 
teenage boys manage to generate "street knowledge" about sexual matters 
(e.g. you can't get her pregnant if she's on top, you can't catch 
anything if you're not gay, etc.).  The classic Perl example of street 
knowledge is the belief that (localtime)[5] contains the last two digits 
of the current year.

So what, you say.  Having a CGI script print out "19100" isn't in the 
same league as a girl getting pregnant or a guy getting AIDS, after all.  
But the failures caused by the use of "street knowledge" in production 
Perl code tend to make Perl look bad in the eyes of PWPH (People With 
Pointy Hair) and potentially translate into mandates-from-high to use 
something like VB instead, simply because some PHB happened to see the 
results of some poorly-written Perl code.  Superstitious learning is not 
something to encourage.




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

Date: Wed, 28 Jul 1999 16:26:56 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Using regular expressions in $\
Message-Id: <MPG.1209319812fd0955989d69@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <7nnsd0$fsi$1@nnrp1.deja.com> on Wed, 28 Jul 1999 21:23:52 
GMT, mgcesar@my-deja.com <mgcesar@my-deja.com> says...
> Does any body know how (or if) regular expression can be used as an
> INPUT_RECORD_SEPERATOR ($\)?  I have a file to parse where the 'RS' in
> Awk would be defined as "\\\xB3{1,4}" (ie 1 to 4 hex B3s).
> Any ideas?

I am absolutely astounded that anyone would ask this question about 
$INPUT_RECORD_SEPARATOR without having read the section on it in 
perlvar.

<QUOTE, BUT AS YOU DON'T KNOW HOW TO READ IT WON'T HELP!>

Remember: the value of $/ is a string, not a regexp. AWK has to be 
better for something :-) 

</QUOTE OF WASTED EFFORT>

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 28 Jul 1999 16:22:39 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Variable in File name problems
Message-Id: <379F90BF.832B7F89@mail.cor.epa.gov>

RICHARDS AMANDA DAWN wrote:
> 
> When opening a file, I am placing a variable in the file name.  I have
> done this before and have been successful.  I do not know what I am doing
> incorrectly.  The only thing different is that I am defining the
> variable by using the split command as opposed to the HTML form(action
> and submit). Please help.
> 
> My code:
> 
> $PreviousInfoPath = "~mypath/$PFcode.txt";
> 
> open(PreviousInfo, "<$PreviousInfoPath") or die "Cannot open $!";
>         $previousProgramInfo = <PreviousInfo>;
> close PreviousInfo
> 
> This gives me a server error, but when I subsititute 10000004 for $PFcode
> (what it is supposed to be), my program works fine.

While Trond gave a good answer based on the supposition that
the tilde is your problem, I thought of a different problem.
When you did your split(), was $PFcode the last entry from your
line?  If so, it may have a newline hanging on it.  Try inserting
this line just before the above code:

chomp $PFcode;

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 288
*************************************


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