[15519] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2929 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 2 21:10:24 2000

Date: Tue, 2 May 2000 18:10:15 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <957316215-v9-i2929@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 2 May 2000     Volume: 9 Number: 2929

Today's topics:
    Re: Puzzled - Please help. <sparky@alt-usage-english.org>
        Redneck Mutha (AL3)
    Re: References and hashes <rbbdsb@earthlink.net>
    Re: reg expressions assistance <lr@hpl.hp.com>
    Re: Saving Uploaded Files using CGI.pm <rootbeer@redcat.com>
    Re: setting an array in a Struct? <crypto_boy@my-deja.com>
    Re: Stuck with my script! <rootbeer@redcat.com>
        Text output <kamri@nortelnetworks.com>
    Re: Text output <rootbeer@redcat.com>
    Re: Thanks Craig. <dburch@teleport.com>
        Wanted: GUI interface for MySQL (AL3)
    Re: Wanted: GUI interface for MySQL <makarand_kulkarni@My-Deja.com>
    Re: Where can I download HotKey.pm module ? <rootbeer@redcat.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 03 May 2000 00:44:10 GMT
From: Bob Cunningham <sparky@alt-usage-english.org>
Subject: Re: Puzzled - Please help.
Message-Id: <PXYPOZ++1+BPwiZdYZa932dstO1q@4ax.com>

On Tue, 2 May 2000 15:32:00 -0400, tadmc@metronet.com (Tad McClellan)
said:

>[I said:]

>>I'm also puzzled, though, by the fact that when I look in the Master
>>Index 

>I do not know what "Master Index" means...

I mentioned it earlier in the posting you replied to:

   For online documentation I've mostly used the Perl Manual at
   <http://www.ug.cs.dal.ca/pub/pub_dir/html/perl/perl.html>, 
   and I've found especially helpful the Master Index at
   <http://www.ug.cs.dal.ca/pub/pub_dir/html/perl/pl-index.html>.

The Master Index is a section of the _Perl Manual_, the author of
which is stated to be Larry Wall.  This version of the _Perl Manual_
is not dated, but it's apparently too old to cover Perl 5.6.

Now that I know about the POD files and where to find them, I probably
won't be using the online _Perl Manual_ much.

I gather that some distributions of Perl include something called
'manpages'.  That seems not to be true of the Windows distribution of
Active Perl.  The file 'perl.pod' says:

   To find out where the configuration has installed the 
   manpages, type:

       perl -V:man.dir

When you type that at the DOS command line, you get:

   man1dir=''
   man3dir=''

So much for manpages under Windows.



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

Date: Tue, 02 May 2000 22:09:20 GMT
From: rofl@eidosnet.co.uk (AL3)
Subject: Redneck Mutha
Message-Id: <390f5206.15424346@news.eidosnet.co.uk>




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

Date: Tue, 02 May 2000 23:09:20 GMT
From: "rbbdsb" <rbbdsb@earthlink.net>
Subject: Re: References and hashes
Message-Id: <AeJP4.19834$g4.524423@newsread2.prod.itd.earthlink.net>

Thanks a bunch to all who responded.
  One last question:  I hate to be dense (and yes I'm RTFMing the Perl
Cookbook but I'm a newbie and floundering).  I am still having trouble.
Keys obviously pulls the name field, but values appears to pull a hash
address.  What I need to do is iterate through the rec hash for each $name
and then each $key and use the $val as the key for yet another array.  Whew!
Should I be looking at Tie::RefHash as part of the solution?

TIA,
Russ

Craig Berry <cberry@cinenet.net> wrote in message
news:sgue2jph1g266@corp.supernews.com...
> rbbdsb (rbbdsb@earthlink.net) wrote:
> :   I'm trying to read in a file with three fields, create an array of the
> : distinct values in the first field, and hashes named the first field
> : containing the second and third fields.  An example would be:
> :
> : name1    field1a    field2a
> : name1    field1b    field2b
> : name2    field1a    field2a
> : name2    field1b    field2b
> : name2    filed1c    field2c
> : ...
> :
> : I want an array containing
> :     name1, name2, ...
> : and hashes
> :     $name1{fiield2a} = field1a;
> :     $name1{field2b} = field1b;
> :     $name2{filled2a} = field1a;
>
> Using symbolic refs (or equivalently, autogenerated variables) is almost
> always a bad idea.  Why not a hash using the first col as a key, and a
> hash ref as the value?
>
> Here's a demo program that shows how easy it is to do it that way:
>
> #!/usr/bin/perl -w
> # hdemo - demo showing how to build hashes and arrays from input data.
> # Craig Berry (20000502)
>
> use strict;
>
> my %rec;
>
> while (<DATA>) {
>   chomp;
>   my ($name, $val, $key) = split;
>   $rec{$name}{$key} = $val;
> }
>
> my @names = sort keys %rec;
>
> print "Names: @names\n",
>       '$rec{name2}{field2a} = ', $rec{name2}{field2a}, "\n";
>
> __DATA__
> name1    field1a    field2a
> name1    field1b    field2b
> name2    field1a    field2a
> name2    field1b    field2b
> name2    filed1c    field2c
>
>
> Output:
> /usr2/people/cberry > hdemo
> Names: name1 name2
> $rec{name2}{field2a} = field1a
>
> --
>    |   Craig Berry - cberry@cinenet.net
>  --*--  http://www.cinenet.net/users/cberry/home.html
>    |   "The road of Excess leads to the Palace
>       of Wisdom" - William Blake




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

Date: Tue, 2 May 2000 15:17:42 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: reg expressions assistance
Message-Id: <MPG.1378f3e07f343d98a9cf@nntp.hpl.hp.com>

In article <7aog6or98e.fsf@Merlin.i-did-not-set--mail-host-address--so-
shoot-me> on Tue, 02 May 2000 20:24:34 GMT, Ala Qumsieh 
<aqumsieh@hyperchip.com> says...
> 
> "spurcell" <skpurcell@hotmail.com> writes:
> 
> > I am trying to get an understanding of efficiency within a regular
> > expression. I have some strings that come back from an application which
> > always seem to have a \n in the front and a \n in the back. So I have been
> > removing the front and rear newline, or space like this:
> > 
> > $fish =~ s/^\s*|\s*$//g;
> > 
> > But is that efficient and correct, or is it better to do it in two lines
> > $fish =~ s/^\s*//g;
> > $fish =~ s/\s*$//g;
> 
> Some time last year, somebody benchmarked the above two approaches,
> and the results were posted in this newsgroup. IIRC, the second
> approach, with the two lines is faster than the one line version. You
> can do a search on the archives for more info.

In each case, though, the '\s*' should be replaced by '\s+' to avoid 
unnecessary work.

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


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

Date: Tue, 2 May 2000 16:58:42 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Saving Uploaded Files using CGI.pm
Message-Id: <Pine.GSO.4.10.10005021656400.13677-100000@user2.teleport.com>

On Tue, 2 May 2000, Mike wrote:

> I have looked at a couple of examples using CGI.pm to upload files.
> Each of these examples do things like echo back the contents, etc.
> 
> But none show how to actually save the file in a specific location.

Do you know how to write a file of your own to a specific location, in a
non-CGI program? It's done in the same basic way when using CGI.pm. See
the docs for open() in the perlfunc manpage, the perlopentut manpage, or
both. If you have further questions after reading those docs, feel free to
ask again. Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 03 May 2000 00:24:08 GMT
From: Crypto-Boy <crypto_boy@my-deja.com>
Subject: Re: setting an array in a Struct?
Message-Id: <8enrip$bpj$1@nnrp1.deja.com>

In article <MPG.1377bf44e9ed866298a9c7@nntp.hpl.hp.com>,
  Larry Rosler <lr@hpl.hp.com> wrote:
> In article <390E0C99.B5892A02@jpl.nasa.gov> on Mon, 01 May 2000
16:00:41
> -0700, Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov> says...
> > Larry Rosler wrote:
> > > In article <8eksln$271$1@nnrp1.deja.com> on Mon, 01 May 2000
21:24:28
> > > GMT, Crypto-Boy <crypto_boy@my-deja.com> says...
> > > > Two questions:
> > >
> > > Boy, your post is certainly Crypto.
> > >
> > > > Given the declaration
> > > >
> > > >    struct Family => { members => '@' };
> > >
> > > What language is that?  Not Perl, for sure.
> >
> > That was my first reaction.  My second reaction was to search CPAN
for a
> > 'struct' module.  What I found was Class::Struct (a part of the perl
> > distribution since 5.004_05) which is used to 'declare struct-like
> > datatypes as Perl classes'.  The original poster should read the
> > Class::Struct documentation.
>
> I cannot find a statement
>
>     use Class::Struct;
>
> in the original post, which would have made the magic manifest.  Now
> that I have read the documentation, I can see what it is about.


Ok, Ok, I should have written "use Class::Struct;" in my post.  Geeezzz.
And I did read the Class:Struct documentation, which doesn't mention
using the (weird to me) @{} notation, or any kind of entire-array
assignment (just one element at a time assignment).

So you (Mr. Rosler) are saying that @{$Family->members} is the array
referred to by the reference that the getter method returns?  I guess
that makes sense.  I found examples of @{} usage in POD/perlref, but I
still don't understand.  Where is a good reference on this @{} stuff?



Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 2 May 2000 17:00:27 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Stuck with my script!
Message-Id: <Pine.GSO.4.10.10005021659130.13677-100000@user2.teleport.com>

On Tue, 2 May 2000, Marcus wrote:

> Subject: Stuck with my script!

Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.

    http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post

> now my cgi-bin has been move and I can't figure it out... 

When you're having trouble with a CGI program in Perl, you should first
look at the please-don't-be-offended-by-the-name Idiot's Guide to solving
such problems. It's available on CPAN.

   http://www.perl.com/CPAN/
   http://www.cpan.org/
   http://www.cpan.org/doc/FAQs/cgi/idiots-guide.html
   http://www.cpan.org/doc/manual/html/pod/

> open(INFOFILE,">$servicesfolder/$in{service}/$in{username}/$infofilename");

Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.

Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 03 May 2000 10:29:11 +1000
From: "Amri, Kuross [WOLL:4009-I:EXCH]" <kamri@nortelnetworks.com>
Subject: Text output
Message-Id: <390F72D7.848736D0@nortelnetworks.com>

Hello, 
	I have a text file that has a formatted out put. It is some tables.
When I created the link to display the text file it sends out a 500
error. In the server logs it complains about unable to exec format. 
	Does enybody know what is happening or what I can do about it?

Thanks 
Kuross


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

Date: Tue, 2 May 2000 18:04:18 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Text output
Message-Id: <Pine.GSO.4.10.10005021803090.13677-100000@user2.teleport.com>

On Wed, 3 May 2000, Amri, Kuross [WOLL:4009-I:EXCH] wrote:

> When I created the link to display the text file it sends out a 500
> error.

That's not a perl error; it's coming from a webserver. You should search
for the docs, FAQs, and newsgroups about webservers. Your local expert
should be able to help you with this, though, since it probably depends
upon your webserver's configuration. Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 02 May 2000 15:11:45 -0700
From: Dan Burch <dburch@teleport.com>
Subject: Re: Thanks Craig.
Message-Id: <390F52A0.C20D2149@teleport.com>

Very good.

Craig Berry wrote:

> Dan Burch (dburch@teleport.com) wrote:
> : This is probably an easy one, but I'm new to Perl and I'm having a hard
> : time figuring this. I have a txt file with line that contain QTY SOLD
> : and then space delimited fields with monthly totals that I can split on.
> : The problem is commas in numbers over 1000 like 1,000.  If I just try to
> : add up the fields it works for numbers under 1000, but gives a zero
> : value for numbers with the comma.  This is what I'm trying:
> :
> :         elsif (  "$data_line[1]" =~ /QTY SOLD/  )
>
> No need to double-quote the left operand above; in fact, it just wastes
> time.
>
> :         {
> :          local $year_total = ($data_line[2] +$data_line[3]
> : +$data_line[4] +$data_line[5] +$data_line[6] +$data_line[7]
> : +$data_line[8] );
>
> There are easier ways to write that, such as
>
>   $year_total = 0;
>   $year_total += $_ foreach @data_line[2..8];

This is great.  Now I can add variables [$x..$y] and make the code reusable.

>
>
> : I tried :
> :
> :   foreach $data_line ( @data_line )
> : {
> :     $data_line = s/,//;
> : }
> :
> : ahead of getting the total but that doesn't seem to work.
>
> First, make sure you're doing that before you split the line into fields
> as operated on above.  Second, as written, this only substitutes the first
> comma.  Third and worst, it's operating on $_, not $data_line; $data_line
> ends up with the number of substitutions done on $_.
>
> Either
>
>   $data_line =~ s/,//g;
>
> or (prefered)
>
>   $data_line =~ tr/,//d;
>
> would do what you want -- again, if performed before the split.
>
> --
>    |   Craig Berry - cberry@cinenet.net
>  --*--  http://www.cinenet.net/users/cberry/home.html
>    |   "The road of Excess leads to the Palace
>       of Wisdom" - William Blake



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

Date: Tue, 02 May 2000 22:08:17 GMT
From: rofl@eidosnet.co.uk (AL3)
Subject: Wanted: GUI interface for MySQL
Message-Id: <390f518c.15302298@news.eidosnet.co.uk>

Anyone know of a cheap (or free) user-friendly interface for MySQL?
Maybe a Perl script or something?

Alan A


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

Date: Tue, 02 May 2000 15:39:48 -0700
From: Makarand Kulkarni <makarand_kulkarni@My-Deja.com>
Subject: Re: Wanted: GUI interface for MySQL
Message-Id: <390F5934.67EE895A@My-Deja.com>

> Anyone know of a cheap (or free) user-friendly interface for MySQL?
> Maybe a Perl script or something?

The download page for Mysql
http://mysql.com/download.html
has some downloads for graphical
MySQL clients

Check www.FreshMeat.com also.
You might find some more there.

--



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

Date: Tue, 2 May 2000 16:24:21 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Where can I download HotKey.pm module ?
Message-Id: <Pine.GSO.4.10.10005021614060.13677-100000@user2.teleport.com>

[ Follow-up set to c.l.p.modules. ]

On Tue, 2 May 2000, Aurelien wrote:

> I have seen in perlfaq8 that the HotKey.pm module is very interesting
> and I'd like to download it.  It is present in the faq but I 'd prefer
> to have it with a makefile like other CPAN modules.
> 
> Someone can give me an URL where I can download it please ?

You're right. It should probably be on CPAN. Why don't you write to the
FAQ's maintainers and ask permission to make it into a proper module, with
documentation and tests and all? (Really, I'm sure they wouldn't mind; and
you probably don't even need permission, but it's only polite. Besides,
they may have some helpful suggestions.)

I'd recommend that you call it something like Term::ReadKey::HotKey, since
there's no need for a new top-level name here. Maybe someone on
c.l.p.modules will have a suggestion of an even better name.

Thanks!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

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


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


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