[9020] in Perl-Users-Digest
Perl-Users Digest, Issue: 2638 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 19 11:08:08 1998
Date: Tue, 19 May 98 08:00:30 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 19 May 1998 Volume: 8 Number: 2638
Today's topics:
Re: CGI editors for windows <dfetter@shell4.ba.best.com>
Connected users on a NT-Server <aej@md-oss.dk>
Re: Does Perl have a IDE?I don't like command line. (Greg Bacon)
Re: Does Perl have a IDE?I don't like command line. (Leslie Mikesell)
Dowload Script Problem <alan_k'necht@canadalife.com>
Re: From Linux/perl to MS SQL <arturcz@kerigma.cyf.gov.pl>
join two array <natoofi@alborz.dac.neu.edu>
Re: join two array (Mike Stok)
Re: New IDE for Perl (robert)
Perl for Windows is important, and comments on COM and <steve.tolkin@fmr.com>
Re: Perl/Wall lingo question (Wayne C. McCullough)
Re: Perl/Wall lingo question (John Porter)
Re: Perl/Wall lingo question <thor@eznet.net>
Re: Progress 4GL and Perl DBD/DBI (Jeff Kalchik)
Re: Question: Is Perl an acronym? (Wayne C. McCullough)
Re: regexp: replacing new line followed by "+" (Mark-Jason Dominus)
Re: Something like "Visual Perl"? (Mark Maurer)
Re: Something like "Visual Perl"? scott@softbase.com
Re: Something like "Visual Perl"? <brians@meetingbywire.com>
Re: Tip: How to access a hash through a pointer <fty@utk.edu>
Re: translate A-Z to 1-26 (Mark-Jason Dominus)
Using @$array_name zbrown@lynx.neu.edu
Re: Using @$array_name (Mike Stok)
Re: while, each & assoc array (John Porter)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 19 May 1998 13:53:13 GMT
From: David Fetter <dfetter@shell4.ba.best.com>
Subject: Re: CGI editors for windows
Message-Id: <6js2s9$mh3$1@nntp1.ba.best.com>
Adam Klein <a_klein@ix.netcom.com> wrote:
> Is there any good editors for writing CGI in windows. Something
> that easily organizes all the subs like a visual basic interface? I
> am really frustrated with programming in notepad.
Get emacs for windows :)
HTH,
David.
--
David Fetter 888 O'Farrell Street Apt E1205
shackle@ren.glaci.com San Francisco, CA 94109-7089 USA
http://www.best.com/~dfetter +1 415 567 2690 (voice)
print unpack ("u*",q+92G5S="!!;F]T:&5R(%!E<FP@2&%C:V5R"@``+)
There is this special biologist word we use for 'stable'. It is 'dead'.
Jack Cohen
------------------------------
Date: Tue, 19 May 1998 15:01:08 +0200
From: "Arne Jaeger" <aej@md-oss.dk>
Subject: Connected users on a NT-Server
Message-Id: <6js6lr$5b0$1@mdtyr.oss.dk>
Does anybody know of some routines to get all the usernames currently
connected to a given NT-Server ?
I need it to send a message from a script, but only if a user have an active
connection to a given server.
Thanx
Hunter
------------------------------
Date: 19 May 1998 13:36:02 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <6js1s2$6km$1@info.uah.edu>
In article <6jpr6c$dsp@mozo.cc.purdue.edu>,
gebis@albrecht.ecn.purdue.edu (Michael J Gebis) writes:
: gbacon@cs.uah.edu (Greg Bacon) writes:
: }What of Tk? Tk code will run on many, many, many more platforms than
: }the hoarde fodder will.
:
: I think you mean, "What of SpecTCL, the tool that allows you to do Tk
: GUI design, since Tk itself does nothing to alleviate the problem
: mentioned."
Unless SpecTCL will generate Perl code, no, I most certainly didn't mean
SpecTCL. I've used Tcl. Tcl sucks. (Hi, orwant! :-) I was referring
to Perl/Tk.
Greg
--
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF
------------------------------
Date: 19 May 1998 09:41:44 -0500
From: les@MCS.COM (Leslie Mikesell)
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <6js5n8$1aq$1@Jupiter.Mcs.Net>
In article <6jq9p0$bh3$1@client3.news.psi.net>,
Abigail <abigail@fnx.com> wrote:
>++
>++ Postgresql is a nice free nearly-complete (lacks HAVING and a
>++ few other things) SQL database: http://www.postgresql.org. It
>++ is actively supported and has a recently updated ODBC driver
>++ that allows access from MS-windows.
>
>
>That's a nice toy, but in a different league then sometimes is required.
>Yes, I'm aware of all the nice free things. Some of them are wonderful.
>I've nothing against free software, in fact, I'm pro-free software.
>But just because Sybase and Postgresql are both RDBSs doesn't mean
>one can replace the other.
Where would you draw the line between trying Postgresql and going
with Sybase/Oracle, etc.? The main problem I see is that Postgresql
doesn't have a built-in way to log transactions to alternate media
between backups or to replicate among multiple servers so you are
only as reliable as your hardware. But, as long as we are talking about
perl you can have the client log the important stuff.
Les Mikesell
les@mcs.com
------------------------------
Date: Tue, 19 May 1998 13:46:01 GMT
From: Alan K'necht <alan_k'necht@canadalife.com>
Subject: Dowload Script Problem
Message-Id: <35618D42.3A883AFB@canadalife.com>
I'm trying to setup up a page that will allow a user to download files
based on their selection from a pull down menu. The problem that I'm
having is that when the file is selected and about to be downloaded, the
filename displayed in the "Save as..." dialog box is the name of the
CGI.
My FORM looks something like this:
<FORM METHOD="POST" ACTION="/cgi-bin/download.pl" TARGET="_top">
<INPUT TYPE="Hidden" NAME="indexpage">
<SELECT NAME="selection">
<OPTION VALUE="/path_to_file1">File 1
<OPTION VALUE="/path_to_file2">File 2
</SELECT>
<INPUT TYPE="SUBMIT" VALUE="GO">
</FORM>
In my CGI:
$selection = $in{'selection'};
print "Location: $selection\n\n";
I've printed out the variable $selection and know that it is the name of
the file the user wants to download.
Any ideas?
------------------------------
Date: 19 May 1998 14:35:35 GMT
From: "Artur R. Czechowski" <arturcz@kerigma.cyf.gov.pl>
Subject: Re: From Linux/perl to MS SQL
Message-Id: <6js5bn$7db$1@kerigma.cyf.gov.pl>
Hello
Some lame question...
> Go to http://www.brodeur.com/~pjacob/dbdsybase/
There are:
SERVER_NAME
query tcp eth0 123.123.123.123 5000
master tcp eth0 123.123.123.123 5000
How can I determine port on which SQL-Server is listening?
Is the value 5000 any standard? Where I can found something about it?
I've got now only msSQL Server REsource Guide and I didn't fount anything...
Regards
--
Artur R. Czechowski <arturcz@kerigma.cyf.gov.pl>
See http://pgp.icm.edu.pl/pks/ for PGP public key
http://kerigma.cyf.gov.pl/~arturcz/
------------------------------
Date: Tue, 19 May 1998 08:34:42 -0400
From: <natoofi@alborz.dac.neu.edu>
Subject: join two array
Message-Id: <Pine.LNX.3.96.980519082314.5551I-100000@alborz.dac.neu.edu>
Hello everyone:
I ran to a Mental block. Did this before, can not remember how?!!!
I have two, two demensional array(@DataInArray,@DataOutArray)
with the 2000 set of entery on the following format respectively:
$Time $ODist $ODeltaYY $ODeltaX $ODeltaY
$Time $IDist $IDeltaYY $IDeltaX $IDeltaY
I want to join them together and for one two demensional array with the
following members
($Time, $ODist,$ODeltaX,$ODeltaY,$IDist,$IDeltaX,$IDeltaY)
" I guess we call it cross referencing them with $Time.
Thnak you
Navid
------------------------------
Date: 19 May 1998 14:27:50 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: join two array
Message-Id: <6js4t6$jno@news-central.tiac.net>
In article <Pine.LNX.3.96.980519082314.5551I-100000@alborz.dac.neu.edu>,
<natoofi@alborz.dac.neu.edu> wrote:
>I have two, two demensional array(@DataInArray,@DataOutArray)
>with the 2000 set of entery on the following format respectively:
>$Time $ODist $ODeltaYY $ODeltaX $ODeltaY
>$Time $IDist $IDeltaYY $IDeltaX $IDeltaY
>I want to join them together and for one two demensional array with the
>following members
>
>($Time, $ODist,$ODeltaX,$ODeltaY,$IDist,$IDeltaX,$IDeltaY)
>
>" I guess we call it cross referencing them with $Time.
One way you can do it is to use a hash whose key is $time e.g. (untested
code alert :-)
%hash = ();
foreach $out (@DataOutArray) {
$Time = $out->[0];
@{$hash{$Time}}[0, 1, 2] = @{$out}[1, 3, 4];
}
foreach $in (@DataInArray) {
$Time = $in->[0];
@{$hash{$Time}}[3, 4, 5] = @{$in}[1, 3, 4];
}
# assuming times are numericaly sortable, maybe you don't mind the order
@result = ();
foreach $Time (sort {$a <=> $b} keys %hash) {
push @result, [$Time, @{$hash{$Time}}[0 .. 5]];
}
This may not be the most efficient or compact way of doing it, but I hope
that it helps you think of ways to do it. If it runs too slowly or
consumes too much memory then there are other ways to do it.
Hoep this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: 19 May 1998 16:14:45 +0200
From: robert@il.fontys.nl (robert)
Subject: Re: New IDE for Perl
Message-Id: <6js44l$7se@bsd1.ilse.net>
smcdow@arlut.utexas.edu (Stuart McDow):
>Ed is the standard text editor.
Syeah, right! Back in the old days, working on a Matrix I, our researchlab
got a new woven-core card with an amazing new program called 'cat' (the
actual name of the program comes from the woven-core pattern resembling a
cat...don't believe the people who say it stems from the word 'concatenation'!)
Now this was an editor which blazed! There wasn't an actual use for it,
since the Matrix I was programmed via paper cards, but 'cat' still amazed
the hell out of us.
And now, after so many years, I can (and do!) still use 'cat' as my editor:
matrix:~$ echo $EDITOR
cat
matrix:~$
I just love it to death...
robert
------------------------------
Date: Tue, 19 May 1998 09:56:53 -0400
From: Steven Tolkin <steve.tolkin@fmr.com>
Subject: Perl for Windows is important, and comments on COM and CPAN
Message-Id: <35618FA3.5FBD2947@fmr.com>
Perl is the best language that I have programmed in (so far).
It is important to me, and I believe to the Perl community,
that it be well supported on Windows.
In particular Perl should facilitate writing COM clients and services.
I want to thank Gurusamy Sarathy and others for the Windows port.
This let me code in Perl a (non-GUI) client program that uses COM.
I had to use COM because that was the only API provided by the vendor
of the software package my company is using.
The vendor provided only a COM API even though all the functionality
(except the GUI) of the product is provided on a Unix server. Why?
The standard way for the GUI to call the "worker" functions is using
COM.
So the most natural API to expose is that very same COM API.
Among the benefits to the vendor is that only one API is needed.
Among the benefits to me, the caller, is that I found no bugs.
I was using the same code paths that were well exercised by the GUI.
A separate API (on UNIX) could have introduced new bugs.
Using Perl for this was far far better than Visual Basic or VBA.
The other alternatives were even worse: C, C++, or Java.
The problem with Java is getting locked in to Microsoft's virtual
machine,
because Sun's is sufficiently purist to disallow calling a COM function.
P.S. CPAN cannot even be installed on Windows 95.
This is documented -- it says CPAN is for Unix only.
This is quite unfortunate in that it prevents Windows users from easily
downloading modules, even those that do not require make or a C
compiler.
I did not notice this important fact in all the recent flame wars on
CPAN and Windows (but I did not read every item).
It would be better if CPAN/FirstTime.pm checked the OS and
quickly gave a message saying e.g. "Windows is not supported".
Now it asks the user a bunch of questions and then just fails badly.
It would be even better if a subset of the CPAN functionality did
install on Windows,
and that modules could express their tool dependencies so that CPAN
would later
respond e.g. "sorry -- that package requires a C compiler but none is
configured.....)"
Best would be if CPAN suggested downloading gcc and Gnu make, etc.
P.P.S. While perl may not be the best first languge to learn
programming I found it to be the best language to teach first graders
*about* programming. (I had 45 minutes.) I assumed that none had even
seen a program, and used analogies such as a program is like a game
(there are rules), is like a recipe card etc. Having a $ in front of
variable names made it easier for me to introduce the concept of a
variable.
Hopefully helpfully yours,
Steve
---
Steven Tolkin steve.tolkin@fmr.com 617-563-0516
Fidelity Investments 82 Devonshire St. R27C Boston MA 02109
There is nothing so practical as a good theory. Comments are by me,
not Fidelity Investments, its subsidiaries or affiliates.
------------------------------
Date: 19 May 1998 13:35:14 GMT
From: wayne@Glue.umd.edu (Wayne C. McCullough)
Subject: Re: Perl/Wall lingo question
Message-Id: <6js1qi$uog$1@hecate.umd.edu>
Mark-Jason Dominus (mjd@op.net) wrote:
: I don't think it's wise to try to take the craft parts out of
: something as craft as computer programming. Sure, there's a lot of
: theory there; that doesn't mean there's no involvement with actual
: computers.
My point is that much of "Computer Science" has diverged from
computers. It is now a set of mathematics that has sprung from the
math that was usefull several years ago for the understanding of
how computers work. Yes, occasionally they do produce something
interesting. But when was the last time you used graph theory
to write a program?
Programming is not computer science. Computer science is not programming.
Programmers have learned from computer science, and vice versa. Learning
computer science may help you become a better programmer. But to really
learn how to program, you need to program.
And to answer Tom's question, an "IT Professional" (or most "software
engineers") are either burecrats or managers unless they get technical.
(ie, they write code.) Or they are technicians doing things by route,
and showing less creativity, basic understanding of the things they work
on, and experiance than a fresh out of school jiffy-lube car maitnance
worker. (sorry. sys-admin gripes. never mind.)
W
------------------------------
Date: Tue, 19 May 1998 14:38:05 GMT
From: jdporter@min.net (John Porter)
Subject: Re: Perl/Wall lingo question
Message-Id: <MPG.fcb64d6d559ff889896d0@news.min.net>
On 18 May 1998 22:27:23 -0400,
in article <6jqqmb$env$1@monet.op.net>,
mjd@op.net (Mark-Jason Dominus) wrote:
>
> In article <6jqidb$gu5$1@csnews.cs.colorado.edu>,
> Tom Christiansen <tchrist@mox.perl.com> wrote:
> >
> > "Computer Science is no more about computers than astronomy
> > is about telescopes." --E.W. Dijkstra
>
> My reaction to that is the same as the first time I heard you quote it:
>
> 1. Dijkstra is full of shit as usual.
> 2. And he doesn't know much about astronomy!
I guess we know what Edsger meant, but the words in this quote
aren't saying that CS isn't about computers, nor that astronomy
isn't about telescopes. To paraphrase:
Astronomy is at least as much about telescopes
as computer science is about computers.
Says exactly the same thing, but sounds a whole lot different!
John Porter
------------------------------
Date: Tue, 19 May 1998 08:32:24 -0400
From: thor <thor@eznet.net>
Subject: Re: Perl/Wall lingo question
Message-Id: <35617BD8.F3DB3C07@eznet.net>
Tom Christiansen wrote:
> A very large program is bogging down the computer and management
> wants to know why, so sets three different employees to solve
> the problem.
>
> The computer scientist analyses the program's algorithm and
> reduces it from cubic to logarithmic.
>
> The computer engineer finds nothing with his oscilloscope
> so decides to install more swap space.
>
> The IT professional goes down to CompUSA and asks whether
> there's a Microsoft Service Pack for this yet.
meanwhile...
The contract systems engineer (unix geek) renices the
offending process into la-la land and not-so-politely
chastizes the idiot who wrote/compiled/ran the job
in front of above mentioned management.
"by the way, here's my timesheet."
thor
god of thunder
------------------------------
Date: Tue, 19 May 1998 13:55:17 GMT
From: jeff_kalchik@spammenot.mw.3com.com (Jeff Kalchik)
Subject: Re: Progress 4GL and Perl DBD/DBI
Message-Id: <35618ee6.854373@news.usr.com>
On Tue, 19 May 1998 01:15:52 GMT, ptf@cybertours.com (Phil Freed)
wrote:
>Has anyone created a DBD/DBI interface to the Progress 4GL? Failing
>that, has anyone done anything clever (aside from the obvious "open a
>pipe from the 4GL" or "open the 4GL from a pipe")?
>
>I'm betting that we can write something nice to work with Webspeed -
>but I hate to reinvent the wheel.
>
>Thanks in advance for your comments.
I'd like to see this too. Because I don't have a copy of ESQL on my
platform, I've been tinkering with a Perl module that executes
progress queries via a system call.
If you're interested, I can email you a copy.
-------------------------
Jeff Kalchik
3Com
Views expressed are my own; not necessarily my employers.
------------------------------
Date: 19 May 1998 13:40:04 GMT
From: wayne@Glue.umd.edu (Wayne C. McCullough)
Subject: Re: Question: Is Perl an acronym?
Message-Id: <6js23k$uog$2@hecate.umd.edu>
Lloyd Zusman (ljz@asfast.com) wrote:
: wayne@Glue.umd.edu (Wayne C. McCullough) writes:
: > Lloyd Zusman (ljz@asfast.com) wrote:
: > : And to the best of my knowledge, the "Practical Extraction and
: > : Reporting Language" acronym was *not* the first one back-fitted by
: > : Larry Wall. As early as 1988, I recall seeing his mention of another,
: > : possibly more appropriate acronym in the Perl man pages.
: >
: > Yes, but he told you (in the man page) not to tell anyone he said that.
: True ... I had forgotten about that. But then again, now that I think
: about it, I vaguely recall a smiley after that admonishment ... or is
: that just wishful thinking?
I haven't decided. I am just afraid of Larry's wrath when he becomes
a vengefull god and makes me code in cobol.
(Bad Wayne. No biscuit. Do not post in the AM.)
W
------------------------------
Date: 19 May 1998 09:28:45 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: regexp: replacing new line followed by "+"
Message-Id: <6js1ed$glc$1@monet.op.net>
Keywords: animadvert partial sharpshoot USSR
In article <r8n2cfum3g.fsf@asc.sps.mot.com>,
Martin Gregory <mgregory@asc.sps.mot.com> wrote:
> @File = <FH>; # slurp in whole file
> $File = join('', @File); # get whole file into a string, for substitution
You should try to avoid this. The line-by-line reading and the `join'
are slow if all you want is t oget the data into a single scalar.
{ local $/ = undef; $File = <FH> }
is always a lot faster.
------------------------------
Date: 19 May 1998 09:13:56 -0400
From: mwmaurer@mtu.edu (Mark Maurer)
Subject: Re: Something like "Visual Perl"?
Message-Id: <6js0ik$rad$1@pace1.cts.mtu.edu>
Heribert Wettels (wettels@respublica.de) wrote:
: Has anybody heard about a programming environment for Perl similar to
: Visual Basic? Or at least an editor that creates indents and does some
: highlighting?
:
: Heribert
Vim 5.1
--
Mark Maurer markm@dct.com mwmaurer@mtu.edu
Programmer, Digital Magic Interactive http://www.dminteractive.com
Senior, Michigan Technological University Houghton, MI
-- Views do not represent those of my employer or school
------------------------------
Date: 19 May 1998 11:44:22 GMT
From: scott@softbase.com
Subject: Re: Something like "Visual Perl"?
Message-Id: <6jrram$r5$1@mainsrv.main.nc.us>
>Has anybody heard about a programming environment for Perl similar to
>Visual Basic?
Since Perl is not a GUI language, this doesn't make any sense.
> Or at least an editor that creates indents and does some
>highlighting?
The Emacs port to Win32 does this. I can't imagine Perl without it.
Many other editors do, too.
Scott
--
Look at Softbase Systems' client/server tools, www.softbase.com
Check out the Essential 97 package for Windows 95 www.skwc.com/essent
All my other cool web pages are available from that site too!
My demo tape, artwork, poetry, The Windows 95 Book FAQ, and more.
------------------------------
Date: Tue, 19 May 1998 13:55:36 GMT
From: "Brian Sullivan" <brians@meetingbywire.com>
Subject: Re: Something like "Visual Perl"?
Message-Id: <sbg81.41$144.1616037@news.rdc1.va.home.com>
Solution Soft (http://www.solutionsoft.com ) has a product called
PerlBuilder that has an integrated editor, debugger and input generator,
output examiners. Is that the kind of IDE people are talking about? Runs on
NT/95 -- seems to work well.
Mark Maurer wrote in message <6js0ik$rad$1@pace1.cts.mtu.edu>...
>Heribert Wettels (wettels@respublica.de) wrote:
>: Has anybody heard about a programming environment for Perl similar to
>: Visual Basic? Or at least an editor that creates indents and does some
>: highlighting?
>:
>: Heribert
>
>Vim 5.1
>
>--
>Mark Maurer markm@dct.com mwmaurer@mtu.edu
>Programmer, Digital Magic Interactive
http://www.dminteractive.com
>Senior, Michigan Technological University Houghton, MI
>-- Views do not represent those of my employer or school
------------------------------
Date: Tue, 19 May 1998 09:23:30 -0400
From: Jay Flaherty <fty@utk.edu>
Subject: Re: Tip: How to access a hash through a pointer
Message-Id: <356187D2.A4AA0D9B@utk.edu>
greene@gucc.org wrote:
> I'm not exactly a newbie to perl (I've been using it for over 18 months), but
> have often wondered what the proper form is for de-referencing pointers to a
> hash. After a bit of trial-and-error, I've found that the following code
> works, and is accepted even with 'use strict' turned on.
>
> my $hashref = \%Hash;
> print "hashref = $hashref\n";
> # prints
> # hashref = HASH(0x88bee0)
>
> foreach (keys %$hashref) {
> print "$_ => $$hashref{$_}\n";
> }
> # note the 'magic' here - %$hashref is the syntax for referencing a hash
> # through a pointer, and $$hashref{$key} is the syntax for referencing
> # a hash element. I guess the problem here was that I was trying to use
> # the * operator, as any good C programmer would.
I prefer the -> notation. myself i.e.my $hashref = \%Hash;
foreach (keys %$hashref) {
print "$_ => $hashref->{$_}\n";
}
Jay
--
**********************************************************************
Jay Flaherty fty@utk.edu
"Once in awhile you get shown the light, in the strangest of places if
you look at it right" - R. Hunter
**********************************************************************
------------------------------
Date: 19 May 1998 09:49:34 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: translate A-Z to 1-26
Message-Id: <6js2le$gpd$1@monet.op.net>
Keywords: Bosch De monarch Petersen
In article <ltaf8fapzc.fsf@asfast.com>, Lloyd Zusman <ljz@asfast.com> wrote:
>But in EBCDIC, the set ('a' .. 'z') contains 41 elements.
You'd think so, but according to this article, it contains 9.
(_Perl and EBCDIC?_, Peter Prymmer, The Perl Journal, vol 2. no
4. pp. 16-16)
------------------------------
Date: 19 May 1998 13:12:24 GMT
From: zbrown@lynx.neu.edu
Subject: Using @$array_name
Message-Id: <6js0fo$1t6$1@isn.dac.neu.edu>
I'm trying to get the hang of using @$array_name between functions, instead
of passing whole lists. I believe I've isolated the following problem:
In a function, I'll be pushing data onto a list to be returned, like this:
push @$total, part_list($_);
And then at the bottom I'll have
return $total;
Everything seems to work fine unless 'part_list()' failed to return anything
to push onto @$total. In such a case, I am completely lost. The value of
$total seems to be a mystery. 'defined @$total' returns false. If I try to
print $total by itself, it will still output something like
"ARRAY(0x80bd830)", which indicates that @$total is indeed a list. But if I
try to print any elements of @$total, such as $$total[0] (or try 'defined
$$total[0]'), that doesn't work either, and complains about uninitialized
variables someplace else in the program, where there are no uninitialized
variables.
I'm very confused. @$array_name doesn't seem to work at all like
@array_name. I've looked in the 2nd edition of _Programming_Perl_ with no
luck. Chapter 4 has very little to say about my situation, since it focuses
more on multidimensional arrays.
Zack
------------------------------
Date: 19 May 1998 13:27:31 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Using @$array_name
Message-Id: <6js1c3$ft9@news-central.tiac.net>
In article <6js0fo$1t6$1@isn.dac.neu.edu>, <zbrown@lynx.neu.edu> wrote:
>I'm trying to get the hang of using @$array_name between functions, instead
>of passing whole lists. I believe I've isolated the following problem:
>
>In a function, I'll be pushing data onto a list to be returned, like this:
>
> push @$total, part_list($_);
>
>And then at the bottom I'll have
>
> return $total;
>
>Everything seems to work fine unless 'part_list()' failed to return anything
>to push onto @$total. In such a case, I am completely lost. The value of
>$total seems to be a mystery. 'defined @$total' returns false. If I try to
>print $total by itself, it will still output something like
>"ARRAY(0x80bd830)", which indicates that @$total is indeed a list. But if I
>try to print any elements of @$total, such as $$total[0] (or try 'defined
>$$total[0]'), that doesn't work either, and complains about uninitialized
>variables someplace else in the program, where there are no uninitialized
>variables.
I assume that $total either didn't refer to an array or referred to an
empty array at the beginning of your code.
You can try seeing what @$total is in a scalar context, if part_list()
really returns nothing then @$total will be an empty list and element 0 of
an empty list is not defined - in the debugger:
DB<1> push @$total, ()
DB<2> print scalar @$total
0
DB<3> print defined $$total[0]
DB<4> X total
$total = ARRAY(0x80503f0)
empty array
DB<5> push @$total, 'something'
DB<6> print scalar @$total
1
DB<7> print defined $$total[0]
1
DB<8> X total
$total = ARRAY(0x80503f0)
0 'something'
>I'm very confused. @$array_name doesn't seem to work at all like
>@array_name. I've looked in the 2nd edition of _Programming_Perl_ with no
>luck. Chapter 4 has very little to say about my situation, since it focuses
>more on multidimensional arrays.
@$array_ref does act very much like @array, if I use array instead of
$total in the debugger example above:
DB<9> push @array, ()
DB<10> print scalar @array
0
DB<11> print defined $array[0]
DB<12> X array
DB<13> push @array, 'something'
DB<14> print scalar @array
1
DB<15> print defined $array[0]
1
DB<16> X array
@array = (
0 'something'
)
This seems reasonable to me.
The complaint about uninitialised varibles may really mean undefined
elements of some aggregate, but the real misunderstanding seems to be that
you expected element 0 of an empty array to be defined somehow (sorry if
I'm wrong or have misinterpreted your question)
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: Tue, 19 May 1998 14:05:53 GMT
From: jdporter@min.net (John Porter)
Subject: Re: while, each & assoc array
Message-Id: <MPG.fcb5d46636d76149896cf@news.min.net>
On Mon, 18 May 1998 16:18:40 GMT,
in article <1d982ps.1cdon0b158dtq3N@roxboro0-027.dyn.interpath.net>,
phenix@interpath.com (John Moreno) wrote:
>
> Yeah, I don't know who should be given the credit for it, but perls
> alternative for the single statement (statement condition;) is much
> better.
What, you're thinking it might be someone other than Larry?
John Porter
------------------------------
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 2638
**************************************