[21799] in Perl-Users-Digest
Perl-Users Digest, Issue: 4003 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 21 00:06:04 2002
Date: Sun, 20 Oct 2002 21:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 20 Oct 2002 Volume: 10 Number: 4003
Today's topics:
Re: Accessing data from constructor (kit)
Re: Accessing data from constructor <nospam@nospam.com>
Re: Convert Perl script to C program (and Why was this <Islaw@lnx.sr>
Re: Convert Perl script to C program (and Why was this <bart.lateur@pandora.be>
Re: Convert Perl script to C program (and Why was this <islaw@w98.sr>
Re: Convert Perl script to C program (and Why was this <flavell@mail.cern.ch>
Re: DBI module INSERT command problem <bwalton@rochester.rr.com>
Re: DBI module INSERT command problem <dgardiner@houston.rr.com>
Digest::MD5 -> /usr/bin/ld -> can't compile <cmustard@nyc.rr.com>
Re: Digest::MD5 -> /usr/bin/ld -> can't compile <tony_curtis32@yahoo.com>
Re: Digest::MD5 -> /usr/bin/ld -> can't compile <cmustard@nyc.rr.com>
Re: Digest::MD5 -> /usr/bin/ld -> can't compile <tony_curtis32@yahoo.com>
Re: Digest::MD5 -> /usr/bin/ld -> can't compile <cmustard@nyc.rr.com>
dynamically named arrays <stuff@nowhere.com>
Re: dynamically named arrays <bwalton@rochester.rr.com>
GNU plot in perl (Anirban Chakraborti)
Re: processing lines in pairs (Bryan Castillo)
Regex Problem sure@yeahyeah.not
Re: Regex Problem <bwalton@rochester.rr.com>
Re: Regex Problem sure@yeahyeah.not
Re: removing commas in an element of an array of csv fi <garry@ifr.zvolve.net>
roman numeric question (Mary Wong)
Re: roman numeric question <jkeen@concentric.net>
Use infinite loop to process option and filter out the (Soon)
Re: Use infinite loop to process option and filter out <krahnj@acm.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 20 Oct 2002 17:32:59 -0700
From: manutd_kit@yahoo.com (kit)
Subject: Re: Accessing data from constructor
Message-Id: <1751b2b5.0210201632.3c3aede7@posting.google.com>
> Given the errors above, I would suggest that you go back and study how to
> pass arguments to regular (non-OO) subroutines by reference before
> attempting methods. Figure out how to write code to achieve your objectives
> using non-OO Perl. Once you've got that down, you can try solving it in
> OOP.
Thanks for your advance, I've tried using pass by reference on my
program without OO, it does work. However, I got stuck when I am
trying to use it in OO.
-------------------------------------------
#! /usr/bin/perl -w
package mainScreen;
use strict;
use warnings;
sub new {
my $class = shift;
my @myarray = (' ' x 51) x 21; # @myarray is the datamember,
# so do @row and @col
my @row=qw{ 1 1 1 1 1 1 1 2 4 6 8 10 12 14 15 15 15 15 15
15 15 14 12 10 8 6 4 2 7 6 5 4 7 6 5 4 9 10 11
12 9 10 11 12 1 2 3 4 12 13 14 15 15 14 13 12
4 3 2 1 };
my @col=qw{ 12 15 18 21 24 27 30 32 32 32 32 32 32 32 30
27 24 21 18 15 12 10 10 10 10 10 10 10 19 17
15 13 23 25 27 29 19 17 15 13 23 25 27 29 6 5
4 3 3 4 5 6 36 37 38 39 39 38 37 36 };
my $self = {};
my $arrayref = \@myarray;
my $rowref = \@row;
my $colref = \@col;
for my $k (0..59){
substr($$arrayref[$$rowref[$k]],$$colref[$k],1)='O';
}
substr($$arrayref[2], 44, 5) = "Hello";
bless ($self, $class);
return $self;
}
sub redrawScreen {
my $arrayref = shift; #line 37
for my $r (0..20) {
print "$$arrayref[$r]\n";
}
}
1;
-------------------------------------------
I have an error with:
Not an ARRAY reference at mainScreen.pm line 37.
inorder to due with this, I've tried changing it into
my $arrayref = \@myarray; #of course, doesn't work..
would you show me a way to solve this question?
Thanks,
Kit
------------------------------
Date: Sun, 20 Oct 2002 19:26:51 -0700
From: "Tan Nguyen" <nospam@nospam.com>
Subject: Re: Accessing data from constructor
Message-Id: <3db3655d$1_6@nopics.sjc>
"kit" <manutd_kit@yahoo.com> wrote in message
news:1751b2b5.0210201632.3c3aede7@posting.google.com...
> > Given the errors above, I would suggest that you go back and study how
to
> > pass arguments to regular (non-OO) subroutines by reference before
> > attempting methods. Figure out how to write code to achieve your
objectives
> > using non-OO Perl. Once you've got that down, you can try solving it in
> > OOP.
>
> Thanks for your advance, I've tried using pass by reference on my
> program without OO, it does work. However, I got stuck when I am
> trying to use it in OO.
> -------------------------------------------
> #! /usr/bin/perl -w
> package mainScreen;
> use strict;
> use warnings;
>
> sub new {
> my $class = shift;
> my @myarray = (' ' x 51) x 21; # @myarray is the datamember,
> # so do @row and @col
> my @row=qw{ 1 1 1 1 1 1 1 2 4 6 8 10 12 14 15 15 15 15 15
> 15 15 14 12 10 8 6 4 2 7 6 5 4 7 6 5 4 9 10 11
> 12 9 10 11 12 1 2 3 4 12 13 14 15 15 14 13 12
> 4 3 2 1 };
> my @col=qw{ 12 15 18 21 24 27 30 32 32 32 32 32 32 32 30
> 27 24 21 18 15 12 10 10 10 10 10 10 10 19 17
> 15 13 23 25 27 29 19 17 15 13 23 25 27 29 6 5
> 4 3 3 4 5 6 36 37 38 39 39 38 37 36 };
> my $self = {};
> my $arrayref = \@myarray;
> my $rowref = \@row;
> my $colref = \@col;
>
> for my $k (0..59){
> substr($$arrayref[$$rowref[$k]],$$colref[$k],1)='O';
> }
> substr($$arrayref[2], 44, 5) = "Hello";
> bless ($self, $class);
> return $self;
> }
>
> sub redrawScreen {
> my $arrayref = shift; #line 37
> for my $r (0..20) {
> print "$$arrayref[$r]\n";
> }
> }
> 1;
> -------------------------------------------
> I have an error with:
> Not an ARRAY reference at mainScreen.pm line 37.
>
> inorder to due with this, I've tried changing it into
> my $arrayref = \@myarray; #of course, doesn't work..
>
> would you show me a way to solve this question?
In redrawScreen, $arrayref holds a mainScreen object (assumed that you
intend to use redrawScreen as a method). I suggest you do a little more
reading on OOP such as this http://www.perldoc.com/perl5.6/pod/perltoot.html
Your code indicates that you haven't had a firm grip on Perl OOP.
Aquick observation
- none of @myarray, @row, @col is attributes (data members) as you wanted
You probably want something like this [untested]
#! /usr/bin/perl -w
package mainScreen;
use strict;
use warnings;
sub new
{
my $proto = shift;
my $class = ref($proto) || $proto;
my $self = {
matrix => (' ' x 51) x 21,
row => qw(1 1 1 1 1 1 1 2 4 6 8 10 12 14 15 15 15 15 15
15 15 14 12 10 8 6 4 2 7 6 5 4 7 6 5 4 9
10 11
12 9 10 11 12 1 2 3 4 12 13 14 15 15 14 13
12
4 3 2 1),
col => qw(12 15 18 21 24 27 30 32 32 32 32 32 32 32 30
27 24 21 18 15 12 10 10 10 10 10 10 10 19
17
15 13 23 25 27 29 19 17 15 13 23 25 27 29 6
5
4 3 3 4 5 6 36 37 38 39 39 38 37 36 }
};
# etc.
return bless ($self, $class);
}
sub redrawScreen
{
my $self = shift;
for my $r (0..20) {
print @{$self->{matrix}[$r]}, "\n";
}
}
1;
__END__
-
------------------------------
Date: Sun, 20 Oct 2002 18:49:43 GMT
From: Islaw <Islaw@lnx.sr>
Subject: Re: Convert Perl script to C program (and Why was this group's name changed?)
Message-Id: <aVCs9.42$C34.6543554@newssvr14.news.prodigy.com>
Twas a nice day on Thu, 17 Oct 2002 18:07:35 -0700, when Fredo proclaimed:
> "Tad McClellan" <tadmc@augustmail.com> wrote in message
> news:slrnaqtvjl.3bg.tadmc@magna.augustmail.com...
>> Jilla Villa <jillavilla@otakumail.com> wrote:
>>
>> > Point taken, but this definately goes both ways. I sincerly hope you
>> > don't think people like Tom Christianson, Tad, et al, have been good
>> > rolemodels of this preaching? A great example of socially
> unexceptable
>> > behavoir is the thread titled "HARASSMENT -- Monthly Autoemail".
>>
>>
>> I did not participate in that thread.
>>
>> Do you have an example of where _I_ was rude?
>>
>> You keep claiming that I frequently am, so it shouldn't be hard to find
>> one to cite.
>
> Oh I've seen plenty of yours. Just go to groups.google.com and enter:
> tad rude
>
> That gives all the proof one needs. The "HARASSMENT -- Monthly
> Autoemail" was used to show just how far some of the regulars have gone,
> and the depressing fact was that he (Tom C) was the author of one of
> some of the most used Perl literature. Of course, why would expect you
> to understand the problem you have taken part in augmenting?
I hae been here most likely longer then you have (I'm a rather quiet
person, and I've found help for problem's using docs/deja-google/etc, so
you wont find too many posts of mine archived), and I've witnessed some
gastly atrosities, one of which is quoted above. Mr Fredo, if you were
really around as long as you claim, you would sure know thatthese folks of
which you denounced have put forth a lot of time and effort to make this
group function. Even if some people can be the most incredibly anal folk
on the planet, there tends to be a REASON for it. The reason here has bene
too many people who have not taken time to find help elsewhere, a method I
have long time used and has served me very well.
Lets end the non sense and get on with life.
P.S. As long as I've been around, I do find it courious as to why exactly
this groups name went from comp.lang.perl to comp.lang.perl.misc. I've
sarch the control-message archives and they basically say it was simply
moving. Thanks for any insight!
-
Islaw
------------------------------
Date: Sun, 20 Oct 2002 19:18:58 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Convert Perl script to C program (and Why was this group's name changed?)
Message-Id: <bsv5ru8ml3pi3ejmoc1a2d84fnju181dca@4ax.com>
Islaw wrote:
>P.S. As long as I've been around, I do find it courious as to why exactly
>this groups name went from comp.lang.perl to comp.lang.perl.misc. I've
>sarch the control-message archives and they basically say it was simply
>moving. Thanks for any insight!
I think it's pretty common if you do a split-up for a group, i.e. here
adding comp.lang.perl.modules, comp.lang.perl.announce, and
comp.lang.perl.tk, that the original group is abandoned and replaced by
a ".misc" group.
Now I don't really have any idea on when all this happened, or where to
search for more info. Google sura wasn't any help.
--
Bart.
------------------------------
Date: Mon, 21 Oct 2002 02:01:57 GMT
From: "Islaw" <islaw@w98.sr>
Subject: Re: Convert Perl script to C program (and Why was this group's name changed?)
Message-Id: <peJs9.7239$Ab.434275669@newssvr21.news.prodigy.com>
"Alan J. Flavell" <flavell@mail.cern.ch> wrote in message
news:Pine.LNX.4.40.0210202353010.10563-100000@lxplus076.cern.ch...
> On Oct 20, Bart Lateur inscribed on the eternal scroll:
>
> > I think it's pretty common if you do a split-up for a group,
>
> Indeed, and news.newusers.questions would seem a more appropriate
> venue to understand this kind of detail about usenet, as it has
> nothing "per se" to do with the Perl programming language.
>
> > i.e. here
> > adding comp.lang.perl.modules, comp.lang.perl.announce, and
> > comp.lang.perl.tk, that the original group is abandoned and replaced
by
> > a ".misc" group.
>
> Just so.
True, but I simply wanted to know *why* this group changed from
comp.lang.perl to comp.land.perl.misc! I think I saw this question
earlier in here recently, can't seem to locate it though, and I think it
got lost in the ever growing pile this thread has become. Something that
was said in that post stands out, that part that asks why the "misc"
part? I tend to agree with the poster's suggestion that the "misc" part
alone could be responsible for the side-related posts in here of the
days of yore all the way to present day c.l.p.m.
> > Now I don't really have any idea on when all this happened,
>
> It's not as if it hasn't been discussed before. The key would be the
> newgroup posting to control.
See above: it seems there would be less need for control if the name of
the group was better chosen, or even left as comp.lang.perl.
Is it just me that finds it a bit strange that the main Perl group is
NOT comp.lang.perl, but instead c.l.p.m. If you compare ot other langs
that are more traditionally named, like comp.lang.c, comp.lang.c++,
comp.lang.pascal, comp.lang.javascript, comp.lang.python,
comp.lang.cobol, comp.lang.php, etc (see a pattern yet?)
So my ultimate question is: Why was it not left as comp.lang.perl? Yes
you have sub-groups but that doesnt mean the main group needed to be
moved, as other programming groups like some of those listed above also
have subgroups.
Jus' Curious ;p
-
Islaw
------------------------------
Date: Sun, 20 Oct 2002 23:58:56 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Convert Perl script to C program (and Why was this group's name changed?)
Message-Id: <Pine.LNX.4.40.0210202353010.10563-100000@lxplus076.cern.ch>
On Oct 20, Bart Lateur inscribed on the eternal scroll:
> I think it's pretty common if you do a split-up for a group,
Indeed, and news.newusers.questions would seem a more appropriate
venue to understand this kind of detail about usenet, as it has
nothing "per se" to do with the Perl programming language.
> i.e. here
> adding comp.lang.perl.modules, comp.lang.perl.announce, and
> comp.lang.perl.tk, that the original group is abandoned and replaced by
> a ".misc" group.
Just so.
> Now I don't really have any idea on when all this happened,
It's not as if it hasn't been discussed before. The key would be the
newgroup posting to control.
AIUI this happened at a time when control messages were in a bit of a
mess. But regular checkgroup messages have been distributed in the
intervening years. News-server admins who continue to promote
non-existent groups (at least on the main hierarchies) are doing no
service to their users.
------------------------------
Date: Sun, 20 Oct 2002 22:53:19 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: DBI module INSERT command problem
Message-Id: <3DB333CC.7000909@rochester.rr.com>
Doug wrote:
> I have been unsuccessful in getting Access to do an INSERT command using DBI
> that has a date component in it. All my database logs show the date as
...
> $database_run=$dbh->do("INSERT INTO $table_type
> (description,project_id,date) VALUES ('$description,
--------------------------^^^^
reserved word
> '$project_id','$today_date')");
>
...
Your syntax error, as it looks like you have surmised in the other
posts, is because 'date' is a reserved word in Microsoft Jet SQL. You
can either quote it (with square brackets is Microsoft's way of doing
it) or you can change the name to something which is not a reserved word.
You can look up the huge long list of reserved words in Access' help by
asking for 'SQL reserved words'.
And, your problem was not a Perl problem, but rather an SQL problem.
The fact that the error message contained the text
[Microsoft][ODBC Microsoft Access Driver]
indicates that it was an error from Access rather than from Perl or the
DBI module.
--
Bob Walton
------------------------------
Date: Mon, 21 Oct 2002 02:49:51 GMT
From: "Doug" <dgardiner@houston.rr.com>
Subject: Re: DBI module INSERT command problem
Message-Id: <jXJs9.174006$Fw2.5103064@twister.austin.rr.com>
[snip]
> >
>
> no.
> First the output in logs often has problems with showing quotes, which is
> one of the mainproblem when I work on databases. (I often use the wrong
> quotes ;)
That was a problem I had a while back, with another script somewhere. I
couldn't remember why, but I remember one time that it was a quoting error.
> Second : even if you submit a wrong SQL-syntax via a perl-script it is no
> perl-problem, but a SQL-problem.
>
> So: when you submit a sql-command to the sql-backend via the "certified"
> console you can be sure about this. If the command works at the console
and
> doesnt work in perl, then its a perl-problem (most probably cause you use
> wrong quotes around your statement :)
>
Now for the silly question. How do you access the direct console and where
is it etc.? I've never heard of that.
> >
> > Hopefully it is the same
> > with other DBD's so that when I move this to the linux machine and use
> > MySQL instead of Access, I'll only have to change the driver call.
> >
>
> Dont hope to much. I dont know how deep you use special features, but I
> work with mySQL and postgreSQL under linux and while the most basic
> statements are the same, porting a program is lot of work.
>
> best,
> peter
>
>
>
> --
> peter pilsl
> pilsl_@goldfisch.at
> http://www.goldfisch.at
>
------------------------------
Date: Sun, 20 Oct 2002 23:34:01 GMT
From: coL mUstard <cmustard@nyc.rr.com>
Subject: Digest::MD5 -> /usr/bin/ld -> can't compile
Message-Id: <slrnar6fkb.1pc.cmustard@nyc.rr.com>
I'm installing LWP but one of the modules it needs is Digest::MD5, i have
downloaded and gzip'ed etc. when i `perl Makefile.pl' from the Digest directory,
i get `testing alignment requirements for U32.... /usr/bin/ld: cannot
find -lgdbm collect2: ld returned 1 exit status cant compile test program
Writing Makefile for Digest::MD5. I do have /usr/bin/ld and as far as i know it
is installed correctly. I have read the `Changes' and README but see no mention
of any bugs in MD5 (version 2.20). Is this is problem? can i ignore it and
finish the install? Will MD5 perlform as expected? I would rather `clear' this
up, but i jsut need it to run.
any ideas? TIA (I know this isn't the `modules' list, there are just more of
you here and i hope to get this cleared up tonight if possible)
--
-mUstard
------------------------------
Date: Sun, 20 Oct 2002 18:45:16 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Digest::MD5 -> /usr/bin/ld -> can't compile
Message-Id: <87smz08yk3.fsf@limey.hpcc.uh.edu>
>> On Sun, 20 Oct 2002 23:34:01 GMT,
>> coL mUstard <cmustard@nyc.rr.com> said:
> I'm installing LWP but one of the modules it needs is
> Digest::MD5, i have downloaded and gzip'ed etc. when i
> `perl Makefile.pl' from the Digest directory, i get
> `testing alignment requirements for U32.... /usr/bin/ld:
> cannot find -lgdbm collect2: ld returned 1 exit status
> cant compile test program Writing Makefile for
> Digest::MD5. I do have /usr/bin/ld and as far as i know
> it is installed correctly. I have read the `Changes' and
> README but see no mention of any bugs in MD5 (version
> 2.20). Is this is problem? can i ignore it and finish
> the install? Will MD5 perlform as expected? I would
> rather `clear' this up, but i jsut need it to run.
The bit to notice is the "cannot find -lgdbm", the error
is in neither ld nor MD5. It appears the perl you are
using was compiled with GDBM support, but the library is
now not on the system (or at least, not in a known
location).
On a related note, sounds like you might benefit from
CPAN, e.g.
# perl -MCPAN -eshell
lets you grab and install modules without having to unpack
them, e.g.
cpan> install MD5::Digest
(The Bundle::CPAN bundle provides a userland "cpan"
program to enter the CPAN shell.)
hth
t
------------------------------
Date: Sun, 20 Oct 2002 23:58:21 GMT
From: coL mUstard <cmustard@nyc.rr.com>
Subject: Re: Digest::MD5 -> /usr/bin/ld -> can't compile
Message-Id: <slrnar6h1u.1pc.cmustard@nyc.rr.com>
In article <87smz08yk3.fsf@limey.hpcc.uh.edu>, Tony Curtis wrote:
>>> On Sun, 20 Oct 2002 23:34:01 GMT,
>>> coL mUstard <cmustard@nyc.rr.com> said:
>
>> I'm installing LWP but one of the modules it needs is
>> Digest::MD5, i have downloaded and gzip'ed etc. when i
>> `perl Makefile.pl' from the Digest directory, i get
>> `testing alignment requirements for U32.... /usr/bin/ld:
>> cannot find -lgdbm collect2: ld returned 1 exit status
>> cant compile test program Writing Makefile for
>> Digest::MD5. I do have /usr/bin/ld and as far as i know
>> it is installed correctly. I have read the `Changes' and
>> README but see no mention of any bugs in MD5 (version
>> 2.20). Is this is problem? can i ignore it and finish
>> the install? Will MD5 perlform as expected? I would
>> rather `clear' this up, but i jsut need it to run.
>
> The bit to notice is the "cannot find -lgdbm", the error
> is in neither ld nor MD5. It appears the perl you are
> using was compiled with GDBM support, but the library is
> now not on the system (or at least, not in a known
> location).
>
> On a related note, sounds like you might benefit from
> CPAN, e.g.
>
> # perl -MCPAN -eshell
>
> lets you grab and install modules without having to unpack
> them, e.g.
>
> cpan> install MD5::Digest
>
> (The Bundle::CPAN bundle provides a userland "cpan"
> program to enter the CPAN shell.)
>
> hth
> t
Tony, thanks for the info. Actually i did install the CPAN module, but it
would not work as desired and kept asking for LWP? and also suggested i
install Net::FTP as well which i did. As far as i know i installed correctly
and gave many CPAN mirrors, i didn't know if cpan needs LWP installed to
run. So that is why i took the temporary manual route. I do have wget and
ncftp installed. I am running perl 5.6.1.
--
I submit it is Colonol Mustard,... in the comp room,... with the pc,...
-mUstard
------------------------------
Date: Sun, 20 Oct 2002 19:29:26 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Digest::MD5 -> /usr/bin/ld -> can't compile
Message-Id: <87u1jghbx5.fsf@limey.hpcc.uh.edu>
>> On Sun, 20 Oct 2002 23:58:21 GMT,
>> coL mUstard <cmustard@nyc.rr.com> said:
> Tony, thanks for the info. Actually i did install the
> CPAN module, but it would not work as desired and kept
> asking for LWP? and also suggested i install Net::FTP as
http://search.cpan.org/author/GAAS/libwww-perl-5.65/lib/LWP.pm
> well which i did. As far as i know i installed correctly
> and gave many CPAN mirrors, i didn't know if cpan needs
> LWP installed to run. So that is why i took the
> temporary manual route. I do have wget and ncftp
> installed. I am running perl 5.6.1.
cpan> o conf init
will reconfigure your CPAN installation, you might need to
re-tell it where external things are now.
# perl -MCPAN -e 'install Bundle::CPAN'
will hopefully update your CPAN, and
# perl -MCPAN -e 'install Bundle::LWP'
should update your LWP.
If that doesn't work, grab the sources of perl, gdbm,
etc. and rebuild it (safest).
hth
t
------------------------------
Date: Mon, 21 Oct 2002 00:33:11 GMT
From: coL mUstard <cmustard@nyc.rr.com>
Subject: Re: Digest::MD5 -> /usr/bin/ld -> can't compile
Message-Id: <slrnar6iup.1pc.cmustard@nyc.rr.com>
In article <slrnar6h1u.1pc.cmustard@nyc.rr.com>, coL mUstard wrote:
> In article <87smz08yk3.fsf@limey.hpcc.uh.edu>, Tony Curtis wrote:
>>>> On Sun, 20 Oct 2002 23:34:01 GMT,
>>>> coL mUstard <cmustard@nyc.rr.com> said:
>>
>>> I'm installing LWP but one of the modules it needs is
>>> Digest::MD5, i have downloaded and gzip'ed etc. when i
>>> `perl Makefile.pl' from the Digest directory, i get
>>> `testing alignment requirements for U32.... /usr/bin/ld:
>>> cannot find -lgdbm collect2: ld returned 1 exit status
>>> cant compile test program Writing Makefile for
>>> Digest::MD5. I do have /usr/bin/ld and as far as i know
>>> it is installed correctly. I have read the `Changes' and
>>> README but see no mention of any bugs in MD5 (version
>>> 2.20). Is this is problem? can i ignore it and finish
>>> the install? Will MD5 perlform as expected? I would
>>> rather `clear' this up, but i jsut need it to run.
>>
>> The bit to notice is the "cannot find -lgdbm", the error
>> is in neither ld nor MD5. It appears the perl you are
>> using was compiled with GDBM support, but the library is
>> now not on the system (or at least, not in a known
>> location).
>>
>> On a related note, sounds like you might benefit from
>> CPAN, e.g.
>>
>> # perl -MCPAN -eshell
>>
>> lets you grab and install modules without having to unpack
>> them, e.g.
>>
>> cpan> install MD5::Digest
>>
>> (The Bundle::CPAN bundle provides a userland "cpan"
>> program to enter the CPAN shell.)
>>
>> hth
>> t
>
> Tony, thanks for the info. Actually i did install the CPAN module, but it
> would not work as desired and kept asking for LWP? and also suggested i
> install Net::FTP as well which i did. As far as i know i installed correctly
> and gave many CPAN mirrors, i didn't know if cpan needs LWP installed to
> run. So that is why i took the temporary manual route. I do have wget and
> ncftp installed. I am running perl 5.6.1.
>
Ok, i installed the gdbm lib of gnu.org, now when i run Digest::MD5 makefile
i get a find -ldb compilation error. I can't find the 'db' lib on gnu.
Any ideas what this lib is, or is a part of?
TIA
--
I submit it is Colonol Mustard,... in the comp room,... with the pc,...
-mUstard
------------------------------
Date: Mon, 21 Oct 2002 11:46:44 +1000
From: "mostuff" <stuff@nowhere.com>
Subject: dynamically named arrays
Message-Id: <n0Js9.235$P5.21954@nasal.pacific.net.au>
i have a list of files that i'd like to put into an array. there are a
number of different files each indentified by a 2 letter prefix. so the
files might be call vs010101.000, ud010101.000, eq010101.000. at any other
time there might a another type added. what i'd like to do is push
modification times of each of those files into arrays for each type.
so i might have
for (@filetypes) {
push(@$_modtime,$modtime);
}
or something like that. what i'd like to know if how i create an array like
that where the first 2 characters of the array are the type of file it is.
thanx in advance
------------------------------
Date: Mon, 21 Oct 2002 03:57:23 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: dynamically named arrays
Message-Id: <3DB37B00.1050601@rochester.rr.com>
mostuff wrote:
> i have a list of files that i'd like to put into an array. there are a
> number of different files each indentified by a 2 letter prefix. so the
> files might be call vs010101.000, ud010101.000, eq010101.000. at any other
> time there might a another type added. what i'd like to do is push
> modification times of each of those files into arrays for each type.
>
> so i might have
>
> for (@filetypes) {
> push(@$_modtime,$modtime);
> }
Note: you never used $_, the index variable for the for loop???
>
> or something like that. what i'd like to know if how i create an array like
> that where the first 2 characters of the array are the type of file it is.
...
Well, you can do that (it's called symbolic references), but it isn't a
good thing to do. Why? Because it corrupts your variable namespace.
Also, depending upon the data coming in, you might get something that
won't parse as a variable name. You could still refer to it as
@$_modtime, but not by its direct name.
To do it using symbolic references, just set $_modtime to the string
which contains the array name you want to create. For example:
$_modtime='a';
push @$_modtime,'b','c';
will create array @a, with two elements, 'b' and 'c'.
Note that this will not pass 'use strict'. Also, note that you will
have to keep track of what variables you created somehow. Further, note
that @a cannot be a lexical variable if you wish to subsequently refer
to it as @a.
How then should you do it? Use a hash, with the key to the hash being
the "array name" you wanted to create, and the value of the hash being a
reference to the array. Something like:
use Data::Dumper;
use strict;
use warnings;
my $_modtime='a';
my %hash;
push @{$hash{$_modtime}},'b','c';
print Dumper(\%hash);
Note that keys(%hash) gives you a list of all the arrays you created.
In the hash, you have a complete private "namespace" available.
HTH.
--
Bob Walton
------------------------------
Date: 20 Oct 2002 21:04:42 -0700
From: achakrab@nmsu.edu (Anirban Chakraborti)
Subject: GNU plot in perl
Message-Id: <f33fa166.0210202004.508f03cf@posting.google.com>
hi,
I am using GNU plot function in perl.I am able to use it
properly when i initalize the x and y axis arrays in the function.But
I am not able to initialise it outside the function at run time.Like
say the x and y axis arrays may be filled by a for loop and the loop
is outside the function but in the same program.but it doesn't work???
thanks,
anir
------------------------------
Date: 20 Oct 2002 19:58:25 -0700
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: processing lines in pairs
Message-Id: <1bff1830.0210201858.125eb9b9@posting.google.com>
> I'm reading from a text file that looks like this:
>
> filename <tab> description
> filename <tab> description
> filename <tab> description
> filename <tab> description
>
In the code below you go through way too many hoops to try and keep
your loop based on processing line by line.
Your logical unit of work is based on 2 lines, so read 2 lines within
each loop.
<snip>
> while (<INDEX>)
> {
> chomp;
> if ($line==0)
> {
> ($picture1file, $picture1text) = ("","");
> if (s/\\$//) { $_ .= <INDEX> ; redo; }
> ($picture1file, $picture1text) = &pictureline($_);
> $line++;
> }
> elsif ($line==1)
> {
> ($picture2file, $picture2text) = ("","");
> if (s/\\$//) { $_ .= <INDEX> ; redo; }
> $line++;
> ($picture2file, $picture2text) = &pictureline($_);
> }
> # and then I process the lines into my web table like this
> if ($line==2)
> { # we're finished. process and print the line
> print qq(<tr>);
> &printpicture($picture1file);
> &printtext($picture1text,"left",$picture1file);
> &printpicture($picture2file,$picture2thumb);
> print qq(</tr>\n<tr>);
> &printtext($picture2text,"right",$picture2file,$picture2thumb);
> print qq(</tr>\n);
> $line=0;
> }
> }
>
I would write this instead:
use strict;
use warnings;
sub process_in {
my $input = shift;
my $callback = shift;
while (1) {
my $ln1 = <$input> || last;
my $ln2 = <$input> || "";
my ($f1, $f2, $d1, $d2) = ("","","","");
if ($ln1 =~ /^\s*(\S+)\t+(.*)/) {
($f1, $d1) = ($1, $2);
}
#else { handle error.....}
if ($ln2 =~ /^\s*(\S+)\t+(.*)/) {
($f2, $d2) = ($1, $2);
}
#else { handle error.....}
&$callback($f1, $d1, $f2, $d2, @_);
last unless($ln2);
}
}
process_in(\*STDIN, sub {
my ($file1, $description1, $file2, $description2) = @_;
print <<END_HTML;
<tr>
<td>$file1</td>
<td>$description1</td>
<td>$file2</td>
</tr>
<tr>
<td> </td>
<td>$description2</td>
<td> </td>
</tr>
END_HTML
});
> Which works fine as long as I guarantee that my lines are in pairs.
>
> I have I have odd line at the end, then EOF ends my while() loop, and
> my printing portion is never activated.
It seems to me that would be an error anyway, wouldn't it. I made the
code above, default to blank strings if there are odd lines.
------------------------------
Date: Sun, 20 Oct 2002 22:47:56 GMT
From: sure@yeahyeah.not
Subject: Regex Problem
Message-Id: <8ha6ruk9l8jrk8l384druu6vj19em4suk2@4ax.com>
I am simply trying to highlight some keywords in some text.
My problem is that I lose capitalization when doing that.
I need a routine that copies the capitalization exactly as it finds it, and
without having to match every possible combination of capitalization.
"Ford Car" = "ford Car" = "FORD car" = "FoRd CaR" = etc...
I must be looking at this wrong! But for the life of me I can't
figure out how to match/substitute without losing capitalization.
Here is my code:
------------------------------------ Snip ----------------------
#!\perl\bin\perl.exe
$text = "I have a Ford car. I love my FoRd. A ford is a shallow place in
water.";
$Highlight1 = "<B>";
$Highlight2 = "<\/B>";
@Phrases=('ford car');
@Words=('water','ford');
# =========== Highlight Keywords
foreach $element (@Phrases)
{$text =~ s/\b$element\b/$Highlight1$element$Highlight2/gi; }
foreach $element (@Words)
{$text =~ s/\b$element\b/$Highlight1$element$Highlight2/gi; }
print "$text\n";
--------------------------------- Snip -------------------------
The output is:
I have a <B><B>ford</B> car</B>. I love my <B>ford</B>. A <B>ford</B> is a
shallow place in <B>water</B>.
Which works except that I lose capitalization on the first and second "Ford".
How do I fix that?
------------------------------
Date: Sun, 20 Oct 2002 23:39:47 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Regex Problem
Message-Id: <3DB33EAD.1050704@rochester.rr.com>
sure@yeahyeah.not wrote:
> I am simply trying to highlight some keywords in some text.
> My problem is that I lose capitalization when doing that.
> I need a routine that copies the capitalization exactly as it finds it, and
> without having to match every possible combination of capitalization.
>
> "Ford Car" = "ford Car" = "FORD car" = "FoRd CaR" = etc...
>
> I must be looking at this wrong! But for the life of me I can't
> figure out how to match/substitute without losing capitalization.
>
> Here is my code:
> ------------------------------------ Snip ----------------------
>
> #!\perl\bin\perl.exe
>
> $text = "I have a Ford car. I love my FoRd. A ford is a shallow place in
> water.";
>
> $Highlight1 = "<B>";
> $Highlight2 = "<\/B>";
>
> @Phrases=('ford car');
> @Words=('water','ford');
>
> # =========== Highlight Keywords
> foreach $element (@Phrases)
> {$text =~ s/\b$element\b/$Highlight1$element$Highlight2/gi; }
>
> foreach $element (@Words)
> {$text =~ s/\b$element\b/$Highlight1$element$Highlight2/gi; }
>
> print "$text\n";
>
> --------------------------------- Snip -------------------------
>
> The output is:
> I have a <B><B>ford</B> car</B>. I love my <B>ford</B>. A <B>ford</B> is a
> shallow place in <B>water</B>.
>
> Which works except that I lose capitalization on the first and second "Ford".
> How do I fix that?
>
>
What you need to do is substitute what you *matched* rather than the
portion of the regex which was involved in the match. To do that,
insert a parentheses group around the portion of the match you want to
substitute, and use the variable $1 to pick up its value. Like:
{$text =~ s/\b($element)\b/$Highlight1$1$Highlight2/gi; }
for example. See:
perldoc perlre
and
perldoc perlop
for details.
--
Bob Walton
------------------------------
Date: Sun, 20 Oct 2002 23:54:50 GMT
From: sure@yeahyeah.not
Subject: Re: Regex Problem
Message-Id: <v7g6ruoc024g25l6rlkaje8ounqkhoo4pl@4ax.com>
>What you need to do is substitute what you *matched* rather than the
>portion of the regex which was involved in the match. To do that,
>insert a parentheses group around the portion of the match you want to
>substitute, and use the variable $1 to pick up its value. Like:
>
> {$text =~ s/\b($element)\b/$Highlight1$1$Highlight2/gi; }
>
>for example. See:
>
> perldoc perlre
>
>and
>
> perldoc perlop
>
>for details.
Thanks a lot! That worked !
Your hired ;-)
I read the Perl docs too, Thanks!
------------------------------
Date: Mon, 21 Oct 2002 01:21:16 GMT
From: Garry Williams <garry@ifr.zvolve.net>
Subject: Re: removing commas in an element of an array of csv file
Message-Id: <slrnar6lcs.iuv.garry@zfw.zvolve.net>
On 19 Oct 2002 12:56:04 -0700, Doggy <tru64dog@yahoo.com> wrote:
> Below underneath my Perl code is a snip of a CSV file. I'm using the
> split function of Perl to parse the CSV file
Why not use the suggestion in the FAQ?
perldoc -q split
"How can I split a [character] delimited string except when
inside [character]? (Comma-separated files)"
use Text::ParseWords;
@words = quotewords(",", 0, $text);
See the Text::ParseWords manual page for details.
--
Garry Williams
------------------------------
Date: 20 Oct 2002 16:54:22 -0700
From: mary_wong1232002@yahoo.com (Mary Wong)
Subject: roman numeric question
Message-Id: <5b85cd30.0210201554.1eabae46@posting.google.com>
Hello,
How to write a program that it accepts roman numeric
------------------------------
Date: 21 Oct 2002 00:16:24 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: roman numeric question
Message-Id: <aovh0o$emk@dispatch.concentric.net>
"Mary Wong" <mary_wong1232002@yahoo.com> wrote in message
news:5b85cd30.0210201554.1eabae46@posting.google.com...
> Hello,
>
> How to write a program that it accepts roman numeric
perldoc -q roman
or
http://search.cpan.org/search?query=Roman&mode=all
------------------------------
Date: 20 Oct 2002 17:28:36 -0700
From: scyeang@hotmail.com (Soon)
Subject: Use infinite loop to process option and filter out the option
Message-Id: <1a7061d5.0210201628.658ab7d7@posting.google.com>
Can I use infinite loop to replace my for loop and look for the option
specified in command line? How to change it appropiately? My code is
as below:
#!/usr/bin/perl -w
$option_l=0;
$option_w=0;
$option_c=0;
for (@ARGV) {
$ARGV=shift;
if ($ARGV eq "-l"){
$option_l=1;
}
elsif ($ARGV eq "-w"){
$option_w=1;
}
elsif ($ARGV eq "-c"){
$option_c=1;
}
elsif ($ARGV eq ""){
$option_l=1;
$option_w=1;
$option_c=1;
}
else {
unshift @ARGV,$ARGV;
$option_l=1;
$option_w=1;
$option_c=1;
}
}
$words = 0;
$lines = 0;
$bytes = 0;
my $current = "";
while (<>) {
if ($current ne $ARGV){
$current = $ARGV;
}
$lines++;
@words = split(' ', $_);
$words += @words;
$bytes += length($_);
}
&formatprint($current,$words,$lines,$bytes);
sub formatprint{
printf "%10s%10s%10s%20s", $lines,$words,$bytes,$current;
print"\n";
}
------------------------------
Date: Mon, 21 Oct 2002 01:09:00 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Use infinite loop to process option and filter out the option
Message-Id: <3DB353C5.AF1ACBA3@acm.org>
Soon wrote:
>
> Can I use infinite loop to replace my for loop and look for the option
> specified in command line? How to change it appropiately? My code is
> as below:
Is there any reason that you can't use Getopt::Std?
perldoc Getopt::Std
> #!/usr/bin/perl -w
use strict;
> $option_l=0;
> $option_w=0;
> $option_c=0;
> for (@ARGV) {
> $ARGV=shift;
> if ($ARGV eq "-l"){
> $option_l=1;
> }
> elsif ($ARGV eq "-w"){
> $option_w=1;
> }
> elsif ($ARGV eq "-c"){
> $option_c=1;
> }
> elsif ($ARGV eq ""){
The shell won't supply @ARGV with an empty string unless you explicitly
type one in on the command line (wc "" somefile) but why would you do it
this way?
> $option_l=1;
> $option_w=1;
> $option_c=1;
> }
> else {
> unshift @ARGV,$ARGV;
This might not do what you expect depending on how the command line was
entered.
> $option_l=1;
> $option_w=1;
> $option_c=1;
>
> }
> }
> $words = 0;
> $lines = 0;
> $bytes = 0;
> my $current = "";
> while (<>) {
> if ($current ne $ARGV){
> $current = $ARGV;
> }
$current will contain the name of the _last_ file processed when the
loop ends.
> $lines++;
> @words = split(' ', $_);
> $words += @words;
No need to create an array here as split in a scalar context will return
the number of items resulting from the split.
$words += split;
> $bytes += length($_);
>
> }
>
> &formatprint($current,$words,$lines,$bytes);
>
> sub formatprint{
> printf "%10s%10s%10s%20s", $lines,$words,$bytes,$current;
> print"\n";
> }
Why pass the variables to the sub and then use them globally? Why use
an ampersand to bypass prototyping when you are not using a prototype or
the @_ array?
John
--
use Perl;
program
fulfillment
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 4003
***************************************