[18438] in Perl-Users-Digest
Perl-Users Digest, Issue: 606 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 2 21:31:25 2001
Date: Mon, 2 Apr 2001 18:31:02 -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: <986261462-v10-i606@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 2 Apr 2001 Volume: 10 Number: 606
Today's topics:
Uninitialized Value warnings with DBD::CSV 0.1024 (mild <webmaster@webdragon.unmunge.net>
using an inifile <jtjohnston@courrier.usherb.ca>
Re: using an inifile nobull@mail.com
Re: Variable scoping/globals issue <gtoomey@usa.net>
Re: what are the new languages? (Logan Shaw)
Re: what are the new languages? <xzrgpnys@yvtugubhfrovm.pbz>
Re: what are the new languages? (Logan Shaw)
Re: what are the new languages? <uri@sysarch.com>
Re: Whats is the best Perl book to tech "How to use Per <keesh@users.pleaseremovethisbit.sourceforge.net>
Why "files" and "No Directories" <whataman@home.com>
Re: Why "files" and "No Directories" <krahnj@acm.org>
Re: Why "files" and "No Directories" <whataman@home.com>
Re: Why do "Programming Perl" Books Do This? a rgexp qu <Juha.Laiho@iki.fi>
Re: Why does no window open at executing the batch file (Si Ballenger)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 2 Apr 2001 19:49:51 GMT
From: "Scott R. Godin" <webmaster@webdragon.unmunge.net>
Subject: Uninitialized Value warnings with DBD::CSV 0.1024 (mildly urgent)
Message-Id: <9aal4v$6qn$0@216.155.32.18>
just out of curiosity (and since a message to someone else reminded me
that I could also do this :) I checked my weblogs with tail -f to see if
anything shows up that I was unaware of with one of my scripts, and lo!
there's about 7300 lines of this:
[Mon Apr 2 14:24:09 2001] ncmapslistdbi.cgi: Use of uninitialized value
at /opt/lib/perl5/site_perl/DBD/CSV.pm line 197.
[Mon Apr 2 14:24:09 2001] ncmapslistdbi.cgi: Use of uninitialized value
at /opt/lib/perl5/site_perl/DBD/CSV.pm line 197, <GEN1> chu
nk 1.
the offending code section:
-=-
package DBD::CSV::Table;
@DBD::CSV::Table::ISA = qw(DBD::File::Table);
sub fetch_row ($$) {
my($self, $data) = @_;
my $fields;
if (exists($self->{cached_row})) {
$fields = delete($self->{cached_row});
} else {
my $csv = $self->{csv_csv}; ## <-- the offending line 197
local $/ = $csv->{'eol'};
$fields = $csv->getline($self->{'fh'});
if (!$fields) {
die "Error while reading file " . $self->{'file'} . ": $!" if $!;
return undef;
}
}
$self->{row} = (@$fields ? $fields : undef);
}
-=-
I'm sure there's a reason for this -- but not 100% certain as to what.
the script body itself can be viewed here, in the most recent version
<http://216.155.0.50/~sgodin/misc/codesample.htm>
(too long to post here)
I looked at my code again and cannot really see where this might be
coming from. ANY help would be appreciated.. I'm QUITE sure my ISP would
prefer and appreciate that I don't fill their weblogs with 7300 lines of
this crap every time my script gets accessed. :/
Any assistance appreciated.
--
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw";
# ( damn spammers. *shakes fist* take a hint. =:P )
------------------------------
Date: Sat, 31 Mar 2001 01:46:39 -0500
From: jtjohnston <jtjohnston@courrier.usherb.ca>
Subject: using an inifile
Message-Id: <3AC57D4E.C0EB28F6@courrier.usherb.ca>
Can I use an inifile in Perl? How? Does anyone have an example? I want
to read (& possibly write to an inifile.)
Thanks,
John
------------------------------
Date: 31 Mar 2001 10:30:05 +0100
From: nobull@mail.com
Subject: Re: using an inifile
Message-Id: <u9snjuqo9u.fsf@wcl-l.bham.ac.uk>
jtjohnston <jtjohnston@courrier.usherb.ca> writes:
> Can I use an inifile in Perl?
I take it you mean Windows style .INI files.
> How? Does anyone have an example? I want
> to read (& possibly write to an inifile.)
There are a choice of modules to do this. Finding them is left as an
exercise for the reader. If you get stuck try the FAQ. In particular
look at the answer to "What modules and extensions are available for
Perl?..."
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Sat, 31 Mar 2001 17:06:31 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: Re: Variable scoping/globals issue
Message-Id: <d9fx6.6426$45.37611@newsfeeds.bigpond.com>
Thanks, guys.
I was confusing packages and modules. It's clearer now.
There are a number of confusing parts to Perl for a newbie:
Modules/Packages/BEGIN..END/OO constructs/local/my/strict.
I'm sure I'm not the only one confused.
Gregory Toomey.
------------------------------
Date: 30 Mar 2001 22:53:21 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: what are the new languages?
Message-Id: <9a3ns1$ek5$1@boomer.cs.utexas.edu>
In article <Docx6.61136$Q47.15177052@news1.rdc1.tn.home.com>,
Todd Smith <todd@designsouth.net> wrote:
> Now the people who learned
>the new PHP have great jobs.
They do?
> So what's the next new programming language
>gonna be?
I'll tell you if you tell me which stock is going to be worth a lot
more money tomorrow than it is today.
Some standard advice applies here: if you want to be able to use the
latest greatest programming language, go teach yourself a variety of
existing languages. Chances are, any new language will mostly
incorporate features that you'll already have learned. (Perl freely
admits it steals from other languages.)
It might be fun to go learn a few languages that challenge your
assumptions about how programming should work. You could start with a
pure functional language, like Standard ML or Haskell.
- Logan
--
whose? my your his her our their _its_
who's? I'm you're he's she's we're they're _it's_
------------------------------
Date: 31 Mar 2001 04:57:24 GMT
From: kevin metcalf <xzrgpnys@yvtugubhfrovm.pbz>
Subject: Re: what are the new languages?
Message-Id: <3AC56470.D7AA3286@yvtugubhfrovm.pbz>
> (Perl freely admits it steals from other languages.)
The author of perl also admits to stealing from other apps. Then again,
some of said apps are by the same author! :)
--
Kevin Metcalf
(Carbon Ocelot)
email: xzrgpnys@yvtugubhfrovm.pbz
Huh? http://www.flactem.com/utils/rot13.html
------------------------------
Date: 31 Mar 2001 01:03:27 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: what are the new languages?
Message-Id: <9a3vfv$i6n$1@boomer.cs.utexas.edu>
In article <3AC56470.D7AA3286@yvtugubhfrovm.pbz>,
kevin metcalf <xzrgpnys@yvtugubhfrovm.pbz> wrote:
>The author of perl also admits to stealing from other apps. Then again,
>some of said apps are by the same author! :)
Just don't tell me perl shares any code with rn[1]. :-)
>Huh? http://www.flactem.com/utils/rot13.html
Hmm... That URL gives a 404 error. Luckily, I can just hit "X" if I
need to decode such a thing[1].
- Logan
[1] Well, I *am* using trn right now...
--
whose? my your his her our their _its_
who's? I'm you're he's she's we're they're _it's_
------------------------------
Date: Sat, 31 Mar 2001 04:09:20 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: what are the new languages?
Message-Id: <x7bsqiwpe6.fsf@home.sysarch.com>
>>>>> "TS" == Todd Smith <todd@designsouth.net> writes:
TS> SO, I know Perl, but lots of people do. When Java first came out,
TS> the people who knew it first got the best high paying jobs. Now
TS> the people who learned the new PHP have great jobs. So what's the
TS> next new programming language gonna be? Is there a place where new
TS> languages are profiled and news is given?
perl6
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: Sat, 31 Mar 2001 13:12:56 +0100
From: "Ciaran McCreesh" <keesh@users.pleaseremovethisbit.sourceforge.net>
Subject: Re: Whats is the best Perl book to tech "How to use Perl With SQL servers"?
Message-Id: <9a4hj5$cpi$1@news6.svr.pol.co.uk>
In article <008501c0b9f2$0bbe9f00$540466d4@NetWork>,
the_programmer@arabicteam.com wrote:
> Hi guys I am an new perl programmer I bought book : Tech yourself Perl
> in 24 hours (SAMS) . And it was very good .=20 now I need book to tech
> me how to use Perl with MySql and MsSql and = PgSql . Regards
Read the Camel. Then read it again. Then read the man pages. Then you'll
understand.
And please don't post HTML news messages...
------------------------------
Date: Fri, 30 Mar 2001 23:51:01 GMT
From: "What A Man !" <whataman@home.com>
Subject: Why "files" and "No Directories"
Message-Id: <3AC51C60.A1837548@home.com>
Why does the following code move all files from $dir to the proper
directory at remote host, but if one of the files in $dir is a
directory, it moves it as a file to the remote host?
# change the directory on the ftp site
$ftp->cwd('/b-bin/recurse') or die "Can't change directories on
Remote site: $!\n";
# define local directory
$dir = "../mvr";
opendir MV, "$dir" or die "Cannot open directory: $!\n";
@files = grep !/^\.\.?$/, readdir MV or die "Can't Read Directory:
$!\n";
close MV, "$dir" or die "Cannot Close directory: $!\n";
foreach $file(@files)
{
$ftp->put($file) or warn $ftp->message;
} ;
$ftp->quit;
Regards,
--Dennis
[Thanks for your previous help Anno]
------------------------------
Date: Sat, 31 Mar 2001 01:58:20 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Why "files" and "No Directories"
Message-Id: <3AC53B78.5F2263EE@acm.org>
"What A Man !" wrote:
>
> Why does the following code move all files from $dir to the proper
> directory at remote host, but if one of the files in $dir is a
> directory, it moves it as a file to the remote host?
>
> # change the directory on the ftp site
> $ftp->cwd('/b-bin/recurse') or die "Can't change directories on
> Remote site: $!\n";
>
> # define local directory
> $dir = "../mvr";
>
> opendir MV, "$dir" or die "Cannot open directory: $!\n";
^^^^^^
perldoc -q "What's wrong with always quoting"
> @files = grep !/^\.\.?$/, readdir MV or die "Can't Read Directory: $!\n";
@files = grep { -f "$dir/$_" and $_ = "$dir/$_" } readdir MV or die
"Can't Read Directory: $!\n";
# or
@files = grep { !-d "$dir/$_" and $_ = "$dir/$_" } readdir MV or die
"Can't Read Directory: $!\n";
> close MV, "$dir" or die "Cannot Close directory: $!\n";
^^^^^^^^^^^^^^^^
closedir MV or die "Cannot Close directory: $!\n";
> foreach $file(@files)
> {
> $ftp->put($file) or warn $ftp->message;
> } ;
>
> $ftp->quit;
John
--
use Perl;
program
fulfillment
------------------------------
Date: Sat, 31 Mar 2001 03:55:04 GMT
From: "What A Man !" <whataman@home.com>
Subject: Re: Why "files" and "No Directories"
Message-Id: <3AC5558F.3B851245@home.com>
"John W. Krahn" wrote:
>
> "What A Man !" wrote:
> >
> > opendir MV, "$dir" or die "Cannot open directory: $!\n";
> ^^^^^^
> perldoc -q "What's wrong with always quoting"
>
> > @files = grep !/^\.\.?$/, readdir MV or die "Can't Read Directory: $!\n";
>
> @files = grep { -f "$dir/$_" and $_ = "$dir/$_" } readdir MV or die
> "Can't Read Directory: $!\n";
> # or
> @files = grep { !-d "$dir/$_" and $_ = "$dir/$_" } readdir MV or die
> "Can't Read Directory: $!\n";
>
> > close MV, "$dir" or die "Cannot Close directory: $!\n";
> ^^^^^^^^^^^^^^^^
> closedir MV or die "Cannot Close directory: $!\n";
>
> > foreach $file(@files)
> > {
> > $ftp->put($file) or warn $ftp->message;
> > } ;
> >
> > $ftp->quit;
>
I made your suggested changes below and also tried it with the !-d
instead of $f... and it still did the same thing. No directories were
transferred.
Here's the changed code...
$dir = "../mvr";
opendir MV, $dir or die "Cannot open directory: $!\n";
@files = grep { -f "$dir/$_" and $_ = "$dir/$_" }
readdir MV or die "Can't Read Directory1: $!\n";
closedir MV or die "Cannot Close directory: $!\n";
foreach $file(@files) {
$ftp->put($file) or warn $ftp->message; } ;
$ftp->quit;
Regards,
--Dennis
------------------------------
Date: 1 Apr 2001 16:27:21 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: Why do "Programming Perl" Books Do This? a rgexp question.
Message-Id: <9a7kt9$930$1@ichaos.ichaos-int>
"Francis Derive" <Francis.Derive@wanadoo.fr> said:
>Page 266 in the french translated O'Reilly book, I read this to generate a
>hash of hash from a file :
>
>>while ( <> ) {
>> next unless s/^(.*?):\s*//;
>> ....
>>}
>
>My first question is : how could it be "zero" occurence of any character,
>before the colon ? Why not *at least* one character : /.+
This is a good point, and already addressed in another followup -- in short,
there are other constraints that should be taken into account in addition
to this one.
>Secondly what is the substitution for ?
Not exactly substitution -- it is a modifier for the preceding expression,
and makes the preceding expression non-greedy:
By default regular expression multiple-character matches try to match as
many characters as possible. The "non-greediness" is to satisfy the match
at first possible location. So, if you had a RE of /.*:?/, and pattern
a:b:c you would match just "a:". With RE of /.*:/ wou would match "a:b:".
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ UH++++$ UL++++ P++@ L+++ E(-) W+$@ N++ !K w !O
!M V PS(+) PE Y+ PGP(+) t- 5 !X R tv--- b+ !DI D G e+ h--- r+++ y+++
"...cancel my subscription to the resurrection!" (Jim Morrison)
------------------------------
Date: Sat, 31 Mar 2001 01:28:43 GMT
From: shb@vnet.net (Si Ballenger)
Subject: Re: Why does no window open at executing the batch file
Message-Id: <3ac5324d.174008155@166.82.1.9>
On Sat, 31 Mar 2001 00:28:57 GMT, Bart Lateur
<bart.lateur@skynet.be> wrote:
>Roland Mösl wrote:
>
>>BTW, what to write at the end of a batch file,
>>that it waits for a keypress instead of closing
>>immedeateley the command prompt window ?
>
> PAUSE
>
>but on my system, BAT files always wait before closing. It must be a
>registry setting...
>
>--
> Bart.
Put cls at the end of your bat file and see if that changes
things.
------------------------------
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 V10 Issue 606
**************************************