[19200] in Perl-Users-Digest
Perl-Users Digest, Issue: 1395 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jul 28 00:05:40 2001
Date: Fri, 27 Jul 2001 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)
Message-Id: <996293108-v10-i1395@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 27 Jul 2001 Volume: 10 Number: 1395
Today's topics:
Re: 5.6.1 on IRIX 6.5 <ashley@pcraft.com>
Apology...Was: Re: DBD:ODBC, Openlink->MSSQL, and LongR (Sebastian)
Re: bitwise operations <goldbb2@earthlink.net>
Caching information about IP subnets <gfk@spamcop.net>
Re: DBI:vvp-How to display sql table results? <mbudash@sonic.net>
Email to mySQL <graham@NOSPAM.just4life.net>
Re: Emal Options Robustness <somewhere@in.paradise.net>
Re: Extract the relative sorting of items from multiple (Richard J. Rauenzahn)
FAQ: How do I expand tabs in a string? <faq@denver.pm.org>
How to use setuid in perl? <shyan@cse.cuhk.edu.hk>
Re: Image Size <somewhere@in.paradise.net>
Re: Informix IDS2000 and Zope/Python/Perl/PHP on Linux <none@nohost.com>
Re: log file to html <somewhere@in.paradise.net>
Re: match regexp pattern in a special context? <no@mail.addr>
Optimization Question <kevin@vaildc.net>
Perl Net::FTP, IIS and file permissions <just@usenet.please>
Re: question with arrays (Balaji)
Re: scroll text on text-modal console? <no@mail.addr>
Simplest form of a module?? <a@b.c>
Re: Simplest form of a module?? (Logan Shaw)
Re: Simplest form of a module?? <bart.lateur@skynet.be>
Re: suidperl works on one system, not another (David Efflandt)
Re: Transporting .db files? (Richard J. Rauenzahn)
Re: Who can help me about the confused (..) operator? <no@mail.addr>
Re: Who can help me about the confused (..) operator? <no@mail.addr>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 27 Jul 2001 17:52:19 -0700
From: "Ashley M. Kirchner" <ashley@pcraft.com>
Subject: Re: 5.6.1 on IRIX 6.5
Message-Id: <3B620CC2.D94DD0EA@pcraft.com>
"Ashley M. Kirchner" wrote:
> I'm trying to compile perl 5.6.1 on an IRIX 6.5 machine, which has
> gcc-3.0 (from freeware.sgi.com) installed. Somewhere during the
> configure, it reaches the following stage and just stops:
>
> ----------
> Checking whether your dlsym() needs a leading underscore ...
> ----------
>
> That's it, nothing else after that.
This also happens with gcc-2.95.2 as well....
--
W | I haven't lost my mind; it's backed up on tape somewhere.
+--------------------------------------------------------------------
Ashley M. Kirchner <mailto:ashley@pcraft.com> . 303.442.6410 x130
IT Director / SysAdmin / WebSmith . 800.441.3873 x130
Photo Craft Laboratories, Inc. . 3550 Arapahoe Ave. #6
http://www.pcraft.com ..... . . . Boulder, CO 80303, U.S.A.
------------------------------
Date: 27 Jul 2001 16:05:40 -0700
From: dethtoll@yahoo.com (Sebastian)
Subject: Apology...Was: Re: DBD:ODBC, Openlink->MSSQL, and LongReadLen
Message-Id: <ea245403.0107271505.73360cf7@posting.google.com>
dethtoll@yahoo.com (Sebastian) wrote in message
...Excessive quoting snipped...
Btw, I apologize for my reply-quoting.
------------------------------
Date: Fri, 27 Jul 2001 23:54:20 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: bitwise operations
Message-Id: <3B62376C.8A8A4901@earthlink.net>
Swanthog wrote:
>
> Greetings all,
>
> I have 4 variables each of which will be set to logic level 1 or 0. I then
> want to use those 4 variables to create a 4 bit vector and compare against
> the 16 possible combinations. I have managed to do this but I don't like the
> solution.
>
> Is there a better way?
>
> Thanks,
> Larry S.
>
> # The 4 variables as described above. The test pattern is decimal 5.
> $var_0 = 1;
> $var_1 = 0;
> $var_2 = 1;
> $var_3 = 0;
print "Status is : 0x";
print unpack "h", pack "b*", join "", $var_0, $var_1, $var_2, $var_3;
print "\n";
This might be preferred:
@var = (1, 0, 1, 0);
print "Status is : 0x", unpack("h", pack "b*", join "", @var), "\n";
Note that if you want to use reversed bitorder, swap h and b for H and B.
--
I need more taglines. This one is getting old.
------------------------------
Date: Fri, 27 Jul 2001 18:15:05 -0400
From: Guillaume Filion <gfk@spamcop.net>
Subject: Caching information about IP subnets
Message-Id: <gfk-CFF302.18150527072001@news.videotron.net>
Hi all,
I'm working with a module that queries IP Whois servers
(ARIN,APNIC,RIPE,etc) and returns the content of the record. This module
offers the option of caching the result of the query but caches it only
considering the IP address.
ex: the cache key for 209.85.157.220 on whois.arin.net is:
209.85.157.220@whois.arin.net
It would be much more efficient to have it cache its data considering
the IP's subnet.
ex: the cache key for 209.85.157.220 on whois.arin.net would be:
209.85.157.0/24@whois.arin.net
or something like that.
That way if I make a query about 209.85.157.100, I could use my cache
instead of reconnecting to the server.
The problem is that I really have no idea on how to do this.
Any pointer or idea would be really appreciated.
Thanks,
GFK's
------------------------------
Date: Sat, 28 Jul 2001 00:42:13 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: DBI:vvp-How to display sql table results?
Message-Id: <mbudash-C76AFE.17421327072001@news.sonic.net>
In article <3B619622.390D3387@americasm01.nt.com>, "Prasad, Victor
[FITZ:K500:EXCH]" <vprasad@americasm01.nt.com> wrote:
> Hello,
>
> I am connected to an Informix database. I want to be able to query a
> table and output to a web page with NEXT and PREVIOUS buttons so they
> can scroll through the data record by record. Not getting all the data
> dumped out on the page.
>
> ie.
>
> NAME [john]
> JOB [math]
>
> -------
>
> (next record after next button is pressed)
>
> NAME [mary]
> JOB [spelling]
>
> etx.
>
> Thanks,
>
> V
HTML::Pager (see cpan) looks interesting... a bit of overkill for your
use, but definitely a possibility for general-purpose web work...
hth-
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: Sat, 28 Jul 2001 00:15:26 +0100
From: "Graham Burgess" <graham@NOSPAM.just4life.net>
Subject: Email to mySQL
Message-Id: <3b61f6ae_1@mk-nntp-1.news.uk.worldonline.com>
I was wondering if anyone had written an email to mysql convertor. I am want
to write a mail listing archiver that utilises a database as all the
archivers that create HTML documents seem to be fine for web surfing but is
very limited to creating the files (the one I use currently can't cope with
more than 1000 message being stored at anyone time) and searching them.
I can do everything easily enough except processing the incoming email to
put it into a database format so I was wondering if anyone has done this in
the past and could help me.
Graham Burgess
------------------------------
Date: Sat, 28 Jul 2001 12:38:13 +1000
From: "Tintin" <somewhere@in.paradise.net>
Subject: Re: Emal Options Robustness
Message-Id: <pCp87.85$hh.287879@news.interact.net.au>
"Kev" <NOSPAMlekkerinsydney@ozemail.com.au> wrote in message
news:3b61a842.266562@news.ozemail.com.au...
> Hi All
>
> Which of the following (all things equal) would
> you gurus suggest to be the most robust for a
> relatively email heavy perl program:
> - perl with sendmail on unix
> - perl with blat on NT
> - perl with the SMTP module on unix
> - perl with the SMTP module on nt
Not really much to do with Perl, but the first option (unix/sendmail) is by
far and away, the best.
------------------------------
Date: 27 Jul 2001 22:14:56 GMT
From: nospam@hairball.cup.hp.com (Richard J. Rauenzahn)
Subject: Re: Extract the relative sorting of items from multiple lists
Message-Id: <996272095.123773@hpvablab.cup.hp.com>
Bart Lateur <bart.lateur@skynet.be> writes:
>I've got a cute little problem here. It's actually more of a question
>for a proper algorithm, than a specific perl problem.
>
>I have to extract the ordering of each item in some arrays, and not
>every item is present in every array. For example:
>
> @list = ([qw(A C F)], [qw(A B C)], [qw(A C D E)], [qw(E F)]);
>
How about using Graph::Directed?
I don't understand all of the functions, but I think there's enough to
implement what you want fairly easily:
use strict;
use Graph::Directed;
my $G = Graph::Directed->new;
my @list = ([qw(A C F)], [qw(A B C)], [qw(A C D E)], [qw(E F)]);
foreach(@list) {
$G->add_path(@$_);
}
print " source: ", $G->source_vertices(), "\n";
print " sink: ", $G->sink_vertices(), "\n";
print "SSSP_DAG: ", $G->SSSP_DAG($G->source_vertices()), "\n";
....
I believe if you have ambiguity you should end up with multiple sources
and/or sinks. I'm not sure what function will detect loops -- you might
have to write some of that. SSSP_DAG didn't work as I expected -- I
expected it to return A,C,F, but rather it traversed the entire list
(maybe its the shortest path that includes all vertices?) I was going
to try removing shortest paths until I was left with the longest, but
that would have had problems. Or you could write a longest path finder
-- but I'm wondering now if SSSP_DAG provides exactly what you want?
Still need an easy way to detect loops. I suspect the api's provide an
easy way to check...
Rich
--
Rich Rauenzahn ----------+xrrauenza@cup.hp.comx+ Hewlett-Packard Company
Technical Consultant | I speak for me, | 19055 Pruneridge Ave.
Development Alliances Lab| *not* HP | MS 46TU2
ESPD / E-Serv. Partner Division +--------------+---- Cupertino, CA 95014
------------------------------
Date: Sat, 28 Jul 2001 00:17:55 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: How do I expand tabs in a string?
Message-Id: <Twn87.114$os9.217462272@news.frii.net>
This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.
+
How do I expand tabs in a string?
You can do it yourself:
1 while $string =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e;
Or you can just use the Text::Tabs module (part of the standard Perl
distribution).
use Text::Tabs;
@expanded_lines = expand(@lines_with_tabs);
-
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.
If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile. If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.
Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to
news:news.answers
or to the many thousands of other useful Usenet news groups.
Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release. It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.
The perlfaq manual page contains the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-1999 Tom Christiansen and Nathan
Torkington. All rights reserved.
This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.
04.23
--
This space intentionally left blank
------------------------------
Date: 28 Jul 2001 02:08:50 GMT
From: ftp <shyan@cse.cuhk.edu.hk>
Subject: How to use setuid in perl?
Message-Id: <9jt6ri$rjv$1@eng-ser1.erg.cuhk.edu.hk>
I have written a CGI programin Perl which can chage the file .htpasswd.
The .htpasswd file must be set to 666 in order to allow the CGI program to
change it.
I want to set the permission of .htpasswd to 644, but setuid must be used.
However, I don't know how to use setuid in Perl.
Is it: (If my program is test.pl)
1. chmod a+s test.pl
2. add a line in test.pl
setuid(0);
The setuid function seems doen't work in perl. The following error message
appears
Undefined subroutine &main::setuid called at ./test.pl line 3.
--
------------------------------
Date: Sat, 28 Jul 2001 12:13:17 +1000
From: "Tintin" <somewhere@in.paradise.net>
Subject: Re: Image Size
Message-Id: <1fp87.81$Wf.244875@news.interact.net.au>
"Scott Yanoff" <yanoff@yahoo.com> wrote in message
news:3B618075.7AC0E34C@yahoo.com...
> "Johannes B." wrote:
> >
> > Hi!
> >
> > How can I get the width and height of an gif image which is located in a
> > folder of my server?
>
> Based on previous posts, I see that you cannot use the CPAN module.
Correction. *Thinks* he can not use a CPAN module. Obviously the OP hasn't
read the FAQ about installing modules.
>Try this script called "isize" at:
>
> ftp://ftp.crc.ricoh.com/pub/www/isize
Even, if you had your URL correct, why do you think this would offer an
easier solution for the OP? He still has to FTP it and load it on his
system.
------------------------------
Date: Fri, 27 Jul 2001 16:57:24 -0700
From: hg <none@nohost.com>
Subject: Re: Informix IDS2000 and Zope/Python/Perl/PHP on Linux
Message-Id: <3B61FFE4.1DBB2F92@nohost.com>
Can't answer for IDS 2000, but here's my $.02.
I'm running IDS 7.30.UC7 on Redhat 6 and IDS 7.31.UC7 on Solaris 7. I have
web access to the databases with perl, PHP, and C/embedded SQL programs and
Apache. I really like PHP because you write and test, write and test, etc.,
instead of compile the program, copy it to cgi-bin, run it, check the log
file(s), etc. Saves on development and implementation time. I don't see
much difference in execution time between the C and PHP programs that do the
same thing.
Hank
Thomas Volkmar Worm wrote:
> Hi all!
>
> I am consindering to use Informix Dynamic Server (Informix Internet
> Foundation 2000/Linux) together with Zope and the other 3 P's.
>
> I wonder, whether somebody has any experience with Linux and
>
> - IDS 2000 and Perl
> or
> - IDS 2000 and PHP
> or
> - IDS 2000 and Python
> or
> - IDS 2000 and Zope
>
> and can tell me about the experience he made with one or more of these
> combinations. I am interested to hear about
>
> - availibility of the needed drivers
> - their (practical) compatibility to (eg. perl DBI, python DB-API 2.0,
> etc.)
> - stability
> - and what else someone has experienced
>
> I already was an php.net, python.org, perl.org, zope.org - I guess I
> know whats available. It looks to me as if the support for IDS is not so
> strong, so I am really interested in real experience somebody had rather
> that what you can read in the READMEs. If you stopped using IDS together
> with P..., please tell me why and what db (other than mySQL, thats
> allready running here) are you using instead.
>
> If some Informix/IBM people are around: Are there any contributions
> planned or in progress for the 3 P's by Informix/IBM? Where can I find
> online information about it?
>
> If you respond to this posting, please send a CC to my email-address
> too.
>
> Thanks for your efforts in advance
>
> Regards
> Thomas Volkmar Worm
------------------------------
Date: Sat, 28 Jul 2001 11:52:09 +1000
From: "Tintin" <somewhere@in.paradise.net>
Subject: Re: log file to html
Message-Id: <dXo87.79$zg.262204@news.interact.net.au>
"novastar" <subscriber@novastar.dtdns.net> wrote in message
news:9jps9e$lis$1@usenet.otenet.gr...
> I have a perl program that generates a really big log file ( printed to
> screen also ) . I thought that it would me more intresting for the users
> watching the log file entries to Internet Explorer at real time . So I
> created a framed page . The bottom is the log file with a refresh period
of
> one second, but this is not smooth ( blocks of text every 1 sec ) . Can
you
> help me ?
No Perl problems here. This is purely a browser issue. You'll notice
Netscape will give you different behaviour to IE. Then of course, different
versions of IE and Netscape (and any other browser) will give you different
results.
------------------------------
Date: Sat, 28 Jul 2001 09:03:06 +0800
From: MMX166+2.1G HD <no@mail.addr>
Subject: Re: match regexp pattern in a special context?
Message-Id: <4u42mt04765usfjkn4o8ildskjdhcacq7u@4ax.com>
On Thu, 26 Jul 2001 01:38:05 GMT, in comp.lang.perl.misc Bob Walton
<bwalton@rochester.rr.com> wrote:
>
>HTML parsing is more complicated that you think. Stick to the tried and
>true solutions already done for you, like use HTML::Parser;, perhaps.
>It's probably already installed on your hard drive. You can get this
>advice yourself with:
>
> perldoc -q HTML
>--
>Bob Walton
Thanks. but I am just learning advanced regexp feature. I want to know
how to match in especial context. the TAG is just a example, not the
purpose.
------------------------------
Date: Fri, 27 Jul 2001 23:42:43 -0400
From: Kevin Michael Vail <kevin@vaildc.net>
Subject: Optimization Question
Message-Id: <270720012342431568%kevin@vaildc.net>
If $var is a reference to an array, and there is a subroutine &proc
with a prototype of (\@), and I want to call &proc with $var as a
parameter and still satisfy the prototype, it's necessary to do
something like
proc(@$var);
which would be basically the same as &proc(\@$var). Does the \@$var
part get optimized back to $var, so that the latter is the same as
&proc($var)?
--
Kevin Michael Vail | a billion stars go spinning through the night,
kevin@vaildc.net | blazing high above your head.
. . . . . . . . . | But _in_ you is the presence that
. . . . . . . . . | will be, when all the stars are dead. (Rainer Maria Rilke)
------------------------------
Date: Fri, 27 Jul 2001 15:33:48 -0700
From: "Um... Oh" <just@usenet.please>
Subject: Perl Net::FTP, IIS and file permissions
Message-Id: <3b61d038$1_1@binarykiller.newsgroups.com>
I use Perl Net::FTP from the most current libnet. I use methods cwd, pwd,
get, put and delete. Nothing else.
Occasionaly (rarely) files on the server I connect to (Microsoft IIS 4) end
up with 0 permissions. They are either created that way, or they are changed
afterwards.
Could it be possible that my script or Net::FTP is somehow causing this?
I don't think that clients setting file permissions is supported by IIS 4,
but I'm not sure. If I:
remotehelp site
it doesn't list "chmod" or "umask". And, I don't find instances of those
strings in Net::FTP.
Do you know of a bug in IIS that my script could inadvertantly be exploiting
to cause this, or can you think of any explanations for how this is
happening?
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
------------------------------
Date: 27 Jul 2001 17:21:27 -0700
From: srinivasanbala@netscape.net (Balaji)
Subject: Re: question with arrays
Message-Id: <86e0f1f4.0107271621.2be1c0b8@posting.google.com>
I managed to get what i wanted.Thanks!
srinivasanbala@netscape.net (Balaji) wrote in message news:<86e0f1f4.0107271044.5b514222@posting.google.com>...
> Hi comp.lang.perl.misc folks
>
>
> my @nvp = split /&/, $ENV{QUERY_STRING};
> This one gives me NAME=VALUE
>
> if i split again
>
> my @nvpnew = split /=/, $nvp[0];
>
> and if i refer back with $nvpnew[0] , it gives NAME VALUE.How will i
> get VALUE only from this array?
>
> How will i directly create arrays for VALUES only so that I can refer
> back later as $array[0],$array[1] etc..
>
> I can create array from a file, but not directly from above said.
> Thanks
------------------------------
Date: Sat, 28 Jul 2001 09:03:07 +0800
From: MMX166+2.1G HD <no@mail.addr>
Subject: Re: scroll text on text-modal console?
Message-Id: <m852mt0bf004iveo78n23gg9mg0koutace@4ax.com>
On Thu, 26 Jul 2001 13:02:26 +0200, in comp.lang.perl.misc Thomas
Bätzler <Thomas@Baetzler.de> wrote:
>On Thu, 26 Jul 200, MMX166+2.1G HD <no@mail.addr> wrote:
>>just going to write a enhancing "more" tool that can scroll plain text
>>forward and backward on the console (say dos command window), and.
>>without TK module. what shall I do?
>
>Install "less"? :-)
>
>If you really want to do that, check out Curses.pm if you're on Unix
>or Term::Cap if you have to make do with a Win32 platform.
>
>HTH,
install TK? oh, it's too big for my purpose and my brain :)
Curses and Term::Cap, thank you very much, where can I find their
examples or tutorials?
------------------------------
Date: Fri, 27 Jul 2001 16:32:24 -0700
From: BCC <a@b.c>
Subject: Simplest form of a module??
Message-Id: <3B61FA08.35E75F48@b.c>
Hi,
I have been struggling through the perldocs (perlmodlib, perlref,
perlobj, Exporter, module, bless etc etc) trying to figure out a very
simple module example.
I want to be able to create a new object of my class, and make reference
calls to methods rather than mung up my namespace with a bunch of
exports, i.e.:
my $stuff = new Stuff;
print $stuff->showMe("test stuff!");
I tried setting up the module like this after creating the skeleton with
h2xs (abbreviated):
package Stuff;
use strict;
use warnings;
require Exporter;
our @ISA = qw(Exporter);
our %EXPORT_TAGS = ( 'all' => [ qw(
) ] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw(
);
our $VERSION = '0.01';
sub new {
my $package = shift;
return (bless{}, $package);
}
sub showMe {
my $s = shift;
return $s;
}
I am clearly missing something with bless and my creation of the
class... but Im missing it. Can someone point out my stoopid mistake?
Thanks!
Bryan
------------------------------
Date: 27 Jul 2001 18:55:13 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Simplest form of a module??
Message-Id: <9jsv11$gnm$1@charity.cs.utexas.edu>
In article <3B61FA08.35E75F48@b.c>, BCC <a@b.c> wrote:
>I want to be able to create a new object of my class, and make reference
>calls to methods rather than mung up my namespace with a bunch of
>exports, i.e.:
>my $stuff = new Stuff;
>print $stuff->showMe("test stuff!");
O.K.
>package Stuff;
>use strict;
>use warnings;
Good so far.
>require Exporter;
>
>our @ISA = qw(Exporter);
>our %EXPORT_TAGS = ( 'all' => [ qw(
>) ] );
>
>our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
>
>our @EXPORT = qw(
>);
I thought you said you didn't want to export stuff. :-)
You don't need to do any of the export stuff if you don't want to
export anything.
>our $VERSION = '0.01';
That looks fine; in fact, it's a good idea.
>sub new {
> my $package = shift;
> return (bless{}, $package);
> }
That looks OK to me.
>sub showMe {
> my $s = shift;
> return $s;
>}
When you call showMe() by invoking it off an object, the first argument
that showMe() will get is the object itself. It's what people
sometimes refer to as an "invisible first argument", except that in
Perl, it's visible (at least, it is to the function, not exactly to the
caller). So, you need to do something more like this:
sub showMe
{
my $self = shift;
my $thingToShow = shift;
return $thingToShow;
}
Of course, ideally you'd actually be storing some useful information
inside the object itself. (What good is it to be able to make
instances of your object if they're all identical?)
So, you might do this instead:
package Stuff;
sub new
{
my $class = shift;
my $self = {}; # create a reference
bless $self, $class; # make it part of this class
$self->{string} = shift; # initialize it w/ the argument
return $self;
}
sub showMe
{
my $self = shift;
return $self->{string}; # return some of the object's contents
}
Then, you can do this:
my $stuff = Stuff->new ("test stuff!");
print $stuff->showMe(), "\n";
You could use the other syntax instead for the first line:
my $stuff = new Stuff "test stuff!";
but that's sort of deprecated, or at least discouraged.
- Logan
--
"Our grandkids love that we get Roadrunner and digital cable."
(Advertisement for Time Warner cable TV and internet access, July 2001)
------------------------------
Date: Sat, 28 Jul 2001 00:55:29 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Simplest form of a module??
Message-Id: <1234mt8dv9luveo1k39p5l782egk73s5lu@4ax.com>
BCC wrote:
>I want to be able to create a new object of my class, and make reference
>calls to methods rather than mung up my namespace with a bunch of
>exports, i.e.:
>my $stuff = new Stuff;
>print $stuff->showMe("test stuff!");
OK...
>package Stuff;
>use strict;
>use warnings;
>require Exporter;
You don't need that. Exporter serves to automate exporting.
>our @ISA = qw(Exporter);
>our %EXPORT_TAGS = ( 'all' => [ qw(
>) ] );
>
>our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
>
>our @EXPORT = qw(
>);
You don't any of the above either.
>our $VERSION = '0.01';
Not really necessary...
>sub new {
> my $package = shift;
> return (bless{}, $package);
> }
OK... $package, when "new" is called as class method (as you want it),
is the string "Stuff". (Well... except when you've subclassed the
module.)
Yyour object is empty, though.
>sub showMe {
> my $s = shift;
> return $s;
>}
>
>I am clearly missing something with bless and my creation of the
>class... but Im missing it. Can someone point out my stoopid mistake?
$s is the object in showMe, the empty, blessed hash. The object is an
extra parameter that gets unshifted unto the parameter list:
$stuff->showMe(@arg);
is equivalent to
Stuff::showMe($stuff, @arg);
So you actually want to print the following parameter, your first real
parameter. The object itself is irrelevant in this case.
sub showMe {
my $s = shift;
return shift;
}
--
Bart.
------------------------------
Date: Sat, 28 Jul 2001 01:44:29 +0000 (UTC)
From: see-sig@from.invalid (David Efflandt)
Subject: Re: suidperl works on one system, not another
Message-Id: <slrn9m467t.1l0.see-sig@typhoon.xnet.com>
On 27 Jul 2001 17:24:10 +0100, nobull@mail.com <nobull@mail.com> wrote:
> efflandt@xnet.com (David Efflandt) writes:
>
>> The following simple script (4755 permission) works on Linux Mandrake 7.0
>> with Perl 5.005_03. However, on Linux SuSE 7.1 with Perl v5.6.0 it fails
>
>> deffland@compaq:~ > ls -l /usr/bin/suidperl
>> -rwxr-xr-x 2 root root 765243 Jan 18 2001 /usr/bin/suidperl
>
> SuSE Linux has stripped the SUID bit off /usr/bin/suidperl. If you
> want suidperl to work you must reinstate it.
>
> SuSE first did this in response to a report from me telling them that
> suidperl was not safe on Linux because if failed to honour the nosuid
> filesystem flag.
>
> I do not know if this bug is fixed in 5.6.0 and if so if there is any
> other valid reason not to install suidperl with the SUID bit set.
Thanks. BTW 'echo "Can't do setuid" | splain' did not explain it and
neither did 'use diagnostics;' with or w/o -verbose.
--
David Efflandt (Reply-To is valid) http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: 27 Jul 2001 22:31:08 GMT
From: nospam@hairball.cup.hp.com (Richard J. Rauenzahn)
Subject: Re: Transporting .db files?
Message-Id: <996273067.609099@hpvablab.cup.hp.com>
usenet@hsdebate.com (Phil Kerpen) writes:
>I recently moved my web site from addr.com (FreeBSD) to
>phpwebhosting.com (Redhat Linux).
>
>Some of the perl scripts I use store data in .db hash files. The new
>server is unable to access these files. What is the best way to
>transport these files? (Unbuild them and rebuild them? How?)
>Thanks.
On BSD, write a Perl program to iterate over the tied hash and write out
the key/data to a file in a portable manner -- Then, on the RedHat
system, write a Perl program to read in that data from the file and load
it into a new tied hash/DB.
The hard part is the 'portable manner'. If you have plain text without
newlines, one way would be to output alternating lines of keys and data.
If you do have newlines, you could try picking a delimeter that your
data is guaranteed not to have. Or you could use Data::Dumper.
TIMTOWTDI and I haven't listed them all =-).
Rich
--
Rich Rauenzahn ----------+xrrauenza@cup.hp.comx+ Hewlett-Packard Company
Technical Consultant | I speak for me, | 19055 Pruneridge Ave.
Development Alliances Lab| *not* HP | MS 46TU2
ESPD / E-Serv. Partner Division +--------------+---- Cupertino, CA 95014
------------------------------
Date: Sat, 28 Jul 2001 09:03:08 +0800
From: MMX166+2.1G HD <no@mail.addr>
Subject: Re: Who can help me about the confused (..) operator?
Message-Id: <fd52mt0aao2hu1fnqds655ev9d4f00io1u@4ax.com>
On Thu, 26 Jul 2001 08:03:39 +0200, in comp.lang.perl.misc Philip
Newton <pne-news-20010726@newton.digitalspace.net> wrote:
>Now, for extra points, add a blank line between the quoted stuff and
>your reply, as Eric and I did. I find that makes things more readable,
>and it's easier to separate who said what.
>
>Cheers,
>Philip
>--
>Philip Newton <nospam.newton@gmx.li>
>That really is my address; no need to remove anything to reply.
>If you're not part of the solution, you're part of the precipitate.
oh, I see. thank you.
which newsreader do you use?
------------------------------
Date: Sat, 28 Jul 2001 09:03:10 +0800
From: MMX166+2.1G HD <no@mail.addr>
Subject: Re: Who can help me about the confused (..) operator?
Message-Id: <th52mt4nd1hjrocb0p55j9i7o9ko4k6paf@4ax.com>
On Tue, 24 Jul 2001 12:16:56 GMT, in comp.lang.perl.misc
helgi@NOSPAMdecode.is (Helgi Briem) wrote:
>On Tue, 24 Jul 2001 08:29:47 +0800, MMX166+2.1G HD
><no@mail.addr> wrote:
>
>>btw:what a strange complex signature. I see it in many posts. Is it
>>used for a special "perl" news reader? what's that? Agent?
>>--
>>On Sat, 21 Jul 2001 04:55:03 GMT, in comp.lang.perl.misc
>>mjd@plover.com (Mark Jason Dominus) wrote:
>>
>>>@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
>>>@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
>>>($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
>>>close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
>>
>This is technically known as a JAPH.
>
>What is a JAPH?
>
>From the Perl FAQ:
>http://www.perlfaq.com/cgi-bin/view?view_by_id=98
>
><START QUOTE>
>JAPH stands for Just Another Perl Hacker. It is a short Perl
>program that prints the string "Just Another Perl Hacker",
>usually in a fun, remarkable or obscure way. The history of
>JAPHs started in the early 1990s, when Randal Schwartz used
>a lot of them in Usenet signatures. JAPHs from the 1990 era
>can be found at http://www.perl.com/CPAN-local/misc/japh.
>SYNOPSIS
> local $, = " ";
> print reverse "Hacker", "Perl", "Another", "Just";
>DESCRIPTION
>If a JAPH is used as a Usenet signature, it ought to fit in
>a 4x80 frame.
><END QUOTE>
>Regards,
>Helgi Briem
but, on my Agent reader, they are just a lot of source codes. which
newsreader do you use?
------------------------------
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 1395
***************************************