[17092] in Perl-Users-Digest
Perl-Users Digest, Issue: 4504 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 3 11:05:29 2000
Date: Tue, 3 Oct 2000 08: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)
Message-Id: <970585512-v9-i4504@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 3 Oct 2000 Volume: 9 Number: 4504
Today's topics:
A matter of style (was Re: Search and Destroy) <nospam@david-steuber.com>
Re: Add on kily@my-deja.com
Re: Another netiquette question? was Re: How to get len <nospam@david-steuber.com>
Re: Archive::Tar woes (Clay Irving)
Re: Archive::Tar woes <johnno@nospam.casebook.org>
Re: Archive::Tar woes (Clay Irving)
Re: Archive::Tar woes (Martien Verbruggen)
Re: Archive::Tar woes <johnno@nospam.casebook.org>
Re: Archive::Tar woes <johnno@nospam.casebook.org>
Re: benefits of arrays over hashes(associative arrays) <juex@my-deja.com>
CGI::Cache 1.01 released <newspost@coppit.org>
compression and clean up of HTML files a_ominous@my-deja.com
Re: compression and clean up of HTML files (Clay Irving)
Re: die() ignores tied STDERR? (Ben Coleman)
Re: die() ignores tied STDERR? <newspost@coppit.org>
Re: die() ignores tied STDERR? <newspost@coppit.org>
Emacs modules for Perl programming (Jari Aalto+mail.perl)
Re: error in mapping array slice (Martien Verbruggen)
Re: Flush buffer and wait for browser input ?? nobull@mail.com
Re: Flush buffer and wait for browser input ?? <flavell@mail.cern.ch>
Formatting with commas <msnsh@telocity.com>
Re: Hash of Arrays oddness? (Martien Verbruggen)
Re: How to get length of scalar? <nospam@david-steuber.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 03 Oct 2000 15:03:38 GMT
From: David Steuber <nospam@david-steuber.com>
Subject: A matter of style (was Re: Search and Destroy)
Message-Id: <m34s2ux8z6.fsf_-_@solo.david-steuber.com>
Larry Rosler <lr@hpl.hp.com> writes:
' But I hate studlyCaps, which belong in Java, not in Perl.
I've used that variable nameing convention in C and C++ for multi-word
variable names. What is your prefered naming convention in Perl?
Or is there a consensus among Perl users on the naming of variables
like using no_studly_caps instead?
--
David Steuber | Perl apprentice, Apache/mod_perl user,
NRA Member | and general Internet web wannabe.
ICQ# 91465842
*** http://www.david-steuber.com/ ***
------------------------------
Date: Tue, 03 Oct 2000 14:37:12 GMT
From: kily@my-deja.com
Subject: Re: Add on
Message-Id: <8rcquo$pqv$1@nnrp1.deja.com>
In article <8rc4i0$95r$1@nnrp1.deja.com>,
kily@my-deja.com wrote:
> In article <u9aecngnrk.fsf@wcl-l.bham.ac.uk>,
> nobull@mail.com wrote:
> > kily@my-deja.com writes:
> >
> > > Subject: Add on
> >
> > Huh? Nonsense subject line!
> >
> > > I'm wondering for a script which can read a file
> > > containing two columns seperated by unknown number of tabulation
or
> > > space, then delete the first column (which is a complete name of
> > > unsers). The second column is the user-ID as: 008253A,
> 008256X,...etc.
> > > I want script to be able to delete the first two charecters and
> > > transform majuscule (A, X, B,...etc) to minuscules ones.
> >
> > perl -pe 's/.*\s+..(.*)/\L$1/' <infile >outfile
> >
> > > PS: I'm workong under Windows NT Server 4.
> >
> > Oh, then command line may not work:
> >
> > #!perl -p
> > s/.*\s+..(.*)/\L$1/
> >
>
> Thank you all for helps, I'm testing the line:
> perl -pe 's/.*\s+..(.*)/\L$1/' <infile >outfile
> it works fine. But how I can put it in file in which I put in and out
> files.
>
> Thanks and excuse me!
>
Hello,
Now the line: perl -pe "s/.*\s+..(.*)/\L$1/" <infile.txt > outfile.txt
works at prompt line, but when I try to put: 's/.*\s+..(.*)/\L$1/' in
file like somthing.pl and then at DOS prompt type:
perl somthing.pl <infile.txt > outfile.txt, I find the file outfile.txt
is empty. Can you explain what wrong?
Thanks
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 03 Oct 2000 14:52:32 GMT
From: David Steuber <nospam@david-steuber.com>
Subject: Re: Another netiquette question? was Re: How to get length of scalar?
Message-Id: <m37l7qx9ho.fsf@solo.david-steuber.com>
"Alan J. Flavell" <flavell@mail.cern.ch> writes:
' [*]i.e not to be confused with multiposting, which I think I can
' fairly say is widely agreed to be abhorrent, no?
Agreed, yes.
Netequette heuristics adjusted. Thanks.
--
David Steuber | Perl apprentice, Apache/mod_perl user,
NRA Member | and general Internet web wannabe.
ICQ# 91465842
*** http://www.david-steuber.com/ ***
------------------------------
Date: 3 Oct 2000 10:08:49 GMT
From: clay@panix.com (Clay Irving)
Subject: Re: Archive::Tar woes
Message-Id: <slrn8tjc1e.fu0.clay@panix3.panix.com>
On Tue, 3 Oct 2000 19:43:09 +1000, Johnno <johnno@nospam.casebook.org> wrote:
>In the code I have written below, I am rolling my home directory (and
>everything contained therein) into a tarball.
>
>In other words, I am doing "tar -cvpf /tmp/johnno.tar /home/johnno/".
>
>#!/usr/bin/perl -w
>use strict;
>use Archive::Tar;
>my $backup = '/tmp/johnno.tar';
>my @files = qw(/home/johnno/);
>my $tarball = Archive::Tar->new();
>$tarball->create_archive($backup, 9, @files);
>$tarball->add_files(@files);
>$tarball->write($backup);
>
>The problem seems to be in the processing of @files. The tarball was
>created, but not as I would have expected:
Print the contents of @files -- I bet you don't find a list of files in
/home/johno/
--
Clay Irving <clay@panix.com>
The doctrine of human equality reposes on this: that there is no man
really clever who has not found that he is stupid.
- G. K. Chesterton
------------------------------
Date: Tue, 3 Oct 2000 21:23:45 +1000
From: "Johnno" <johnno@nospam.casebook.org>
Subject: Re: Archive::Tar woes
Message-Id: <39d9b420$0$12451$7f31c96c@news01.syd.optusnet.com.au>
"Clay Irving" <clay@panix.com> wrote:
> > In the code I have written below, I am rolling my home directory (and
> > everything contained therein) into a tarball.
> > In other words, I am doing "tar -cvpf /tmp/johnno.tar /home/johnno/".
> > #!/usr/bin/perl -w
> > use strict;
> > use Archive::Tar;
> > my $backup = '/tmp/johnno.tar';
> > my @files = qw(/home/johnno/);
> > my $tarball = Archive::Tar->new();
> > $tarball->create_archive($backup, 9, @files);
> > $tarball->add_files(@files);
> > $tarball->write($backup);
> > The problem seems to be in the processing of @files. The tarball
> > was created, but not as I would have expected:
> Print the contents of @files -- I bet you don't find a list of files in
> /home/johno/
Okay, that seems to be the limitation of that. It's clear now.
In that case, how can Archive::Tar be used to recursively pack files in a
given directory like tar itself does?
--
Johnno (johnno@nospam.casebook.org)
http://johnno.casebook.org
------------------------------
Date: 3 Oct 2000 11:01:13 GMT
From: clay@panix.com (Clay Irving)
Subject: Re: Archive::Tar woes
Message-Id: <slrn8tjf3p.h6u.clay@panix3.panix.com>
On Tue, 3 Oct 2000 21:23:45 +1000, Johnno <johnno@nospam.casebook.org> wrote:
>>> In the code I have written below, I am rolling my home directory (and
>>> everything contained therein) into a tarball.
>
>>> In other words, I am doing "tar -cvpf /tmp/johnno.tar /home/johnno/".
>
>>> #!/usr/bin/perl -w
>>> use strict;
>>> use Archive::Tar;
>>> my $backup = '/tmp/johnno.tar';
>>> my @files = qw(/home/johnno/);
>>> my $tarball = Archive::Tar->new();
>>> $tarball->create_archive($backup, 9, @files);
>>> $tarball->add_files(@files);
>>> $tarball->write($backup);
>
>>> The problem seems to be in the processing of @files. The tarball
>>> was created, but not as I would have expected:
>
>> Print the contents of @files -- I bet you don't find a list of files in
>> /home/johno/
>
>Okay, that seems to be the limitation of that. It's clear now.
>
>In that case, how can Archive::Tar be used to recursively pack files in a
>given directory like tar itself does?
Something like this?
#!/usr/local/bin/perl -w
use File::Find;
use Archive::Tar;
my $backup = 'foo.tar';
find(\&wanted, '/home/clay/tmp');
sub wanted { push @files, "$File::Find::name" };
my $tarball = Archive::Tar->new();
$tarball->create_archive($backup, 9, @files) or die "$!\n";
$tarball->add_files(@files) or die "$!\n";;
$tarball->write($backup) or die "$!\n";;
--
Clay Irving <clay@panix.com>
You know I could rent you out as a decoy for duck hunters?
- Groucho Marx
------------------------------
Date: Tue, 3 Oct 2000 21:41:10 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Archive::Tar woes
Message-Id: <slrn8tjdu6.jr6.mgjv@martien.heliotrope.home>
On Tue, 3 Oct 2000 19:43:09 +1000,
Johnno <johnno@nospam.casebook.org> wrote:
>
> It appears that directory names stored in @files pose as a problem.
>
> Archive::Tar seemingly does not behave the way tar itself would behave when
> run as "tar -cvpf /home/johnno".
>
> Has anyone experienced this before?
>
> Am I missing something, or is this a genuine problem with Archive::Tar?
Not a problem, this is just how Archive::Tar works.
Martien
--
Martien Verbruggen |
Interactive Media Division | Can't say that it is, 'cause it
Commercial Dynamics Pty. Ltd. | ain't.
NSW, Australia |
------------------------------
Date: Tue, 3 Oct 2000 22:42:02 +1000
From: "Johnno" <johnno@nospam.casebook.org>
Subject: Re: Archive::Tar woes
Message-Id: <39d9c67d$0$12426$7f31c96c@news01.syd.optusnet.com.au>
"Clay Irving" <clay@panix.com> wrote:
> > In that case, how can Archive::Tar be used to recursively pack
> > files in a given directory like tar itself does?
> Something like this?
[...]
> use File::Find;
[...]
> find(\&wanted, '/home/clay/tmp');
> sub wanted { push @files, "$File::Find::name" };
Thanks; that'll do the job nicely.
--
Johnno (johnno@nospam.casebook.org)
http://johnno.casebook.org
------------------------------
Date: Tue, 3 Oct 2000 22:43:08 +1000
From: "Johnno" <johnno@nospam.casebook.org>
Subject: Re: Archive::Tar woes
Message-Id: <39d9c6bb$0$12441$7f31c96c@news01.syd.optusnet.com.au>
"Martien Verbruggen" <mgjv@tradingpost.com.au> wrote:
> > It appears that directory names stored in @files pose as
> > a problem.
> >
> > Archive::Tar seemingly does not behave the way tar itself
> > would behave when run as "tar -cvpf /home/johnno".
> >
> > Has anyone experienced this before?
> >
> > Am I missing something, or is this a genuine problem with
> > Archive::Tar?
> Not a problem, this is just how Archive::Tar works.
Thanks.
As can be seen in Clay's reply, I need to use File::Find.
--
Johnno (johnno@nospam.casebook.org)
http://johnno.casebook.org
------------------------------
Date: Tue, 3 Oct 2000 07:34:54 -0700
From: "Jürgen Exner" <juex@my-deja.com>
Subject: Re: benefits of arrays over hashes(associative arrays) and vice versa
Message-Id: <39d9ee99@news.microsoft.com>
"Cameron Elliott" <celliot@tartarus.uwa.edu.au> wrote in message
news:39d7648e$0$31974@echo-01.iinet.net.au...
> Can someone tell me which is better to use?
Which is better to use, an 18-wheeler or a Porsche? Well, it depends on if
you want to haul your girl friend or 200 refrigerators.
> I cant see the point of a hash except to store something by reference to a
> name which is possible to do through creative uses of arrays anyway.
> Can someone please correct me if I am wrong (which is probable) and inform
> me of the advantages/disadvantages of each.
See it from a different point of view: arrays are a restricted form of
hashes (or actually associative arrays).
Both are mappings, but while hashes accept any string as index (or domain)
arrays are limited to numbers.
jue
------------------------------
Date: Mon, 2 Oct 2000 18:20:00 -0400
From: David Coppit <newspost@coppit.org>
Subject: CGI::Cache 1.01 released
Message-Id: <stjr4tmna76i02@corp.supernews.com>
Description:
- Perl extension to cache output of time-intensive CGI scripts so that
subsequent visits to such scripts will not cost as much time.
WARNING
The interface as of version 1.01 has changed considerably
and is NOT compatible with earlier versions.
Download:
- You can download CGI::Cache from CPAN:
http://www.cpan.org/authors/id/D/DC/DCOPPIT/CGI-Cache-1.01.tar.gz
- Until the file propagates to the mirrors, you can use the following URL:
http://www.cs.virginia.edu/~dwc3q/code/CGI-Cache-1.01.tar.gz
Changes:
- Maintenance handed over to David Coppit <david@coppit.org>. All
changes in this version are made by him.
- Underlying caching is now handled by File::Cache. This allows for extra
features such as cache maximum sizes, transparent cache entry expiration,
etc.
- The cache key can now be any data structure instead of just a simple
string. This means that one can just hand the CGI parameters directly to
CGI::Cache and it will figure out a suitable stringified cache key.
- Because File::Cache now does most of the cache management automatically,
SetRoot, Expire, and ExpireLRU have been removed from the interface
- Output is now cached and then printed as each print statement occurs.
Previously all the output would be dumped to STDOUT after the script
completed execution. (This helps the responsiveness of the CGI script for
browsers which can handle on-the-fly layout of web pages.)
- Output is not cached if the script exits from an error condition.
Previously, a problem with the script would cause an empty document to be
cached.
- A setup(\%options) subroutine has been added for setting up the details of
the cache.
- The file mode parameter for most functions has been removed. Instead, the
file mode is set when initializing the module using the setup(\%options)
subroutine.
Thanks,
David
------------------------------
Date: Tue, 03 Oct 2000 13:02:57 GMT
From: a_ominous@my-deja.com
Subject: compression and clean up of HTML files
Message-Id: <8rcldu$l3i$1@nnrp1.deja.com>
hi all
I've been looking around for a few days for a Perl script ideally to
remove comments from HTML files. I also want to remove whitespace,
possibly only leading whitespace. We are charged per byte by our web
hosting company and we also want to improve response times for the
users.
The bulk of the HTML files have been generated by Net Dynamics but have
been tidied up and formatted for readability / maintenace.
I have been able to locate some Windows tools for doing something along
these lines, but I want a Perl script as the product builds will be
moved over to Unix in the coming months.
I could write my own, but don't want to start from scratch if I can
help it.
Any ideas / pointers?
TIA
-AO-
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 3 Oct 2000 13:14:51 GMT
From: clay@panix.com (Clay Irving)
Subject: Re: compression and clean up of HTML files
Message-Id: <slrn8tjmua.n6a.clay@panix3.panix.com>
On Tue, 03 Oct 2000 13:02:57 GMT, a_ominous@my-deja.com <a_ominous@my-deja.com>
wrote:
>I've been looking around for a few days for a Perl script ideally to
>remove comments from HTML files. I also want to remove whitespace,
>possibly only leading whitespace. We are charged per byte by our web
>hosting company and we also want to improve response times for the
>users.
>The bulk of the HTML files have been generated by Net Dynamics but have
>been tidied up and formatted for readability / maintenace.
>I have been able to locate some Windows tools for doing something along
>these lines, but I want a Perl script as the product builds will be
>moved over to Unix in the coming months.
>I could write my own, but don't want to start from scratch if I can
>help it.
Something like:
HTML::Clean
The HTML::Clean module encapsulates a number of HTML optimizations and
cleanups. The end result is HTML that loads faster, displays properly
in more browsers. Think of it as a compiler that translates HTML input
into optimized machine readable code.
http://www.perl.com/CPAN-local/modules/by-module/HTML/
--
Clay Irving <clay@panix.com>
2.4 statute miles of intravenous surgical tubing at Yale University
Hospital: 1 I.V. League
------------------------------
Date: Tue, 03 Oct 2000 14:33:37 GMT
From: oloryn@mindspring.com (Ben Coleman)
Subject: Re: die() ignores tied STDERR?
Message-Id: <39d9ec5d.321028124@localhost>
On Sun, 1 Oct 2000 01:48:26 -0400, David Coppit <newspost@coppit.org>
wrote:
>
>I tied STDERR to a module in order to detect when something goes wrong
>in a CGI script.
You may want to look at the Tie::STDERR module on CPAN, as you may be
reinventing the wheel.
Ben
------------------------------
Date: Tue, 3 Oct 2000 10:14:24 -0400
From: David Coppit <newspost@coppit.org>
To: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: die() ignores tied STDERR?
Message-Id: <Pine.GSO.4.21.0010031011540.5579-100000@mamba.cs.Virginia.EDU>
On Mon, 2 Oct 2000, Martien Verbruggen wrote:
> > I tied STDERR to a module in order to detect when something goes wrong
>
> why?
Because I'm now maintaining CGI::Cache, which caches output from CGI
scripts to speed up execution on subsequent runs. The problem is that
I don't want to cache output if an error occurred. This means that I'd
like to determine when the script writes to STDERR, and dump the
captured STDOUT instead of caching it.
Right now my solution is to tie STDERR and set a flag if print is
called on it, AND to check $? in the END block of CGI::Cache to
determine if the script is exiting via die(). It seemed to me that I
should be able to avoid the $? check because die also writes to
STDERR.
David
------------------------------
Date: Tue, 3 Oct 2000 10:21:48 -0400
From: David Coppit <newspost@coppit.org>
Subject: Re: die() ignores tied STDERR?
Message-Id: <Pine.GSO.4.21.0010031017390.5579-100000@mamba.cs.Virginia.EDU>
On Tue, 3 Oct 2000, Martien Verbruggen wrote:
> > Why? Perl developers should decide things basing on how things are
> > going to be *used*. It is the responsibility of users to bug the
> > developers about not-intuitive behaviour (if the behaviour is judged
> > not-intuitive by *users*).
>
> Yes, you are right. The above paragraph wasn't exactly clear. Later in
> the post I stated more clearly what I meant: The perl developers can
> decide whether or not this was _intended_ behaviour. In other words, is
> this difference there by design, or not.
Well, let me then lobby for warn() and die() to obey STDERR
"tie-ness". I think my CGI::Cache situation (described in another post
in this thread) is an example of why it should be that way. Is there
any good reason why warn() and die() should be special cases?
Language regularity is a good thing, right? ;)
I get the feeling that when tied handles were added this situation was
missed.
David
------------------------------
Date: 03 Oct 2000 13:41:57 GMT
From: <jari.aalto@poboxes.com> (Jari Aalto+mail.perl)
Subject: Emacs modules for Perl programming
Message-Id: <perl-faq/emacs-lisp-modules_970580411@rtfm.mit.edu>
Archive-name: perl-faq/emacs-lisp-modules
Posting-Frequency: 2 times a month
URL: http://home.eu.org/~jari/ema-keys.html
Maintainer: Jari Aalto <jari.aalto@poboxes.com>
Announcement: "What Emacs lisp modules can help with programming Perl"
Preface
Emacs is your friend if you have to do anything comcerning software
development: It offers plug-in modules, written in Emacs lisp
(elisp) language, that makes all your programmings wishes come
true. Please introduce yourself to Emacs and your programming era
will get a new light.
Where to find Emacs
XEmacs/Emacs, is available to various platforms:
o Unix:
If you don't have one, bust your sysadm.
http://www.gnu.org/software/emacs/emacs.html
http://www.xemacs.org/
Emacs resources at http://home.eu.org/~jari/emacs-elisp.html
o W9x/NT:
http://www.gnu.org/software/emacs/windows/ntemacs.html
Emacs Perl Modules
Cperl -- Perl programming mode
.ftp://ftp.math.ohio-state.edu/pub/users/ilya/perl
.<olson@mcs.anl.gov> Bob Olson (started 1991)
.<ilya@math.ohio-state.edu> Ilya Zakharevich
Major mode for editing perl files. Forget the default
`perl-mode' that comes with Emacs, this is much better. Comes
starndard in newest Emacs.
TinyPerl -- Perl related utilities
.http://home.eu.org/~jari/tiny-tools-beta.zip
.http://home.eu.org/~jari/emacs-tiny-tools.html
If you ever wonder how to deal with Perl POD pages or how to find
documentation from all perl manpages, this package is for you.
Couple of keystrokes and all the documentaion is in your hands.
o Instant function help: See documentation of `shift', `pop'...
o Show Perl manual pages in *pod* buffer
o Load source code into Emacs, like Devel::DProf.pm
o Grep through all Perl manpages (.pod)
o Follow POD manpage references to next pod page with TinyUrl
o Coloured pod pages with `font-lock'
o Separate `tiperl-pod-view-mode' for jumping topics and pages
forward and backward in *pod* buffer.
o TinyUrl is used to jump to URLs (other pod pages, man pages etc)
mentioned in POD pages. (It's a general URL minor mode)
TinyIgrep -- Perl Code browsing and easy grepping
[TinyIgrep is included in the tgz mentioned above]
To grep from all installed Perl modules, define database to
TinyIgrep. There is example in the tgz (ema-tigr.ini) that shows
how to set up datatbases for Perl5, Perl4 whatever you have
installed
TinyIgrep calls Igrep.el to run the find for you, You can adjust
recursive grep options, ignored case, add user grep options.
You can get `igrep.el' module from <kevinr@ihs.com>. Ask for copy.
Check also ftp://ftp.ihs.com/pub/kevinr/
TinyCompile -- Browsing grep results in Emacs *compile* buffer
TinyCompile is minor mode for *compile* buffer from where
you can collapse unwanted lines, shorten the file URLs
/asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file1:NNN: MATCHED TEXT
/asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file2:NNN: MATCHED TEXT
-->
cd /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/
file1:NNN: MATCHED TEXT
file1:NNN: MATCHED TEXT
End
------------------------------
Date: Tue, 3 Oct 2000 21:56:42 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: error in mapping array slice
Message-Id: <slrn8tjera.jr6.mgjv@martien.heliotrope.home>
[Please, for future reference, post your reply AFTER the suitably
TRIMMED text you reply to. It makes the whole thing much easier to
follow, and it follows the convention used on this group]
On Tue, 03 Oct 2000 15:21:16 +0800,
Tk Soh <r28629@email.sps.mot.com> wrote:
[reordered post]
> Jim Mauldin wrote:
> >
> > Tk Soh wrote:
> > > @b = map {$_} @a[-10 .. -1]; # line 2
[snip]
> > From "Programming Perl", Chapter 33: Diagnostic Messages
[snip]
> array slicing with non-existing subscripts produces list of undef's. Why
> puzzles me is why it bombed when this list (of undef's ) was passed to
> map {$_}, since it simply pass on the value (i.e. undef) as is, with no
> attempt to modify it. Unless there are undocument feature that I am not
> aware of, or missed. The fact that $_ is reference to the array elements
> doesn't justify for that error, IMHO.
But it does. It means that there have to be values to refer to. That
means that for $_ to be a reference to $a[-10], there actually has to be
a $a[-10], so perl will silently DWYM and autovivify it for you. When
it's trying to do that, it finds out that it can't.
Actually that isn't always true.
\begin[top secret]{hidden}
# perl
$[ = -20;
$a[-10] = 3;
print "$a[-10]\n";
__END__
3
#
\end{hidden}
But don't tell anyone I told you that, and don't actually use it. Just
don't use negative subscripts on an array if you don't mean to use them.
I am almost afraid to ask... Why?
Martien
--
Martien Verbruggen |
Interactive Media Division | This matter is best disposed of from
Commercial Dynamics Pty. Ltd. | a great height, over water.
NSW, Australia |
------------------------------
Date: 03 Oct 2000 12:45:38 +0100
From: nobull@mail.com
Subject: Re: Flush buffer and wait for browser input ??
Message-Id: <u9hf6uno65.fsf@wcl-l.bham.ac.uk>
sarbayo@telis.org (Steve A.) writes:
> " how do I make a perl CGI program wait for input from the
> browser,
You can't, this has nothing to do with Perl - the same applies to CGI
programs in any language.
> Solution ??
You probably want to look into one the modules that implements so
called session variables in CGI.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 3 Oct 2000 14:35:26 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Flush buffer and wait for browser input ??
Message-Id: <Pine.GHP.4.21.0010031413360.19286-100000@hpplus03.cern.ch>
On Wed, 27 Sep 2000, Steve A. wrote:
> The question is simple;
> " how do I make a perl CGI program wait for input from the
> browser, to take it's next action , prior to program termination"
Simple indeed: it shows you haven't got the mental picture of web
programming yet. Nothing specific to Perl though.
(That spaced-out text is kinda hard to read; and I resisted the
temptation to crosspost to alt.possessive.its.has.no.apostrophe ).
> program waits for <stdin> input.
CGI scripts are invoked from a web server. The idea is they run, take
their input from the specified CGI input interface, return an answer
to the specified CGI output interface, and finish. End of story.
Web servers don't like processes hanging around while users decide
what to do next; and rightly so.
> 3) " cgi-bin/Programme.pl " goes into a "wait loop", waiting
> for next input from browser.
The web doesn't normally work this way. So if you want good results,
you do it the web's way, instead of trying to make it up as you go
along.
You send the browser back an intermediate page, complete with some
token that lets you maintain state, and then your script exits.
At some later time, the user will (or at least "may") submit the
desired input using your intermediate page. The script will be
re-invoked. Will use the token to remember where it got to, and carry
on from there.
Again, not a Perl question: however, look at CGI.pm's way of using
sticky values to facilitate this kind of operation.
[f'ups suggested to more-appropriate group]
------------------------------
Date: Tue, 3 Oct 2000 10:00:47 -0500
From: "Telocity" <msnsh@telocity.com>
Subject: Formatting with commas
Message-Id: <OvmC5.753$9X2.344077@newsrump.sjc.telocity.net>
Is there any way to format large numbers with
comma separators in Perl output? Printf and
sprintf do not seem to have this capability.
TIA
J. Darrow
------------------------------
Date: Tue, 3 Oct 2000 22:11:24 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Hash of Arrays oddness?
Message-Id: <slrn8tjfms.jr6.mgjv@martien.heliotrope.home>
On Tue, 03 Oct 2000 02:36:27 -0400,
Andrew Pearce <pearce@aw.sgi.com> wrote:
>
> --------------FED30AC2ADA2225E66D960F3
> Content-Type: text/plain; charset=us-ascii
Please don't so this. Usenet is a plain text medium. There is no place
for this multipart MIME stuff here.
> Didn't see this in the FAQ, and can't find a mention in any reference,
> so I appologize if it is painfully obvious.
>
> I have a hash and one element is to be an array. As I construct it,
> I'm using the push() call as recommended;
Recommended by whom?
> # NOTE: exists( $hash{$key}) == 0
> @array = makeArrayFunc();
> foreach $ae (@array) {
> push (@{$hash{$key}}, $ae);
> }
Why not just
my @array = makeArrayFunc();
$hash{$key} = \@array;
or if you can't work with a lexically scoped variable, and you need to
copy the elements:
$hash{$key} = [@array];
> Which mostly works, but it is dropping the first element. If I do the
> following, it works:
Dropping the first element? I don't believe you:
# perl
@a = qw (foo bar baz banana);
foreach $ae (@a)
{
push @{$hash{bleb}}, $ae;
}
print "@{$hash{bleb}}\n";
__END__
foo bar baz banana
Are you sure that your makeArrayFunc is correct?
> # length( $hash{$key}) == 0, i.e. it does not yet exist
Oh?
# perl -wl
$hash{bleb} = '';
print length $hash{bleb};
print exists($hash{bleb}) ? "yes" : "no";
__END__
0
yes
If you want to test for existence of a hash key, use exists. If you want
to know the length of a string, use length. Don't use one to do the
other's job.
> @array = makeArray();
> foreach $ae (@array) {
> push (@{$hash{$key}}, $ae);
> if ($ae eq $array[0]) {
> push (@{$hash{$key}}, $ae);
> }
> }
I am not even going to comment on this. You're barking down the wrong
tree, since your code didn't skip the first element. The problem is
something else.
> The first push is creating the array reference, but it is not placing
> the value $ae in the array as it would if the first argument to push
> were a non-existant array. Have I encountered a bug with the PERL
> implementation I have or am I missing something obvious here? Thanks
> for your time.
If it's a bug in perl, then it is only your local copy, or maybe a very
limited set of copies. Perl 5.004_05, 5.005_03 and 5.6.0 on my system
have no problem with this at all.
I suspect it's a bug somewhere in your code. maybe in one of the bits
you're not showing us. You should probably make very sure that -your_
code is correct before starting to blame perl. It's in widespread use.
Mainstream code like this is hardly likely to have bugs.
Martien
--
Martien Verbruggen |
Interactive Media Division |
Commercial Dynamics Pty. Ltd. | What's another word for Thesaurus?
NSW, Australia |
------------------------------
Date: Tue, 03 Oct 2000 14:49:08 GMT
From: David Steuber <nospam@david-steuber.com>
Subject: Re: How to get length of scalar?
Message-Id: <m3aecmx9nd.fsf@solo.david-steuber.com>
Larry Rosler <lr@hpl.hp.com> writes:
' What happened when you tried it?
perl -e '$ref = \{name => value}; print length $ref;'
yielded 17
perl -e '$ref = \{name => value}; print $ref;'
yielded SCALAR(0x80f1948)
' (Translation: Surely you have an installation of perl that you can test
' this trivia on without bothering the newsgroup.)
Lost my head for a moment there. My bad.
It looks like I screwed up doing a reference to an anonymous hash
though. Clearly I haven't found my head yet.
--
David Steuber | Perl apprentice, Apache/mod_perl user,
NRA Member | and general Internet web wannabe.
ICQ# 91465842
*** http://www.david-steuber.com/ ***
------------------------------
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 4504
**************************************