[15692] in Perl-Users-Digest
Perl-Users Digest, Issue: 3105 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 19 21:15:30 2000
Date: Fri, 19 May 2000 18:15:16 -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: <958785316-v9-i3105@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 19 May 2000 Volume: 9 Number: 3105
Today's topics:
Re: the use of $_ <uri@sysarch.com>
Re: the use of $_ <mcdonabNO@SPAMyahoo.com>
Re: the use of $_ <callgirl@la.znet.com>
Re: the use of $_ (Elliot Finley)
Re: the use of $_ <thunderbear@bigfoot.com>
Re: the use of $_ <lr@hpl.hp.com>
Re: Use/Require Difference <Jonathan.L.Ericson@jpl.nasa.gov>
Re: What book on perl-cgi for a perl-programmer? (DEDSRD)
Re: What is the CPAN module repository (url) name that <jeff@vpservices.com>
Win32::ODBC and -w (Bob M)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 19 May 2000 22:08:26 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: the use of $_
Message-Id: <x7og62fb1i.fsf@home.sysarch.com>
>>>>> "G" == Godzilla! <godzilla@stomp.stomp.tokyo> writes:
G> Brian McDonald wrote:
>> The problem here is (clearly) that I am already
>> using $_ to hold the input file name. What are
>> my options?
G> It's local bigotry. Oh my $word.
and you are our local moron.
G> http://www.plover.com/~mjd/perl/local.html
G> Plover's site.
his name isn't plover. but you can't read for comprehension. proof is in
the first section:
my makes most uses of local obsolete. So it's not surprising
that the most common useful uses of local arise because of
peculiar cases where my happens to be illegal.
so it is not bigotry, but a proper understanding of why my is better for
all cases BUT these 7 special ones. having special cases means that my
is meant to be used and not local unless local is needed.
you stick with local not because it is better than my or that my has
problems, but becuase you think perl4 is a real thing used by real
people. notice how we rarely get perl4 problems here? nobody is using it
anymore but dinosaur isps and people who like the smell of rotting camel
flesh.
so to clarify the issue in words you can understand:
there are major benefits to using my over local. there are 7 useful
exceptions where local is needed, and all involve symbol table issues
such as type globs, special variables, and scoping. my is safer than
local as it is lexically scoped and it is the only way to dynamically
allocate memory for closures. those are the reasons it should be used
for all regular variable declarations.
as for local, my rule applies: it should only be used by someone who
know when NOT to use it. this rule mean you. you don't understand what
local is doing and why my is better. so you should stick to my and later
learn what local does. but i doubt that will happen.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Fri, 19 May 2000 15:55:54 -0700
From: "Brian McDonald" <mcdonabNO@SPAMyahoo.com>
Subject: Re: the use of $_
Message-Id: <8g4gqv$i6q$1@nntp9.atl.mindspring.net>
Thanks Tad, et.al.
I'm going with the "foreach" construct that you proposed below... pretty
much as is.
My mistake on the meaning of while(<>). I didn't think that it actually read
in input... I thought it just allowed one to cycle through the arguments in
@ARGV.
Also, this...
> > open (TXTIN,$_) || die "";
>
> That is a profoundly sad diagnostic. :-(
was a profoundly funny comment. But, I was just abbreviating, since I was
typing as opposed to pasting.
I'm getting a new error now, and I'm hard pressed to understand it. I don't
mind if someone tells me just how to go about finding information on a
"keyword" such as "bareword" in the ActivePerl (or other) documentation. I
see no master index and I cannot deduce the section to look in. I've
searched on "bareword" at deja and at perl.com and just get a lot of fluff.
Here's the error:
"Bareword found where operator expected at txt2xml.pl line 172, near "if
(/FIRSTNAME"
(Might be a run-away multi-line // string starting on line 153
Do you need to predeclare if?)
syntax error at txt2xml.pl line ...
"
"
Excution of txt2xml.pl aborted due to compilation errors."
Here's the code:
use strict;
...
...
# get next input file from ARGV array
foreach my $infile (@ARGV) {
# append new .xml extension to output file
my $outfile = $infile;
$outfile =~ s/.txt/.xml;
# open file for reading line by line
open (TXTIN, $infile) || die "can't open $infile: $!";
open (XMLOUT, ">$outfile") || die "can't open $outfile: $!";
# print the xml file header declaration, and etc.
print XMLOUT "<?xml version=\"1.0\"?>\n";
print XMLOUT "<!DOCTYPE xxx SYSTEM \"xxx.dtd\">\n";
print XMLOUT "$roottag\n";
print XMLOUT getIndent(1);
print XMLOUT "$childtags[0]"; # <...>
#######################################
# loop over all the lines in the file
#######################################
while (<TXTIN>) {
chomp;
## check if this is a descriptor or a line
if (/FIRST=*/) {
# get first name
s/FIRST=//;
$firstnm = $_;
} elsif (/LAST=*/) {
$lastflag = 1; # set last name flag
# get last name
s/LAST=//;
$lastnm = $_;
print XMLOUT $firstnm . " " . $lastnm . $childetags[0] . "\n"; # </...>
} elsif (/TITLE=*/) {
# get title
s/TITLE=//;
...........................
..............
getIndent(1) is a call to a subroutine. I have a faint suspicion that this
might be the instigator, but I am too much a newbie to imagine how.
Thanks again,
brian
"Tad McClellan" <tadmc@metronet.com> wrote in message
news:slrn8ib6vv.920.tadmc@magna.metronet.com...
> On Fri, 19 May 2000 11:53:29 -0700, Brian McDonald
<mcdonabNO@SPAMyahoo.com> wrote:
>
> >I am confused by the manner in which Perl assigns values to the default
> >variables.
>
>
> And also, it appears, by how command line args are passed :-)
>
> You are not confused by "while(<>)" since you say below that
> you see what the problem is.
>
>
> >Now I am modifying it so that I can list the
> >text files as arguments on the command line.
>
>
> The command line args are in the @ARGV array.
>
> If you want to process them yourself (instead of having <>
> process them for you), then process them yourself :-)
>
>
> > So, I am wrapping a new while
> >statement around the while that does the core text processing.
> >
> ># get next input file from command line
> >while (<>) {
>
>
> That does NOT "get next input file from command line"!
>
> It:
>
> opens the file named on the command line
>
> reads lines from that file
>
> You are processing the _contents_ of the file, not the _filename_ here.
>
>
> > my $outfile = $_;
> > $outfile =~ s/.txt/.xml;
>
>
> foreach my $infile ( @ARGV ) { # foreach instead of while
> my $outfile = $infile;
> $outfile =~ s/.txt/.xml;
> ...
>
>
> Or, if you are really attached to while():
>
> while ( my $infile = shift ) { # shift defaults to shifting @ARGV in
main
> my $outfile = $infile;
> $outfile =~ s/.txt/.xml;
> ...
>
>
>
> > # open file for read
> > open (TXTIN,$_) || die "";
>
>
> That is a profoundly sad diagnostic. :-(
>
>
> open (TXTIN, $infile) || die "could not open '$infile' $!";
>
>
> > # open file for output
> > open (XMLOUT,">$outfile") || die "";
> >
> > while (<TXTIN>) {
>
>
> You can continue using $_ for that loop if you like.
>
>
> >The problem here is (clearly) that I am already using $_ to hold the
input
> >file name. What are my options?
>
>
> Use a variable with different name for one or the other of them.
>
>
> >I suspect that this is a stupid question, but the camel book doesn't
provide
> >a discourse on the use of $_, and the documentation that comes along with
> >ActivePerl doesn't provide me with either the detail or the clarity I
need.
> >Unless there's another source of info than "perlvar".
>
>
> You never _have_ to use $_.
>
> You can _always_ fall back to naming all of your own variables,
> it just means more typing.
>
>
> --
> Tad McClellan SGML Consulting
> tadmc@metronet.com Perl programming
> Fort Worth, Texas
------------------------------
Date: Fri, 19 May 2000 16:35:24 -0700
From: Kiralynne Schilitubi <callgirl@la.znet.com>
Subject: Re: the use of $_
Message-Id: <3925CFBC.DC4E4D97@la.znet.com>
Uri Guttman wrote:
> and you are our local moron.
(snipped further harassment)
Mr. Guttman, one more incident of stalking
and harassment of myself, I will file a
series of formal complaints with both
Hurricane Electric Internet Services and
Media 1 Internet Services. These complaints
will be countersigned by our family civil
attorney for emphasis with a suggestion
of litigious remedy.
Your posting history for the past five months,
those posts directed at me, contain vulgarity,
vile personal insults, libelous statements,
threats of crime and other equally sociopathic
statements. All of these postings are well
documented, hard copied and in the hands of
our family attorney along with being quite
independently verifiable via archived articles
online at various news providers.
One more incident of stalking and harassment
Mr. Guttman, our family and our civil attorney,
will pursue aggressive and appropriate actions
against you personally, your com site, your
internet account and we will give our blood money
attorney the go ahead on a contingency basis to
relieve you of whatever money he feels will be
awarded as compensatory compensation for personal
injury and libel.
As you know I recently filed criminal concerns
with law enforcement regarding another actively
participating within this group. I will be even
more aggressive regarding you, especially in
light of your past criminal conduct regarding
our family, this is, threatening to commit
crimes against our family, which in itself,
is criminal, as is your stalking and harassment.
Kiralynne Schilitubi
cc: abuse@mediaone.net
cc: hostmaster@he.net
------------------------------
Date: Fri, 19 May 2000 23:55:21 GMT
From: efinley@efinley.com (Elliot Finley)
Subject: Re: the use of $_
Message-Id: <3928d439.69290559@news.firstworld.net>
On Fri, 19 May 2000 15:55:54 -0700, "Brian McDonald"
<mcdonabNO@SPAMyahoo.com> wrote:
>I'm getting a new error now, and I'm hard pressed to understand it. I don't
>mind if someone tells me just how to go about finding information on a
>"keyword" such as "bareword" in the ActivePerl (or other) documentation. I
>see no master index and I cannot deduce the section to look in. I've
>searched on "bareword" at deja and at perl.com and just get a lot of fluff.
>
>Here's the error:
>
>"Bareword found where operator expected at txt2xml.pl line 172, near "if
>(/FIRSTNAME"
> (Might be a run-away multi-line // string starting on line 153
> Do you need to predeclare if?)
>syntax error at txt2xml.pl line ...
> "
> "
>Excution of txt2xml.pl aborted due to compilation errors."
>
>Here's the code:
>
>use strict;
>...
>...
># get next input file from ARGV array
>foreach my $infile (@ARGV) {
> # append new .xml extension to output file
> my $outfile = $infile;
> $outfile =~ s/.txt/.xml;
^^^^^^^^^^^
There's your error.
>
># open file for reading line by line
> open (TXTIN, $infile) || die "can't open $infile: $!";
> open (XMLOUT, ">$outfile") || die "can't open $outfile: $!";
>
># print the xml file header declaration, and etc.
> print XMLOUT "<?xml version=\"1.0\"?>\n";
> print XMLOUT "<!DOCTYPE xxx SYSTEM \"xxx.dtd\">\n";
> print XMLOUT "$roottag\n";
> print XMLOUT getIndent(1);
> print XMLOUT "$childtags[0]"; # <...>
>
>#######################################
># loop over all the lines in the file
>#######################################
> while (<TXTIN>) {
> chomp;
> ## check if this is a descriptor or a line
> if (/FIRST=*/) {
> # get first name
> s/FIRST=//;
> $firstnm = $_;
> } elsif (/LAST=*/) {
> $lastflag = 1; # set last name flag
> # get last name
> s/LAST=//;
> $lastnm = $_;
> print XMLOUT $firstnm . " " . $lastnm . $childetags[0] . "\n"; # </...>
> } elsif (/TITLE=*/) {
> # get title
> s/TITLE=//;
>...........................
>..............
>
>getIndent(1) is a call to a subroutine. I have a faint suspicion that this
>might be the instigator, but I am too much a newbie to imagine how.
>
>Thanks again,
>
>brian
>
>
>"Tad McClellan" <tadmc@metronet.com> wrote in message
>news:slrn8ib6vv.920.tadmc@magna.metronet.com...
>> On Fri, 19 May 2000 11:53:29 -0700, Brian McDonald
><mcdonabNO@SPAMyahoo.com> wrote:
>>
>> >I am confused by the manner in which Perl assigns values to the default
>> >variables.
>>
>>
>> And also, it appears, by how command line args are passed :-)
>>
>> You are not confused by "while(<>)" since you say below that
>> you see what the problem is.
>>
>>
>> >Now I am modifying it so that I can list the
>> >text files as arguments on the command line.
>>
>>
>> The command line args are in the @ARGV array.
>>
>> If you want to process them yourself (instead of having <>
>> process them for you), then process them yourself :-)
>>
>>
>> > So, I am wrapping a new while
>> >statement around the while that does the core text processing.
>> >
>> ># get next input file from command line
>> >while (<>) {
>>
>>
>> That does NOT "get next input file from command line"!
>>
>> It:
>>
>> opens the file named on the command line
>>
>> reads lines from that file
>>
>> You are processing the _contents_ of the file, not the _filename_ here.
>>
>>
>> > my $outfile = $_;
>> > $outfile =~ s/.txt/.xml;
>>
>>
>> foreach my $infile ( @ARGV ) { # foreach instead of while
>> my $outfile = $infile;
>> $outfile =~ s/.txt/.xml;
>> ...
>>
>>
>> Or, if you are really attached to while():
>>
>> while ( my $infile = shift ) { # shift defaults to shifting @ARGV in
>main
>> my $outfile = $infile;
>> $outfile =~ s/.txt/.xml;
>> ...
>>
>>
>>
>> > # open file for read
>> > open (TXTIN,$_) || die "";
>>
>>
>> That is a profoundly sad diagnostic. :-(
>>
>>
>> open (TXTIN, $infile) || die "could not open '$infile' $!";
>>
>>
>> > # open file for output
>> > open (XMLOUT,">$outfile") || die "";
>> >
>> > while (<TXTIN>) {
>>
>>
>> You can continue using $_ for that loop if you like.
>>
>>
>> >The problem here is (clearly) that I am already using $_ to hold the
>input
>> >file name. What are my options?
>>
>>
>> Use a variable with different name for one or the other of them.
>>
>>
>> >I suspect that this is a stupid question, but the camel book doesn't
>provide
>> >a discourse on the use of $_, and the documentation that comes along with
>> >ActivePerl doesn't provide me with either the detail or the clarity I
>need.
>> >Unless there's another source of info than "perlvar".
>>
>>
>> You never _have_ to use $_.
>>
>> You can _always_ fall back to naming all of your own variables,
>> it just means more typing.
>>
>>
>> --
>> Tad McClellan SGML Consulting
>> tadmc@metronet.com Perl programming
>> Fort Worth, Texas
>
--
Elliot (efinley@efinley.com) Weird Science!
------------------------------
Date: Sat, 20 May 2000 02:19:35 +0200
From: =?iso-8859-1?Q?Thorbj=F8rn?= Ravn Andersen <thunderbear@bigfoot.com>
Subject: Re: the use of $_
Message-Id: <3925DA17.CAFD682A@bigfoot.com>
Kiralynne Schilitubi wrote:
> > and you are our local moron.
>
> (snipped further harassment)
>
> Mr. Guttman, one more incident of stalking
> and harassment of myself, I will file a
Sorry, Mam.
I don't belive anyone have written in your name here for the last five
months.
How could Uri Guttman have harrassed you then?
--
Thorbjørn Ravn Andersen "... plus .. Tubular Bells!"
http://www.mip.sdu.dk/~ravn/
------------------------------
Date: Fri, 19 May 2000 17:35:51 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: the use of $_
Message-Id: <MPG.138f7dbe10f4a81098aaa1@nntp.hpl.hp.com>
[Please don't quote the entire article you are responding to, especially
not at the end of your post. Interleave your comments into the relevant
quoted segments, as I have done below.]
In article <8g4gqv$i6q$1@nntp9.atl.mindspring.net> on Fri, 19 May 2000
15:55:54 -0700, Brian McDonald <mcdonabNO@SPAMyahoo.com> says...
...
> I'm getting a new error now, and I'm hard pressed to understand it. I don't
> mind if someone tells me just how to go about finding information on a
> "keyword" such as "bareword" in the ActivePerl (or other) documentation. I
> see no master index and I cannot deduce the section to look in. I've
> searched on "bareword" at deja and at perl.com and just get a lot of fluff.
I searched perldata for 'bare' and got this:
A word that has no other interpretation in the grammar will be treated
as if it were a quoted string. These are known as ``barewords''.
> Here's the error:
>
> "Bareword found where operator expected at txt2xml.pl line 172, near "if
> (/FIRSTNAME"
> (Might be a run-away multi-line // string starting on line 153
> Do you need to predeclare if?)
> syntax error at txt2xml.pl line ...
> "
> "
> Excution of txt2xml.pl aborted due to compilation errors."
>
> Here's the code:
>
> use strict;
> ...
> ...
> # get next input file from ARGV array
> foreach my $infile (@ARGV) {
> # append new .xml extension to output file
> my $outfile = $infile;
> $outfile =~ s/.txt/.xml;
I'll bet the line above is line 153, though you don't say so. The
diagnostic tells you exactly what is wrong.
...
> if (/FIRST=*/) {
And I'll bet that that is line 172 or so.
Big hint: I'll bet you dont find a '/' in any of the lines inbetween.
<SNIP rest of 197-line post, including Jeopardosis>
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 19 May 2000 16:46:11 -0700
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: Use/Require Difference
Message-Id: <3925D243.65086A89@jpl.nasa.gov>
[I fixed your jeopardy quote and snipped some lines to make this
discussion more readable]
Scott Pritchett wrote:
> "M.J.T. Guy" <mjtg@cus.cam.ac.uk> wrote in message
> news:8g10mr$o5i$1@pegasus.csx.cam.ac.uk...
> > In article <8g0dj7$9mo$1@lure.pipex.net>,
> > Scott Pritchett <scott@salmon.ltd.uk> wrote:
> > > #!perl -w
> > > use strict;
> > > $::x=5;
> > > use isb;
> > > print "x is $::x\n";
> > > exit;
> > >
> > >In isb :-
> > >
> > > $::x=4;
> > > print "in isb x is $::x\n";
> > >
> > >This returns :-
> > >
> > > in isb x is 4
> > > x is 5
> > >
> > >When I replace the 'use' with 'require' I get what I expected, namely :-
> > > in isb x is 4
> > > x is 4
> > >
> > >Why?!
> >
> > Because require happens at run time, use at compile time.
> >
> > perldoc -q require
> > perldoc -f use
> > perldoc -f require
>
> I know this, but what difference does that make here?
If you 'use isb', the code in isb.pm is executed _before_ your script is
executed. If you 'require isb', the code in isb.pm is executed _when_
your script is executed. Play around with:
$ perl -e '$x = 5;print qq(x is $x\n);use isb;'
to clear things up a bit. (Hint: observe the order of the output and
s/use isb;/require isb;/.)
Jon
--
Knowledge is that which remains when what is
learned is forgotten. - Mr. King
------------------------------
Date: 19 May 2000 22:27:50 GMT
From: dedsrd@aol.com (DEDSRD)
Subject: Re: What book on perl-cgi for a perl-programmer?
Message-Id: <20000519182750.18867.00000192@ng-fb1.aol.com>
for "http stuff"
TCP/IP Illustrated Volume 1
W. Richard Stevens
1994 Addison-Wesley
thought it was clear in its presentation about the protocol
Darrell
------------------------------
Date: Fri, 19 May 2000 18:01:32 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: What is the CPAN module repository (url) name that can be used for PPM/VPM?
Message-Id: <3925E3EC.CBA28B86@vpservices.com>
Eric Liao wrote:
>
> Does it exist? THanks.
No, but, IMHO, it would be a good idea, even if it mainly pointed at
other repositories.
--
Jeff
------------------------------
Date: Sat, 20 May 2000 00:49:56 GMT
From: slipper@canada.com (Bob M)
Subject: Win32::ODBC and -w
Message-Id: <UilV4.5409$714.158362@news.magma.ca>
If I run the following code using -w, I get the warning:
"Use of uninitialized value at C:/Perl/site/lib/Win32/ODBC.pm line 261"
for every call to $db->Data(). I get the same thing if I rewrite using
$db->DataHash(). However, everything seems to work fine if I don’t use -w (or
if I put "local $^W=0;" within the while loop). Is it the normal behavior of
Win32::ODBC to spew this warning or am I making some stupid newbie mistake?
Thanks
Bob
use strict;
use Win32::ODBC;
my $db;
$db=new Win32::ODBC("DSN=finances;UID=me;PWD=password")
or die Win32::ODBC::Error();
if($db->Sql("SELECT * FROM tTransactions ORDER BY Index")){
print "SQL error: " . $db->Error() . "\n";
$db->Close();
exit;
}
while ($db->FetchRow()){
my @data;
(@data) = $db->Data();
print "@data \n";
}
$db->Close();
------------------------------
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 3105
**************************************