[16279] in Perl-Users-Digest
Perl-Users Digest, Issue: 3691 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 17 09:05:25 2000
Date: Mon, 17 Jul 2000 06: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: <963839112-v9-i3691@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 17 Jul 2000 Volume: 9 Number: 3691
Today's topics:
Re: [NEW-B] What's wrong with this script? <bart.lateur@skynet.be>
Re: [NEW-B] What's wrong with this script? <?@?.?>
Can i 'logout' a protected directory? <nivel33@hotmail.com>
DBI object version 1.13 does not match <terri143@email.msn.com>
Re: Did I FLOCK this correctly? (Eric Bohlman)
Re: Getting a random var as output <mauldin@netstorm.net>
Newbie needs help! <eric.selin@pp.inet.fi>
Re: Newbie needs help! (Spike)
Re: Newbie needs help! <mauldin@netstorm.net>
Re: Newbie needs help! <mauldin@netstorm.net>
Newbie: iterated reading from file (Tony Balazs)
Re: Newbie: iterated reading from file (Bernard El-Hagin)
Re: Newbie: iterated reading from file (Tony Balazs)
Re: padding strings with zero's <bart.lateur@skynet.be>
Perl and Mysql <dfleet@avaterra.com>
Perl and Mysql <dfleet@avaterra.com>
Perl and Mysql <dfleet@avaterra.com>
Perl and Mysql <dfleet@avaterra.com>
Perl and Mysql <dfleet@avaterra.com>
Perl and Mysql <dfleet@avaterra.com>
Re: Perl and Mysql (Bernard El-Hagin)
Re: Perl and Mysql <thunderbear@bigfoot.com>
Re: PERL IDES <mike.solomon@eps.ltd.uk>
Re: programming tools and techniques <dmvo@NOSPAM.artic.net>
Re: programming tools and techniques <jamcquay@BOOM.hotmail.com>
Re: Read a file into a hash ? <uackermann@orga.com>
Re: Read a file into a hash ? <sumus@aut.dk>
Re: Read a file into a hash ? <partha@mihy.mot.com>
Re: Read a file into a hash ? <partha@mihy.mot.com>
Re: Read a file into a hash ? <partha@mihy.mot.com>
Re: Testing and debuging scripts locally (Eric Bohlman)
Re: Testing and debuging scripts locally <john99@NOSPAMcanada.com>
Re: The problem of two Submit buttons (Philip Lees)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 17 Jul 2000 12:28:26 +0200
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: [NEW-B] What's wrong with this script?
Message-Id: <39n5nskuoq4b6s6d569j44kgkkubl3isjj@4ax.com>
Kliffoth wrote:
>I'm using this part of the script to make an Allknowing Oracle.
>http://eej.virtualave.net/orakel.html
It doesn't seem to know too much. The first ten questions I typed in,
all got blank answers. There isn't much fun in a oracle that fails to
produce actual replies to most questions.
You could also check out the ChatBot::Eliza module, for which Randal
Schwartz wrote a web interface for one of his Web Techniques columns.
http://www.stonehenge.com/merlyn/WebTechniques/
see #23 and #24.
--
Bart.
------------------------------
Date: Mon, 17 Jul 2000 11:13:16 GMT
From: "Kliffoth" <?@?.?>
Subject: Re: [NEW-B] What's wrong with this script?
Message-Id: <gTBc5.401127$k22.1765362@flipper>
I know Bart; the trick is, I append all the questions to a file, I'll look
at the file to see what questions are commonly asked, then I add keywords to
the code with a proper answer, making the oracle more intelligent every day
:)'
--
-----------------------------------------------------
Click here for Free Video!!
http://www.gohip.com/free_video/
"Bart Lateur" <bart.lateur@skynet.be> wrote in message
news:39n5nskuoq4b6s6d569j44kgkkubl3isjj@4ax.com...
> Kliffoth wrote:
>
> >I'm using this part of the script to make an Allknowing Oracle.
> >http://eej.virtualave.net/orakel.html
>
> It doesn't seem to know too much. The first ten questions I typed in,
> all got blank answers. There isn't much fun in a oracle that fails to
> produce actual replies to most questions.
>
> You could also check out the ChatBot::Eliza module, for which Randal
> Schwartz wrote a web interface for one of his Web Techniques columns.
>
> http://www.stonehenge.com/merlyn/WebTechniques/
>
> see #23 and #24.
>
> --
> Bart.
------------------------------
Date: Mon, 17 Jul 2000 13:06:42 +0200
From: "Nivel33" <nivel33@hotmail.com>
Subject: Can i 'logout' a protected directory?
Message-Id: <8kupbd$sbj$1@diana.bcn.ttd.net>
When i protected a directory and the user is identificated, I need the
'change login' option
If i send a 'logout' (HTTP Header) i can't ask the new login & password
Ex.
Input user :
www.onedomain.com/protecteddir/
[Login : xxxx]
[Passwd : xxx ]
The user see the page and wants to change login to see as another user.
Press the [logout button] ( but the browser have this data in your cache)
the system cgi send the HTTP Header -> (Invalid password) but the login and
password it doesn´t work again
sorry my english
------------------------------
Date: Mon, 17 Jul 2000 06:01:47 -0500
From: "terri143" <terri143@email.msn.com>
Subject: DBI object version 1.13 does not match
Message-Id: <ORWmJ397$GA.401@cpmsnbbsa08>
Hi,
I have installed MySql on my server
MySQL-3.23.10-1
MySQL-bench-3.23.10-1
MySQL-client-3.23.10-1
MySQL-devel-3.23.10-1
and perl modules:
Data-Dumper-2.101
Data-ShowTable-3.3
DBI-1.13
Msql-Mysql-modules-1.2018
mysql-DBI-perl-bin
DBI-perl-bin
When I try to run my perl script that I have ran on another server I get
this error message:
install_driver(mysql) failed: [Mon Jul 17 07:45:57 2000] index.cgi: Can't
locate DBD/mysql.pm
in @INC (@INC contains: /usr/lib/perl5/5.00503/i386-linux
/usr/lib/perl5/5.00503
/usr/lib/perl5/site_perl/5.005/i386-linux /usr/lib/perl5/site_perl/5.005 .)
I added the directory that DBD was installed in to @INC using this code:
BEGIN {
unshift @INC, "/usr/lib/perl5/site_perl";
}
I get this error:
[Mon Jul 17 07:49:47 2000] index.cgi: DBI object version
1.13 does not match $DBI::VERSION 0.93 at
/usr/lib/perl5/5.00503/i386-linux/DynaLoader.pm line
188.
I opened DynaLoader.pm and went to line 188 and found this:
# Many dynamic extension loading problems will appear to come from
# this section of code: XYZ failed at line 123 of DynaLoader.pm.
# Often these errors are actually occurring in the initialisation
# C code of the extension XS file. Perl reports the error as being
# in this perl code simply because this was the last perl code
# it executed.
I have searched deja news, read docs, tried to reinstall MySql and the perl
modules. I have tried everything I can think of and nothing works. I am
going on day five with this problem.
Anyone have any idea of what I may be doing wrong or what the "XS file" is?
Maybe someone has seen this before?
Thanks for ANY help as I am about to loose "it" over this problem.
------------------------------
Date: 17 Jul 2000 10:16:32 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Did I FLOCK this correctly?
Message-Id: <8kume0$10d$8@slb2.atl.mindspring.net>
BUCK NAKED1 (dennis100@webtv.net) wrote:
: #!/usr/local/bin/perl
Missing -w
Missing 'use strict;'
: print "Content-type: text/html\n\n";
: open HITS, "pagehits3.dat";
No checking if open was successful
Use of relative path in CGI program without chdir()ing to a known location
: #The line below LOCKS the file
: flock HITS, 2;
Use of magic number rather than defined constant
: $hits = <HITS>;
: ++$hits;
: open(HITS,">pagehits3.dat");
Failure to check, relative path, automatically closes file and releases
lock. After this statement your file is empty and unlocked; if another
copy of your program executes at this point, it will read an undefined
value into $hits, which will get treated as zero in the increment, which
will cause your counter to reset to 1.
: print HITS $hits;
: 1 while $hits =~ s/(.*\d)(\d\d\d)/$1,$2/;
: 1 while $hits =~ s/(11$|12$|13$)/$1th/;
: 1 while $hits =~ s/(1$)/$1st/;
: 1 while $hits =~ s/(2$)/$1nd/;
: 1 while $hits =~ s/(3$)/$1rd/;
: 1 while $hits =~ s/(4$|5$|6$|7$|8$|9$|0$)/$1th/;
: # The line below locks the file for 2 seconds
: sleep 2;
No it doesn't
: # The following 2 lines UNLOCK the file
: flock HITS, 8;
You don't want to explicitly unlock a file before closing it.
: close HITS;
: print <<HTML;
: <DIV align='center'><font size='2' color='#66000'>You are the $hits
: person to visit this website. Thanks for dropping by.</font>\n</DIV>
: HTML
Generating invalid HTML (no <title> element).
I suggest you read the sections about file locking in the FAQ.
------------------------------
Date: Mon, 17 Jul 2000 11:47:38 GMT
From: Jim Mauldin <mauldin@netstorm.net>
Subject: Re: Getting a random var as output
Message-Id: <3972F192.548310CF@netstorm.net>
"Clinton A. Pierce" wrote:
> $vref=$varlist[rand @varlist];
>
This was a (useful) surprise - that a subscripted fractional number will be
treated as an integer. I see there's a similar example in perlfaq4. This
seems to be almost undocumented - the only reference I can find is on page 537
of "Programming Perl" 2nd edition in a chapter about efficiency:
"Subscripting sometimes forces conversion from floating point to integer ..."
I guess that's why we read this NG.
-- Jim
------------------------------
Date: Mon, 17 Jul 2000 10:38:06 GMT
From: "Eric Selin" <eric.selin@pp.inet.fi>
Subject: Newbie needs help!
Message-Id: <imBc5.587$Av5.15171@news.kpnqwest.fi>
I am having trouble with regexps on several lines. My program should grep
info from a textfile like this:
Textfile:
[link to a site] [explanation]
[link to a site] [explanation]
[link to a site] [explanation]
e.g.
www.perl.com A perl site
The program should make a link with the text before the tab.
The idea is that the program greps all lines including e.g. "perl".
Don't ask but I have to do it this way.
I hope you get the idea....
Thanks, Eric Selin
------------------------------
Date: Mon, 17 Jul 2000 11:00:46 GMT
From: sp@spike.co.za (Spike)
Subject: Re: Newbie needs help!
Message-Id: <3972e65c.664527@news.is.co.za>
Try this:
while(<TEXTFILEHANDLE>) {
if (/^(.+)\t(.+)$/) {
$link = $1 ;
$descr = $2 ;
# now you can do what you like with $link and $descr ...
}
}
Hope this is what you are looking for !
Spike
www.spike.co.za
On Mon, 17 Jul 2000 10:38:06 GMT, "Eric Selin" <eric.selin@pp.inet.fi>
wrote:
>I am having trouble with regexps on several lines. My program should grep
>info from a textfile like this:
>Textfile:
>[link to a site] [explanation]
>[link to a site] [explanation]
>[link to a site] [explanation]
>e.g.
>www.perl.com A perl site
>The program should make a link with the text before the tab.
>The idea is that the program greps all lines including e.g. "perl".
>Don't ask but I have to do it this way.
>
>I hope you get the idea....
>
>Thanks, Eric Selin
>
>
------------------------------
Date: Mon, 17 Jul 2000 12:32:45 GMT
From: Jim Mauldin <mauldin@netstorm.net>
Subject: Re: Newbie needs help!
Message-Id: <3972FC22.44B7DA3A@netstorm.net>
Spike wrote:
> if (/^(.+)\t(.+)$/) {
> $link = $1 ;
> $descr = $2 ;
> }
($link, $descr) = (/\[(.*?)]/g);
will get the contents within the brackets.
-- Jim
------------------------------
Date: Mon, 17 Jul 2000 12:39:15 GMT
From: Jim Mauldin <mauldin@netstorm.net>
Subject: Re: Newbie needs help!
Message-Id: <3972FDA9.C3C4A537@netstorm.net>
Jim Mauldin wrote:
> ($link, $descr) = (/\[(.*?)]/g);
($link, $descr) = /\[(.*?)]/g;
Correction: parens not needed in /\[(.*?)]/g. ($link, $descr) supplies
the list context. (For my own edification, really).
-- Jim
------------------------------
Date: Mon, 17 Jul 2000 10:24:30 GMT
From: tbalazs-this-must-go@netcomuk.co.uk (Tony Balazs)
Subject: Newbie: iterated reading from file
Message-Id: <3972cff2.4889865@1.0.0.119>
I am having some difficulty writing a Perl program to produce some
output from a data file.
My data file, update.dat, currently looks like:
(100, Analyst, $40K, Permanent);
(200, Programmer, $50K, Contract);
I was naively hoping that the following:
---------------
#!/usr/bin/perl
use strict;
open(UPDATE, "update.dat") || die "$!";
while (my @qq = <UPDATE>){
my $ww = $qq[0];
print $ww;
}
close(UPDATE) || die "$!;
-----------------
would produce:
100
200
as the output.
Instead, I'm getting:
(100, Analyst, $40K, Permanent);
as the output.
What I actually want to achieve is this, to turn:
(100, Analyst, $40K, Permanent); # or 100,Analyst,$40K,Permanent
(200, Programmer, $50K, Contract); # ditto
into
text1 100 text2 Analyst text3 $40K text4 Permanent
text1 200 text2 Programmer text3 $50K text4 Contract
As before, any help would be much appreciated.
Tony.
------------------------------
Date: Mon, 17 Jul 2000 10:50:01 GMT
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Newbie: iterated reading from file
Message-Id: <slrn8n5ou4.90q.bernard.el-hagin@gdndev25.lido-tech>
Tony Balazs <tbalazs-this-must-go@netcomuk.co.uk> wrote:
>I am having some difficulty writing a Perl program to produce some
>output from a data file.
>
>My data file, update.dat, currently looks like:
>
>(100, Analyst, $40K, Permanent);
>(200, Programmer, $50K, Contract);
>
>I was naively hoping that the following:
>---------------
>#!/usr/bin/perl
>use strict;
>
>open(UPDATE, "update.dat") || die "$!";
>while (my @qq = <UPDATE>){
> my $ww = $qq[0];
> print $ww;
>}
>close(UPDATE) || die "$!;
>-----------------
>would produce:
>100
>200
>as the output.
>
>Instead, I'm getting:
>(100, Analyst, $40K, Permanent);
>as the output.
This bit...
my @qq = <UPDATE>;
...puts the input file into array @qq line-by-line. How is Perl supposed
to know that you want to split the data in a different way?
>What I actually want to achieve is this, to turn:
>
>(100, Analyst, $40K, Permanent); # or 100,Analyst,$40K,Permanent
>(200, Programmer, $50K, Contract); # ditto
>
>into
>
>text1 100 text2 Analyst text3 $40K text4 Permanent
>text1 200 text2 Programmer text3 $50K text4 Contract
Here's one way which assumes that there are no commas in the data
itself:
__________________
#!/usr/bin/perl -w
use strict;
my $i = 1;
while (my $data = <DATA>){
chomp ($data);
$data =~ s/^\((.*)\);/$1/g;
my @data = split /,/, $data;
foreach (@data)
{
print "text" . $i++ . " $_ ";
}
print "\n";
$i = 1;
}
__DATA__
(100, Analyst, $40K, Permanent);
(200, Programmer, $50K, Contract);
__________________
Bernard
--
perl -e'@x=(3,2,4,1,3,2,1,3,1,3,2,3,3,2,3,0,0,1,2,1,1,1,4,1,2,1,1,2,2,1,
2,1,2,1,2,1,2,1,1,1,2,1,0,0,3,2,3,2,3,2,1,1,1,1,1,2,4,2,3,2,1,2,1,0,0,1,
2,1,1,1,4,1,2,1,1,1,2,2,1,1,4,1,1,1,2,1,1,1,2,1,0,0,3,2,4,1,1,2,1,1,1,3,
1,1,1,4,1,1,1,2,1,1,3,0,0);sub x{print q x$xx$_;print q x x x shift@x};#
while(defined($_=shift @x)){s o0o\no;$_!=0?x:print}' #Symmetry yrtemmyS#
------------------------------
Date: Mon, 17 Jul 2000 12:52:47 GMT
From: tbalazs-this-must-go@netcomuk.co.uk (Tony Balazs)
Subject: Re: Newbie: iterated reading from file
Message-Id: <39730183.17580941@1.0.0.119>
<snip>
What I actually want to achieve is this, to turn:
>>
>>(100, Analyst, $40K, Permanent); # or 100,Analyst,$40K,Permanent
>>(200, Programmer, $50K, Contract); # ditto
>>
>>into
>>
>>text1 100 text2 Analyst text3 $40K text4 Permanent
>>text1 200 text2 Programmer text3 $50K text4 Contract
>
>Here's one way which assumes that there are no commas in the data
>itself:
<snip>
Bernard,
with the the following adaptation of your code:
#!/usr/bin/perl -w
use strict;
open(UPDATE, "update.dat");
my $i = 1;
while (my $data = <UPDATE>){
chomp ($data);
$data =~ s/^\((.*)\);/$1/g;
my @data = split /,/, $data;
foreach (@data)
{
print "text" . $i++ . " $_ ";
}
print "\n";
$i = 1;
}
close(UPDATE);
I'm getting the following error message:
global symbol "@data" requires explicit package name at filename.pl
line 8.
Would it be better to have the data file as:
100
Analyst
$40K
Permanent
200
Programmer
$50K
Contract
etc and have $1 = line1, $2 = line2 etc.
Tony.
------------------------------
Date: Mon, 17 Jul 2000 12:52:11 +0200
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: padding strings with zero's
Message-Id: <g9p5nskq4elim8cscscnn3s2ms0atuv9kt@4ax.com>
shearn666@my-deja.com wrote:
>I can't get
>number to pad with strings at all.
Put a "0" between the "%" sign and the numberthat follows, in the
sprintf() format string.
--
Bart.
------------------------------
Date: Mon, 17 Jul 2000 11:48:44 +0100
From: "David Fleet" <dfleet@avaterra.com>
Subject: Perl and Mysql
Message-Id: <3972e268_1@nnrp1.news.uk.psi.net>
I am having serious problems trying to get my Perl script to connect to my
Mysql database.
Has anyone had problems trying to get Perl to access their mysql database?
If so, what did you have to do to correct it?
I thought the usaul 'make' commands configured it all?
Han.
------------------------------
Date: Mon, 17 Jul 2000 11:48:44 +0100
From: "David Fleet" <dfleet@avaterra.com>
Subject: Perl and Mysql
Message-Id: <3972e70e$1_2@nnrp1.news.uk.psi.net>
I am having serious problems trying to get my Perl script to connect to my
Mysql database.
Has anyone had problems trying to get Perl to access their mysql database?
If so, what did you have to do to correct it?
I thought the usaul 'make' commands configured it all?
Han.
------------------------------
Date: Mon, 17 Jul 2000 11:48:44 +0100
From: "David Fleet" <dfleet@avaterra.com>
Subject: Perl and Mysql
Message-Id: <3972e75f_1@nnrp1.news.uk.psi.net>
I am having serious problems trying to get my Perl script to connect to my
Mysql database.
Has anyone had problems trying to get Perl to access their mysql database?
If so, what did you have to do to correct it?
I thought the usaul 'make' commands configured it all?
Han.
------------------------------
Date: Mon, 17 Jul 2000 11:48:44 +0100
From: "David Fleet" <dfleet@avaterra.com>
Subject: Perl and Mysql
Message-Id: <3972e819_2@nnrp1.news.uk.psi.net>
I am having serious problems trying to get my Perl script to connect to my
Mysql database.
Has anyone had problems trying to get Perl to access their mysql database?
If so, what did you have to do to correct it?
I thought the usaul 'make' commands configured it all?
Han.
------------------------------
Date: Mon, 17 Jul 2000 11:48:44 +0100
From: "David Fleet" <dfleet@avaterra.com>
Subject: Perl and Mysql
Message-Id: <3972e6f8$1_2@nnrp1.news.uk.psi.net>
I am having serious problems trying to get my Perl script to connect to my
Mysql database.
Has anyone had problems trying to get Perl to access their mysql database?
If so, what did you have to do to correct it?
I thought the usaul 'make' commands configured it all?
Han.
------------------------------
Date: Mon, 17 Jul 2000 11:48:44 +0100
From: "David Fleet" <dfleet@avaterra.com>
Subject: Perl and Mysql
Message-Id: <3972f582_1@nnrp1.news.uk.psi.net>
I am having serious problems trying to get my Perl script to connect to my
Mysql database.
Has anyone had problems trying to get Perl to access their mysql database?
If so, what did you have to do to correct it?
I thought the usaul 'make' commands configured it all?
Han.
------------------------------
Date: Mon, 17 Jul 2000 11:16:51 GMT
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Perl and Mysql
Message-Id: <slrn8n5qge.90q.bernard.el-hagin@gdndev25.lido-tech>
On Mon, 17 Jul 2000 11:48:44 +0100, David Fleet <dfleet@avaterra.com> wrote:
>I am having serious problems trying to get my Perl script to connect to my
>Mysql database.
You are having serious trouble with posting the same post 4 times.
Bernard
--
perl -e'@x=(3,2,4,1,3,2,1,3,1,3,2,3,3,2,3,0,0,1,2,1,1,1,4,1,2,1,1,2,2,1,
2,1,2,1,2,1,2,1,1,1,2,1,0,0,3,2,3,2,3,2,1,1,1,1,1,2,4,2,3,2,1,2,1,0,0,1,
2,1,1,1,4,1,2,1,1,1,2,2,1,1,4,1,1,1,2,1,1,1,2,1,0,0,3,2,4,1,1,2,1,1,1,3,
1,1,1,4,1,1,1,2,1,1,3,0,0);sub x{print q x$xx$_;print q x x x shift@x};#
while(defined($_=shift @x)){s o0o\no;$_!=0?x:print}' #Symmetry yrtemmyS#
------------------------------
Date: Mon, 17 Jul 2000 13:56:05 +0200
From: =?iso-8859-1?Q?Thorbj=F8rn?= Ravn Andersen <thunderbear@bigfoot.com>
Subject: Re: Perl and Mysql
Message-Id: <3972F455.F279F7E2@bigfoot.com>
David Fleet wrote:
>
> I am having serious problems trying to get my Perl script to connect to my
> Mysql database.
Can have many reasons. What errors do you see?
--
Thorbjørn Ravn Andersen "...plus...Tubular Bells!"
http://bigfoot.com/~thunderbear
------------------------------
Date: Mon, 17 Jul 2000 11:20:02 +0100
From: "mike solomon" <mike.solomon@eps.ltd.uk>
Subject: Re: PERL IDES
Message-Id: <8kumnf$37lbq$1@ID-36965.news.cis.dfn.de>
robin
try vim
http://www.math.fu-berlin.de/~guckes/vim/
this is a great editor and it is free
it is bases on the Unix standard editor vi
it has perl syntax highlighting
Robin Bank <rbank@csf.edu> wrote in message
news:8knutk$116q$1@reader.nmix.net...
> Anyone know any good PERL IDEs for Win98, I'm sick of notepad, and I need
to
> be able to rapidly develop perl.
>
> Thanks,
> Robin
>
>
------------------------------
Date: Mon, 17 Jul 2000 08:36:10 +0000
From: Dmitri V <dmvo@NOSPAM.artic.net>
Subject: Re: programming tools and techniques
Message-Id: <3972C57A.3F266118@NOSPAM.artic.net>
Thank you, Andrew, that *was* an impressive exposition. I'll keep this
text for my future reference on how to write educational materials.
Dmitri
------------------------------
Date: Mon, 17 Jul 2000 14:47:25 +0200
From: "Jamie" <jamcquay@BOOM.hotmail.com>
Subject: Re: programming tools and techniques
Message-Id: <963838069.911325@news.knoware.nl>
to excel in your course, wy not read the text book??
<acunet3278@my-deja.com> wrote in message
news:8krrgp$ihl$1@nnrp1.deja.com...
> I am taking a beginner C language course.
> Could you kindly share your experience with me?
> Where can information be found about the following topics:
>
> When, why and how to use a debugger?
> What is it used for?
>
> When, why and how to use a Make?
> What is it used for?
>
> Additionally:
> What is a target?
> What is build?
> What is a makefile?
> What is a project file?
>
> Your advise, tips, comments, suggestions are welcome. I look forward to
> hearing from you. Thank you.
>
>
> --
> http://www.pucho.com
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
------------------------------
Date: Mon, 17 Jul 2000 13:20:49 +0200
From: Ulrich Ackermann <uackermann@orga.com>
Subject: Re: Read a file into a hash ?
Message-Id: <3972EC11.D9761A00@orga.com>
Fidelio wrote:
> Suppose I read the file into an array like:
>
> open(PASSWD, '/etc/passwd');
> @users = <PASSWD>;
> close (PASSWD);
> foreach $lines(@users) {
> chop($lines);
> @line = split(/\:/,$lines);
> # put users into %users ??
> }
>
> Then I can access all the fields with @user{'root'} and eg. the home
> dir with $user{'root'}[5] right ?
> I a lost how to do this. @user{$line[0]} = @line just doesn't work.
^^^ ^^^
A hash can only hold strings as values. If you want to hold an array,
you've got to store the reference of that array. If you had used the
"-w" switch in your shebang-line you should have received a
warning-message with your code. BTW: You should do this in every script
you are writing!
So, if you want to store the home dir of root in a hash, after having
read your line into @line, this probably might work:
$user{$line[0]}{dir} = $line[5].
I'm relativly new to Perl, so use my hints with care ;-)
HTH, Ulrich
--
Ulrich Ackermann
ORGA Kartensysteme GmbH (SY-PEAT-STA)
Tel.:+49.5254.991-925
mailto:uackermann@orga.com
------------------------------
Date: 17 Jul 2000 13:42:31 +0200
From: Jakob Schmidt <sumus@aut.dk>
Subject: Re: Read a file into a hash ?
Message-Id: <snt96l08.fsf@macforce.sumus.dk>
rjn@pobox.com (Fidelio) writes:
There must be a million ways but here's one starting with your own code:
> open(PASSWD, '/etc/passwd');
Remember check:
open(PASSWD, '/etc/passwd') or die "Heck! It said: $!";
> @users = <PASSWD>;
> close (PASSWD);
This is OK but there's really no reason to slurp the entire file. Your
approach from the first code snippet was better:
while ( <PASSWD> ) {
....
In stead of $lines just use $_ in the loop body and the code does the same
thing.
> foreach $lines(@users) {
(while...)
> chop($lines);
just chop;
> @line = split(/\:/,$lines);
just @line = split ':';
> # put users into %users ??
$users{ shift( @line ) } = [ @line ];
> }
Here's the cleanup:
use strict;
my %users;
open(PASSWD, '/etc/passwd') or die "Heck! It said: $!";
while ( <PASSWD> ) {
chop;
my @line = split ':';
$users{ shift( @line ) } = [ @line ];
}
# %users is ready for use
--
Jakob
------------------------------
Date: Mon, 17 Jul 2000 17:33:08 -0500
From: Ramanujam Parthasarathi <partha@mihy.mot.com>
To: Fidelio <rjn@pobox.com>
Subject: Re: Read a file into a hash ?
Message-Id: <397389A4.73A4F617@mihy.mot.com>
Fidelio wrote:
> open(PASSWD, '/etc/passwd');
> @users = <PASSWD>;
> close (PASSWD);
> foreach $lines(@users) {
> chop($lines);
> @line = split(/\:/,$lines);
> # put users into %users ??
> }
# Try doing this in the foreach loop ...
# assuming that user-name is the first entry in the 'passwd' file
$user = shift(@users);
$user_hash{$user} = [ @users ];
-------
# Now, you can access the details of each user as:
foreach $users (sort keys %users_hash ) {
print("$users => ", join(":", @$users_hash), "\n");
}
-------
# For a purticular entry in the list, you can use:
print("User-id of $user => $$users_hash[2]\n");
-------
HTH
-Partha
------------------------------
Date: Mon, 17 Jul 2000 17:33:37 -0500
From: Ramanujam Parthasarathi <partha@mihy.mot.com>
To: Fidelio <rjn@pobox.com>
Subject: Re: Read a file into a hash ?
Message-Id: <397389C1.3509343F@mihy.mot.com>
Fidelio wrote:
> open(PASSWD, '/etc/passwd');
> @users = <PASSWD>;
> close (PASSWD);
> foreach $lines(@users) {
> chop($lines);
> @line = split(/\:/,$lines);
> # put users into %users ??
> }
# Try doing this in the foreach loop ...
# assuming that user-name is the first entry in the 'passwd' file
$user = shift(@users);
$user_hash{$user} = [ @users ];
-------
# Now, you can access the details of each user as:
foreach $users (sort keys %users_hash ) {
print("$users => ", join(":", @$users_hash), "\n");
}
-------
# For a purticular entry in the list, you can use:
print("User-id of $user => $$users_hash[2]\n");
-------
HTH
-Partha
------------------------------
Date: Mon, 17 Jul 2000 17:34:01 -0500
From: Ramanujam Parthasarathi <partha@mihy.mot.com>
To: Fidelio <rjn@pobox.com>
Subject: Re: Read a file into a hash ?
Message-Id: <397389D9.55C9C088@mihy.mot.com>
Fidelio wrote:
> open(PASSWD, '/etc/passwd');
> @users = <PASSWD>;
> close (PASSWD);
> foreach $lines(@users) {
> chop($lines);
> @line = split(/\:/,$lines);
> # put users into %users ??
> }
# Try doing this in the foreach loop ...
# assuming that user-name is the first entry in the 'passwd' file
$user = shift(@users);
$user_hash{$user} = [ @users ];
-------
# Now, you can access the details of each user as:
foreach $users (sort keys %users_hash ) {
print("$users => ", join(":", @$users_hash), "\n");
}
-------
# For a purticular entry in the list, you can use:
print("User-id of $user => $$users_hash[2]\n");
-------
HTH
-Partha
------------------------------
Date: 17 Jul 2000 10:05:08 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Testing and debuging scripts locally
Message-Id: <8kulok$10d$7@slb2.atl.mindspring.net>
jason (elephant@squirrelgroup.com) wrote:
: Ecco aka Homer - go away ..
:
: this is a misleading answer .. a CGI script will not run as expected
: straight from the browser - it will not output to the browser window and
: on some systems it will not work at all
In fact, the whole notion of "running a script in a browser" is an
incorrect mental model that causes many beginning CGI programmers to
waste a lot of time because they don't understand that *they* aren't
running the script, the Web server is, and the server doesn't have access
to the programmer's environment, current working directory, etc.
------------------------------
Date: Mon, 17 Jul 2000 12:32:44 GMT
From: John <john99@NOSPAMcanada.com>
Subject: Re: Testing and debuging scripts locally
Message-Id: <3972FBF4.9AB81273@NOSPAMcanada.com>
Hello
This is the best application that I've found
It has everything you need
http://www.indigostar.com/indigoperl.htm
EM wrote:
>
> Is there any way to test if a perl script works without having to go online
> and upload it to my cgi-bin
> Like it would be great if i could somehow start my browser and enter the
> file as c:\scripts\script.cgi and be able to see it as if it were online
>
> I am new to cgi so i dont know these things
------------------------------
Date: Mon, 17 Jul 2000 12:39:13 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Re: The problem of two Submit buttons
Message-Id: <3972f71c.18645050@news.grnet.gr>
On Fri, 14 Jul 2000 14:17:33 -0700, Larry Rosler <lr@hpl.hp.com>
wrote:
>In article <963583114.8285@itz.pp.sci.fi> on 14 Jul 2000 14:00:29 GMT,
>Ilmari Karonen <iltzu@sci.invalid> says...
>> In article <Pine.GHP.4.21.0007141529330.20198-100000@hpplus03.cern.ch>, Alan J. Flavell wrote:
>> >On Fri, 14 Jul 2000, Philip Lees wrote:
>> >
>> >> if ( ! $add_button eq "" ){
>> >> #add something
>> >
>> >Boggle. Do you normally test for the negative of what you didn't
>> >want?
>>
>> Could've been worse. He might have written it as:
>>
>> unless ( ! $add_button ne "" ){
>
>Each of those is nonsense, because '!' binds with very high precedence
>to the succeeding operand. So the logical negation of any string other
>than '0' is the null string.
Now this is interesting, at least to a beginner like me. I assumed
that:
if ( ! $a eq $b )
would compile to the same as:
if ( $a ne $b ).
If I understand you correctly, you're saying the the ! $a will be
evaluated before the comparison and so if $a="xyz" then ! $a will be
the null string and the comparison will always give the same result.
If this is true, then my crummy code shouldn't work at all - and yet
it does.
Out of interest, is
if ( !( $a eq $b ) )
equivalent to
if ( $a ne $b ) )?
Phil
--
Philip Lees
ICS-FORTH, Heraklion, Crete, Greece
Ignore coming events if you wish to send me e-mail
'The aim of high technology should be to simplify, not complicate' - Hans Christian von Baeyer
------------------------------
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 3691
**************************************