[18161] in Perl-Users-Digest
Perl-Users Digest, Issue: 329 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 21 18:05:59 2001
Date: Wed, 21 Feb 2001 15:05:17 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <982796716-v10-i329@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 21 Feb 2001 Volume: 10 Number: 329
Today's topics:
[ANNOUNCE] New Tk::ObjEditor widget <domi@komarr.grenoble.hp.com>
ANNOUNCE: DDL::Oracle v1.02 <rvsutherland@yahoo.com>
ANNOUNCE: Expect v1.11 <RGiersig@cpan.org>
ANNOUNCE: Filter::Simple 0.50 (Damian Conway)
Re: chop and chomp <russ_jones@rac.ray.com>
email & date question <jzhang@voodoo.ca.boeing.com>
Re: Help with ?: and ! operators <mjcarman@home.com>
Re: Help with ?: and ! operators <uri@sysarch.com>
Re: how to create private/public functions in modules? <uri@sysarch.com>
Re: how to create private/public functions in modules? <mjcarman@home.com>
Re: how to create private/public functions in modules? <godzilla@stomp.stomp.tokyo>
I thought filehandles were Global? <moot@cfl.rr.com>
Re: IPC with Unix (ksh) system calls (Abigail)
Re: Is this taint example correct? <elijah@workspot.net>
Re: MacPerl help for a newbie <bart.lateur@skynet.be>
Module access to private vars in caller <bdesany@houston.rr.com>
Re: Module access to private vars in caller <bmb@ginger.libs.uga.edu>
Re: Need help creating a simple class. <c.manley@chello.nl>
Re: perl DBI cron problem <russ_jones@rac.ray.com>
Perl Debuger <afshina@newbridge.com>
Re: Print a page of HTML egwong@netcom.com
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 19 Feb 2001 15:44:18 +0100
From: Dominique Dumont <domi@komarr.grenoble.hp.com>
Subject: [ANNOUNCE] New Tk::ObjEditor widget
Message-Id: <t9893bs1qtgpbf@corp.supernews.com>
Hello
I've just uploaded to CPAN a new perl Tk widget: Tk::ObjEditor.
Installing this module will add a new demo to the contributed demo of
the widget program so you can try it easily.
Tk::ObjEditor provides a GUI to edit the attributes of an object or
the elements of a simple hash or array.
The editor is a Tk::ObjScanner with additional function to edit data.
When the user double clicks (with left button) on an item, the
value of the item will be displayed in the HList.
Use the right button of the mouse of an element to modify its
value. Depending on the context, you will also be able to delete the
element or to add a sub-element.
This module is available on CPAN:
http://search.cpan.org/search?mode=module&query=ObjEditor
Cheers
--
Dominique_Dumont@grenoble.hp.com
------------------------------
Date: Sun, 18 Feb 2001 18:07:31 -0500
From: "Richard Sutherland" <rvsutherland@yahoo.com>
Subject: ANNOUNCE: DDL::Oracle v1.02
Message-Id: <t9893nk00pe6cb@corp.supernews.com>
===========================================================================
Release of DDL::Oracle, Version 1.02
===========================================================================
CHANGES
Implemented patch from Jan Pazdziora regarding null PCTINCREASE on
Solaris for Oracle 8.0 and 8i. Thanks Jan!
Fixed bug #132023 regarding PL/SQL not always having a newline at the end.
Eliminated PARALLEL clause on CREATE INDEX for Oracle7, since the
dictionary does not contain this info.
Put a BUG entry in the pod that a bug has been detected but not fixed
regarding quoted table names in triggers.
DESCRIPTION
Designed for Oracle DBA's and users, for Oracle versions 7.3, 8.0
and 8i. Reverse engineers database objects (tables, indexes, users,
profiles, tablespaces, roles, constraints, etc.). Generates DDL to
*resize* tables and indexes to the provided standard or to a user
defined standard. Can reorganize/defragment tablespaces.
SYNOPSIS
use DBI;
use DDL::Oracle;
my $dbh = DBI->connect(
"dbi:Oracle:dbname",
"username",
"password",
{
PrintError => 0,
RaiseError => 1
}
);
# Use default resizing and schema options.
# query default DBA_xxx tables (could use USER_xxx for non-DBA types)
DDL::Oracle->configure(
dbh => $dbh,
);
# Create a list of one or more objects
my $sth = $dbh->prepare(
"SELECT
owner
, name
FROM
dba_tables
WHERE
tablespace_name = 'MY_TBLSP' -- your millage may vary
"
);
$sth->execute;
my $list = $sth->fetchall_arrayref;
my $obj = DDL::Oracle->new(
type => "table",
list => $list, );
);
my $ddl = $obj->create; # or $obj->resize; or $obj->drop; etc.
print $ddl; # Use STDOUT so user can redirect to desired file.
AUTHOR
Richard V. Sutherland
rvsutherland@yahoo.com
COPYRIGHT
Copyright (c) 2000, 2001 Richard V. Sutherland. All rights reserved.
This module is free software. It may be used, redistributed, and/or
modified under the same terms as Perl itself. See:
http://www.perl.com/perl/misc/Artistic.html
===========================================================================
AVAILABILITY
===========================================================================
DDL::Oracle is available from the CPAN, and from:
http://sourceforge.net/projects/ddl-oracle/
------------------------------
Date: Tue, 20 Feb 2001 15:19:22 GMT
From: Roland Giersig <RGiersig@cpan.org>
Subject: ANNOUNCE: Expect v1.11
Message-Id: <t98934s2rlhcbc@corp.supernews.com>
Expect v1.11 has been uploaded to CPAN and is also
available from http://sourceforge.net/projects/expectperl/
>From the README:
Expect.pm v1.11
Expect requires IO::Tty and IO::Stty, also available from CPAN.
There is a Bundle::Expect available that installs everything for
you.
If you prefer manual installation, the usual
perl Makefile.PL
make
make install
should work. I finally started a simple testsuite for Expect, but
it doesn't really test anything deeper right now.
It would probably be wise to read the docs on IO::Tty before
doing a make install with it.
The Expect for Perl module was inspired more by the functionality the
Tcl tool provides than any previous Expect-like tool such as Comm.pl
or chat2.pl.
The Tcl version of expect is a creation of Don Libes (libes@nist.gov).
The Tcl Expect home page is http://expect.nist.gov/. Don has written
an excellent in-depth tutorial of Tcl/Expect, which is _Exploring
Expect_. It is the O'reilly book with the monkey on the front. Don has
several references to other articles on the Expect web page.
I try to stay as close to Tcl/Expect in interface and semantics
as possible (so I can refer questions to the Tcl/Expect docu ;-).
Suggestions for improvement are always welcome.
I started a new FAQ (Expect_FAQ.pod), so please let me know if there's
something you'd like to see answered there that isn't.
>From the Changelog:
===================
Bugs fixed:
! max_accum (match_max) finally really restricts the match-buffer-size.
! expect() didn't return the correct error state upon EOF
! soft_close() was re-reading the filehandle even when an EOF
had already been detected, resulting in a very long delay.
! exp_continue() returned a value that got truncated with certain
perl versions (5.6 :-( ) on certain systems.
Features added:
+ Lee Eakin <leakin@japh.itg.ti.com>contributed a perl version of the
kibitz script which might be of common interest. See the
examples/kibitz subdir. Thanks Lee!
+ Expect got it's own print() so we can show what's getting
sent to the spawned program when exp_internal is set.
(suggested by horos@earth.he.net)
+ a session can now be logged to a file by setting log_file(). Thanks to
Marcel Widjaja <marcel.widjaja@sun.com> for suggesting this.
+ I added some aliases for certain methods to help Tcl/Expect users
to a WLIE experience (Work Like I Expect). 'exp_pid', 'match_max',
'log_file', 'log_user', even 'send' (which is an alias for 'print')
are all there now. But I won't make 'send_user' an alias for
'print STDOUT', you have to draw a line somewhere.
+ some diagnosis messages now use cluck to print a stacktrace
(suggested by horos@earth.he.net)
+ there is a new option 'restart_timeout_upon_receive', that, when
set to 1, will restart the timeout within the expect call. This is
useful when supervising an application that produces periodic, but
not well-defined output and you still want to react to certain
patterns. Just say
$exp->restart_timeout_upon_receive(1);
$exp->expect($timeout,
[ timeout => \&report_timeout ],
[ qr/pattern/ => \&handle_pattern ]);
(suggested by horos@earth.he.net)
Thanks to everybody who wrote to me, either with bug reports or
enhancement suggestions!
Roland Giersig (Expect.pm maintainer)
RGiersig@cpan.org
2001-02-20
------------------------------
Date: 21 Feb 2001 15:43:58 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: ANNOUNCE: Filter::Simple 0.50
Message-Id: <t9892uo4lcu6b7@corp.supernews.com>
Keywords: perl, module, release
==============================================================================
Release of version 0.50 of Filter::Simple
==============================================================================
NAME
Filter::Simple - Simplified source filtering
SYNOPSIS
# in MyFilter.pm:
package MyFilter;
use Filter::Simple sub { ... };
# in user's code:
use MyFilter;
# this is filtered
no MyFilter;
# this is not
DESCRIPTION
The Filter::Simple module provides a simplified interface to
Filter::Util::Call; one that is sufficient for most common cases.
AUTHOR
Damian Conway (damian@conway.org)
COPYRIGHT
Copyright (c) 2000, Damian Conway. All Rights Reserved. This module
is free software. It may be used, redistributed and/or modified under
the terms of the Perl Artistic License
(see http://www.perl.com/perl/misc/Artistic.html)
==============================================================================
CHANGES IN VERSION 0.50
(No changes have been documented for this version)
==============================================================================
AVAILABILITY
Filter::Simple has been uploaded to the CPAN
and is also available from:
http://www.csse.monash.edu.au/~damian/CPAN/Filter-Simple.tar.gz
==============================================================================
------------------------------
Date: Wed, 21 Feb 2001 13:26:49 -0600
From: Russ Jones <russ_jones@rac.ray.com>
Subject: Re: chop and chomp
Message-Id: <3A941679.B6EDA20A@rac.ray.com>
"Alan J. Flavell" wrote:
>
> On 20 Feb 2001, Another Way wrote:
>
> > hey
> > whats the diff. between chop and chomp
>
> What's the difference between reading the freely-available
> documentation that's installed with Perl, and posting to the
> world-wide usenet community and waiting to be flamed?
The difference is that if you are too dumb/lazy/rude/etc to read the
manual, somebody in the world-wide usenet community will flame you AND
tell you the answer. And it's easy to just skip over the flame part.
As we Buddhists say, WWBD? BWRTFM!
--
Russ Jones - HP OpenView IT/Operatons support
Raytheon Aircraft Company, Wichita KS
russ_jones@rac.ray.com 316-676-0747
Te audire non possum. Musa sapientum fixa est in aure. - Plautus
------------------------------
Date: Wed, 21 Feb 2001 20:56:29 GMT
From: Jian Zhang <jzhang@voodoo.ca.boeing.com>
Subject: email & date question
Message-Id: <3A942B7D.C20AC9CF@voodoo.ca.boeing.com>
Hi, all,
I'm mainly an UNIX programmer, but I need some help under NT environment:
1. On a Window NT server, how do I send email in my perl cgi script?
2. How do I get the current date information under the same environment?
Thanks in advance.
Jian
------------------------------
Date: Wed, 21 Feb 2001 13:01:17 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: Help with ?: and ! operators
Message-Id: <3A94107D.2AF3B526@home.com>
mshort wrote:
>
> I am just learning Perl 5 and will probably have questions from time to
> time. Here's my first-
>
> 1?2?3:4:5
>
> The book says that this equates to 3 and is the same as 1?(2?3:4):5
>
> When looking at that statement and speaking in english is this what you
> think--
>
> 1 is true so 2, 2 is true so 3. STOP since 3 is true it doesn't mean
> 4 or 5 otherwise
You started out on the right track, but wandered off course. The '3' is
never evaluated for boolean truth, it's just a return value for the
second (nested) ?: The ternary operator is is just a shortcut for
if-else:
This
1 ? 2 : 3
is the same as this
if (1) {
2;
}
else {
3;
}
So your example (1?2?3:4:5) is the same as this
if (1) {
if (2) {
3;
}
else {
4;
}
else {
5;
}
> And the other question is with the ! operator
>
> if
> !1 is 0
> !0 is 1
>
> I think I understand the !1. It means NOT 1, but I don't understand
> how !0 equals 1. Unless 0 is false and 1 is true. Is that right?
! is a boolean NOT. In Perl, the values 0, undef, and '' (the empty
string) are boolean false. Everything else is true. The canonical values
for true and false are 1 and 0, respectively, and that's what you'll get
as a return value from ! EXPR.
-mjc
------------------------------
Date: Wed, 21 Feb 2001 20:19:57 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Help with ?: and ! operators
Message-Id: <x7zoffiyab.fsf@home.sysarch.com>
>>>>> "MC" == Michael Carman <mjcarman@home.com> writes:
MC> ! is a boolean NOT. In Perl, the values 0, undef, and '' (the empty
MC> string) are boolean false. Everything else is true. The canonical values
MC> for true and false are 1 and 0, respectively, and that's what you'll get
MC> as a return value from ! EXPR.
also '0' is false. and ! returns a special version of false that is ''
in a string context and 0 in a numeric context. play with this:
#!/usr/local/bin/perl -w
$x = !1 ;
$y = '' ;
$sum = $x + 1 ;
$sum2 = $y + 1 ;
$string = "[$x]" ;
print $sum, $sum2, $string, "\n" ;
notice that there is a warning about the $sum2 line but not for the $sum
line. that is because $x is both 0 and '' at the same time. you can use
it in a numeric or string context without any warnings.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Wed, 21 Feb 2001 19:07:48 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: how to create private/public functions in modules?
Message-Id: <x73dd7kg6z.fsf@home.sysarch.com>
>>>>> "n" == nobull <nobull@mail.com> writes:
n> "JH Foo" <foojh@hotmail.com> writes:
>> Hi guys, I'm trying to write some perl modules and I want to
>> emulate OOP-style programming as much as possible. for starters, i
>> want to create modules which have 'internal' functions to be called
>> by other functions within the modules. I also want to have some
>> public functions which are 'safe' to be called by other modules.
>>
>> it seems to be that perl does not have this kind of
>> restriction. can someone pls confirm this?
n> Confirmed. (Should be in Perl6).
perl6 should have this but you can do something like it in perl5.
there are two ways to do this. the conventional way is to name your
internal functions with a _ prefix. this marks them as internal and not
to be called as external methods. like many other parts of OO perl this
is a rule which can be broken but you shouldn't if you play nice. these
subs can be called as regular subs or as object methods.
another technique which is truly private is a little clumsy but
works. you create anon subs and assign them to file scoped my vars:
my $private_func = sub { blah blah }
and call them like:
$private_func->( args )
which is prefered IMO or the uglier:
&$private_func( args )
those subs can not be seen from outside this file and are truly
private. unfortunately they can't be used in method style calls as they
have no entry in the symbol table.
and as usual ignore moronzilla, who responded with a query for code when
this was a conceptual problem that example code would not have
helped. also she know diddly about perl and even less about OO perl and
modules.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Wed, 21 Feb 2001 12:32:33 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: how to create private/public functions in modules?
Message-Id: <3A9409C1.7DD0B8FF@home.com>
nobull@mail.com wrote:
>
> "JH Foo" <foojh@hotmail.com> writes:
>
>> Hi guys, I'm trying to write some perl modules and I want to emulate
>> OOP-style programming as much as possible. for starters, i want to
>> create modules which have 'internal' functions to be called by other
>> functions within the modules. I also want to have some public
>> functions which are 'safe' to be called by other modules.
>>
>> it seems to be that perl does not have this kind of restriction.
>> can someone pls confirm this?
>
> Confirmed. (Should be in Perl6).
>
There are some things you can do in the meantime. For the most part,
Perl doesn't enforce privacy, it expects people to be polite and not
stick their noses where they don't belong. Those who do deserve whatever
headaches they get when the "private" portion of your module changes.
It might be sufficient for you to not export the functions and not list
them in the documentation. Many programmers prefix "private" subs with
an underscore [e.g. _foo()] as a visual indication that the function is
not for public use. This is how most of the Perl world does things.
If you're really paranoid about someone calling a sub that's not
intended for public consumption, you can use a lexically scoped coderef
to enforce visbility:
my $foo = sub {
print "foo() here!\n";
}
-mjc
------------------------------
Date: Wed, 21 Feb 2001 11:46:18 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: how to create private/public functions in modules?
Message-Id: <3A941B0A.5313D6D8@stomp.stomp.tokyo>
Uri Guttman wrote:
> nobull wrote:
> > JH Foo wrote:
I like "Godzilla" more than "bull" and "foo".
(snipped)
> perl6 should have this but you can do something like it in perl5.
> ...this is a rule which can be broken but you shouldn't
> if you play nice....
* boggled *
We all play nice!!!
> and as usual ignore moronzilla, who responded with a query for code
A query? I am well known for being bisexual, but query?
Does my being a woman and having been with more women
than you, annoy you? Heh!
Uri, I didn't ask for code. I suggested this author write
code and experiment to discover an answer. This is a sound
scientific method which provides direct answers, instantly.
> when this was a conceptual problem that example code would
> not have helped.
* boggled again * So why did you provide example code?
> also she know diddly about perl and even less about
> OO perl and modules.
Ahh, but I can play Bo Diddly on my violoncello like
a Fother Mucker!
* slips on very dark Beatnik sunshades *
Heh! I am too cool even for Maynard G. Grebs.
* shakes out her wild mane of black hair *
Oh yeah! Let's Rock N Roll!
* waves her Lynn Hannings bow around menacingly *
Are you ready for this, Uri?
Godzilla!
--
http://la.znet.com/~callgirl5/bodiddly.mid (Diamond Ring)
------------------------------
Date: Wed, 21 Feb 2001 22:57:30 GMT
From: tux <moot@cfl.rr.com>
Subject: I thought filehandles were Global?
Message-Id: <38B5B830.E64A9837@cfl.rr.com>
Maybe I'm delerious today. I opened a file in a package, and although
the handle was global in the package, it wasn't scoped in main or other
packages. I ended up doing somehting like:
pachage p;
sub openit
{open F, 'myfile';
*main::F=F;
}
1;
and in main:
openit();
print F 'test'; #looks normal here....
and in other packages
package p2;
sub s
{print main::F 'test'; #nothing pretty about this!
}
1;
-------------------------------------------------------------------------------
So I guess when the docs talk about a filehandle being global, it means
global in a package?
------------------------------
Date: 21 Feb 2001 19:11:44 GMT
From: abigail@foad.org (Abigail)
Subject: Re: IPC with Unix (ksh) system calls
Message-Id: <slrn9984ng.8cf.abigail@tsathoggua.rlyeh.net>
Allan (eggrock@MailAndNews.com) wrote on MMDCCXXXI September MCMXCIII in
<URL:news:3A956F3D@MailAndNews.com>:
!! This has two parts, I'll try to keep it short.
!!
!! 1) I want to call a .ksh script that sets and exports various variables from
!! a
!! Perl script, and have those values available in %ENV.
You can't.
This is discussed in the FAQ.
!! 2) I also want to pass arguments to the .ksh script
!!
!! Here's what I came up with:
!! `ksh ". /path/to/program.ksh arg1 arg2"`;
!!
!! This seems to work, but I don't know if I should be checking return values,
!! or
!! using open() (which BTW I completely don't understand after reading the IPC
!! FAQ).
Checking return variables is always good.
Whether backticks or open() is "better" depends on a lot of variables,
and isn't easily resolved in a newsgroup.
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
------------------------------
Date: 21 Feb 2001 19:05:25 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: Is this taint example correct?
Message-Id: <eli$0102211404@qz.little-neck.ny.us>
In comp.lang.perl.misc, Darren Dunham <ddunham@redwood.taos.com> wrote:
> Michael Fuhr <mfuhr@dimensional.com> wrote:
> > I'd guess that because the program receives the first element as
> > argv[0], that argument needs to pass the path test. The called program
> > might use argv[0] to exec itself under certain circumstances such as
> > a configuration change (sendmail does this, for example) -- if argv[0]
> > weren't taint-clean, you could have a security problem.
> Sure. I have no problem with that. But in this case argv[0] *is* taint
> clean (it came from static text in the script). It is somehow proposing
Yes, but it is not safe as an executible name.
> that argv[0] will be used to later call some program in the PATH
> directly, or the leading '/' wouldn't untaint it.
>
> I disagree with this assesment.
I think that perl should require you to set the path explicitly before
running any other programs, since one can never tell if they have broken
ideas about the PATH.
Elijah
------
has seen 'whoami' scripts that assume /bin/id is the first id on the PATH
------------------------------
Date: Wed, 21 Feb 2001 22:12:40 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: MacPerl help for a newbie
Message-Id: <52f89to380rf48lmf0nhfbc9ikmqe4v34k@4ax.com>
mbb wrote:
>so I was hoping for an elegant solution rather than
>using my workstudy student's time to do "Save As" for 400 some files.
If Excel bieuwer really doesn't know how to handle .WK1 files, you'll
have to do something like that, but not necessarily manually. Win32::OLE
could probably do that for you. That's a module that uses Windows' OLE
to control external programs, in this case, Excel. You do need Perl and
Excel on Windows, though.
For info to get started, check out the Win32::OLE FAQ includes with
ActiveState's distribution of Perl:
<http://velocity.activestate.com/docs/ActivePerl/faq/Windows/ActivePerl-Winfaq12.html>
and, there's the module docs:
<http://velocity.activestate.com/docs/ActivePerl/site/lib/Win32/OLE.html>.
--
Bart.
------------------------------
Date: Wed, 21 Feb 2001 15:21:09 -0600
From: "bdesany" <bdesany@houston.rr.com>
Subject: Module access to private vars in caller
Message-Id: <971bev$4d4@gazette.bcm.tmc.edu>
My understanding is that in order for private variables (my $variable) to be
accessible from a subroutine, the variable and the subroutine have to be
declared within the same enclosing scope. So you put braces around them. But
what if the subroutine is in an external module?
I've seen suggestions that you can access global variables by fully
qualifying the names, but I don't want to use global variables, and in any
case I don't want the module to have to know what variables it's supposed to
access (the variables are passed in as part of a single string, and there
could be any number of different ones). Can it be done?
------------------------------
Date: Wed, 21 Feb 2001 17:31:44 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Module access to private vars in caller
Message-Id: <Pine.A41.4.21.0102211729180.11852-100000@ginger.libs.uga.edu>
On Wed, 21 Feb 2001, bdesany wrote:
> My understanding is that in order for private variables (my $variable) to be
> accessible from a subroutine, the variable and the subroutine have to be
> declared within the same enclosing scope. So you put braces around them. But
> what if the subroutine is in an external module?
> I've seen suggestions that you can access global variables by fully
> qualifying the names, but I don't want to use global variables, and in any
> case I don't want the module to have to know what variables it's supposed to
> access (the variables are passed in as part of a single string, and there
> could be any number of different ones). Can it be done?
If I understand you, the answer is probably in perlmod - Perl modules
(packages and symbol tables)
e.g., perldoc perlmod
Brad
------------------------------
Date: Wed, 21 Feb 2001 20:20:24 GMT
From: Craig Manley <c.manley@chello.nl>
Subject: Re: Need help creating a simple class.
Message-Id: <3A94238B.F86F50B8@chello.nl>
Hi 'nobull',
Thanks for the help. That was exactly what I needed (aside from the free
syntax checking service). It would be nice to see this and some
explanation included somewhere like in perltoot so that we can all learn
about this Perl 'magic'.
nobull@mail.com wrote:
>
> Craig Manley <c.manley@chello.nl> writes:
>
> > egwong@netcom.com wrote:
> > >
> > > Craig Manley <c.manley@chello.nl> wrote:
> > > > I read the perltoot but it doesn't explain how to access class variables
> > > > as in my example.
>
> I assume you mean 'instance' not 'class'.
>
> Why should it? There's nothing different in tie()ing a varable that
> happens to be an instance variable from tie()ing any other variable.
> Why should perltoot say anything about it?
>
> > > > I don't want to use accessor methods, but a sort
> > > > of $dude->{'age'} = 10; thingy just as in the DBI when you say
> > > > $dbh->{AutoCommit} = 1; Setting $dbh->{AutoCommit} in the DBI causes
> > > > multiple statements to be executed instead of just setting a class
> > > > variable.
> > >
> > > Please put your replies *underneath* the quoted text -- it makes
> > > it easier for people to follow.
> > >
> > > My guess is that you want to read up on tie-ing a hash in perltie.
>
> Actually in this case tie()ing scalars is probably more relevant if
> only a few elements of the hash need to be magical. There are also
> more complex solutions using tied hashes.
>
> > I've already read perltoot, perltie, perloo, the DBI source, and tried
> > expermenting writing a simple class but couldn't get it right.
>
> There is a typo in line 17.
>
> > That's when I posted my first question. So I guess I'm still stuck
> > where I was then. I was just hoping somebody could quickly put me on
> > the right track with a short example.
>
> The problem is that your question is fundamentally not simple, in that
> it consists of two separate (simple) sub-problems: objects and tied
> variables.
>
> The _simple_ approach is to use accessor methods:
>
> $dude->age(10); # Store age attribute
> print $dude->age(); # Fetch age attribute
>
> But you say you don't want to use accessor methods. What you really
> mean is you want to dress up the accessor methods in syntactic sugar
> so that you can do the same apparently by simply accessing elements of
> the hash %$dude.
>
> Try something like:
>
> #!/usr/bin/perl
> use warnings;
> use strict;
>
> package Tie::Scalar::Property;
>
> sub TIESCALAR { bless [ @_[1,2] ], $_[0] }
> sub FETCH { $_[0][0]->${\$_[0][1]}() }
> sub STORE { $_[0][0]->${\$_[0][1]}( $_[1] ) }
>
> sub make {
> my $class = shift;
> my $object = shift;
> tie $object->{$_}, $class, $object, $_
> for @_;
> }
>
> package FOO;
> sub new {
> my $class = shift;
> my $self = bless {}, $class;
> Tie::Scalar::Property->make($self => qw( Bar ));
> $self;
> }
>
> sub Bar {
> my $self = shift;
> if ( my ($value) = @_ ) {
> print "Set Bar to $value\n";
> $self->{Internals}{Bar} = $value;
> } else {
> print "Fetch Bar\n";
> $self->{Internals}{Bar};
> }
> }
>
> package main;
>
> my $foo = FOO->new;
>
> # Explict accessor method interface
> $foo->Bar(1);
> print $foo->Bar,"\n";
>
> # Property interface
> $foo->{Bar} = 2;
> print "$foo->{Bar}\n";
>
> __END__
>
> --
> \\ ( )
> . _\\__[oo
> .__/ \\ /\@
> . l___\\
> # ll l\\
> ###LL LL\\
------------------------------
Date: Wed, 21 Feb 2001 13:14:28 -0600
From: Russ Jones <russ_jones@rac.ray.com>
Subject: Re: perl DBI cron problem
Message-Id: <3A941394.ED49B101@rac.ray.com>
john kelly wrote:
>
> Can anyone give any reason to this.
>
> We have been running several perl programs on a HP10.x system using perl
> 5 with ORACLE DBI without any problems. Theses programs have been
> connecting to a 7.3.4 DB fine. We just migrated one of our databases to
> 8.1.6. Here's the problem.. The perl programs runs fine interactively,
> but when we run it from CRON we get a core file during the connect.
It's been quite awhile since I worked on a 10.x system, but I had the
same problem once. There were some things that ran just fine
interactively, but if the same program/script/whatever was run by
cron, or triggered by MeasureWare or by ITO or Glance, it would croak.
It was a known bug in HPUX, and it had to do with how STDIN was
allocated, but poking around on HP's support site, I can't seem to
come up with any kind of search string that makes any sense. Better
call it in.
--
Russ Jones - HP OpenView IT/Operatons support
Raytheon Aircraft Company, Wichita KS
russ_jones@rac.ray.com 316-676-0747
Te audire non possum. Musa sapientum fixa est in aure. - Plautus
------------------------------
Date: Wed, 21 Feb 2001 14:26:16 -0500
From: Afshin Akbari <afshina@newbridge.com>
Subject: Perl Debuger
Message-Id: <3A941658.B2B4F11F@newbridge.com>
All,
I am trying to set up perl debuger, however I have been getting
a number of errors. Since I have no root permision, I thought
I should be able to install it locally. So I downloaded
Devel-ptkdb-1.107 & Tk800.021
Made 2 seprate directories: 1) Devel 2) Tk800.021
Then I did the following:
perl Makefile.pl PREFIX= . (while I was in the Devel dir. )
make PREFIX=.
make install PREFIX=.
I read on the web that if we specify PREFIX it should install it in that
dir.
(in that case ".")
Q1) Does Devel and TK being in two different dir. going to cause any
problem ?
Q2) If I ever get them to install properly
do I just add a " -I ~/my homeDir/perl/Devel " to the first line
of my scripts or
are there anything else that I have to do ?
This is the last error I was getting:
gcc -c -I.. -I/usr/openwin/include -I. -Ibitmaps -I/usr/openwin/include
-I/usr/local/include -O -DVERSION=\"800.021\"
-DXS_VERSION=\"800.021\" -fPIC
-I/system/solaris/lib/perl5/sun4-solaris/5.00404/CORE -Wall
-Wno-implicit-int -Wno-comment -Wno-unused -D__USE_FIXED_PROTOTYPES__
-isystem /usr/openwin/include Lang_f.c
/usr/local/sparc-sun-sunos4.1.3/bin/as: unrecognized option `-k'
*** Error code 1
make: Fatal error: Command failed for target `Lang_f.o'
Current working directory /users/afshina/perl/Tk800.021/pTk
*** Error code 1
make: Fatal error: Command failed for target `pTk/libpTk.a'
Thanks in advance,
aa-
------------------------------
Date: 21 Feb 2001 20:59:08 GMT
From: egwong@netcom.com
Subject: Re: Print a page of HTML
Message-Id: <971a6s$164u$3@newssvr06-en0.news.prodigy.com>
Rafael Garcia-Suarez <rgarciasuarez@free.fr> wrote:
> Sereno Barr-Kumar wrote in comp.lang.perl.misc:
>> How could I print a HTML formatted page to a printeer
>> using perl or any other method.
>>
>> Is this possible, I imagine some browser emulation
>> of the page needs to be done before it is sent to
>> the printer.
> Yes, I imagine that a good way to do this is to convert the page to
> postscript. I don't know if there are perl modules on CPAN that perform
> this conversion -- you'll have to search (http://search.cpan.com/).
> There is probably some software somewhere on the web that perform this
> conversion, and that are callable from the command-line (and
> consequently from Perl). Sorry, I can't help more...
html2ps (http://www.tdb.uu.se/~jan/html2ps.html)
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 329
**************************************