[8510] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2126 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 18 14:17:56 1998

Date: Wed, 18 Mar 98 11:00:53 -0800
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, 18 Mar 1998     Volume: 8 Number: 2126

Today's topics:
    Re: "Getting data from another machine" <beske@worldnet.att.net>
    Re: ? Any Perl scripts already written to print out all <chasecreek.systemhouse@usa.net>
    Re: ? Any Perl scripts already written to print out all <fp@pmpcs.com>
    Re: Are There Any Snazzy Perl Editors for Windows? (Alan Schwartz)
    Re: Are There Any Snazzy Perl Editors for Windows? (PAF)
    Re: Are There Any Snazzy Perl Editors for Windows? (Mick Knutson)
    Re: building for perl 5.004_04 on NT <uwe.honekamp@etas.de>
    Re: building for perl 5.004_04 on NT <james-detg.smith@ubs.com>
    Re: Changing password & security issue <chasecreek.systemhouse@usa.net>
    Re: Chicago Perl Mongers (brian d foy)
        compiling perl <matt@corp.airmedia.com>
        creating directories with cgi <fish@civl.port.ac.uk>
    Re: Dynamically checking for existing functions <quentin@jihad.amd.com>
        Fastest way to grep through a file? (Agent Hall)
    Re: Fastest way to grep through a file? <ron@mrrrossbayeng.com>
    Re: Good Perl book lvirden@cas.org
    Re: grep on hashes (Abigail)
    Re: grep on hashes <jefpin@bergen.org>
    Re: grep on hashes <uri@sysarch.com>
    Re: help: s?\s[a-z][sd]t\s[12][90]? ? doesn't remove 19 (Tom Grydeland)
        How to populate a 2D array from a file. <james-detg.smith@ubs.com>
    Re: How to populate a 2D array from a file. (Kevin Reid)
    Re: How to populate a 2D array from a file. (Bennett Todd)
    Re: How to use "@" literally in perl scripts <barnett@houston.Geco-Prakla.slb.com>
    Re: How to use "@" literally in perl scripts murple@erols.com
    Re: How to use CPAN modules/no permission to install lvirden@cas.org
    Re: Is there a "Newsgroup" for Newbies to Perl? (Michael J Gebis)
        Optimizing a Perl Sendmail routine? (Mick Knutson)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 18 Mar 1998 12:31:09 -0500
From: Bryan Beske <beske@worldnet.att.net>
Subject: Re: "Getting data from another machine"
Message-Id: <6ep0e0$m66@bgtnsc02.worldnet.att.net>

Write a simple perl program to do it locally, install it on
the target system and use the httpd calls the results.

b^2



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

Date: Wed, 18 Mar 1998 16:04:30 GMT
From: Sneex <chasecreek.systemhouse@usa.net>
Subject: Re: ? Any Perl scripts already written to print out all of the field names on a form?
Message-Id: <350FEF36.E983034@usa.net>

Yes - It's called CGI.pm.  Under the CGI.pm module it's called dump();

An example of which was posted here a day or two ago.
Try search DejaNews for CGI.pm

HTH,
Sneex :-)


Peter Perchansky wrote:

> Greetings:
>
> Does any one have a Perl script where they point it to a HTML page with a
> form, and it prints out all of the field names on the form?
>
> Thank you.
>
> --
> ===========================================================
> Peter Perchansky,  Computer Consultant & Microsoft FrontPage MVP
> Dynamic Net, Inc. DBA PMP Computer Solutions
> Providing Dynamic Databases, Design, &  Electronic Commerce Solutions
> FrontPage Web Hosting at http://www.pmpcs.com/services/fpwebhosting.htm
> FrontPage Support http://www.pmpcs.com/support/frontpage.htm





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

Date: Wed, 18 Mar 1998 13:19:42 -0500
From: "Peter Perchansky" <fp@pmpcs.com>
Subject: Re: ? Any Perl scripts already written to print out all of the field names on a form?
Message-Id: <6ep3b3$t3a$1@usenet42.supernews.com>

Greetings:

Sneex wrote in message <350FEF36.E983034@usa.net>...
>Yes - It's called CGI.pm.  Under the CGI.pm module it's called dump();
>
>An example of which was posted here a day or two ago.
>Try search DejaNews for CGI.pm

I don't think that's the answer.

Given a HTML page... print out all of the field names, not the values... and
it should not take submitting the form in order to get the field names.

--
===========================================================
Peter Perchansky,  Computer Consultant & Microsoft FrontPage MVP
Dynamic Net, Inc. DBA PMP Computer Solutions
Providing Dynamic Databases, Design, &  Electronic Commerce Solutions
FrontPage Web Hosting at http://www.pmpcs.com/services/fpwebhosting.htm
FrontPage Support http://www.pmpcs.com/support/frontpage.htm





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

Date: 18 Mar 1998 16:26:52 GMT
From: alansz@araw.mede.uic.edu (Alan Schwartz)
Subject: Re: Are There Any Snazzy Perl Editors for Windows?
Message-Id: <6eoskc$150q$1@piglet.cc.uic.edu>

Alan Silver  <alan@consultancy-services.ferret.com> writes:
>Alan Schwartz <alansz@araw.mede.uic.edu> wrote ...
>>I also love PFE. When using it with Perl, a handy thing is to tell
>>it that the "compile" command is "perl -cw". You can then 
>>hit compile and watch another window pop up containing all your warnings,
>>etc., so you can fix up the code.
>
>Sounds good, where do we get it ?
>
>Alan

 http://www.lancs.ac.uk/people/cpaap/pfe/

 - The other Alan

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
         Alan Schwartz                  | Disclaimer: I represent no one
        <alansz@uic.edu>                |
Asst. Prof. of Clinical Decision Making | Life is what happens to you while
University of Illinois at Chicago       | you're busy making other plans
Department of Medical Education         |          - J. Lennon
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-



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

Date: Wed, 18 Mar 1998 20:24:25 +0300
From: "Alexander Petrosyan (PAF)" <paf@design.ru>
Subject: Re: Are There Any Snazzy Perl Editors for Windows?
Message-Id: <6eovu8$q4j$1@news.rinet.ru>

I use FTE:

Text Mode text editor.     Version 0.46b5
Color syntax highlighting  for   C/C++,
REXX, HTML, IPF, PERL, Ada, Pascal, TEX
Multiple  file/window  editing,  Column
blocks, configurable menus and keyboard
bindings,  mouse  support,   undo/redo,
regular expression  search and replace,
folding, background compiler execution.

WWW:   http://ixtas.fri.uni-lj.si/~markom/fte

And
***********************************************************
     ActiveState Perl Debugger 1.0
          from ActiveState Tool Corp.
         http://www.ActiveState.com
***********************************************************

GUI interface debugger, looks just as any debugger, not that funny
default -d

ActiveState Perl DebuggerT is a lightweight yet powerful GUI debugger for
your perl scripts that lets you focus on the code.

Key Benefits
? Easy to use. Just run Perl with the -d option, and you're debugging!
? Zero Learning Curve. Whether you are familiar with popular GUI debuggers
or not, you will feel right at home with ActiveState Perl Debugger.
? Saves time. Remembers your settings, including breakpoints and bookmarks,
so that you can focus on your code.

Key Features
? Proximity Window. Displays scalar variables near the instruction pointer
so you can focus on what is relevant as you step through your code.
? Syntax Coloring. Single and double quoted strings, regular expressions,
comments, POD, and Perl key words are color coded to help you navigate your
script.
? Detailed Information. Call stack, list and hash dumps, several watch
windows, quick eval and conditional breakpoints let you get the information
you need.


-
But I've leard that under UNIX emac and vi editors can be configured so that
one could step through the code right in debugger, so we get so-called IDE,
but I never heard of such under windows. Maybe ActiveState guys someday
would embed an editor into that thing. I hope they will. Even sure of :)


--
Alexander Petrosyan (PAF), Moscow.
email: paf@design.ru; paf@i-connect.ru
web: http://www.design.ru/paf

Alan Silver wrote in message ...
>Alan Schwartz <alansz@araw.mede.uic.edu> wrote ...
>>I also love PFE. When using it with Perl, a handy thing is to tell
>>it that the "compile" command is "perl -cw". You can then
>>hit compile and watch another window pop up containing all your warnings,
>>etc., so you can fix up the code.
>
>Sounds good, where do we get it ?
>
>Alan
>
>
>NOTE - In order to discourage unsolicited e-mail, the address in the
>header may have .ferret added. Please remove this before replying.
>
>--
>
>Sent By   : Alan Silver
>Fish Page : http://www.geocities.com/Heartland/Hills/6749/fishtank.html
>
>It's not an optical illusion, it just looks like one



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

Date: Wed, 18 Mar 1998 10:46:44 -0800
From: mknutson@websolution.com (Mick Knutson)
Subject: Re: Are There Any Snazzy Perl Editors for Windows?
Message-Id: <MPG.f79b670625ec70b989689@news.greatbasin.net>

In article <6eoskc$150q$1@piglet.cc.uic.edu>, alansz@araw.mede.uic.edu 
says...
> Alan Silver  <alan@consultancy-services.ferret.com> writes:
> >Alan Schwartz <alansz@araw.mede.uic.edu> wrote ...
> >>I also love PFE. When using it with Perl, a handy thing is to tell
> >>it that the "compile" command is "perl -cw". You can then 
> >>hit compile and watch another window pop up containing all your warnings,
> >>etc., so you can fix up the code.
> >
> >Sounds good, where do we get it ?
> >
> >Alan
> 
>  http://www.lancs.ac.uk/people/cpaap/pfe/
> 
>  - The other Alan
> 
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>          Alan Schwartz                  | Disclaimer: I represent no one
>         <alansz@uic.edu>                |
> Asst. Prof. of Clinical Decision Making | Life is what happens to you while
> University of Illinois at Chicago       | you're busy making other plans
> Department of Medical Education         |          - J. Lennon
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> 
> 
I use Code Wright by Premia at www.premia.com
-- 

***************************************
* Mick Knutson
***************************************
*** Support Legal B.A.S.E. Jumping! ***
***************************************
*
* The B.A.S.E. Board *
* http://www.websolution.com/base/board/index.shtml
*
***************************************
*
* Add yourself to The B.A.S.E. Mailer at:
* http://www.websolution.com/base/mail/index.shtml
***************************************


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

Date: 18 Mar 1998 16:06:17 GMT
From: "Uwe Honekamp" <uwe.honekamp@etas.de>
Subject: Re: building for perl 5.004_04 on NT
Message-Id: <01bd5287$c0554c00$931a0180@fe13803>

> Mine is the one you can download from=20
> http://language.perl.com/CPAN/src/latest.tar.gz

I downloaded from the same source.

> Which Browser do you use?

Sorry, I didn't mention. It's Internet Explorer 3.02

> And please note I had a path        //F|/dir1/dir2/.../file.html.
> (Two slashes at the beginning)

I recently tried both cases and got no trouble.

Regards=20

Uwe

--

Uwe Honekamp * ETAS GmbH * Borsigstr. 10 * D-70469 Stuttgart =20
uwe.honekamp@etas.de * voice: ++49/(0)711/89661-143 * fax: -107



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

Date: Wed, 18 Mar 1998 16:34:12 +0000
From: Jim Smith <james-detg.smith@ubs.com>
Subject: Re: building for perl 5.004_04 on NT
Message-Id: <350FF783.F9FBDC2F@ubs.com>

Frank@but_dont_use_this.address wrote:

> Hello all,
>
> I'm trying to build perl 5.004_04 on NT 4.0 SP3.  I'm using the source
>
> - All links in the HTML version of the doc were "broken". I suspect
> <snip>



> like: //F|/dir1/dir2/.../file.html. This is a syntax not familar to me

This is standard syntax for accessing local files rather than from a
server. I have had problems with the case of filenames on PC filesystems,
although VFAT (which is how FAT supports long filenames) usually preserves
the correct case.

--

Jim Smith



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

Date: Wed, 18 Mar 1998 15:57:55 GMT
From: Sneex <chasecreek.systemhouse@usa.net>
Subject: Re: Changing password & security issue
Message-Id: <350FEDA9.635CB3B3@usa.net>

At www.perl.com search on keyword security, you will see a program I wrote
(actually two) called WebPass.
Also, if you have 5.004x installed you can use the Perl Module call Expect
v1.04 to help you do the same thing as my Web Pass program(s) and you
won't need to install the TCL Expect system...

HTH,
Sneex :-)


Baher M. Safwat wrote:

> I already have written a cgi script to make users able to change their
> passwords via a web page
>
> my OS is Solaris 2.5.1 and I am using a netscape enterprise server
> I want an advise for solving that security issue
> the default user that use the cgi script is "nobody" who has no
> permission even to read "/etc/shadow" to check the old password first
> and of course no permission to write the new one back!
>
> one  suggest - I really do not like -  is to change that default user
> to become the "root" user, but that may create a security holes in the
> future.
>
> can anyone advise me , what is the practical solution?
> I want to facilitate users work with avoiding destroying my whole
> system
>
> thanks in advance
>
> Baher M. Safwat
> Egypt Online
> http://www.egyptonline.com





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

Date: Wed, 18 Mar 1998 13:48:01 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Chicago Perl Mongers
Message-Id: <comdog-ya02408000R1803981348010001@news.panix.com>
Keywords: from just another new york perl hacker

In article <6emtil$22k$1@usenet76.supernews.com>, petdance@maxx.mc.net (Andy Lester) posted:

>: it's about time to set up a group in Chicago. I've made tentative
>: contact with a couple people, but now I'm officially announcing my
>: intent. All you Windy City Perl M(o|u)ngers interested in participating,
>
>You didn't mention the donuts and dancing girls.  How do you expect us to
>get any members if you don't?  Duh.
>
>DONUTS AND DANCING GIRLS!  At EVERY meeting!

that's what works for NY.pm at least.  i think Randal even has a 
picture worthy of extortion and blackmail.

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>


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

Date: Wed, 18 Mar 1998 13:50:52 -0500
From: Matthew MacGibbon <matt@corp.airmedia.com>
Subject: compiling perl
Message-Id: <3510178C.5F0F@corp.airmedia.com>

I remember a while back someone had come up with something that allowed
you to create an executable from a perl script.  Does anyone know
anything about that?  (or a perl 2 c converter?)


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

Date: Wed, 18 Mar 1998 17:11:37 -0000
From: "Fish" <fish@civl.port.ac.uk>
Subject: creating directories with cgi
Message-Id: <6eov6s$t443@tech.port.ac.uk>

Please excuse my ignorance but...

I am trying to create a directory in a Web space from a cgi Perl script. Can
I do this? I have tried using mkdir commands in the script using values
returned from a form but I feel I am missing the point. Any advice please?
It would be much appreciated. Thanks in advance.

Fish




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

Date: 18 Mar 1998 11:18:06 -0600
From: Quentin  Fennessy <quentin@jihad.amd.com>
Subject: Re: Dynamically checking for existing functions
Message-Id: <ximemzzc3zl.fsf@jihad.amd.com>


>>>>> "AML" == Andrew M Langmead <aml@world.std.com> writes:

    AML> This has the side effect of calling the subroutine. (whether
    AML> that matters or not depends on what coder() does.) Also, eval
    AML> STRING is an expensive call in terms of execution speed.

    AML> The other suggestion of using "defined &coder" (to use your
    AML> example name) only involves a symbol table lookup, and
    AML> doesn't actually call the subroutine to check for its
    AML> existance.  -- Andrew Langmead

Thanks, Andrew.  I missed that.  So you can check if a subroutine
exists like this:

	print "found\n" if defined(&coder);

-- 
Quentin Fennessy			AMD, Austin Texas

Secret hacker rule #11 - hackers read manuals


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

Date: 18 Mar 1998 11:37:09 -0500
From: hallm4@cortez.sss.rpi.edu (Agent Hall)
Subject: Fastest way to grep through a file?
Message-Id: <6eot7l$6cus@cortez.sss.rpi.edu>

I have a small program that has to open up several text data
files, and search through them for a particular string, and
return the number of times it sees the pattern.

@data = <FILE>; # slurp!
$count = grep /$pattern/, @data;

seems rather slow. the files are all about 20K, so any speed
improvements i make will show.

while(<FILE>) {
 $count++, if /$pattern/;
} 

is another way i've thought of. i assume since memory is faster than
disk access, that perhaps reading it all in at once, and then doing 
a search on the data would be faster. as opposed to reading a line,
searching it, reading a line, etc.

i'm just looking for some better methods to get the # of times the pattern
string appears (once per line)...

thanks!

Just another Perl newbie.


-- 
Become an arms trafficker! -export-a-crypto-system-sig -RSA-3-lines-PERL
#!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
$/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=pack('H*',/((..)*)$/)


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

Date: Wed, 18 Mar 1998 10:10:22 -0800
From: "Ron Aaron" <ron@mrrrossbayeng.com>
Subject: Re: Fastest way to grep through a file?
Message-Id: <6ep2p1$ad4@news.microsoft.com>


Agent Hall wrote in message <6eot7l$6cus@cortez.sss.rpi.edu>...
>I have a small program that has to open up several text data
>files, and search through them for a particular string, and
>return the number of times it sees the pattern.
>
>@data = <FILE>; # slurp!
>$count = grep /$pattern/, @data;
>


How about:
    @counts = `grep -c $filelist`;

would give you an array of filename:count values, and grep is quite fast




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

Date: 18 Mar 1998 18:41:32 GMT
From: lvirden@cas.org
Subject: Re: Good Perl book
Message-Id: <6ep4gs$19f$1@srv38s4u.cas.org>


According to Art Cohen  <upsetter@shore.net>:
:I wouldn't consider "Learning Perl" to be dry... (Or "Programming Perl" 

I did have an interesting exchange in the past week about LP though.
An acquaintence was taking a class and LP was one of the resources
provided (along with hard copy of the online doc and a copy of the
teacher's slides).  There were some labs given by the teacher, and
the acquaintence was ticked when they tried to use LP to look up
some particular function to see how it was used - I don't recall which
function, but which ever it was had a mention in LP but no example of
how it would be used in code.  Trying to locate that kind of info in
a _printed_ copy of the online doc is also pretty difficult, since there's
no general index to tell you what reference section things are in, etc.

I suspect that PP would have given the student the info that was needed -
however, that wasn't one of the options provided.

The reason I bring this up is that folk learning perl need to think about
keeping some reference material handy as well.

Anyone written something similar to the perl reference 'card' for the
CPAN library?


-- 
<URL:mailto:lvirden@cas.org> Quote: In heaven, there is no panic,
<*> O- <URL:http://www.teraform.com/%7Elvirden/> only planning.
Unless explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.


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

Date: 18 Mar 1998 16:03:19 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: grep on hashes
Message-Id: <6eor87$sdf$1@client3.news.psi.net>

Christopher Lambrou (hold@cglis.com) wrote on MDCLX September MCMXCIII in
<URL: news:01bd521c$c7fde8b0$a66f6420@akis>:
++ Hello,
++ I want to count the number of keys in a hash array
++ that are equal to a value, say 'foo'.
++ 
++ So I said, assuming %a to be the hash in question:
++ 
++ @count = grep {$_ eq 'foo'} %a;
++ $count = $#count + 1;
++ 
++ This works(?) but is this the best way to do this?

No, as it can produce the wrong value. (bar => 'foo') doesn't
have any keys equal to 'foo', yet you get a count of 1.

This is efficient: $count = exists $a {foo} ? 1 : 0;

++ The Camel book does not mention anything
++ about using hashes with 'grep'.

If, by any chance, you would like to count the number of times
'foo' occurs as value, then consider 2 things. First, grep in
scalar context returns the number of matches, so there's no
need for creating the array. Second, use the function 'values':

$count = grep {$_ eq 'foo'} values %a;



Abigail
-- 
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'


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

Date: Wed, 18 Mar 1998 12:02:13 -0500
From: "I have a life, and I can prove it!" <jefpin@bergen.org>
To: Christopher Lambrou <hold@cglis.com>
Subject: Re: grep on hashes
Message-Id: <Pine.SGI.3.95.980318115928.11548A-100000@vangogh.bergen.org>

>@count = grep {$_ eq 'foo'} %a;
>$count = $#count + 1;

Better to do:
$count = scalar( grep { $_ eq 'foo' } %a );

question: why does the %a there only check the keys, and not the values as
well?

--
| I only please one person a day, and today ain't your day...
| (tomorrow's not looking good either!)

    Jeff Pinyan | http://users.bergen.org/~jefpin | jefpin@bergen.org
             techmaster@bergen.org | techmaster@mindless.com
                qw[jeff] on #perl,#javascript,#cgi on IRC

 &jp('"($``','','$)EDF8```','$*52J4```','$+E1G4```','#J``@','#2__`');sub
jp{for$w(@_){$c=unpack('B48',unpack('u',$w));$c=~tr/10/# /;print "$c\n"}}



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

Date: 18 Mar 1998 13:21:54 -0500
From: Uri Guttman <uri@sysarch.com>
To: "I have a life, and I can prove it!" <jefpin@bergen.org>
Subject: Re: grep on hashes
Message-Id: <x7ogz3j1vh.fsf@sysarch.com>

"I have a life, and I can prove it!" <jefpin@bergen.org> writes:

> >@count = grep {$_ eq 'foo'} %a;
> >$count = $#count + 1;
> 
> Better to do:
> $count = scalar( grep { $_ eq 'foo' } %a );
> 
> question: why does the %a there only check the keys, and not the values as
> well?

because it doesn't! so it is wrong.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire  ----  8 Years of Perl Experience, Available Immediately
uri@sysarch.com  ---------  Resume and Perl Example at http://www.sysarch.com
Use the Best Search Engine on the Net  --------  http://www.northernlight.com


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

Date: 18 Mar 1998 17:00:00 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: help: s?\s[a-z][sd]t\s[12][90]? ? doesn't remove 19.
Message-Id: <slrn6gvvcg.nja.Tom.Grydeland@mitra.phys.uit.no>

On Wed, 18 Mar 1998 09:14:31 -0500,
parv <mail-me@psu.edu> wrote:
> - my actual address is hyphen free -

Then you should've written it like that in the header.

> why doesn't the following code prints the year w/o 19?

>   $time =~s?\s[a-z][sd]t\s[12][90]? ? ; # should remove, e.g., ' EST 19'

because E isn't part of [a-z] unless you've asked for case insensitive
matching.  Add /i to taste.

> - anu

-- 
//Tom Grydeland <Tom.Grydeland@phys.uit.no>


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

Date: Wed, 18 Mar 1998 16:28:17 +0000
From: Jim Smith <james-detg.smith@ubs.com>
Subject: How to populate a 2D array from a file.
Message-Id: <350FF620.3824894B@ubs.com>

 I am just getting started with Perl and have hit what must be a common
problem.

I want to display football league tables of the form "Team Pl W L D For
Ag Pts". For the purpose of passing into the display subroutine I have
defined a table as an array of references to arrays.

Doing this manually (ex 1) works fine.

Ex 1
$tab[0]=["Rangers",25,20,3,2,57,37,80];
$tab[1]=["Celtic",25,20,3,2,57,37,79];
$tab[2]=["Hearts",25,20,3,2,57,3,78];
$tab[3]=["Kilmarnock",25,20,3,2,5,37,77];
$tab[4]=["Hibernian",25,20,3,2,57,37,76];

&DisplayTable(@tab);

However trying to populate the array from a file (ex 2) doesn't work
because each reference always points to the same area of memory.

Ex 2

open(TABLE,"<spl.dat");
$i=0;
while ( <TABLE> ) {
 @ar=split(/,/);
    $tab[$i]=\@ar;
    $i++;
    #undef @ar;
}
close TABLE;

I had thought that undef'ing the @ar variable each time would force the
allocation of new memory for each invocation but it doesn't, it just
undef's it resulting in a blank display. (I would have thought that the
fact that a reference to the variable existed would stop it being
cleared out).

I can think of various workarounds in this situation, but as a general
problem it must be fairly common. What is the perl solution to this? (I
suppose I _should_ say "what are the perl solutions?"

TIA
--
Jim Smith



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

Date: Wed, 18 Mar 1998 12:13:36 -0500
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: How to populate a 2D array from a file.
Message-Id: <1d6355y.1v6nms01jvlm38N@slip166-72-108-185.ny.us.ibm.net>

Jim Smith <james-detg.smith@ubs.com> wrote:

> However trying to populate the array from a file (ex 2) doesn't work
> because each reference always points to the same area of memory.
> 
> Ex 2
> 
> open(TABLE,"<spl.dat");
> $i=0;
> while ( <TABLE> ) {
>  @ar=split(/,/);
>     $tab[$i]=\@ar;
>     $i++;
>     #undef @ar;
> }
> close TABLE;
> 
> I had thought that undef'ing the @ar variable each time would force the
> allocation of new memory for each invocation but it doesn't, it just
> undef's it resulting in a blank display. (I would have thought that the
> fact that a reference to the variable existed would stop it being
> cleared out).

#!perl -w

open TABLE, "<spl.dat" or die "Open failed: $!";

$i = 0;
while (<TABLE>) {
  chomp;
  $tab[$i++] = [split /,/]; # 2nd [] is anonymous array.
}
close TABLE;

# just to prove that it works
print join ";\n", map {join ":", @$_} @tab;

-- 
  Kevin Reid.      |         Macintosh.
   "I'm me."       |      Think different.


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

Date: Wed, 18 Mar 1998 17:58:52 GMT
From: bet@network.rahul.net (Bennett Todd)
Subject: Re: How to populate a 2D array from a file.
Message-Id: <slrn6h038h.52r.bet@ritz.mordor.net>

1998-03-18-16:28:17 Jim Smith:
>However trying to populate the array from a file (ex 2) doesn't work
>because each reference always points to the same area of memory.

Here are a couple of reasonable choices.

Use a lexically local variable (with "my"):

	while (<TABLE>) {
		my(@ar) = split /,/;
		push @tab, \@ar;
	}

Better still, just enclose the results of split in an anonomous array:

	while (<TABLE>) {
		push @tab, [ split /,/ ];
	}

Then use map and this can degenerate to a one-liner; perhaps

	@tab = map { [ split /,/ ] } IO::File->new("<spl.dat")->getlines;

(untested). That could be shorter with backticks, but I don't like the extra
cat(1) process required:

	@tab = map { [ split /,/ ] } `cat spl.dat`;

Depending on how you're expecting to process this goo you might end up happier
if you get a chomp into the game as well, to lose the newlines. Might even
want to do some whitespace canonicalizing. Maybe

	@tab = map { [ map { s/\s+// } split /,/ ] } `cat spl.dat`;

(again, untested).

-Bennett


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

Date: Wed, 18 Mar 1998 11:08:11 -0600
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
Subject: Re: How to use "@" literally in perl scripts
Message-Id: <350FFF7B.690D2A11@houston.Geco-Prakla.slb.com>

Hiren Shah wrote:
> 
> Hello,
> 
> I've been trying to write a program that would autorespond on completion
> of a web-based form. I would like to put my email address in the
> auto-response message. How do I include "@" sign in the message ?
> 
Type it in?

Is perl giving some kind of error?  How about a code snippet?  Maybe you
should post to comp.lang.perl.psychics?  

I digress.

perl -w should give a warning about @ must be escaped, if you are using
the -w switch, and put your email address as:
$address = "barnett@houston.Geco-Prakla.slb.com";

If you enter it as:
$address = 'barnett@houston.Geco-Prakla.slb.com';

perl will not complain.

Is that what you meant?

> Thanks.
> 
> Hiren

Dave

-- 
"Security through obscurity is no security at all."
		-comp.lang.perl.misc newsgroup posting

------------------------------------------------------------------------
* Dave Barnett               U.S.: barnett@houston.Geco-Prakla.slb.com *
* DAPD Software Support Eng  U.K.: barnett@gatwick.Geco-Prakla.slb.com *
------------------------------------------------------------------------


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

Date: 18 Mar 1998 17:50:06 GMT
From: murple@erols.com
Subject: Re: How to use "@" literally in perl scripts
Message-Id: <6ep1ge$1ij$1@winter.news.erols.com>

Hiren Shah <hiren@clam.rutgers.edu> scribbled:
: I've been trying to write a program that would autorespond on completion
: of a web-based form. I would like to put my email address in the
: auto-response message. How do I include "@" sign in the message ? 

print "username\@host.tld";

Escape the @ with a backslash.


-- 

    .-'~~~-.        Craig Schenk
  .'o  oOOOo`.      <murple@erols.com>
 :~~~-.oOo   o`.    
  `. \ ~-.  oOOo.
    `.; / ~.  OO:
    .'  ;-- `.o.'
   ,'  ; ~~--'~     "The opposite of a correct statement is a false
   ;  ;             statement. But the opposite of a profound truth
_\\;_\\//_          may well be another profound truth." -Niels Bohr


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

Date: 18 Mar 1998 15:53:15 GMT
From: lvirden@cas.org
Subject: Re: How to use CPAN modules/no permission to install
Message-Id: <6eoqlb$o97$1@srv38s4u.cas.org>


According to Andreas Laufer  <laufera@ruf.uni-freiburg.de>:
:> How can I install and use perl modules which have in the readme the
:> lines
:> perl Makefile.PL
:> make
:> make test
:> make install
:> when I have only a cgi-bin on a machine with perl5 but neither root
:> access nor a telnet access, only ftp ?

If by some strange likelihood you have the same hardware and OS as
your ISP has, build a version of perl configuring it identially to
the way your ISP has configured, then for each package above, go thru
the above steps watching carefully where things are installed.  Then
ftp each piece into the appropriate directory.

It seems highly unlikely that you will have the combination of permissions and
hardware/software needed to do this.

So it's my believe the answer to your question is - you can't get
build the modules.  So you will have to pay your ISP (or find
someone on the site who has the proper permissions) to build what
you need .

If that's not possible, then it's time to look for a different ISP.

-- 
<URL:mailto:lvirden@cas.org> Quote: In heaven, there is no panic,
<*> O- <URL:http://www.teraform.com/%7Elvirden/> only planning.
Unless explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.


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

Date: 18 Mar 1998 18:17:18 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: Is there a "Newsgroup" for Newbies to Perl?
Message-Id: <6ep33e$hkj@mozo.cc.purdue.edu>

a-bnc@microsoft.com (Nicholas Carey) writes:
}On Fri, 13 Mar 1998 22:37:48 -0600, rasta@spacestar.net wrote:
}>People with some compassion would monitor a newbie group to help
}>out people who are having a hard time understanding...

}What's in it for people to do so?

"Look, ma, my name in lights!"

}That's all that's being asked of people -- do a little research before
}asking questions.

I find it refreshing that there are still people who still belive it
could work.

Maybe comp.lang.perl.help isn't the answer, but neither is expecting
people to listen to yet another cry of "use the resources."  It's just
not working or even having an effect on the endless parade of moronic
questions.

The unfortunate side effect is that even the "not moronic, just
seriously misguided" questions get heavy flames these days, scaring
off people who actually tried to use resources.

-- 
Mike Gebis  gebis@ecn.purdue.edu  mgebis@eternal.net


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

Date: Wed, 18 Mar 1998 10:41:14 -0800
From: mknutson@websolution.com (Mick Knutson)
Subject: Optimizing a Perl Sendmail routine?
Message-Id: <MPG.f79b52440793b42989688@news.greatbasin.net>

I create an array of 250 addresses and the use a for loop to create a 
Bcc. to each address.
Is there a qucker, more efficient way to send an e-mail to a large list 
of users?

Also, how can I add Posting ability to an NNTP news group from this 
routine?

-- 

***************************************
* Mick Knutson
***************************************
*** Support Legal B.A.S.E. Jumping! ***
***************************************
*
* The B.A.S.E. Board *
* http://www.websolution.com/base/board/index.shtml
*
***************************************
*
* Add yourself to The B.A.S.E. Mailer at:
* http://www.websolution.com/base/mail/index.shtml
***************************************


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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 V8 Issue 2126
**************************************

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