[6735] in Perl-Users-Digest
Perl-Users Digest, Issue: 360 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 24 02:07:37 1997
Date: Wed, 23 Apr 97 23:00:19 -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 Wed, 23 Apr 1997 Volume: 8 Number: 360
Today's topics:
Re: 1-D hash completely different from 2-D hash? (David Alan Black)
ADVERTISE TO OVER 100 MILLION PEOPLE FOR FREE!!! nejeh@gdi.net
Re: Any graphic module available? <rootbeer@teleport.com>
Re: CGI scripts (Paula Chase)
dbm hash file always expanding grajek@orasis.com
Re: Get Chars up to first | without splitting <rootbeer@teleport.com>
How to match an * <mandbx@wco.com>
Re: How to match an * (brian d foy)
Re: How to track memory usage (Mark Mills)
Re: Lisp is neither (was Re: Ousterhout and Tcl lost th (Chris Bitmead uid(x22068))
Re: migrate from Perl4 to Perl5 <rootbeer@teleport.com>
Re: Newbie Alert! Problems getting netscape to recogni <rootbeer@teleport.com>
Re: Ousterhout and Tcl lost the plot with latest paper (David Combs)
Re: Ousterhout and Tcl lost the plot with latest paper (Chris Bitmead uid(x22068))
Re: Ousterhout and Tcl lost the plot with latest paper <amullhau@ix.netcom.com>
Re: Perl compiler <...petri.backstrom@icl.fi>
Re: printing variable names (Perl needs MACROS!) (Abigail)
Re: STDOUT | PAGER <rootbeer@teleport.com>
Re: switch and if (Chipmunk)
Uninitialized variable warning (Bruce Schiller)
Re: wretched C++ (Was: Ousterhout and Tcl lost the plot (Chris Bitmead uid(x22068))
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 24 Apr 1997 03:42:32 GMT
From: dblack@icarus.shu.edu (David Alan Black)
Subject: Re: 1-D hash completely different from 2-D hash?
Message-Id: <5jmkr8$2u4@pirate.shu.edu>
Hello -
pjscott-remove-to-email-sorry@euclid.jpl.nasa.gov (Peter Scott) writes:
>I'm misunderstanding something about the nature of hashes and LoL here.
>Try this:
> #!/usr/local/bin/perl -w
> $x{foo} = "bar" # line 1
> $x{foo}{baz} = "bletch"; # line 2
> print "$foo{bar} $foo{bar}{baz}\n"; # line 3
>The result of this is
> bar bletch
>which is different from what I expected, and what I get if I comment out
>line 1:
> HASH(0xcb814) bletch
I don't get your results from the above (even when I add the
semicolon to line 1 :-) Are you sure your print statement is
testing what you mean to test?
However, I think that this example gets at what you're getting at:
$x{foo}{bar} = 5;
print $x{foo}; # prints HASH...
$x{foo} = "abc";
$x{foo}{bar} = 5;
print $x{foo}; # prints abc
print $x{foo}{bar}; # prints 5
Now, to thicken the plot, add:
print keys %abc;
which prints 'bar'.
What's happening is that "$x{foo}" provides a hash reference both
times an assignment is made to $x{foo}{bar}, but in different ways.
The first time, $x{foo} has no value, so it can be assigned a hard
hash reference. But the second time, $x{foo} already has a value, and
that value isn't a hash reference, so it is taken as a symbolic
reference: "abc". Thus, by (unknowingly) assigning to it, you bring
a new hash, %abc, into being.
use strict; will warn you of this. If you add:
use strict;
my %x;
to the above example, you'll get:
Can't use string ("abc") as a HASH ref while "strict refs" in
use at hashrefs line 9.
(line 9 is the second $x{foo}{bar} = 5; Who'd'a thought it
involved the string "abc"? :-)
I must say, this is an excellent example of why use strict is good
(at least, I've found it instructive to work through your problem).
Imagine what would happen if you also had created a hash called
%abc....
David Black
dblack@icarus.shu.edu
------------------------------
Date: Wed, 23 Apr 1997 20:24:29
From: nejeh@gdi.net
Subject: ADVERTISE TO OVER 100 MILLION PEOPLE FOR FREE!!!
Message-Id: <5jm92f$65g@news.gdi.net>
Please take the time out to read this email. it is worth your time.
ADVERTISE TO OVER 100 MILLION PEOPLE FOR FREE!!!
Or send a message to millions of people...
NOW YOU CAN ADVERTISE FREE AND GET DRAMATICALLY
MORE RESPONSES THAN ADVERTISING ON NATIONAL TELEVISION
With E-mail your potential customer is forced to read at least the
headline of your letter. Unlike TV, magazines, newspaper ads, and
direct mail where more than 99.99% of the recipients will skip right
over your advertisement.
TURNS YOUR COMPUTER INTO A CASH REGISTER: Conservative estimates indicate
well over 100 MILLION people will have E-mail accounts in the next year!
E-Mail Blaster turns your computer into a cash register by giving you FREE,
immediate access to all of them. Do you think some of the more than 100
million people with E-mail addresses would be interested in your products or
services? Even if you don't have your own products or services you can
still make money buy promoting our computer software!!!
You can make money with our new software called E-MAIL BLASTER
Here's how:
* By Using E-Mail To Sell Your Products & Services
* By Using E-Mail To Sell our Computer Software such as: Email Blaster, Web Walker,
Email Lock Box etc.
* By Renting or Selling Your E-mail Addresses
* By Becoming A Distributor for e-mail BLASTER
MUCH FASTER: With bulk E-mail you get responses back in 1 to 4
days instead of waiting weeks or months like with television or print
advertising. You can begin filling orders the same day you send E-mail.
FREE ADVERTISING WORTH MILLIONS: It costs millions of dollars to mail out
millions of letters using the United States Postal Service! Now you can
send your ad to MILLIONS of people for FREE using E-Mail BLASTER
E-MAIL BLASTER IS ACTUALLY 3 PROGRAMS IN 1: E-Mail Blaster is amazing new
technology and the most advanced bulk E-mail software on the market today.
(1) E-Mail BLASTER automatically extracts E-mail addresses from America
Online, CompuServe, Prodigy, and the other online services, the Internet,
web pages, news groups, and hundreds of other sources. (2) E-Mail BLASTER
automatically stores the E-mail addresses in your computer along with
keywords that describe hobbies and interests to created highly targeted
E-mail addresses. (3) E-Mail BLASTER sends your marketing letter or ad to
MILLIONS of targeted E-mail addresses at the push of a single button!
HOW DOES E-MAIL BLASTER WORK? E-Mail Blaster has dozens of special filters
to automatically harvest E-mail addresses from major online services such as:
America OnLine, Compuserve, Delphi, Genie, and of course the internet.
AOL AUTO EXTRACTOR: E-Mail Blaster has many special features like the AOL
Auto Extractor that let's you use a regular dial-up Internet connection to
collect names and addresses from America Online. Collect America Online
addresses without being a member. Allows you to download names and addresses
from America Online without paying membership fees or online charges. Auto Extractor
for all of the online services and Special E-mail database search engines will
also be available at no additional charge.
SIMPLE TO USE: E-Mail Blaster does all the work for you. Unlike other
programs where you must cut & paste addresses, E-Mail Blaster does it for you
automatically. And, unlike other E-mail programs, with E-Mail Blaster there
is no need to purchase any additional software
SPEED: Your time is important. E-MAIL Blaster is DRAMATICALLY FASTER at
extracting and sending E-mails than all the other programs on the market
that we tested it against.
NO SPECIAL EQUIPMENT NEEDED: E-Mail Blaster runs on a PC with Windows
3.xx Windows 95, Windows NT, a 386 or faster processor, 4 MB RAM, and a
hard drive with at least 10 MB free and your own SLIP or PPP connection. No
other software needed. Also runs on a Macintosh with Soft Windows installed.
******************************************************************
This message was sent using E-Mail Blaster.
E-Mail Blaster is The World's Leading Bulk E-mail software.
With E-Mail Blaster you can advertise to over 100 million people for FREE!
Cost: We are giving away Email Blaster your only cost is $165.00 License fee.
THAT'S IT!!!
Our company is in the software business of developing cutting edge products, so
we know if you have the opportunity to use our software FREE you will be our future
customers. We know we need you to make our software business a true success!
(Please if our lists are incorrect put "remove" in the subject and just
hit "REPLY" and you will not be bothered again. Please forgive our mistake).
**************************************************************************************************************
To take advantage of this opportunity, please fill out the order form below and fax to
1-407-380-3545. Don't miss out on this opportunity! Sales Rep: (Nejeh Yusuf @ 407 380 3545 )
Name: _____________________________________________________
Address:____________________________________________________
City:___________________________________________
State:___________________________
Zip:_____________________________
Telephone::_____________________________________________
E-Mail Address:__________________________________________
#of Copies @ $165.00 each ______________
If you would like to run Email Blaster on multiple computers or if you would
like to resell Email Blaster for up to $499. you may purchase additional copies
of Email Blaster for only $165.00. Retails for $499.00 This price is only available
at the time of this order! So, Take advantage now and reserve your additional copies now!
****************************************************************************
WE DO ALSO ACCEPT CHECKS BY FAX AND PHONE. WHY WAIT WHILE YOU CAN GET AHEAD.
*********************************************************************************
If you would like to pay by check, money order, or cashiers check please make payable to: Nejeh Yusuf mail to: 2168 River Park Blvd. Orlando Florida 32817 or Fax to 1-407-380-3545 along with this order form.
nejeh@gdi.net
------------------------------
Date: Wed, 23 Apr 1997 22:00:12 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: fish <gis84514@cis.nctu.edu.tw>
Subject: Re: Any graphic module available?
Message-Id: <Pine.GSO.3.96.970423215927.7796G-100000@kelly.teleport.com>
On 23 Apr 1997, fish wrote:
> Is there any module that can handle this?
If there is, it should be on CPAN. If it's not, you're welcome to submit
one. :-) Hope this helps!
http://www.perl.com/CPAN/
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: Thu, 24 Apr 1997 00:12:16 -0400
From: paula@irnoise.com (Paula Chase)
Subject: Re: CGI scripts
Message-Id: <paula-2404970012160001@mfs-2-105.port.shore.net>
In article <3354EE5C.45B6@netcom.ca>, hydrogen@netcom.ca wrote:
> Hi!
> Does anyone know of an ISP that is friendly or open to the idea of
> allowing space on their servers for testing CGI's for non-commercial
> use. I'm learning perlI and would like to be able to test my CGI
> scripts. Preferably this ISP would charge nothing or very little for
> this service if I was to use them as my service provider. I live in the
> Toronto, Ontario area.
> Thanks
> Luis
We use best.com in California, and they let us use whatever CGI's we
want. And their prices are very reasonable.
Paula
------------------------------
Date: Wed, 23 Apr 1997 23:01:22 -0600
From: grajek@orasis.com
To: grajek@orasis.com
Subject: dbm hash file always expanding
Message-Id: <861854113.19295@dejanews.com>
Greetings:
I am having trouble w/ a perl DBM on a linux system (RedHat 2.0.24)
using Perl 5.003.
My problem is that the hash file keeps expanding - regardless
of the fact that the associative array is always staying around
4,000 entries. Though, I am deleting and adding 500 entries
every 4 hours.
The bottom line is that the hash file, over the course of a few
months, has expanded to 40 MB!
Of course, I am running a delete when I remove an entry from
the dbm:
delete $filebase{$dc3_file};
In addition, I am checked via the debugger that I always
close the dbm: (I run as root)
dbmopen(%filebase, $HASH_TABLE, 0744) || ($dbm_err=1);
...
dbmclose(%filebase);
Lastly, I have confirmed that the entries are no longer in
the dbm, by running, after the deletes, a function that list
all known elements: (I then check for the deleted elements -
they are always removed)
foreach $key (sort keys %filebase) {
print ("key= $key :: $filebase{$key}\n");
}
OK, bottom line: Am I missing something? Is there some kind
of "compress" command I can run to tell perl to compress this
hash file after doing the deletes?
Please e-mail me directly as well. Thanx for your help.
Garret Grajek
grajek@orasis.com
714 829-0636
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Wed, 23 Apr 1997 21:18:00 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "christop@ozinter.co.jp" <christop@ozinter.co.jp>
Subject: Re: Get Chars up to first | without splitting
Message-Id: <Pine.GSO.3.96.970423204525.7796A-100000@kelly.teleport.com>
On Wed, 23 Apr 1997, christop@ozinter.co.jp wrote:
> I've got a text file that contains this -
>
> 001|something|something else|and some more
>
> - reading into $line a line at a time and I want to just put the 001 bit
> into $FirstBit.
> Can I extract the characters up to the first occurrence of | ?
Yes, and Perl can do this in N ways, where N is arbitrarily large and the
code is arbitrarily ugly. :-) For N=6,
$first = substr $line, index($line, '|');
($first) = split /\|/, $line;
($first) = $line =~ /^(.*?)\|/;
$first = $line; chop $first while index($first, '|') > -1;
$_ = ($first = $line) =~ tr/|//; 1 while chop($first) ne '|' or --$_;
{ my @foo; $_ = $line; push @foo, $_ while length chop;
$first = (sort { length $b <=> length $a } grep !/\|/, @foo)[0] }
The first is probably as good as anything you can get, but the second
shouldn't be too bad either. The others are just TMTOWTDI, and I'd avoid
them no matter how many other people recommend any of them. :-) Hope this
helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: Wed, 23 Apr 1997 20:55:33 -0700
From: Mike_and_Beth <mandbx@wco.com>
Subject: How to match an *
Message-Id: <335ED9B5.588@wco.com>
I have a simple text file I want to strip all previously REMMED out
lines from. The original author used asterisks to begin/mark unused
lines. ie;If the line starts with a "*" ... delete it. I can't seem to
get PERL to not use the wildcard or 0 or more literal meaning. I've
tried $string = "*"; and used the /\Q$string\E/ ...
any suggestions ?
I am plugging thru "eZone's PERL5 Interactive Course book" I may be slow
but I'm slow.
Mike in SRCA
------------------------------
Date: Fri, 25 Apr 1997 00:13:31 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: How to match an *
Message-Id: <comdog-2504970013310001@nntp.netcruiser>
In article <335ED9B5.588@wco.com>, Mike_and_Beth <mandbx@wco.com> wrote:
> I have a simple text file I want to strip all previously REMMED out
> lines from. The original author used asterisks to begin/mark unused
> lines. ie;If the line starts with a "*" ... delete it. I can't seem to
> get PERL to not use the wildcard or 0 or more literal meaning. I've
> tried $string = "*"; and used the /\Q$string\E/ ...
that didn't work? maybe something else was wrong?
#!/usr/bin/perl
$string = "asterisk -> * <-";
# there's more than one way to do it :)
#$string =~ s/ \* //x;
#$string =~ s/ \Q* //x;
#$regex = '*'; $string =~ s/ \Q$regex //x;
#$regex = '*'; $string =~ s/ \Q$regex\E //x;
$regex = '\*'; $string =~ s/ $regex //x;
print $string, "\n";
__END__
--
brian d foy <URL:http://computerdog.com>
unsolicited commercial email is not appreciated
------------------------------
Date: Wed, 23 Apr 1997 06:09:19 GMT
From: mark@ntr.net (Mark Mills)
Subject: Re: How to track memory usage
Message-Id: <335ea72d.183894367@news.ntr.net>
On Mon, 21 Apr 1997 11:10:09 -0700, Tom Phoenix
<rootbeer@teleport.com> wrote:
>I'm no expert, but I believe that recent versions of Perl can be compiled
^^^^^^^^^^^^^
You take that back! => Next thing you know he'll be using IMHO in
his .sig!
>-- Tom Phoenix http://www.teleport.com/~rootbeer/
>rootbeer@teleport.com PGP Skribu al mi per Esperanto!
>Randal Schwartz Case: http://www.lightlink.com/fors/
>
--
Mark <mark@ntr.net>
Please don't sue my boss because you don't
understand the concept of free speech.
------------------------------
Date: 24 Apr 1997 13:33:49 +1000
From: Chris.Bitmead@alcatel.com.au (Chris Bitmead uid(x22068))
Subject: Re: Lisp is neither (was Re: Ousterhout and Tcl lost the plot)
Message-Id: <s6y2081m6w2.fsf@aalh02.alcatel.com.au>
"M. Prasad" <prasadm@polaroid.com> writes:
> We seem to have lots of opinions, with a fair amount
> of blame placement on management. But you don't get to manage
> a start-up with that many high-powered brains, unless
> you are really good and proven. So I still doubt the
> "bad management" theory very much.
All too often start-ups are not managed by people who really
understand the technology and where they should be headed. Often they
are glorified salesmen and hype merchants.
I can think of several start-up companies which should be taking the
market by storm, but can't get it together.
------------------------------
Date: Wed, 23 Apr 1997 21:27:09 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Yuxi Yin <yin@parc.xerox.com>
Subject: Re: migrate from Perl4 to Perl5
Message-Id: <Pine.GSO.3.96.970423212448.7796C-100000@kelly.teleport.com>
On Tue, 22 Apr 1997, Yuxi Yin wrote:
> I got the following error for one of the Perl4 files when they are
> migrated to Perl5:
>
> Could not load file10.pl: No such file or directory
> Loading file10.pl got error
> file10.pl has too many errors
>
> Is there a way to display the detail error message?
There is no file called file10.pl in the place where the
script was looking for it.
What more details would you want? You may want to put some print
statements into the offending code to show you some debugging information.
Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: Wed, 23 Apr 1997 22:02:21 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Richard Schwinn <wpc@waterfordbikes.com>
Subject: Re: Newbie Alert! Problems getting netscape to recognize a perl script.
Message-Id: <Pine.GSO.3.96.970423220106.7796H-100000@kelly.teleport.com>
On Sun, 20 Apr 1997, Richard Schwinn wrote:
> Subject: Newbie Alert! Problems getting netscape to recognize a perl script.
>
> I've entered a simple program and loaded in my directory on our UNIX
> server. I can run the program through telnet by invoking PERL directly
> but I can't get Netscape to recognize the script as a PERL program.
> Netscape treats it like an HTML file and doesn't recognize the commands?
You don't have a Perl-enabled Netscape Navigator, do you? :-)
This is a server problem, not a Perl problem. When you're having trouble
with a CGI form in Perl, you should first look at the
please-don't-be-offended-by-the-name Idiot's Guide to solving such
problems. It's available on the perl.com web pages. Hope this helps!
http://www.perl.com/perl/
http://www.perl.com/perl/faq/
http://www.perl.com/perl/faq/idiots-guide.html
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: Thu, 24 Apr 1997 04:17:30 GMT
From: dkcombs@netcom.com (David Combs)
Subject: Re: Ousterhout and Tcl lost the plot with latest paper
Message-Id: <dkcombsE94Jx6.q4@netcom.com>
> TO LISP AND FORTH FANS: one important reason your languages
> have never caught on may be due to the fact that many natural languages
> follow the "subject verb object" form. Usage of SOV, OSV, VSO, and VOS
> are less likely ...
Spanish, I believe, often uses VSO and VOS, even.
------------------------------
Date: 24 Apr 1997 12:39:58 +1000
From: Chris.Bitmead@alcatel.com.au (Chris Bitmead uid(x22068))
Subject: Re: Ousterhout and Tcl lost the plot with latest paper
Message-Id: <s6y67xdm9dt.fsf@aalh02.alcatel.com.au>
ark@research.att.com (Andrew Koenig) writes:
> In article <335D64A7.167E@nospam.acm.org> Thant Tessman <thant@nospam.acm.org> writes:
>
> > And I recommend folks learn *any* language that supports higher-order
> > functions, automatic memory management, and incremental compilation
> > to see how truly wretched C++ is, regardless of whatever claims
> > Stroustrup makes for it.
>
> I learned Standard ML, which has all three of these properties,
> several years ago, and I can say with confidence that from where
> I sit, C++ is not wretched by comparison -- just different.
> Each language has its strengths and weaknesses.
><snip goes on to explain a particular problem with the ML language>
I can't speak for ML since I've never used it. The problem you
describe with ML has nothing whatsoever to do with automatic memory
management, higher order functions or incrememental compilation. I
think Thant's comment still stands. The problem you describe with ML
does not exist in the Lisp languages for example.
Yes C++ is wretched. I too was an early adopter of C++. I really liked
it at the time. I thought it was the bees-knees. Now having worked on
lots of major projects using it, I know that C++ has set back
commercial software development practice by at least a decade, maybe
more.
> Incidentally, this whole discussion talks only about language. In deciding
> what programming tools to use, there is more than that to consider. After
> all, if all you care about is how easy the language is for you to use, why not
> just invent your own language? You won't have a compiler for it unless you
> write one, but if ease of programming is all you care about, that doesn't
> matter. Of course, this facetious remark is intended to illustrate that
> having a compiler that works well in your context matters too. But even that
> is not all that matters. There is also the question of what tools your colleagues
> use, and what tools the people might be using who will be maintaining your
> code, and what machines you might be called on to support in the future.
I'd swap every "tool" and code generator and visual do-dad in the
world for a good language any day of the week. I'd rather do a project
in basic Lisp than C++ with every imaginable tool, class library and
visual whatever in the world. C++ is simply not productive, end of
story.
> C++ built on C precisely so that it would appeal to the existing C community.
> As a result, support tools, a body of knowledge, and a community came along
> more readily than they would have if the language had been designed totally
> from scratch.
Yes, the community came along readily. It's a tradgedy isn't it?
> And that knowledge and community, and those tools, are among
> the main reasons why C++ is now in widespread commercial use and so many
> of the designed-from-scratch languages are not.
------------------------------
Date: Thu, 24 Apr 1997 01:07:02 -0400
From: "Andrew P. Mullhaupt" <amullhau@ix.netcom.com>
Subject: Re: Ousterhout and Tcl lost the plot with latest paper
Message-Id: <335EEA76.5433@ix.netcom.com>
Kelly Murray wrote:
>
> I propose a new dialect which has a simplified syntax, that makes it accessible,
> but without losing it's power, by adding a few simple keywords
> to replace parenthesis.
Readers in comp.lang.python who are subjected to this relentlessly
Lisp-ish thread via crossposting will no doubt rejoice that at least
someone, somewhere, wants to get rid of some parentheses....
Later,
Andrew "We don't need no steenkin' Dyck languages" Mullhaupt
------------------------------
Date: Tue, 22 Apr 1997 23:35:00 +0200
From: Petri Backstrom <...petri.backstrom@icl.fi>
Subject: Re: Perl compiler
Message-Id: <335D2F04.447A@icl.fi>
Jaime Stuardo wrote:
>
> Is there a Shareware Perl compiler?
No, but there's one that doesn't cost anything. ;-)
Start with
http://www.perl.com/perl/
and
http://www.activeware.com
(the latter if you want a Win32 version of Perl).
regards,
...petri.backstrom@icl.fi
ICL Data Oy
Finland
------------------------------
Date: Thu, 24 Apr 1997 05:17:52 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: printing variable names (Perl needs MACROS!)
Message-Id: <E94Mps.B0D@nonexistent.com>
On Thu, 24 Apr 1997 02:30:28 GMT, David Combs wrote in
comp.lang.perl.misc <URL: news:dkcombsE94Eys.7zA@netcom.com>:
++ In article <5j5vk5$lqc@netnews.upenn.edu>, sdm <sdm@red.seas.upenn.edu>
++ wrote:
++ > I am wondering if there is a way to print out the actual name
++ >of a variable, as well as what the variable contains. Something like this:
++ >
++ >foreach $os ($Windows,$Windows31,$Windows95,$WindowsNT) {
++ > print $os,"\t\t",$os,"\n";
++ >}
++ >
++ >Where the first $os is the name of the variable, not what is contained
++ >in it.
Perhaps you want:
$ perl -w
use vars qw ($foo $bar);
$foo = "This is foo";
$bar = "This is bar";
foreach $n (qw (foo bar)) {
print $n, ": ", $$n, "\n";
}
__END__
foo: This is foo
bar: This is bar
$
Abigail
------------------------------
Date: Wed, 23 Apr 1997 21:42:31 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Chipmunk <Ronald.J.Kimball@dartmouth.edu>
Subject: Re: STDOUT | PAGER
Message-Id: <Pine.GSO.3.96.970423212731.7796D-100000@kelly.teleport.com>
On 23 Apr 1997, Chipmunk wrote:
> My perl program pipes some of its output through a pager:
> $pager = $ENV{PAGER} || 'more';
> open (PAGER, "| $pager") or *PAGER = *STDOUT;
Hmmm.... Do you know what happens if someone's selected pager can't be
run?
> Unfortunately, if the pager is more, and I exit more in the middle of
> the output by typing 'q', my perl program exits with the message
> 'Broken Pipe'.
>
> How can I make the perl continue execution normally if someone exits
> the pager before reaching the end of the output?
Have you tried catching the SIGPIPE? Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 24 Apr 1997 04:00:09 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: switch and if
Message-Id: <5jmls9$ap0$1@dartvax.dartmouth.edu>
In article <335E3B6E.39D8@prestel.net>
iqbal gandham <igandham@prestel.net> writes:
> Is it better to use an if statement or switch, or doesn't it make much
> difference.
>
> I have about eight if else statemants.
>
> As far as I know if you use if statements then it checks through every
> statement, whereis using the switch method you can fall out of the block
> when say the pattern is met.
You are absolutely right about that. There is no reason to use
multiple if/else statements like that in Perl, when Perl's switch
statement will do the same thing much more efficiently.
Chipmunk
------------------------------
Date: 24 Apr 1997 03:05:49 GMT
From: brew1@voicenet.com (Bruce Schiller)
Subject: Uninitialized variable warning
Message-Id: <5jmimd$rj3$1@news2.voicenet.com>
I've been working on a problem the past day or so with no progress, and so
am turning here for help.
I wrote a perl script (actually I used Randall's Tiny Database example
from his Unix World column of a few years ago as a starting point, (thanks
Randall!)) and it worked OK on my PC (using 5.000M5). But on the SunOS
machine (perl 5.003 EMBED) which I ultimately want it to run on the w
switch reports an uninitialized variable.
And indeed, the if statement using that variable doesn't see it after it
is set to 1. If the var is not set to 1, but left at zero, I don't get
the warning.
I fail to see an uninitialized var. Could someone please help me sharpen
my eyesight?
I've tried using my vs. local, and a few other things in the if statement
which shouldn't make a difference, and they don't. Still uninitialized.
I've searched dejanews for "perl uninitialized variable" for clues with no
luck.
I wrote a small cut down script to ferret out the problem with on the
SunOS machine, but it didn't fail.
The part of the script that fails follows.
Thanks for any ideas you may have.
brew
================================================================
#!/usr/bin/perl -w
sub get_listings {
my ($filename, $data_hash1) = @_;
my ($ref_entry, $flag, $pointer_key);
my $file_read_flag = 0;
if(open(INFILE, $filename)) {
# load the database into an array of anon structs
while (<INFILE>) {
# for each entry:
$ref_entry = {}; # anon hash
A -----> $flag = 0;
foreach (split /\n/) {
# for each line in entry;
B -----> if ($flag == 0) { <--- also tried if (!$flag)
if (/^(.*?): (.*)$/) {
$$ref_entry{$1} = $2;
if ($1 eq "Listing") {
C -----> $flag = 1;
# uninitialized variable warning at B, after $flag is set to 1 at C.
}
}
}
# this adds the lines after the listing part starts
else {
$$ref_entry{$1} .= "\n" . $_;
}
}
# make the key to the pointer hash
$pointer_key = "$$ref_entry{\"A/C code\"}" .
"$$ref_entry{\"Cat\"}" . "$$ref_entry{\"Address\"}";
# save to a hash of pointers,
$$data_hash1{$pointer_key} = $ref_entry;
}
$file_read_flag = 1;
close INFILE;
}
return($file_read_flag);
}
------------------------------
Date: 24 Apr 1997 12:59:42 +1000
From: Chris.Bitmead@alcatel.com.au (Chris Bitmead uid(x22068))
Subject: Re: wretched C++ (Was: Ousterhout and Tcl lost the plot with latest paper)
Message-Id: <s6y4tcxm8gx.fsf@aalh02.alcatel.com.au>
thornley@visi.com (David Thornley) writes:
> OK, so your compiler doesn't support the draft ANSI standard,
> and doesn't provide warnings or clues. This looks like an
> implementation problem to me. In particular, I don't think
> it's actually Stroustrup's fault you spent hours figuring this
> out.
>
> >C++ is *full* of bullshit like this and I've spent way too
> >much of my life fighting it.
>
> No, C++ compilers are full of bullshit. On my favorite platform,
> the C++ libraries automatically installed are really, really
> shaky, requiring explicit iterator_traits declarations just
> in able to do a simple vector<Fnord, allocator<Fnord> >
> (which, of course, should be writable as vector<Fnord>).
The fact is, C++ has reached a level of complexity that even given
infinite resources and talent, it's near (but not quite) impossible to
write a fully conforming C++ implementation without bugs or
quirks. The language definition itself is ambiguous. (Think about all
the ways you can use ">" and "<" as an example.) Forget about writing
one which actually compiles and links fast.
By contrast Lisp is infinitely more powerful and expressive as a
language, and yet before I even learnt how to write a loop in lisp I
sat down one weekend and wrote a lisp interpreter. Wow! what sort of
Lisp compilers would we have if Sun and others sunk the same effort
they do with C++ compilers into lisp?
> When the dust is settled, C++ will have many of the things I like
> about Lisp, and will be cheaper, more readily available, and will
> be better about producing stand-alone applications. Further, I
> think C++ will be very usable, and that many of its faults can
> be corrected with libraries, just as many things that should be
> in Common Lisp have been implemented with macros.
Oh boy. The problems of C++ are nothing to do with the cleverness of
the libraries. C++ is beyond hope. Yes you can do lots of powerful
things in C++. Even more so as more libraries become available. But
you can't do big projects in non-geological timeframes.
------------------------------
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 360
*************************************