Re: Exception Handling - Professionally

2004-06-10 Thread drieux
On Jun 9, 2004, at 9:57 AM, Randal L. Schwartz wrote:
Drieux == Drieux  [EMAIL PROTECTED] writes:
Drieux  if ( ref($got_back) eq Foo::Bar)
No no no.  Stop using ref().  It means you can't replace it
with a subclass of it.
You want (and I show in my still-hidden article);
if (UNIVERSAL::isa($got_back, Foo::Bar)) { ... }

On Jun 9, 2004, at 10:14 AM, Wiggins d Anconia wrote:
[..]
Example 2: Subroutine that returns a value or an exception on failure,
must check type of return value
my $value = $obj-function_that_returns_value;
if (UNIVERSAL::isa($value, 'Exception')) {
# rethrow exception
return Exception-new-throw($value);
}
# optional else
else {
# handle value here
}
[..]
the tactic I would probably use, besides wiggins,
clearly it is time to just refactor it all
would be something on the order of
my $exception;
my $got_back = $obj-method(@args, \$exception);
since the 'list nature' of method invocation it would
be simpler in the initial pass NOT to change how things
are already being returned - so as not to break any of
the existing code. But I could start refactoring the
code slowly and transitionally.
hence in
sub method {
my ($var1,...,$exception) = @_;
...
if (bad_condition)
{
$$exception = new Foo::Bar
if ( ref($exception) );

}

}
would be a part of the progression for that method,
it would not break any of the existing code.
This way leads to things like
my $got_back = $obj-method(@args, \$exception);
if ( $exception )
{
print got exception\n;
my $type = ref($exception);

if ($type eq Foo) {
print doing foo type handling\n;
} elsif ($type eq Foo::Bar) {
print doing foo::bar type handling\n;
} else {
print unknown exception - $type\n;
}
}
Which is where I have problems with the
if (UNIVERSAL::isa($got_back, Foo::Bar)) { ... }
approach is that problem of resolving who really
should be handling which 'classes' of problems anyway.
I will conceded that in the 'return value or exception'
the strategy is 'required' and more 'extensible' since we
would hope that Foo::Bar is a subclass of Foo.
Granted were one to 'sub class' Exception - then one
could start into the 'standard exception classes' - and
be off for a day at the races with the sorts of complications
that exist over in say java with their
try {
} catch {
} catch {
}

So one either adopts wiggin's generalized solution
as a last stage in the catching, and merely rethrows it,
or wouldn't it have been simpler to deal with it as
if (UNIVERSAL::isa($value, 'Exception')) {
# rethrow exception
   return Exception-new-throw($value);
}
or why not simply go with
if (UNIVERSAL::isa($value, 'Exception')) {
# rethrow exception
   return($value);
}
and let the caller deal with the crisis?
Allow me the argument the other way around, and a part
of the problem as I deal with it in c89 types of problems.
So I have library foo, it could throw an exception from
using something that sets errno, and could be 'stringified'
by perror(), so when foo_doo_bar(var,...) runs into that
problem rather than returning FOO_OK as the 'no errors noted'
return, it would return FOO_CHECK_ERRNO, and in the documentation
about the function it would note that if that were returned
then one would need to deal with the errno and if need be
use perror().
If the Library Bar were built on foo, it would know that if it
got FOO_CHECK_ERRNO, then it would know that it needed to deal
with what ever the errno was...
One part of the problem here is 'getting the exception handling'
into the process so that there are enough 'error message indicators'
to assert what went wrong, and hopefully where. But the b-side of
that would be working out how to deal with them.
The classic one that few have seen active is
malloc failed
and the simplistic case of 'got malloc failure, exit' can
be ugly if one needed to embark upon an orderly shutdown
of the sockets, and other things.
Yes, all of this is implying a level of 'professional complexity'
that the typical 'new to scripting in perl' may not yet have had
the experience to know about or deal with. BUT... they did ask
us what sort of professional angst we have when out here.
HTH.
ciao
drieux
---
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: procfarm equivalent

2004-06-10 Thread drieux
On Jun 9, 2004, at 8:25 PM, Ron Willmert wrote:
Is there a Unix equivalent Win32-ProcFarm? I really like having the 
module decide how many process' to create and how it doles out the 
jobs and getting the return values from the process' so easily.
Forgive me for asking this,
but why are you allowing a module
work out how many processes to create?
ciao
drieux
---
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Exception Handling - Professionally

2004-06-09 Thread drieux
On Jun 8, 2004, at 11:34 AM, Scott Stearns wrote:
[..]
For you professional Perl programmers: how do you approach
exception-handling in the your world? I know there are a lot of ways 
Perl
gives us to do this: basic 'die', eval'ing blocks of code and the
Exception.pm module but is there a standard in the real world for 
handling
exceptions?
[..]
On Jun 8, 2004, at 11:39 AM, Wiggins d Anconia wrote:
[..]
In my world, and a scary place it tis', I use a home
grown object and just throw it as a return value.
Subs generally then return either undef or the exception,
or in the case I need a return value back I just check that
return value to see if it is an instance of my exception
object type.
[..]
As a strategy this seems to be catching on.
I have not looked at Schwartz's kvetchings
about the Exception::Class - but it too would
seem to be working in this tactic; a la:
my $got_back = $obj-method(@args);
if ( ref($got_back) eq Foo::Bar)
{
# deal with 'foo::bar' case
} else {
# else cope with alternative...
}
But a core part of the problem is that one either
goes back into the 'original code' and starts to
clean it up to lace the 'exception handling' into it.
Or one essentially uses it and wraps it with this
type of exception handling.
On Jun 8, 2004, at 12:51 PM, Randal L. Schwartz wrote:
In a few weeks, you'll be able to read
http://www.stonehenge.com/merlyn/PerlJournal/col12.html, or you can
get it from TPJ now if you're a subscriber.  But in there,
I tout Exception::Class as a good solution.
We look forward to the kvetch.
ciao
drieux
---
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Calling subs

2004-06-09 Thread drieux
On Jun 9, 2004, at 9:19 AM, Werner Otto wrote:
Hi All,
How would I go about calling a sub from a script from another script.
I am trying to call that sub just to get the values in my current
script and then perform aditional logic, other than duplicating the 
process?
[..]
what you might want to do is learn about 'perl modules'
perldoc perlmod
since it will be easier in the long run if you
build one module that has the function in it
that both scripts can then 'use'.
Today it's one function in some other script,
then next thing you know you have a bunch of
scripts using serveral commonly shared functions.

ciao
drieux
---
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Perl Class simple problem

2004-05-29 Thread drieux
On May 29, 2004, at 5:10 AM, Graeme McLaren wrote:
[..]
I create an object and pass a value to my constructor like this: 
Conf-new(site='x'), this tells the constructor which site I want the 
config for, then at the end of the constructor I call $self-_init();
This passes a reference to $self ( I think ) using $self = shift;  
When I die out using: die %{$self};
I get the value that x equals (  x = '/usr/local/apache/htdocs/x' ) 
 I need to perform additional logic in $self-_init(); and what I 
really need to do is get the name, which in this case is x instead 
of the value which in this case is /usr/local/apache/htdocs/x.  How 
do I do this I'm a bit lost with perl OO programming :(

Thank you for any light anyone can shed on this.
Graeme :)
 Perl Code #
sub new{
   my ($caller, %arg) = @_;
   my $conv = {
 x = '/usr/local/apache/htdocs/x',
 y = '/usr/local/apache/htdocs/y',
 z = '/usr/local/apache/htdocs/z'
   };
   my $caller_is_obj = ref($caller);
   my $class = $caller_is_obj || $caller;
   my $self = bless {}, $class;
   $self-{_doc_root} = $conv-{$arg{site}||'x'};
   if(!exists $conv-{$arg{site}}){
  die check for typos in yer params;
   }
   $self-_init();
}
sub _init{
 my $self = shift;
 die %{$self};
}
# End of Perl Code 
Well, you could start a whole lot simpler with say
#-
# Our Stock Constructor
# note: http://www.perlmonks.org/index.pl?node_id=52089
sub new
{
my $class = shift;
my $self = {};
bless $self, $class;
} # end of our simple new
since that part about the
my $caller_is_obj = ref($caller);
is not as useful - note the url to perlmonks
Then if you really want to go with the '_init()'
Idea then you could grow that to
sub new
{
my $class = shift;
my $self = {};
bless $self, $class;
   $self-_init(@_);
}
sub _init{
   my ($caller, %arg) = @_;
   my $conv = {
 x = '/usr/local/apache/htdocs/x',
 y = '/usr/local/apache/htdocs/y',
 z = '/usr/local/apache/htdocs/z'
   };
  
self; # since the 'new' returns the blessed self...
}

ciao
drieux
---
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Can Perl be faster than C ?

2004-05-19 Thread drieux
On Apr 27, 2004, at 3:37 AM, John W. Krahn wrote:
Sumanth Sharma wrote:
[..]
Are there instances/scenarios where Perl can really be faster that
C/C++. (Do not include coding or design time here, consider only 
run-time).
Yes.  Check out this URL for proof.  :-)
http://cm.bell-labs.com/cm/cs/who/bwk/interps/pap.html
Sorry to have missed this discussion last month...
Another way of presenting the problem of
comparing apples to banana's would be
which is faster building one's cgi code in raw Perl
or should I build it with mod_perl so that it compiles once
and then just runs.
So a part of the core issue of 'should this be in c89 or Perl?'
is what are you really trying to solve.
If the c-coder is not afraid of optimizing for the OS that
the code is targetted for - then they can cut down on the
overall size of their code at 'run time' in ways that
Perl Coders can not do - since they need the ref_count
and run time environment.
Similarly there are tricks that the Perl Coder can
pull off far faster and far simpler outside of the
'canonical code' that will not require the ECR ( engineering
change requrest ) to get routed ... As a specific
Gee you want to fix that in the lex and yacc
or should I just write the hack in Perl to do
what needs to be done for this other app?
and if you know lex and yacc, you know that the answer was
yeah, just pop the regEx in Perl it will be simpler
Whereas there is a lot of stuff that is much closer to
the OS specifics that are easier to write and maintain
in a 'c-code' source that one builds an XS module to
expose to the Perl Coders as the compromise.
cf: perldoc h2xs
So use the correct Swiss Army Chainsaw on the problem.
ciao
drieux
---
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Recommended Readings

2004-04-25 Thread drieux
On Apr 23, 2004, at 11:17 AM, John Pretti wrote:
[..]
What are some of the books you all recommend for learning perl?
I have several perl books and none of them make any sense.
[..]

John,

let's try the question the other way around.

Which books have you read so far, and what
is it in them that you are not getting
your head around?
A part of the problem can be that you are new
not only to Perl but to 'coding' and/or 'software
development' as well - and hence there are general
ideas that will seem fundamentally 'strange',
and let's be honest folks, UN-NATURAL.
First off all coding languages are 'formal languages'
and hence have to be formalizable, this is why they
are by definition 'not natural languages'. So the
question then really is what part of the 'formalization'
are you having problems with?


ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Security Question

2004-04-25 Thread drieux
On Apr 23, 2004, at 9:04 PM, WC -Sx- Jones wrote:
[..]
Please, decode this key:

SxEyj/gJs5pXISX11386025

Thank you in advance  :)
[..]

My compliments to your wit.

ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Daemon configuration for Apache

2004-04-25 Thread drieux
On Apr 24, 2004, at 2:46 AM, amrahsa wrote:
[..]
1) When the system boots up I found in which run level System boots up 
and go to corresponding directory e.g. /etc/rc.d/rc3.d
2) I look for Sxxapache or Sxxhttp file to see if apache startup file 
is there

Now my problem is one apache startup The configuration file Sxxapache 
or Sxxhttp has used some configuration file based on some shell script 
to invoke the configuration file as parameter and i need to know that 
file in my daemon to read that file e.g. httpd.conf file

If  you have any idea please help me to resolve this problem.
[..]

Let me see if I get your core problem here,

you want to parse out the httpd.conf
but you want to find it 'dynamically'
based upon what is in the /etc/rc.d/rc3.d section?
you do understand that you could find the 'init script'
for apache in
	/etc/rc.d/apache

on SuSe distributions, while on Red Hat you would
need to be looking for
	/etc/rc.d/init.d/httpd

eg:
disky: 62:] ls -li ./init.d/httpd ./rc3.d/S99httpd
1055235 -rwxr-xr-x1 root root 2245 Dec 10 02:05 
./init.d/httpd
  97370 lrwxrwxrwx1 root root   22 Aug  7  2002 
./rc3.d/S99httpd - /etc/rc.d/init.d/httpd
disky: 63:]

so clearly first off you can figure out which version
of linux you are playing with by how they did their
lay out - and there is little real 'useful' information
that is in those init scripts to begin with. The
line you would of course be interested in is
	[ -r /etc/sysconfig/apache ]  . /etc/sysconfig/apache

the other line where it is 'including' anything
is merely the shell library of rc_init functions
that is common to all of the rc scripts.
So what you really want to be resolving is whether
you will find the httpd.conf in say
	/etc/httpd/conf/httpd.conf

or not - since reasonable folks do not generally
stuff shell variables into /etc/sysconfig/apache
At which point there is the other odd question
that comes to mind, why? What is it you are
really trying to work out ? Why not talk to
the httpd directly?
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: [PHP] PHP vs PERL? HOPE THIS HELPS

2004-04-25 Thread drieux
On Apr 22, 2004, at 7:56 AM, Brent Clark wrote:
[..]
http://www.bagley.org/~doug/shootout/index2.shtml

http://www.bagley.org/~doug/shootout/bench/ary3/
[..]

First off thanks for the URL - it is fun to
watch folks do 'bench mark' work - it is a
factor in sorting out how to solve 'but which
language should I pick' - unfortunately that
is really only one part of the problem.
As the saying goes - anything can be turned
into a club - the questions then become what
exactly was one planning to beat to a pulp
with it.
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: coding standards question and RFC

2004-04-21 Thread drieux
On Apr 21, 2004, at 4:16 AM, Michael C. Davis wrote:
[..]
Thanks for the insights, drieux.  While I wish I were
in a position to establish corporate policy, I'm not,
and my objective is merely to satisfy
myself that I have a reasoned, workable approach.
Your feedback helps a lot.
Coming up with a 'coding standard' in any language
can be the first step on the road into the abyss.
If it really helps with creating Clean API's then
it is a good thing. If it becomes an excuse to
merely 'refactor code' so that all of the curly
braces are in compliance with a standard - rent a life,
buying one may be too expensive at this point.
But since one has started to see the merit of
having a 'stock way' of seeing easily and quickly
that some 'token' should be a [ constant | local_var | global_var |
method | Module | briefPsychoticInterlude ] then
it will make cutting the API's simpler - as everyone
will use the same 'reading skills'.
At which point one, in Perl, has already figured
out that managing their Perl Modules is the simplest
and cheapest way to 're-use code'.
At which point it really is time to work on the
whole t/ Test::Harness way of documenting and
validating that the Module is Good. And that
the POD is truthful and honest.
I was explaining the transition from using Perl's
t/ strategy and porting it over to doing c-code
and that saved us a bunch when we did the 32-bit to
64-bit cut over - because the obvious dumbs, and
with them the core dumping in that t/ stopped when
we had cleaned up the places where we wanted a u32int
vice a 64-bit int... At which point we were ready to
step forward and do the basic dynamic testing, and
all was good with the world. When I chatted about
this with the Freak who converted me to Perl, he
noted:
oh no, I am a bit harsher. If the code does not
come with a 'make test' - then I want your pager
number, and you will be in my office within 15 minutes
and YOU will be bringing the Chocolates...
Where this whole 't/' static testing saves one in the
long run is that it will allow one to grow out the suite
of basic tests over time as one has those ParaNoidDelusional
moments that says:
	but what if a code monkey did foo???

and if one builds the test, and it breaks your Module,
then you needed to fix that anyway - and the test is
still there in the t/ and the code is better...
So in classical Trinitarianism it is:

Phase I: Master Yourself

Phase II: Collect Underlings

Phase III: Global Domination!!!

ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Fwd: Interview Questions

2004-04-20 Thread drieux
p0: don't you hate it when

a. you reply to something that was sent to the cgi list
and then accidentally send it back to the beginner's list
b. have the lack of coffee to spell 'perl' lower case when
talking about the coding language vice the binary executable.
p1: my working excuse is

a. I had a staff meeting and only the voices in my head showed up.
b. The coffee had not yet kicked in.
c. My Spellchecker is out on vacation
d. there was no adult at the keyboard, I was getting in touch
with my inner juvenile delinquint
e. something witty here
On Apr 20, 2004, at 9:04 AM, Wiggins d Anconia wrote:
[..]
This has what to do with CGI?

[..]

Wiggins, think about the idea for a moment,
what if it were you first time in the barrel
as the guy who had to do the interviewing of
folks who were going to be writing perl code
for some portion of the CGI project?
Where would you go to see if folks had a
stock set of basic perl code questions that
related to doing web-work.
My lead engineer sets them up with a basic
walk through on basic so called 'simple perl questions'
that are actually a part of a diabolical interegation
method - since it starts out with
	what is CPAN?

and based upon that he will roll into the questions
about building perl modules for CPAN. Which normally
fishes up things like have they or have they not
worked with h2xs and/or XS code, hence can they
do the bridge work to perl from pre-existing
c-code libraries that would be required for doing
some of the basic web-technology work.
That also gets us chances to talk about things like
the t/ and 'make test' as a code coverage concern.
At which point one knows a lot about what the
person does with 'perl' as a 'coder' or as a 'scripter'
and hence whether they will be useful at the design
layer or merely at the typing layer.
Toss in the usual questions about why would one use
javascript, and how, vice perl on the server side.
lace a few basic 'write me a perl code implementation
of say the towers of hanoi problem or this or that,
and one check for how they deal with an ambiguously
worded coding problem - hence whether they should
be looking before leaping - and then one catches
their basic issues with actually doing perl code.


ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: coding standards question and RFC

2004-04-20 Thread drieux
On Apr 19, 2004, at 9:06 AM, Michael C. Davis wrote:
[..]
I realize it's hard to read without formatting, so here's a copy of the
same document, with formatting for readability:
http://www.knology.net/~mcdavis941/codingstandards.html

Thanks very much in advance for any feedback.
[..]

Props for the write up!

You have clearly done your homework, and a reasonable
arrangement of the basic 'talking points' about a
coding standard.
The problem then becomes, and I can not tell from
your email - if you are in the position to be setting
'corporate policy' - Which is the Real Issue here.
My own personal standard is that I follow, religiously,
all of the rules in the perl style guidelines as best
as I can. My corporate policy position is that I defer
to the 'chief perl perkin in residence' and leave it
in their custody that they have agreed on such conventions.
At that level it is more important to me that they agree
on what their API signatures will be, how the overall
design of their coding solution is, and that they can
deliver on time.
To be honest, I have delivered product where the naming
convention also included 'inside jokes' that the code
monkies thought were funny, did not distract from the
overall project, and kept the code monkies coding happily.
The ultimate concern is when the code is 'in maintenance'
and someone else has to come along and maintain it. If
the 'style guide' simplifies that process - it is a bonus.
But you will probably find that spending time on creating
the appropriate code coverage in the t/ and making sure
that the POD is useful are the places where your time is best spent.
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Interview Questions

2004-04-20 Thread drieux
On Apr 20, 2004, at 9:04 AM, Wiggins d Anconia wrote:
[..]
This has what to do with CGI?

[..]

Wiggins, think about the idea for a moment,
what if it were you first time in the barrel
as the guy who had to do the interviewing of
folks who were going to be writing perl code
for some portion of the CGI project?
Where would you go to see if folks had a
stock set of basic perl code questions that
related to doing web-work.
My lead engineer sets them up with a basic
walk through on basic so called 'simple perl questions'
that are actually a part of a diabolical interegation
method - since it starts out with
	what is CPAN?

and based upon that he will roll into the questions
about building perl modules for CPAN. Which normally
fishes up things like have they or have they not
worked with h2xs and/or XS code, hence can they
do the bridge work to perl from pre-existing
c-code libraries that would be required for doing
some of the basic web-technology work.
That also gets us chances to talk about things like
the t/ and 'make test' as a code coverage concern.
At which point one knows a lot about what the
person does with 'perl' as a 'coder' or as a 'scripter'
and hence whether they will be useful at the design
layer or merely at the typing layer.
Toss in the usual questions about why would one use
javascript, and how, vice perl on the server side.
lace a few basic 'write me a perl code implementation
of say the towers of hanoi problem or this or that,
and one check for how they deal with an ambiguously
worded coding problem - hence whether they should
be looking before leaping - and then one catches
their basic issues with actually doing perl code.


ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Where do you put your modules?

2004-04-10 Thread drieux
On Apr 10, 2004, at 10:40 AM, Kevin Old wrote:
[..]
Should I just put /home/kdo/perlmods in my @INC on every system?
personally I would recommend that you
read the perldoc h2xs and just step
on down the lane.
This way one puts together a CPAN style
Package that will simplify the process
all the way around the board.
If you are not the 'perl person' who
can install the module in the canonical
site_local section with the
perl Makefile.PL
make
make test
make install
then the strategy that I recommend is
that you make your scripts that are
contingent on it to use the simple strategy
of being put in
	$ENV{HOME}/bin

with a uselib line of

	$ENV{HOME}/lib/perl5

then use your installer with the offset
values to install it there.
Haul around one distribution and it will
work for all of your 'user names' on
all of the machines.
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Process control from LAN master computer

2004-03-28 Thread drieux
On Mar 24, 2004, at 8:43 AM, Peterson, Darren - Contractor.Westar wrote:
[..]
I tried Proc::Background so my script wouldn't wait on the invoked 
task as
with the Perl system command.  Actually, I've found that ssh isn't 
what I
need since the invoked task displays on the local, and not remote, 
machine.
are you 'getting off' to the far host? and hence seeing
the stuff done on the far host in the ssh pipe that you
opened onto the remote machine?
	local - rsh far_host -c do foo - far_host

the command actually gets invoked on the far_host, but locally
you get to see the 'remote shell' invocation, since, well,
one actually is 'on the far host' at the time.
I need to initiate a task on a remote machine and have that task run 
and
display on the remote machine.  The Perl script should initiate then 
ignore
the remote process.
[..]

The part about 'initiate and ignore' is the part that worries me.
So what exactly do you mean by 'display on the remote machine'?
Where is the STDOUT going to be pointed in that event? to /dev/console?
The more traditional solution is something of the form:

MON_BOX - message - host_box
|
V
  starter_code - start daemon process
|
 --return_info 
 |
 V
   Display Output
Where one does a pipe and exec sequence then reads through
the list of open FD's as info comes back, cf perldoc IO::Select
and then as one needs to 'update' incoming information, one
does that...


ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: How to determine if STDIN has piped data?

2004-03-28 Thread drieux
On Mar 28, 2004, at 5:01 PM, Keith P. Boruff wrote:
[..]
In other words, how do I get this code:

while(STDIN)
{
   print $_ . \n;
}
not to even loop at all if it has to wait for a human being to enter 
data?
[..]

actually the simplest trick would be say:
use IO::Handle;
my $io = new IO::Handle;
if ($io-fdopen(fileno(STDIN),r)) {
$io-blocking (0);
 print $io-getline
while( !$io-eof );
   $io-close;
}
print past the line\n;
[jeeves: 27:] ./stdio.plx
past the line
[jeeves: 28:] echo Hello there\
Happy Happy | ./stdio.plx
Hello there
Happy Happy
past the line
[jeeves: 29:]
HTH.

yes, your old school tie 'c coding tricks'
are mostly what you fill find most useful...
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: How to add an item into Shopping cart

2004-03-24 Thread drieux
On Mar 22, 2004, at 5:53 PM, B. Fongo wrote:

I'm working on a shopping cart, and yet to implement Apache::Session.
But before then, I have a question on how to populate a shopping cart
without the page reloading. Is there a way of achieving this using 
perl?
Let me see if I get you correct here, the concern is that
you want to have an
	add to shopping cart

that will not send a message back to the web-server as
a 'form' event? yes?
 I believe it is possible to use JavaScript event-handler can be to 
keep
track of items added into the cart, and later passed to perl to do the
necessary entry into the database.
If all of the items that can be placed in the cart are
on one page, then you seem to have your solution here.
The trick becomes if one has to create a shopping cart
that will persist over several web page presentations.


ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: From Windows - Linux

2004-03-19 Thread drieux
On Mar 13, 2004, at 7:35 PM, Robert wrote:
[..]
Where is a quick tutorial on using CPAN?
Using in the sense of getting modules
and compiling them for use.
Well there are are two questions you may be
asking here
a. perldoc CPAN - how the Cpan module works for you
b. how to read through the information at the CPAN
and how to pick and choose what you want to play with.
in the later category there is

	http://search.cpan.org/faq.html

which is the short faq about the CPAN.

As an illustration, one just for the fun of it:
http://search.cpan.org/~tscanlan/AI-Fuzzy-0.05/Fuzzy.pm
will bring up a web-page about AI::Fuzzy - the perl extension
for the Fuzzy Logic Module. If you click on the 'source' you
can see the actual 'modules' source - as one would see it
with say
perldoc -m AI::Fuzzy
but what you want to click on is the line above it that is
the AI-Fuzzy-0.05 which will take you to:
http://search.cpan.org/~tscanlan/AI-Fuzzy-0.05/

where there is a 'download' hot point, that will give you
the expected tar.gz file of the 'source distribution' that
you can make. The other hotpoints will include 'change'
information, as well as which CPAN testors have put together
any test information about it.
Sometimes the Module will rest upon actual XS code that will
need to be compiled, and you will need to make sure that
you read the README on those since some of them have 'known'
issues about various versions of Linux at different OS Rev's.
In this case there is a Testor's report that would take you to
http://testers.cpan.org/show/AI-Fuzzy.html#AI-Fuzzy-0.05
and it would tell you which OS Rev's it was tried with, did
they pass/fail...
At about this point if you haven't already picked up the 3rd
Edition of Programming Perl, and become familiar with the
sections on 'building perl modules' - you will clearly want
to start down that road. As you feel more at home with
how to build your own modules, you will find it easier to
decide which CPAN modules you find more useful, since they
will simplify your needing to build your own. Also look
for the 'learn perl references, objects, modules' by R. Schwartz,
it will help get you into module building as well...
HTH.

ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: collecting data from a TL1 devices

2004-03-19 Thread drieux
On Mar 17, 2004, at 2:10 PM, Ravi Malghan wrote:

Hi: has anybody built a perl scripts to receive data
from multiple TL1 devices and process them? Is there a
module? Or any other suggestions on how this can be
done.
Ok, there is no specific 'perl module' that I could find
for you at the CPAN on the TL1 API from our friends at
Bellcore - so you will basically need to work out a simple
enough 'translation table' solution on that side.
Then depending upon how exactly you are going to be connecting
to the specific TL1 devices, you will want to feel at home
with a 'select loop' approach for keeping track of which of
them you are dealing with as they write to you. But you can
get that part spun up after you have your basic translation
table in place.
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: STATing large files

2004-03-11 Thread drieux
On Mar 11, 2004, at 3:41 PM, Phil Schaechter wrote:

Folks,

Does anyone know of a workaround for stat'ing large files on perl  
5.6.1 ?

For large files, stat and print -M both return nothing.

We cannot install any modules, or upgrade/recompile perl.
The problem is that you will need to build your perl
with USE_LARGE_FILES for it to be able to look at
files greater than the 2Gig limit. You will also have
problems with the rest of the basic file test suite
if the file in question is larger than the 2Gig limit.
There is no 'work around' for the problem - save the
really dorky part that you know the file is 'there'
and open up the directory block with 'opendir()'
and do what you can with any information you can
get from that, but even that is 'dicey' and not
something that I have tested. I got bit by that
problem a while back - and simply rebuilt the code
with the USE_LARGE_FILES flag.
HTH.

ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: True IP behind a router?

2004-03-10 Thread drieux
On Mar 10, 2004, at 6:26 AM, Bee wrote:

Is there any modules can check my true IP( NOT 192.168.x.x )
I am on while I am behind a router?
The problem here is that it is all dependent upon
which type of DSL Router one is working with, and
what the vendor offered in the way of an interface.
One way to go about this type of problem is discussed at
http://www.wetware.com/drieux/CS/Proj/DI704/


ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: how do modules work?

2004-02-20 Thread drieux
On Feb 17, 2004, at 8:33 PM, R. Joseph Newton wrote:
Andrew Gaffney wrote:

This is what I didn't quite understand. I didn't realize
that Perl's black magic allowed the blessed reference to
refer back to the object already in memory. In effect, the
blessed reference carries around the entire class object with it.
Not quite.  The beauty of references is that you don't have to
lug the whole object around. The reference is more like a map
that shows where to very quickly find the object.  So what
you carry around evcerywhere is access to the object, not
the object itself.
A good way of stating that.

On top of the usual perdoc referrences that I think Wiggin's
has pointed, the traditional documentation that explains most
of what is going on with modules and references, specifically
blessed references, it would probably do Andrew some good to
get a feel for what 'compilers' have to do to take a text file
and turn it into an 'executable bit stream', whether we are
talking 'traditional compilers' or 'runtime compilers' like perl.
In the dark, to a compiler, everything is a symbol, it is either
going to be translated into a reference to a memory slot that one
peeks and/or pokes to 'stash' dynamic data - or it is a reference
to some 'block of code stuff' that will need to be deconstructed
down to 'machine language' that can be easily loaded into the
CPU for it to much 'one instruction at a time'.
Depending upon how one implements an 'object' - it is either
the case that one has to load all of the 'methods' dynamically
for each instance of an object. OR one implements the compiler
to load one instance of the methods, and implements a dispatching
table associated with an 'instance' of the object that knows
how to find the 'methods'.
The real challenge when 'containing' another module inside of
one's own module, is how much you will 'expose' about the, in
this case DBI, to the users of one's module. Some people go
completely BONKERS having to crawl up the inheritence chain
of documentation to understand what methods can really be
used on a sub_sub_sub_sub_class... So make sure that your
documentation makes clear where to find all of the other docs...
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: $self

2004-02-20 Thread drieux
On Feb 19, 2004, at 8:45 PM, Ohad Ohad wrote:

No, but it's a cool convention

From: Jacob Chapa [EMAIL PROTECTED]
To: Perl Beginners [EMAIL PROTECTED]
Subject: $self
Date: Thu, 19 Feb 2004 22:23:14 -0600
is $self a special scalar?
actually the simpler solutions is

sub my_do_foo
{
my ($me, $arg, $other) = @_;
$me-doOther($arg) unless $other ;
...
}
but I am fond of 'my $me' and it saves me from
having to type two additional letters...
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: how do modules work?

2004-02-17 Thread drieux
On Feb 17, 2004, at 5:07 PM, Andrew Gaffney wrote:

In my module, I created a function that connects to a MySQL database 
and then returns a DB handle. In the script that receives the DB 
handle, I removed the 'use DBI;' line. I can make queries against the 
database without problems. Why does this work?
I presume that you did the

package My::DB
use DBI;
and that your function is say

sub do_get_db_handle
{

$dbh = DBI-connect($data_source, $user, $pass, $driver);
...
$dbh;
}
hence it is called like

use My::DB;
...
my $db = do_get_db_handle(@arglist);
...
$rv  = $db-do($statement);
as Will has noted he thinks that the $dbh is a 'blessed' referece,
if you rummage around inside it you will find that yes, it is a
blessed reference. Since your module has already asserted the
	'use DBI'

it will have already both 'required' and 'imported' all of
the stuff 'needed' to understand what a blessed reference to
a DBI is all about.
As such your calling script did not need to make the 'use DBI'
since it would be required IN your module. This is a part of
how/why one likes to encapsulate things into perl modules so
that one can hide the common repeatively repeated redundent parts
without having to keep retyping them over and over and over again
in each new script that you need.
HTH.

ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Virtual Directory Problem

2004-02-15 Thread drieux
On Feb 14, 2004, at 12:18 AM, Mallik wrote:
[..]
In Apache, the /usr/local/fsuser/sbin directory is mapped to the
virtual directory http://192.168.0.10/fsuser/cgi-bin/.
From browser, I am able to access all the .cgi and .pl files
present in the /usr/local/fsuser/sbin and its subdirectories.

But I am not able to access the html files present in this
directory. When I am giving the following URL it is giving
the Premature end of script error.
http://192.168.0.10/fsuser/cgi-bin/help.htm.

Whereas, I am able to access the same html with the following URL.

http://192.168.0.10/help.htm.
[..]

first off best to post it to one or the other groups,
I have sent this reply back to the cgi list.
I think you are confusing the 'logical' address
of a file - eg
	schema://host_port/logical_path

with the actual file system path to the file.

Then adding the confusion between the idea of separating
the cgi code from the actual html files - which is hte
point of having a cgi-bin directory.
The idea of the cgi_bin is that it is where one will
put executables - and a flat html file does not need
to be executed, it is merely dished up as a stream of
bits back to the browser.
So you might want to go back and review what exactly
you are trying to do in the process.
Do you really like having a declared cgi-bin directory?

ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: testing state of filehandle

2004-02-11 Thread drieux
On Feb 11, 2004, at 11:13 AM, Michael C. Davis wrote:
[..]
This suggests doing it in an eval (so the error message gets trapped) 
and
testing the result, but that seems like a complicated solution for a 
simple
problem.  Can anyone suggest a better way?

Thanks very much in advance.


have you looked at say

	perldoc IO::Handle

eg:
   $io-opened
   Returns true if the object is currently a valid file 
descriptor,
   false otherwise.

The perldoc IO::File is a subclass of IO::Handle...

ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Email module

2004-02-09 Thread drieux
On Feb 9, 2004, at 7:46 AM, Jan Eden wrote:
[..]
which email module would you recommend? I searched CPAN and found a 
whole bunch. In CGI Programming with Perl, Mail::Mailer is mentioned, 
but since the book is a little older, this might not be the best 
choice.
[..]

Perl is a little older 8-)

If all you need is a form mail then check out
http://cvs.sourceforge.net/viewcvs.py/nms-cgi/formmail/
but it rests on even 'older' technology than the
Mail::Mailer modules...


ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Your vendor has not defined SGI::FAM macro new

2004-02-05 Thread drieux
On Feb 5, 2004, at 7:43 AM, [EMAIL PROTECTED] wrote:

Given that Fedora is not Irix, how exactly were
you planning that integration?
Everything went ok (at least I did not see any error messages). The 
problem is that running for example:

perl -e'use SGI::FAM; my $fam = new SGI::FAM;'
did you try say

	perl -MSGI::FAM -e 'my $fam = new SGI::FAM;'


returns error message:

Your vendor has not defined SGI::FAM macro new at -e line 1
http://search.cpan.org/~jglick/SGI-FAM-1.002/lib/SGI/FAM.pm

indicates that it is suppose to be aware of it.

while actually reading it
http://search.cpan.org/src/JGLICK/SGI-FAM-1.002/lib/SGI/FAM.pm
you will note that

a. there is no 'new' in the perl code,
b. hence it goes into the AutoLoader, but
gets a response back that the 'new' construct is not found
in the underlying XS code.
HTH.

ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: special vars

2004-02-04 Thread drieux
On Feb 4, 2004, at 10:23 AM, Rob Dixon wrote:
[..]
Disabling output buffering in Perl should be seen as
a nicety that helps debugging, but not much else. Only
a hardware solution can guard against losing power at the wrong time.
Minor Nit, yes I know that the thread has
been about disk and/or filesystem I/O - but
the need to disable output buffering becomes
very important when one is doing client-server
code over a socket and/or pipe.
Nothing like having one side waiting for the otherside
to do something - but the message did not get sent because
it is sitting in a buffer waiting to be flushed...
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: (U) What are the best Perl books out there ... More than 1 is fin e ... list as many as you like

2004-02-04 Thread drieux
On Feb 4, 2004, at 2:36 PM, Johnson, Michael wrote:

CLASSIFICATION: UNCLASSIFIED
Classification: UNCLASSIFIED
I guess a part of the question is at what level.

My general documentation is at:
http://www.wetware.com/drieux/CS/Proj/TPFH/gen_doc.html
if you feel at home reading just Perl Doc's,
the the simpler fix is to read it from
	http://www.perldoc.com/

so are you looking at reading or teaching?

ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: upgrading perl to 5.6 from 5.005_03 question?

2004-02-02 Thread drieux
At 08:51 AM 2/2/04 -0800, Ravi Malghan wrote:
Hello: I have perl 5.005_03 on solaris 2.8 which was
installed with the OS. I would like to upgrade it to
5.6. Should I pkgrm the existing perl before I install
the new perl ? or is there any other recommended way
to upgrade.
you might check with Sun, I think that they have
a patch that will upgrade their version of perl
that is actually in /usr/perl5.
So what you can do is build a version of perl 5.8.3
and install it in /usr/local/ you can then make the
symbolic link for /usr/bin/perl point at /usr/local/bin/perl
and Sun's stuff will work in it's own space, since it
is built to look for /usr/perl5/bin/perl
eg
vladimir: 59:] head /usr/bin/kstat | sed 's/^/ /'
#!/usr/perl5/bin/perl
#
# Copyright (c) 1999, 2001 by Sun Microsystems, Inc.
# All rights reserved.
#
#ident  @(#)kstat.pl   1.3 01/11/09 SMI
require 5.6.1;
use strict;
use warnings;
vladimir: 60:]
HTH.

ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: tty settings

2004-02-02 Thread drieux
On Feb 2, 2004, at 3:21 PM, [EMAIL PROTECTED] wrote:
[..]
I am wanting to know if there is a way to disable users
from breaking out  of a perl script, specifically CNTRL C , D?
[..]

You might want to peek at say

	perldoc perlipc

and work on a SIG handler for the signal that is
sent to the perl code that will deal with that.
But there is the problem with the sigkill, which
is a non-maskable interrupt.
cf
man stty
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Use and Require

2004-01-30 Thread drieux
On Jan 29, 2004, at 9:57 AM, Mallik wrote:
[..]
What is the difference between Use and Require.
[..]

The easiest way to think about it was that
once upon a time we wanted to have 'functions'
that would be in 'perl libraries' - so there
needed to be a directive that indicated that
the code 'required' certain things - such as
a minimum version of perl, or a named perl library.
the idea of the 'use Foo::Bar' on the other hand
is about indicating that the perl compiler merely
need to know that we will be using a perl Module
that is external to this file and that it will
a. look for Bar.pm in some sub_directory Foo
that is in the @INC path
b. either directly invoke the 'import()' method
of that module - or invoke it with a list of
tokens that will be imported...
So as the other person noted,

	What exactly are you interested in knowing about them?

ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: print outbut being buffered...

2004-01-29 Thread drieux
On Jan 27, 2004, at 6:59 AM, Michael W.Cocke wrote:

This is probably a stupid question, but does anyone know how to force
the output of print to actually PRINT, without forcing me to use a \n?
did you try

	$| = 1;

cf perldoc perlvar

ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: How to import symbols and semantics from one namespace into another

2004-01-29 Thread drieux
On Jan 28, 2004, at 11:24 PM, [EMAIL PROTECTED] wrote:
[..]
my circumstance is that I have a 10,000 line standalone command-line 
Perl program which I am refactoring into working as both a web app 
(Apache+Mod_perl+MySQL) and a command-line app.  I'm not yet clear on 
what either the file or object architecture will be, which is why I'm 
not carving pieces out into separate files quite yet.   All of the 
code written so far is pretty tightly coupled, again making it 
nontrivial to partition.  It also has some long CPU-bound computation 
sequences, and I'm reluctant to make changes which would add overhead.
ouch. Given this context it makes some reasonable sense
why you were trying to solve it all in one file. But you
may need to rethink your strategy a bit here, and work
on the slow and steady decoupling of the code so that
you wind up with two different code lines and their
supporting common collection of perl modules.
foo_cli - the classical command line code
foo_web - the web based app
both of which use the Foo::Monkey suite of modules.

This way you can work out what will really be required to
be added to the web app itself...
[..]
I also find that it's really convenient, for now, to have all my 
source in one file (at least until I'm sure of the new architecture), 
for the same reason that someone on the list has advocated merging all 
the perl docs into a single file: for supereasy search and, in my 
case, replace.   Also, as I transition into a packaged system of 
namespaces, I have a lot of code that expects a lot of names to be 
omnipresent (about 250 total subs, maybe half as object methods and 
half plain old subroutines); again it might be convenient to be able 
to put names in packages but still have them omnipresent until I'm 
clear how it all fits together.
[..]

with 250 subs you will want to sort out which of them
have clean API's and as such can be easily pulled out as is.
By clean, I mean they are not expecting anything to have
water falled into them, nor are they doing the side effect
of setting things globally that were not passed into them.
I can appreciate the idea that it is easier to hunt them down
in one file in one editor - but you might want to also look
at the advantage of having more than one file open in more
than one editor...
But as japhy has already noted, if you want to put it all into
one file you can use the BEGIN block and then start sorting
out your package spaces:
  SomePackage-import('foo');
  foo();
  FOO::Bar-foo(bed time again);
  BEGIN {
package SomePackage;
require Exporter;
our @ISA = 'Exporter';
our @EXPORT = 'foo';
sub foo { print foo!\n }
package FOO::Bar;
sub foo { my ($me,$arg) = @_; print have arg: $arg\n; }
  }


ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: procedure entry point slcvs2ptr message

2004-01-28 Thread drieux
On Jan 28, 2004, at 10:01 AM, Johnson, Shaunn wrote:
[..]
I want to use Perl to connect to an Oracle 9i database
on Windows 200x and have installed DBI v. 1.37
on my NT workstation.  I am getting a message like so when
I run the script:
[snip]
The procedure entry point slcvs2ptr could not
be located in the dynamic link library oracore9.dll
[/snip]
Has anyone else seen this?  If so, how do I fix this?
[..]

it appears that you have a DLL mismatch problem there.

I think the version of the client side is is not correct
for what the wrapping code is trying to get to.
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Passing several arguments

2004-01-28 Thread drieux
On Jan 27, 2004, at 3:26 AM, Jan Eden wrote:
[..]
I have a subroutine which fills into several hashes and arrays 
(%author_indexlines, %poem_lines, @alphabet_index etc). How can I 
return those variables and pass them to another subroutine? This does 
not work, of course
[..]

perldoc -q How can I pass/return a {Function, FileHandle, Array,

remember that your core signature is

	my @return_list = function(@arglist);

so the only way that you can return more than one
array or hash will be by passing their refs
my ($auther, $poem, $index) = function(@arglist);

sub function {

(\%author_indexlines, \%poem_lines, [EMAIL PROTECTED], $etc)
}
then you re-ref them as

while( my ($k,$v) = each %$author )
{

}
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: How to import symbols and semantics from one namespace into another

2004-01-28 Thread drieux
On Jan 28, 2004, at 10:32 AM, [EMAIL PROTECTED] wrote:

Hi, this question has to do with importing names from one package into 
another.
[..]
outcome:

This obviously won't work because 'use' expects a module name, not a 
package name.  Same issue with 'require'.

Can't locate SomePackage.pm in @INC (@INC contains: 
d:/app/xampp/perl/lib D:/app/xampp/perl/lib D:/app/xampp/perl/site/lib 
.) at test_import.pl line 3.
BEGIN failed--compilation aborted at test_import.pl line 3.

That's it.  Any ideas?
[..]

first off my complements on the most excellent work so far.

Well there are a couple of basic solutions here.

a. decide the perl modules should be in an external file
so that one can simply use the
	use SomePackage;

approach that simply requires that the module be external.

b. decide that the 'package' approach needs to be in the
perl script itself and adopt the oo-ish type of approach
so that one winds up accessing the methods by indirection
through say a blessed reference, rather than by importation
into the package main.
for more details you might want to

a. pick up the perl modules and reference book.
http://www.oreilly.com/catalog/lrnperlorm/
b. see my stock rant
http://www.wetware.com/drieux/CS/lang/Perl/PM/quick_pm.html
Since basically I go with the idea that perl modules really
belong as perl modules and then one has a simpler overall
management problem. First because then multiple scripts
can use the package, then as you so elegantly have demonstrated,
because it winds up becomeing so much simpler than trying to
work around managing the namespace issues on one's own.


ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: why Bad file descriptor at line 94

2004-01-28 Thread drieux
On Jan 26, 2004, at 3:03 PM, mark123 wrote:
[..]
This script telnets into a telnet server (cisco) then telnets into 
other
cisco router to grab there configs. I get these errors when trying to
connect to certain routers (5, 11,12,13,14). If I look in my dump logs 
I see
that the device didn't echo anything back. I have play with some 
control and
break commnads wich help but doesn't fix all of them. I have a feeling 
it
has something to so with the filehandle or buffer but not sure.

Either case can anyone tell me why I am getting Bad file descriptor at 
line
94 ?? I have the line marked 

This is my first perl script so please don't laugh ;-(

[..]
use Net::Telnet::Cisco;
 $session = Net::Telnet::Cisco-new(
Host = $host,
   Dump_Log = c:/perl/bin/.$filename,
   Input_log = c:/perl/bin/.$file,
   Timeout = $secs);
[..]
 use Net::Telnet::Cisco;
 $session = Net::Telnet::Cisco-new(
Host = $host,
Port = $port,
Dump_Log = c:/perl/bin/routerdump.$line..txt,
Input_log = c:/perl/bin/router.$line..txt,
Timeout = $secs,
Errmode = sub {
  #print \n\n!!Bad command ? . port: $port! $! \n;
  $error = $error + 1; #  1 means error has occurred.
   warn $!;
# option are die return and warn   ***THIS IS LINE 94 *
  }
   );
[..]

First off, you will want to become good friends with

a. 'use strict' and 'use warnings'
b. only putting that
use Foo::Bar
once.
The error around line 94 could be one of several problems.
Those of course will be easier to identify once one has
started to sort out which variables in the problem are
not a part of the problem.
I presume that you have read the POD for both
Net::Telnet
Net::Telnet::Cisco
Your comment notes the options as 'die', 'return' and 'warn'
and yet you are using a specific piece of there
You might want to try say

sub my_cisco_err_handler {
  $error = $error + 1; #  1 means error has occurred.
   warn $!;
}
 use Net::Telnet::Cisco;
 $session = Net::Telnet::Cisco-new(
Host = $host,
Port = $port,
Dump_Log = c:/perl/bin/routerdump.$line..txt,
Input_log = c:/perl/bin/router.$line..txt,
Timeout = $secs,
Errmode = \my_cisco_err_handler
   );
You might also find a better place to write your Dump_log
and hence also where you are puttng your Input_log to read from
and put those in variables as well...
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Placing handmade modules

2004-01-27 Thread drieux
On Jan 26, 2004, at 2:45 PM, Jan Eden wrote:

Now I learned some more perlish behaviour: double colons are used for 
both the namespace and the replicated directory structure.
actually, the double colons indicate a name space,
and IF the name space IS external, then it is
left to the File System Implementation of 'use'
and/or 'require' how to go and find the appropriate file.
As you will have noticed from say

BEGIN {
package Foo::Bar;
..
} # end begin
# back in package main::*
One can put packages into a script and use them,
without having to externalize them as a Perl Module.
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Placing handmade modules

2004-01-26 Thread drieux
On Jan 26, 2004, at 8:38 AM, Jan Eden wrote:
[..]
The module sits in /Users/jan/Library/Scripts/Modules/Test. Now Perl 
tells me it cannot locate the subroutine choose. If I place 
Template.pm directly into the path set in the use lib line and 
remove the Test:: at both places, everything works fine.
sounds like your package line in the Template.pm
file is set as
	package Template;

and NOT as

	package Test::Template;

Hence what you wanted to do is

use lib $ENV{HOME}/Library/Scripts/Modules;
use Template;
...
my ($update_path, $gallery_title) = Test::Template::choose();
I read in the camel that double colon separators in a module name 
would be translated to a directory structure when Perl searches for 
them.
Yes and no - the yes part is that IF the package line and
the file name are set appropriately.
This is one of the reasons that the perldoc advocates
doing the start of a perl module with h2xs
	cf perldoc h2xs

so that you can start off at least modestly sanely

my traditional rant on PM's is at
http://www.wetware.com/drieux/CS/lang/Perl/PM/quick_pm.html
When I am brewing up a new module, I then of course use
something like
http://www.wetware.com/drieux/CS/lang/Perl/PM/PerlInstall.plx

so that i can install the module in my home directory.

ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Objects and Arrays...

2004-01-25 Thread drieux
On Jan 25, 2004, at 7:47 AM, Pedro Miguel Freire Custódio wrote:
[..]
sub _init {
	my $self = shift;
	$self-{OBJECT} = (xpto1,xpto2); --- THE PROBLEM! It 
only stores xpto2
	if (@_) {
		my %extra = @_;
		@$self{keys %extra} = values %extra;
	}
}

And when i try to use this method:

sub object {
my $self = shift;
return $self-{OBJECT} unless @_;

my @list = $self-{OBJECT};
[..]

have we thought about doing that as an array ref?

$self-{OBJECT} = [xpto1,xpto2];
...
my @list = @{$self-{OBJECT}};
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: String concatenation qn

2004-01-24 Thread drieux
On Jan 23, 2004, at 5:24 PM, wolf blaum wrote:

For Quality purpouses, Ajey Kulkarni 's mail on Saturday 24 January 
2004 17:52
may have been monitored or recorded as:

i would like to quickly append a string to a variable.

open NEWFH,  $filename.new or die new procmailrc err;
where $filename has /tmp/xyz
Anything really silly here??
Nothing I didnt do wrong at least a thousand times:

open NEWFH,  $filename..new or die new procmailrc err;
[..]

forgive me for being 'pedantic' but
given the sequence
foreach my $filename (@list_of_file_names)
{
open(NEWFH,  ${filename}.new ) or die new $filename err:$!;

	}

One has 'less ambiguity' using the curley braces around
the variable name so that it will KNOW without a doubt
that one really means that to be the variable should
suffice -  It really becomes important when you want
to concatenate without things like a . between tokens
foreach my $start (@entree) {
foreach my $phrase (@list_of_sillies) {
my $freak = ${start}Buzz${phrase}here;
rhetorical_devices($freak);
}
}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: can i do it with perl ?

2004-01-24 Thread drieux
On Jan 24, 2004, at 12:48 PM, Dan Anderson wrote:
On Fri, 2004-01-23 at 20:49, John McKown wrote:
On Fri, 23 Jan 2004, Dan Anderson wrote:
Give me a little bit of time with a soldering iron, some wire, and a
laptop connected to your home network and your dishwasher and that 
can
be rectified.  :-D
I don't think that the lady who comes in and does my dishes is going 
to
let you anywhere near her with a soldering iron in your hand! grin
We are borg.  You will be assimilated.  Resistance is futile. grin
why does

	perldoc Cleaning::Woman

cause my computer to go into a rage about the
cleaning woman[1]
And do I need to take down the Satelite Dish first
before trying to wash it Or can I put the whole
house into the dishwasher
You know this with trying to be a Terran is
clearly much tougher than the original briefing said...
ciao
drieux
---

[1] cf:  Deadmen don't wear plaid for those
who may not be old enough to remember that Homage
to Film Noir
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: simple probability problem using PERL

2004-01-24 Thread drieux
On Jan 24, 2004, at 3:31 PM, Charles Lu wrote:

$probability = {  '1' = 0.1,
  '2' = 0.1,
  '3' = 0.7,
  '4 = 0.1
}
What if you did it the other way around?

my $probability= {0 = 1, 1 = 2, 9 = 4};
my $value = 10;

for(my $i= 0 ; $i $value ; $i++ )
{
$probability-{$i} = 3
unless(exists($probability-{$i}));
}
my $roll = int(rand($value));

print  \$roll is = $roll = shows side $probability-{$roll} \n;
notice we will wind up with ten elements in the hash ref,
and we have already assigned our basics...
Or you could have gone with a list.

my @probability = qw/1 2 3 3 3 3 3 3 3 4/;
my $value = 10;
my $roll = int(rand($value));
print  \$roll is = $roll = shows side $probability[$roll] \n;
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: modules and _DATA_

2004-01-23 Thread drieux
On Jan 23, 2004, at 1:27 PM, Eric Walker wrote:

I have some code I want to add a package in the same file.  I already
have some _DATA_ in the file.  Currently, the code is not seeing the
_DATA_.  How can I add a package in the same file then.
[..]

since the

__DATA__
vice
_DATA_
has been addressed, my pet favorite way to include a
package inside of a piece of code is
BEGIN {
package Foo::Bar;

}
That way it will be compiled early and so you can
place it above the __DATA__ section since it is
not 'data'.
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: modules and _DATA_

2004-01-23 Thread drieux
On Jan 23, 2004, at 1:36 PM, Eric Walker wrote:
[..]
when I tried to add a package to it, I did some test and its not 
reading
the DATA anymore. Is there a certain order?
[..]

How did you put the package in?

ciao
drieux
---

#!/usr/bin/perl -w
use strict;

my $foo = new Foo::Bar;

while(DATA){
$foo-showMe($_);
}

BEGIN {
package Foo::Bar;
use 5.006;
use strict;
use warnings;
our $VERSION = '0.01';
#-
# Our Stock Constructor
# note: http://www.perlmonks.org/index.pl?node_id=52089
sub new
{
my $class = shift;
my $self = {};
bless $self, $class;

} # end of our simple new

#-
# so that AUTOLOAD finds one here
sub DESTROY {}
#
#
sub showMe
{
my ($me,$line) = @_;
print $line;

} # end of showMe


1; # so that the 'use Foo::Bar'
   # will know we are happy
} # end begin

__DATA__
This line
and then the world.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Loading and using modules using eval

2004-01-23 Thread drieux
On Jan 23, 2004, at 1:23 PM, Papo Napolitano wrote:
[..]
xml
  file source=file1.txt module=TextFile parameters=1/
  file source=file2.csv module=TextFile parameters=2/
  file source=file3.xml module=XMLFile parameters=this and 
that/
/xml

To tell me I have to do:

TextFile::process('file1.txt', '1');
TextFile::process('file2.csv', '2');
XMLFile::process('file3.xml', 'this and that');
[..]

Why not try something a bit more vanilla
where one does the
	use SomeModuleHere;

for all the modules you want to use. Then you
can use the no strict refs option IF you
really want to do the strictly functional approach.
I do not think that

	eval(${module}::process('$param1', '$param2'));

will do what you want it to do.

IF the Text::process and XML::process functions are things
that you are building out you may want to think about the
idea of doing the perl oo-ish aproach, as
	$foo-showMe($line);

will work without requiring the no strict refs.

ciao
drieux
---

Some code to play around with would be:

#!/usr/bin/perl -w
use strict;
my ($foo, $line) ;
while(DATA){
chomp;
/^([\w:]+)\s+(.*)/;
($foo, $line) = ($1,$2);
# this assumes that the Package is External
#   require $foo.pm if (!exists($INC{$foo.pm}));
# the way that will work by indirection
#$foo-showMe($line);
my $code = ${foo}::showMe;
no strict 'refs';
$code-($line);
# does not invoke the code
#eval{ ${foo}::showMe($line) };
if ($@)
{
print Error: had \$foo - $foo\n\t\$line - [EMAIL 
PROTECTED];
}

}
print and now a Procecural call:\n ;

Foo::showMe(Procedural\n$line\n);

BEGIN {
package Foo::Bar;

#
#
sub showMe
{
#my $me = shift if ( $_[0] eq __PACKAGE__);
my ($line) = @_;
print $line;
print \n unless $line =~ /\n/gim;

} # end of showMe

1;

package Foo;

#
#
sub showMe
{
#my $me = shift if ( $_[0] eq __PACKAGE__ or
#   ref($_[0]) eq __PACKAGE__ );
my ($line) = @_;
print foo sees:\n\t $line\n;

} # end of showMe


1; # so that the 'use Foo::Bar'
   # will know we are happy
} # end begin

__DATA__
Foo word up
Foo::Bar not that one.
Foo This is a Happy Line
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: modules and _DATA_

2004-01-23 Thread drieux
On Jan 23, 2004, at 2:47 PM, Eric Walker wrote:
[..]
while DATA{
do something;}
    package ONE
 package stuff;
 1;
    package main
  
 __DATA__
    data stufff
yes, one can do the reset back to package main.

part of the reason I opt for the

	BEGIN { package  }

approach is so that I know that the compiler
will deal with the BEGIN { BLOCK } before
worrying about anything else in the code.
That way I know that my objects will be sorted out foist.

As a general rule of thumb, though, once I have played
out an idea then it is going off to it's own
	Monkey.pm

file where it is a fully externalized perl module...

ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Calling SUPER::constructor in the constructor

2004-01-22 Thread drieux


On Jan 22, 2004, at 9:13 AM, Dan Anderson wrote:

Is it possible to call the constructor that a function inherits from 
its
parent?  I tried calling SUPER:: and SUPER- in a constructor and got
errors.  Am i correct in assuming that if I rewrite the constructor 
that
a copy of the parent object won't be available?
[..]

did you try something like

sub new
{
my $type  = shift;
# call our parent class new to get our $self
my $self = $type-SUPER::new();
.
}
cf:
http://www.wetware.com/drieux/pbl/perlTrick/OO/Object_in_Object.html


ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: How to take command line argument and use it to run an upgrade script.

2004-01-22 Thread drieux
On Jan 22, 2004, at 3:39 PM, wolf blaum wrote:
[..]
call:
scriptname.pl Universe  42 douglas 'Zappod Beblebrox'
#! /usr/bin/perl
use strict;
use warnings;
print You called me with , scalar @ARGV,  Arguments.\n;
if (@ARGV) {
  print  Param to script: $_\n foreach (@ARGV);
}


My Compliments on a well done piece.

One of the stock modules most of us use is Getopt::Long
which is really good for the more complex command line optioning.
cf:
perldoc  Getopt::Long
An Illustration:
http://www.wetware.com/drieux/pbl/perlTrick/CommandLine/ 
do_get_opt_long.txt



ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Referencing Control Operators

2004-01-22 Thread drieux
On Jan 22, 2004, at 4:32 PM, Mark LoBue wrote:
At 12:12 PM 1/22/2004, John Baker wrote:
[..]
and change it such that the 'unless' conditional operator is
referenced conceptually similar to the following:
  sub getFieldFromAllRecords {
  my ($self, $directive, $keyword, $matchCondition) = @_;
Rather than trying to write code into variables or self-modifying 
code, I think I would try defining some constants:

use constant MATCH_IF = 0;
use constant MATCH_UNLESS = 1;
Then assign $mc to MATCH_IF or MATCH_UNLESS any way you like

Then use xor:

map { next if ( ($$value{$directive} =~ /$_/i) xor $mc); } @{$regArr};

This is untested, but you get the idea.
Fashionable and stylish as ever...

But it has the problem that it will cause a runtime error.
The following I think may help the OP:
use constant MATCH_IF = 0;
use constant MATCH_UNLESS = 1;
my @list = qw/foo Foo bar baz/;

my @foo = if_unless('foo',MATCH_IF,@list);

my @not_foo = if_unless('foo',MATCH_UNLESS,@list);

print foo got $_\n foreach(@foo);
print not_foo got $_\n foreach(@not_foo);

#
#
sub if_unless
{
my ($token, $mc, @list) = @_;

grep { $_ if ( ($token =~ /$_/i) xor $mc) } @list;

} # end of if_unless
generates:

foo got foo
foo got Foo
not_foo got bar
not_foo got baz
whereas changing the 'grep' to a 'map' will generate:

foo got foo
foo got Foo
foo got
foo got
not_foo got
not_foo got
not_foo got bar
not_foo got baz
so there is that point to take into account as to what one is
really trying to do here.
[..]
   my %ar = %$allRecs;

   push @{$regArr}, qr/$keyword/i;

   my %select;
   while( my($key, $value) = each(%ar)) {
map { next $mc ($$value{$directive} =~ /$_/i); }   # 
changed
@{$regArr};
$select{$key} = $$value{$directive};
   }
[..]

now the minor question, why assign the %ar? you could
ahve done the while
	while( my($key, $value) = each %$allRecs) {

minor nit.

So what exactly were you planning to assign the output
of that map to???
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Need help comparing lines in two files

2004-01-22 Thread drieux
On Jan 22, 2004, at 4:52 PM, [EMAIL PROTECTED] wrote:

This very green newbie would like to compare two files, let's say File1
and File2.   I
want to put the difference from File2 only, into a new file, File3.
For example:

File1.txt
oranges
apples
bananas
File2.txt
apples
kiwi
bananas
The result I want for File3 is the new entry in File2, which is kiwi.  
(I
don't care that oranges was in File1 and not File2.)
in theory then file2.txt could have been

oranges
apples
kiwi
banana
what about
apples
kiwi
wombat
bananas
you would want to have kiwi and wombat

One strategy would be say:
my @file1 = qw(oranges apples bananas);
my @file2 = qw(apples kiwi bananas frodo bagins);

my @list = get_diff_list([EMAIL PROTECTED],[EMAIL PROTECTED]);

print we see $_\n foreach(@list);

#
#
sub get_diff_list
{
my ($list1, $list2 ) = @_;

my %hash = map { $_ = 1 } @$list1;

my @ret_list;
foreach (@$list2)
{
if ( $hash{$_} )
{
delete( $hash{$_} );
} else {
push(@ret_list,$_);
}
}
# if you wanted to have the remaining bits that were
# in list1 and not in list2
#push(@ret_list,$_) foreach(keys(%hash));
@ret_list;

} # end of get_diff_list
or how about

sub get_diff_list
{
my ($list1, $list2 ) = @_;

my %hash = map { $_ = 1 } @$list1;
grep { $_ if ( ! exists($hash{$_})) } @$list2;
}
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



The Challenge of Learning to Explain - Re: How to take command line argument and use it to run an upgrade script.

2004-01-22 Thread drieux
On Jan 22, 2004, at 5:56 PM, wolf blaum wrote:
[..]
Nevertheless Im happy it seems this is a group were
you can even learn how to explain (and what the group-iquette  is 
anyway).
[..]

Good point there.

A part of the struggle is always sort out what
the OP is really working with, and where are they
really trying to go with their idea. The only way
that a person can sort that out is by trial and error.
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: On import v. Just Do It.

2004-01-21 Thread drieux
 off strict and warnings instead of
consciously turn it on like we tell people to do over an over an 
over...
Perchance this is the crucial point.

If the coders in your organization are failing to do this,
and one needs to create a perl module to wrap the pragma
for them, perchance there is some other more pressing issue
that really needs to be addressed?
I personally support the use of Flogging Bad Coders.

I mean as long as I make it clear, and I would definitely blab about 
it as an advantage, that by doing
	use Foo::Monkey;
	# enables strict and warnings for your script for better scripting 
practice!!
	# If you don't like that use no warnings and no strict.. But why 
would you do that?
I don't think I will ever be able to deal with a

	Foo::Monkey

in quite the same light ever again

8-)

I of course start from 'templates' of code stuff, so
that my stock perl code comes out the door for a mere
dull boring illustrative code as:
#!/usr/bin/perl -w
use strict;

# #FILENAME# - is for
so yes, technically, now that I do 5.8 I should upgrade that
template...
But IF you find that the solution of Foo::Monkey is simpler
to implement as a corporate policy in lieu of Flogging, I
am all the more willing to support your life style choice here...
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Join strings problem

2004-01-21 Thread drieux
On Jan 21, 2004, at 2:26 PM, Luinrandir Hernsen wrote:

#!/usr/local/bin/perl
use strict;
use warnings;
my ($Building, $row, $col);
{ dan's gonna kill me for that one... 8-) }

print qq|Content-type: text/html\n\n|;

my $EW5NS5=TEST.gif; ##this is the string I need to build.

print qq|TABLE\n|;
for ($row=0; $row10; $row++)
{
print qq|TR\n|;
for ($col=0; $col  10; $col++)
  {
  ##build variable
  $Building=join(.EW.$row.NS.$col);
with warnings on it would have told you about the bare word's
so you could try say:
$Building=EW${row}NS${col};
or say
 $Building = sprintf(EW%sNS%s, $row, $col);
or say
$Building= 'EW' . $row . 'NS' . $col ;
  print qq|TD bgcolor=black$Building/TDTD/TD\n|;
  }
print qq|/TR\n|;
}
print qq|/TABLE\n|;
print qq|x $EW5NS5 x br\n|;
print qq|x $Building x\n|;
and the last lines look like:

TD bgcolor=blackEW9NS8/TDTD/TD
TD bgcolor=blackEW9NS9/TDTD/TD
/TR
/TABLE
x TEST.gif x br
x EW9NS9 x
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Join strings problem

2004-01-21 Thread drieux
On Jan 21, 2004, at 6:46 PM, Luinrandir Hernsen wrote:

I thanks you very much for reply and all 3 ways do work.
unfortunately I did not state the situation completely.
$Building is to = the variable $EW0NS0 thru $EW10NS10
This is so I can set certain variables like
my $EW5NS5=TEST.gif;
to show a certain pictures, while other squares of the table remain 
empty.
Ah! I think I see a bit more where you are going,
sounds like what you really want is an array of arrays
so as not to need to worry about the problem of trying
to create 'variables'.
As it now works $Building does = EW0NS0 etc, but I need $Building to 
equal
the string/value that $EW0NS0
represents early in the program. (a rread/write file will soon be 
built in
here.)
Right what you want to do is the majik variable trick.
This is highly not recommended.
Do I express it better this time?
I apollogize for my lack or explination and Thank you for your efforts 
and
furture help.
[..]

My mistake for misreading the first time,
allow me to illustrate the idea.
#!/usr/bin/perl
use strict;
use warnings;

my ($Building, $row, $col);

my $max=4;

my @array = ();
foreach $row (0..$max){
foreach $col (0..$max){
$array[$row][$col] = bob at ${row} said $col;
}
}

$array[3][3] = The Majik word is 3 by 3;

print qq|Content-type: text/html\n\n|;

my $EW5NS5=TEST.gif; ##this is the string I need to build.

print qq|TABLE\n|;
foreach my $row (0..$max)
{
print qq|TR\n|;
foreach my $col (0..$max)
  {
$Building = $array[$row][$col];
print qq|TD bgcolor=black$Building/TDTD/TD\n|;
  }
print qq|/TR\n|;
}
print qq|/TABLE\n|;
print qq|x $EW5NS5 x br\n|;
print qq|x $Building x\n|;
print the Majik Word is: $array[3][3]\n;
HTH...

ciao
drieux


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Why isn't perl used more in business and industry

2004-01-19 Thread drieux
On Jan 18, 2004, at 11:58 PM, Gabor Urban wrote:

I might know something for an answer. Though Perl is really good and
fantastic, flexibole, etc. it has the bad reputation being hard to
read. An average manager wants his or her stuff to be clean and
neat. Seeing a tricky Perl code with regexp stuff is rather alarming.
On the other hand Python seems to boom these days (but not MUCH better
readability..) as was Java before.
My compliments to your wit!

As most folks know, there are the obligatory
obfuscatory yourProgrammingLanguageHere contests
that are designed to establish the specific 'unreadablity'
standards for a given language. Perl, like all proper
modern languages, has such a contest.
I remember back in 1991 when the Pythonites were trying
to sell the idea that it was better than Perl4 because
unlike Perl4, it was natively OO-ish, hence cooler by
the HipBuzzDuJure...
A part of the problem with these 'language comparison'
types of problem remains how to differenciate the merely
comical from the simply amusing aspects about why the
advocates advocate using Foo over Bar. If one stumbles
into the 'read ability' giggler, then one should deal
with the 'real issue' of so why did you accept the
code without the Proper POD and internal comments?
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



On import v. Just Do It.

2004-01-18 Thread drieux


p0: yes, one can use an import() from a package
to make something like the scam of 'require in line'
for the twin pragma of 'use strict' and 'use warnings'
{ oye! }
p1: But there is this minor technical overhead that
comes with the process -
1.a: one needs to use h2xs to make sure that the
module will conform with the current best practices
and be appropriately installable in the CPAN way
1.b: one has to maintain that module just to make the
two lines of pragma readily available to all of one's
perl code.
1.c: the count of lines of the perl module vice the
simple inclusion of the two lines makes the process
a bit Wonky if you know what I mean.
p2: clearly the fact has been established that it can be done,
but it also notes the 'and you want this pain why?' problem
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Fwd: AUTOLOAD error in a module

2004-01-18 Thread drieux
Sometimes life is Ironic. I had meant
to send this to the list, sent it, and
then remembered that I wanted to add something.
As a general rule of good form, one should leave
all upper case package names to sections and
all lower case package names to 'pragma' - as
such one may want to think about solving the form
here with say
	package Virgilio::Gai;

So that one has both upper and lower case letters
in the name space. I opted to hang it in the Virgilio
section because that is the 'name' you were emailing from.
On Jan 18, 2004, at 9:32 AM, Luca Ognibene wrote:
package gai;
require Exporter;
require DynaLoader;
@ISA = qw(Exporter DynaLoader);
package gai;
bootstrap gai;
package gai;
@EXPORT = qw( );
1;
looks like you have one package line too many in there.

I would of course start with h2xs...
Amongst other things it will help with your initial
frame work and provide the first test script.
get all of the declaration stuff out of your way
and THEN call bootstrap. eg
package Virgilio::Gai;
use 5.006;
use strict;
use warnings;
require Exporter;
require DynaLoader;
our @ISA = qw(Exporter DynaLoader);
our @EXPORT = qw( );
our %EXPORT_TAGS = ( 'all' = [ qw() ] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
	our $VERSION = '1.03';

	bootstrap Virgilio::Gai $VERSION;

	1;

So how exactly ARE you exporting the names of functions
in this module to the user???
Is there a difference between the version of perl you are
using on your PC and the 5.8 version on the linux box???
yes, i'm using perl-5.8.1 and he is using 5.8.0
Strange.

ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Why isn't perl used more in business and industry

2004-01-17 Thread drieux
On Jan 17, 2004, at 2:35 PM, Dan Muey wrote:
[..]
http://www.perl.com/pub/a/2004/01/09/survey.html
Nice!
folks may also take a look under the covers
in the blogWare that is popular amongst various
blogs out there. they might also look at what
is under the covers in the wikipedia movement.
So the fact that perl is in use, and not self
identifying itself as perl, as opposed to *.php
or *.jsp or *.asp, might be an 'issue' for some.
But the real question remains, are you using the
right coding language for the problem in front of you,
or are you trying to work around your coding language.
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Use strict inside module to apply to entire script?

2004-01-17 Thread drieux
On Jan 17, 2004, at 3:21 PM, Dan Muey wrote:

I was curious if it's possible to have a module like so:

package Foo:Monkey;

use strict;
use warnings;
Then in my script:

#!/usr/bin/perl

use Foo::Monkey;
No.

Try to think about the Issue of Scoping.

I can appreciate the idea that it would be cooler
if one could start with say
	use Foo::Monkey;

and have it contain

#!/usr/bin/perl
use strict;
use warnings;
use diagnostics;
and work in the sort of

	#include stockHeaderStuff

way that would turn it into a one liner.



ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Use strict inside module to apply to entire script?

2004-01-17 Thread drieux
On Jan 17, 2004, at 5:20 PM, James Edward Gray II wrote:
[..]
I believe I read that strict and warnings are supposed to
be defaults in Perl 6 modules too.
James
Ironically it would seem to be the correctish
behavior for use strict and use warnings
to be the default when one builds perl so that
by default
	#!/usr/bin/perl

would be all that one would need to start a 'script'/programme
out and know that the cool stuff was already there.
My concern of course is that this would cause problems
with the command line gags of
	perl -pie 'some_stuff_here'

But then again I have template files that I use to start
the basic perl code that I will actually create and they
have
#!/usr/bin/perl
use strict;
use warnings;
already in them - along with various other things that
I have found useful to have as a basic template for this
or that type of perl coding...
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: AUTOLOAD error in a module

2004-01-17 Thread drieux
On Jan 16, 2004, at 11:08 AM, Luca Ognibene wrote:

Don't know if this is the correct list.. tell me if i'm wrong!
I'm doing perl bindings for a c library (gai). I've used swig with some
typemaps.. It works in mine pc, but when i've sended my works to gai's
author.. :
perl Makefile.PL works fine,
make works fine,
make install works fine!


This would be a great time to start building out the t/
test directory of test code so that you can do
	make test

and see what explodes as the code moves around.

but when he try to launch a simple example :
 ./hello-world.pl
 Use of inherited AUTOLOAD for non-method gai::gai_init() is deprecated
 at ./hello-world.pl line 9. Can't locate auto/gai/gai_init.al in @INC
 (@INC contains: /usr/lib/perl5/5.8.0/i386-linux /usr/lib/perl5/5.8.0
 /usr/lib/perl5/site_perl/5.8.0/i386-linux
 /usr/lib/perl5/site_perl/5.8.0
 /usr/lib/perl5/site_perl .) at ./hello-world.pl line 9
 mmm what is this? if you want i can send Makefile.PM and gai.pm
[..]

There are clearly two or more problems here:

a. the 'inherited autoload' problem - where something
in your gai.pm has been set to 'autoload' the code
gai::gai_init()
that it thinks it is suppose to be finding by inheritence
rather than from bootstrap
b. Hence you should have set that up for use DynaLoader
vice use AutoLoader?
Is there a difference between the version of perl you are
using on your PC and the 5.8 version on the linux box???
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Redirect stdout, stderr to file and stdout

2004-01-16 Thread drieux
On Jan 16, 2004, at 5:02 PM, Larry Guest wrote:

I have a small script that does some admin work for me.

What I need to do now is not only have is display information to STDERR
and STDOUT but also write the same information I see when I run the
command to a file.
I have written it for others who are not very technical.  I want them 
to
be able to see the script working and what it is doing.  But I also 
need
a log file of the same information so I can have it mailed to me and
keep a copy on the server.
Here's a bit of a wacky Idea - solve it by
a bit of indirection - namely write the
code so that it does what you want it to do
then nest it inside of a script like say
	#!/bin/sh

	myPerlCode 21 | tee /tmp/myOutput.$$

mail me -s command run  /tmp/myOutput.$$
/bin/rm -f /tmp/myOutput.$$
that way your perl code remains simple, but what you
hand out to the users to use is going to deal with
all of the STDOUT|STDERR as well a always sending
you the email...
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: deprecated

2004-01-15 Thread drieux
On Jan 15, 2004, at 2:14 AM, Jabez Wilson wrote:
[..]
Forgive my ignorance, but in this context what does deprecated 
actually mean?

[..]

as most have noted, 'deprecated' denotes that
while the foo will function in this release
it is no longer considered good form, and may
well be removed in any of the coming releases.
In the particular case you raised, it would mean
that while there are those who have done this trick,
and you too may be one of them, it is a trick that
is now considered garish and grotesque and will make
people look at your code and say rude things at you,
or worse yet, that it will stop working soon.
When one notices that deprecated is used in
documentation about code that means it is time to
go back and refactor any code you had that used
that trick so as to be safer in subsequent releases.
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



knowledge v. IDE was Re: Apel of VIM was Emacs Wizards

2004-01-15 Thread drieux
On Jan 14, 2004, at 12:56 PM, Bradley A. Brown wrote:
[..]
 but I heard it said once that
knowledge of a language can never be replaced by an IDE.
[..]

I want to underscore that.

Mastering a Language means understanding it's subtle
nuances and arcanea, which is Perl is a LifeStyle,
and not something that happens in a mere 21 day cram course.
The unpleasant part is that IDE's can help simplify
some of the technical minutia and as such replace some
of the really routine bits. As such they can make a
good programmer better, but they can make a mediocre
typists perchance appear to be a coder.
Where the problems always show up is in the area of
design and analysis. IDE's really can not get one out
of that problem. While it can help, as more and more
Editor's With LifeStyle Issues do, as in the case of
bbedit - by having a 'find in reference' button that
can open up the Perl Docs on a high lighted module or
function - if one didn't know to think about Foo::Bar
then one will not know to check it's POD.
Similarly if one Zoned OUT on writing usable POD for
one's really cool perl module/application then one is
again up the creek, because one's IDE will not be able
to help you read up on what you failed to write up...
One can also do the OOPSIE that while this 'feature'
of reading your POD is groovey, it in itself can not
help you sort out how to partition up your one big
perl module into a set of supporting perl modules so
that one only loads the functions/methods that will be needed
What I keep waiting for is

	myCoolerIDE --no_brain_stoopids --no_bugs

so that it will protect me from coding myself into a
corner because I didn't take the time to think about
the problems of creating a multiple class inheritence
problem that is worse than a Jeff Foxworthy Joke...
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: error.

2004-01-15 Thread drieux
On Jan 14, 2004, at 3:02 PM, Eric Walker wrote:

Does anyone know what this means...
code..
for ($i = 0;$i = $size; $i+=$temp){
 $type= split(::,shift (@hold));
 }
Warning:
Use of implicit split to @_ is deprecated at .//test.pl line 21


here's a bit of a shilly thought

for ($i = 0;$i = $size; $i+=$temp){
($type) = split(::,shift (@hold));
}
this way the first element of the string
will be pushed into $type
one might want to 're design' that as say

for ($i = 0;$i = $size; $i+=$temp)
{
foreach (@hold)
{
($type) = split(::);

}
}
so that you have a slightly more 'obvious' solution...

ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Upgrading Perl linux 5.6 rpm to 5.8.2 source

2004-01-15 Thread drieux
On Jan 14, 2004, at 11:16 AM, Guay Jean-Sébastien wrote:

Which I interpreted as without being forced to reinstall all my 
modules
which are not part of the standard Perl distribution. So you confirm 
that
that isn't possible, and that any modules that contain XS code and 
which
were not part of the 5.8 RPM will have to be recompiled or otherwise
reinstalled from a 5.8-compatible source (CPAN, RPMs, etc.)?

I am also asking for my personal benefit, as that's one question I 
never
quite understood the subtleties of...
All that you really need to understand is
that XS is perl's way of generalizing a
perl interface into code that was originally
written in c code - or c like code.
cf:
perldoc perlxstut
perldoc perlxs
This way one can write the Bar.XS file, that
will get 'converted' into a Bar.c file that
will get ginned up into a Bar.so file ( on most
unix boxes, consult your dll life style manglement )
and some other voodoo that will get loaded into
the machine architecture specific section of the
@INC directories so that your pure perl side
of the Foo::Bar will do all the pure perl voodoo
right up to the
	bootstrap Foo::Bar $VERSION;

line - cf perldoc DynaLoader

the Funk of course is all the bits and bobs
that change in the includes at
#include EXTERN.h
#include perl.h
#include XSUB.h
and the parts about how the binary executable perl understands
what to do with the bootstrap statement
Other than that, there is really not a lot that you
need to know or understand about the underlying
binary incompatibility between 5.6 and 5.8.X at
the XS level...
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Emacs Wizards

2004-01-14 Thread drieux
On Jan 14, 2004, at 8:07 AM, Paul Kraus wrote:

Sort of perl related assuming you hackers are using 'real editor' :)
real coders of course would do

	:.,5s/^/#/

because we are not afraid of vi.

8-)

Or if we are using our bbedit it is some
find and replace with grep using the selected
region only or in 
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Upgrading Perl linux 5.6 rpm to 5.8.2 source

2004-01-14 Thread drieux
On Jan 14, 2004, at 10:33 AM, Guay Jean-Sébastien wrote:

This should allow you to do an upgrade rather then remove and upgrade.
If it's possible to do that (and have it actually work), does that 
mean that
it's only on Windows (with ActiveState Perl) that Perl 5.6 and 5.8 are 
not
binary compatible for XS modules? If not, I would think that simply
upgrading Perl and not all the other modules you have installed would
seriously bork the install...
[..]

two different issues.

the upgrade will upgrade and install the
XS compatible for 5.8.X version of the code
for all of the components that are in the RPM.
any additional perl modules that have an XS component
will need to be re-built and installed.
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Apel of VIM was Emacs Wizards

2004-01-14 Thread drieux
On Jan 14, 2004, at 10:49 AM, Paul Kraus wrote:
[..]
 Why? I started with emacs just because it happened
to be the 1st I heard about. Since you know both why
does vim appeal to you over emacs? Other then size.
Not wishing to start an editor war, allow me to wander.

A part of the issue we are wandering into is the problem
of can one code without an IDE... and in particular without
a GUI that provides colour coded syntax matching...
One way to think about the problem is:
http://www.wetware.com/drieux/PR/blog2/Code/200401.html#id3156855452
One of the reasons that folks tend to use vi,
and hence vim, is that it is small, it is one of
those tools that is now ubiquitous, and at ohDarkSquat
on a telnet session to the far side of the moon you
can quickly hack a patch... It beats the snot out
of trying to either do it all in ed, which we did,
or trying to make that one liner perl -pie ''
work right the first time...
So it is a logicalish progression to go from vi to vim,
with or without the Xwindow GUI widget set.
Does that mean that we are willing to give up our
preferred IDE's with cool colour coded syntax matching
Yeah, Right. When you Rip It From My Cold DEAD Hands...

ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Perl modules on Mac OS X

2004-01-13 Thread drieux
On Jan 12, 2004, at 11:34 PM, Jan Eden wrote:
[..]
Now here are my questions (finally):

* Can someone on OS X put a copy of 'make' somewhere for me to 
download?
* Is there anything else but the program itself to install?
* Which is the standard path for make? (/usr/bin, I would guess, but I 
am not sure)

Thanks a lot for any help,
[..]

You might want to actually install the developer tools
since that will get you the whole suite of things that
will be needed to build and make things.
You do not have to do a full re-install to whip out the
Developer Tools from the CD it is actually a stand alone
CD and will get you the current gcc plus all of the expected
supporting libraries.


ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Oreilly's Learning Perl 3rd Edition

2004-01-13 Thread drieux
On Jan 13, 2004, at 7:11 AM, [EMAIL PROTECTED] wrote:
[..]
I'm nearly finished with this book (definitely excellent book!).
Some items I need to review again (expressions will take some work).
 Afterwards I plan on moving upward and onward in perl.  I'm curious
if Oreilly's Programming Perl or Perl Cookbook would be good to
jump into.  Or is there another book I should study?
[..]

Getting the Programming Perl, and the pocket reference:
http://www.oreilly.com/catalog/perlpr4/
are worth it, so that you have the time to wander around
in the former on general principle, and the later for
those Duh! moments we all have when we are trying to
remember some arcania. These are so that you can start
sorting out where you want to start specializing.
The Learning Perl Objects and References is the
learning progression you will want to step up to
in terms of learning perl.
Then you become friends with

	http://perl.oreilly.com/

and

	http://www.perldoc.com/

and the current version of perldoc stuff
that came with your release of perl.
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Anti-Prototyping - Re: RFC: Prototyping, do or don't?

2004-01-13 Thread drieux
On Jan 13, 2004, at 6:59 AM, Dan Anderson wrote:
[..]
	1.  Prototyping can lead to inlined functions which increases the 
speed
of commonly used functions.  Prototype when you can.
	2.  As soon as somebody uses your function in a way it wasn't supposed
to be used, your program can explode.  Never prototype.

(This is not verbatim -- but it's the same general idea)

Can anyone go more in depth about the pros and cons of prototyping?
[..]

I remember going back to myUnterStumpenFumbler and asking
him this very question - since I took some time to prototype
a few things - since it looked like it was a cooler idea -
you know make my perl modules look more like ANSI C, or
Java, or Lions  Tigers  Bears...
I hate to come out so strongly against prototyping,
but let's look at the 'virtue' side - it might increase
some of the speed - but if speed were the issue, then
why are we using a jitc language where we have a ref count
memory model
This then gets us into the minor technical problem that
perl is a list muncher
	my @got_back = function(@arglist);

so the effort to provide some sort of 'signature' where
we can say
	sub function($$$) { ... }

is great for requiring that they be scalars - but it
does not really resolve 'scalars of what' as it were.
The Prototype there is not going to be able to
resolve that problem for you. That will
still need to be checked in the function... so that
one knows that the three scalars on @_ are scalars
of the type that you really wanted, and not, well
a plain scalar, an array ref, or an object ref
{ yes, I know there are some ways to be a bit more
clearer that one wanted a FooRef for basic perl primatives }
So while the compiler will be able to protect you from
some stoopids, it will not protect you from the fact that
perl is not a strongly typed language where the Compiler
will protect you from all Evil! That is it's Strength!
Prototyping was an effort to try to do some of the context
clarification to try to bring a bit of strong arming to
the process...
So it's one of those, well, misadventures that is a
part of the Perl Legacy.
If you need to have your coding language be in BDSM,
then you can start with prototyping, then get really
in touch with croak and caller, and make absolutely
certain that anyone using your module in a way not
expressly asserted in your POD knows for 100% certain
that it was their fault - go for it...
Otherwise, accept that in the long run it is simpler
to skip over the prototyping
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Upgrading Perl linux 5.6 rpm to 5.8.2 source

2004-01-13 Thread drieux
On Jan 13, 2004, at 1:02 PM, Paul Kraus wrote:

On a Linux system how can I remove the 5.6 rpm and then install the 
5.8.2
from source and still maintain dependencies? If something is looking 
for
perl how do I make sure that it upgrades correctly?
This is probably a bit odd,
but why not skip the part where
you remove the 5.6 rpm and simply
do the build and install of 5.8.2 ???
You can of course visit say
http://rpmfind.net/linux/RPM/index.html
there appear to be several perl-5.8.2 rpm's
for various versions of linux...
which of course would be the more traditional solution,
do a 5.8.2 upgrade by rpm and then STOMP on it with
your own build...
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Prototyping, do or don't?

2004-01-13 Thread drieux
On Jan 13, 2004, at 10:33 AM, Rob Dixon wrote:
[..]
Like I said, read what others have to say and adopt your own policy,
but be consistent.
Rob
My only complaint is that the consistency
position should be consistent within the
context - either in an archeological sense -
namely that if one finds code written from
the same period it should all have a similar
consistency - or in a totally contextual sense -
namely that a given perl module that one cuts that
has a clear and compelling argument within itself
for adhering to the given rule set and/or exception
to the rule set...
The important point is that one should cut the code
with the open dread that one will be the person who
will have to come back and refactor the code - so leave
one's self bread crumb trails about why one did which -
it will help
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Problem with dereferencing of $_

2004-01-13 Thread drieux
On Jan 13, 2004, at 10:12 AM, Duan Toh wrote:
[..]
while ($sel-fetchrow_array) {

print OUTPUT '';

print OUTPUT join ',', map {$_||0} @$_;

print OUTPUT '',\n;

}
[..]

you might want to go back and re-read
the perldoc on perlvar - yes it is the
default value - if that were a FH type
of operation. think about the problem like
my $boo = some_sub();
print \$boo is a , ref($boo) , \n;

my $i=0;
while( some_sub($i++) )
{
last unless $_;
print got $_ \n;
}

print ending $i\n;
#
#
sub some_sub
{
my $i = shift;
my @list = qw/a b c d/;

return ($i)? 0: [EMAIL PROTECTED] ;

} # end of some_sub
in this case there is a function call in the while
loop that will return the array reference - but there
is the minor detail that it is NOT being assigned to $_
as is your assumption...
HTH.

ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: One line variable declaration with multiple conditions

2004-01-08 Thread drieux
On Jan 8, 2004, at 7:45 AM, Dan Muey wrote:
[..]
Except I need to do this to about ten variabels all in a row.
Which gives me 10 lines with Bob's way and 40 with my very
first example. Boo for that! :)
[..]

Have you thought about a simplification process?
One of the tricks I do is say
	my ($var1,$var2,$var3,$var4) = ('' , '' , '', '');

This way I have declared them and initialized them,
so that they will not bounce with that 'use of undefined
var at line X error.
This way when you get down to

	my $guts = ($use_second_choice)? $var2:$var1;

you don't need to worry about the additional bit of
making sure that it is
	my $guts = ($use_second_choice)? $var2: $var1 || '';

Just a thought to think...

ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: One line variable declaration with multiple conditions

2004-01-08 Thread drieux
On Jan 8, 2004, at 10:38 AM, Dan Muey wrote:
[..]
The vars to be assigned ($var1, $var2,etc...) come from a
database query so they are handled already earlier. So how
they are declared are irrelevant to the issue. (Yes they must be
initialized for a warnings safe environment and they are, just
assume that they are so the issue is not clouded by where they come 
from.)
I think I better see the context at this point.
note, as I presume you did
my ($var1,$var2,$var3,$var4) = ('', 'bob', '', '');
print ($var1,$var2,$var3,$var4)\n;
 ($var1,$var2,$var3,$var4) = db_query();
print ($var1,$var2,$var3,$var4)\n;
#
#
sub db_query
{
my ($input) = @_;

('',$input);

} # end of db_query
will explode on the second print statement - since the
little db_query() returned only two of four possible variables,
and in this case three of them are undef and thus 'resetting' the 
values.
[..]

hence the problem being that mere 'initialization' alone
is not going to 'save the day'.
Bob's example does this quite perfectly, thanks again Bob!\
yeah, I can see that now.

ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: What is the source of my input, file or STDIN?

2004-01-07 Thread drieux


On Jan 6, 2004, at 1:07 PM, david wrote:
[EMAIL PROTECTED] wrote:
Case 3. (this is the difficult case for me) the script is invoked
with no file and no pipe to it.  I would like the script to
end quietly, such as
test.input.source

Instead, it waits for input.

test.input.source
no command line args - switching to STDIN

and now it waits forever.
select / IO::Select is what you are looking for.
[..]

My compliments to David, as always.

The reason the code is 'waiting for ever' in
the case of having no STDIN is that it is in a
blocking IO Read on STDIN.
So since we have a better spec, I have updated the code
to show how the IO::Select could be used to gate
for the case that the code was called without
command line input, nor a current connection for STDIN.
http://www.wetware.com/drieux/pbl/perlTrick/CommandLine/ 
file_or_stdin.plx

Note all of the noisy 'print statements' are there
merely to show the transition of the logic of the code.
On Jan 6, 2004, at 12:53 PM, Steve Grazzini wrote:

On Jan 6, 2004, at 3:17 PM, [EMAIL PROTECTED] wrote:
Case 3. (this is the difficult case for me) the script is
invoked with no file and no pipe to it.  I would like the
script to end quietly
  die usage() if @ARGV == 0 and -t;
You might not want to test if there is a
controlling terminal - since that would prevent
the pipe fitting from working unless there was a
controlling terminal. A problem that will crop up
when JoeBob opts wants to use the pipe fitting in
their KSH script...
I didn't show you how to check for the pipe (-p) because
this should probably work, too:
  % your-script input.txt
We have So got to talk about your meds here...

8-)

To be honest, I had not thought about the idea of
'-p' even trying to test to see if it was a pipe
since it is-ish when one connects the pipe fittings
of the standard shell, or as you have done, the
express redirection of input...
[jeeves: 30:] wc -l funk*
  14 funk_env.plx
[jeeves: 31:] ./file*  funk*
no command line args - switching to STDIN
STDIN had 14 number of lines
we saw 14 number of lines
[jeeves: 32:]
The 'redirect in' of  simply is a way of changing
how STDIN is feed to the calling program by the shell.
It of course is dependent upon how the shell copes
with re-attaching STDIN|STDOUT combo's...
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Pipe and STDIN - Re: What is the source of my input, file or STDIN?

2004-01-07 Thread drieux
On Jan 6, 2004, at 12:17 PM, [EMAIL PROTECTED] wrote:
[..]
It just dawned on me that I may not be using the
correct terminology since pipe and STDIN probably
imply much more than I mean for them to convey.
[..]

This is a good angst point to raise.

Technically STDIN|STDOUT|STDERR denote
merely 'file descriptors' that will be
opened by the shell in compliance with
how the shell saw the voodoo passed to it.
Normally they will be implemented as a 'pipe'
unless we do something else with them, at
which they may be implemented as a 'closed fd'
8-)
One can implement Pipes that are not the
first three fd's in the _iobuf[] - and yes,
one can get into massed weirdness when screwing
around at that level. So the way to think about the
problem is that the first three fd's stdin|stdout|stderr
will be implemented at pipes, and as such are a proper
subset of the set of Pipes. We tend to speak in terms
of 'pipe fittings' because we think of them in terms of say
	ps -ef | grep foo | egrep -v grep | awk '{print $2}'

which we on the perl side of the line could have implemented
with say perl's popen() approach of say
open(PS, ps $ps_args |) or die unable to popen(ps $ps_args): $!;
while(PS)
{
# your proc grovelling here...
}
close(PS);
But for some reason, I'd hazzard to say that about 99%
of us fail to set a $SIG{'PIPE'} handler to deal with
the prospects of the pipe breaking because, well
most of the time we just do not care. Even MORE SO
when it is stdin|stdout|stderr ...
So the converse of your kvetch is of course,

Gosh, now that I feel at home writing pipe fittings,
when, where and how would I really want to be building
my own pipes and/or popen() types of tricks?
well for that there is perldoc perlipc
for everything else, there is ioctl()
8-)
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: case and functions

2004-01-07 Thread drieux
On Jan 6, 2004, at 2:08 PM, [EMAIL PROTECTED] wrote:

Yo.
what Up.

I read in Learning Perl that there are no such constructs
like a case statement.  Is there something similar or did I misread 
this?
As folks have already pointed to both
the classic perlfaq, and implied that
one should consult
	perldoc Switch

which if you are not on perl5.8 can be
downloaded from the CPAN from
http://search.cpan.org/~dconway/Switch-2.09/Switch.pm

 Also what about functions and function calls,
do these exits or does the subroutines replace these?
[..]

This of course brings us to the more interesting
side of the swtich/case statement problem - namely
what are you trying to do with them, and have you
thought about the classic 'dispatching table' type
of solution - say something like
my %process = (
start = \do_start,
stop = \do_stop,
test = \do_test
);
if ( defined( $process{$ARGV[0]}))
{
$process{$ARGV[0]}(@ARGV);
} else {
print issued invalid command: $ARGV[0]\n;
}
sub do_start { ... }
sub do_stop  { ... }
sub do_test  { ... }
you will notice that this is similar to the classic
init script most folks have seen as say
#!/bin/sh

case $1 in
start) do_start ;;
stop)  do_stop ;;
test)  do_test ;;
*) echo i do not know how to to $1 ;;
esac
So it's sorta a case of what exactly were you trying
to do with the case like statement???
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Integrating perl scripts into KDE / Gnome

2004-01-07 Thread drieux
On Jan 7, 2004, at 9:00 AM, Dan Anderson wrote:

I was curious if anyone knows a good resource on integrating Perl
scripts into KDE (and I suppose gnome).  I want to start doing things
like adding my scripts to my taskbar, and was curious if that was
possible without compiling C extensions.
ok, I'm slow and it has been some time
since I did KDE/gnome - but if the code
is executable, then it is merely a matter
of Identifying the 'name' of the code just
as one would do with any other piece of code.
If you have command line code that needs to run
in a shell, and you were not planning on wrapping
it in say Perl/Tk or some other window GUI form
then how about the old dog trick of
##!/bin/sh
###
###if [ ${DISPLAY} =  ]
###then
### /usr/ucb/echo -n what display? 
### read DISPLAY
### export DISPLAY
###fi
###
###nohup xterm -geometry 80x60+0+0 -e goWork /dev/null 21 
###
###exit
###
vladimir: 58:]
this will invoke the 'goWork' code in an xterm...

HTH

ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



-t and STDIN was Re: What is the source of my input, file or STDIN?

2004-01-07 Thread drieux
On Jan 7, 2004, at 10:37 AM, Steve Grazzini wrote:
[..]
I want to test whether STDIN (the default argument for -t)
is hooked up to the terminal (which is what -t tells you) so
that ARGV doesn't block waiting for user input.
[..]

I have absolutely no problem with the idea that
one wants to use '-t' to establish that there is
a controlling terminal, AKA a ttyline - but the
problem is the false assumption that this is in
some way associated with STDIN.
IF i am going to guard my code with '-t' to
establish if there is any STDIN then as soon
as the code is used inside of a forked and exec'd
event where the child process is no longer attached
to the TTYLINE then
	foo | bar

will break because bar, failing to find it's controlling
terminal will not see the information coming at it from
foo through the STDIN pipe. So if one wanted to check
that there were bits in STDIN, then one should do that
with the IO::Select approach - since that will tell one
if there are bits on STDIN, even if the process itself
is being run without a controlling terminal.
To help illustrate the point:

http://www.wetware.com/drieux/pbl/perlTrick/CommandLine/ 
got_ttyline.plx

now granted, I have only tested this on darwin|freebsd|solaris|linux
and only with perl 5.6 and 5.8 but they all come back with:
vladimir: 67:] perl got_ttyline.plx
This Will Gin Up:
Mother Got Back:hello, I am /tmp/drieux/CallMe.txt
Mother Got Back:what tty line?
Mother Got Back:STDIN says : /tmp/drieux/SomeCmd.txt:About to shout out
Mother Got Back:STDIN says : sending var1
Mother Got Back:STDIN says : sending thing2
Mother Got Back:STDIN says : sending thing3
vladimir: 68:]
So it is possible that there are implementations of this
which will not work in the way that I expect it - but
as a general rule of thumb if one wants to know that
one has a controlling terminal - -t then one should
test for it. But simply because there is no controlling
terminal does NOT mean that there is nothing on STDIN.
So that we are clear on this, it is not merely an issue
in Perl, this is even MORE depressing when it is coded
in a 'realCoderLanguage[dm]' and worse YET when the dilbert
made TOTALLY irrational presumptions that if there was no
controlling terminal that this of course meant that the build
was suppose to use some WingNarkFrimFrimFrim library that of
course leads to totally wacky problems when the build by hand
at a terminal works find, and all of the code builds correctly
but Blows Big Ones when done in an automated environment


ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: One line variable declaration with multiple conditions

2004-01-07 Thread drieux
On Jan 7, 2004, at 2:20 PM, Dan Muey wrote:

Is that possible to do with one line?
technically no, because you needed
my ($firstchoice, $use_second_choice_if_first_is_empty);
my $secondchoice = 's2';
then you can do

my $guts = ($use_second_choice_if_first_is_empty)? $secondchoice : 
$firstchoice || '';

ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: What is the source of my input, file or STDIN?

2004-01-06 Thread drieux
On Jan 6, 2004, at 9:32 AM, [EMAIL PROTECTED] wrote:
[..]
So, 1. from within perl.script, how can one tell if the input stream is
coming from
STDIN or a file that was opened by ?
2. If input stream is not coming from STDIN, but a file, how can one
tell which file is the current file (assuming multiple files were
specified on the command line)?
This is gonna sound a bit silly, so laugh along
with me while I play this out.
If you want to know which is the whom For What,
why not simply code it that way?
As an illustration:
http://www.wetware.com/drieux/pbl/perlTrick/CommandLine/ 
file_or_stdin.plx

In this case I will walk the @ARGV if there is
anything to walk, test that the file exists,
then pass it off to a count_lines() function,
which will open it and count the number of lines.
If there are no arguments at the command line,
then we will call count_lines() without a file name.
On the inside of the count_lines() function is the trick

	$file ||= '-'; # we open STDIN unless file

either we were passed a file name to open, or we
will set $file to '-' so that it will read from STDIN.
cf: perldoc -f open

ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Microsoft Services for UNIX/LINUX

2004-01-05 Thread drieux
On Jan 5, 2004, at 9:32 AM, [EMAIL PROTECTED] wrote:
[..]
I was wondering if anyone on this list have had any luck with this
technique of executing UNIX-based applications.  One thing that comes 
to
mind is CGI-scripting, but this is not an option for me.
[..]

I agree with Tim that essentially you are
not really asking a Perl question, since you
seem to be new to both Xwindows as well as
the idea of Unix Services for Windows, and not
sure how much of the '*nix' box needs to be
directly connected to the Windows box to make
the voodoo do the whoDoo you would like it to do.
So you might want to solve that set of issues
before you start worrying about the idea of
solving your 'client-server' issues with a
round of CGI code that will wind up on some
web server that will allow an 'all browser'
approach to get you around using the Xwindows
and/or SMB/NFS and/or 
I can empathise with you on the concern here,
since a part of the issues is how to set up a
network where there are various services being
provided by various server types and which need
to allow users to 'plop right down on the box'
with something like Xwindows - so that the user
can have an xterm on that box, and which merely
need a client side application...
But you may wish to check with say Hummingbird
http://www.hummingbird.com/exceedusers/
and see if any of the specific issues you think
you may be having with putty-exceeds have already
been dealt with.
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Net - SCP - errstr uninitialized

2004-01-05 Thread drieux
On Jan 5, 2004, at 10:49 AM, Paul Kraus wrote:

Code

#!/usr/bin/perl
use strict;
use warnings;
dhcpd;

sub dhcpd {
  use Text::DHCPparse;
  use Net::SCP qw( scp iscp );
  my $scp = Net::SCP - new( 'hylafax', 'pkraus' );
  $scp - get ( 'dhcpd.leases' ) or die $scp-{errstr};
  print hello\n;
}
Error
-
Use of uninitilazed value in die at C:\Documents and Settings\pdk\My
Documents\perl code\squidlogs\squid.pl line12. Died at C:\... line 12


Ok, there are two things I would think about
doing:
a. check and see if you got the file dkcp.leases
from the host hylafax - and of course a part of the
problem there is whether or not that file would
actually be where you think it is
b. it is possible that a part of the problem
is actually in how the local implementation
of
  waitpid $pid, 0;
  if ( $?  8 ) {
my $errstr = join('', $error);
#chomp(my $errstr = $error);
$self-{errstr} = $errstr;
0;
  } else {
1;
  }
is working on your machine - the way you
would like it to work -
cf:
http://search.cpan.org/src/IVAN/Net-SCP-0.06/SCP.pm
check first the get() function
and then into the scp() function.
then play with say:

$? = 12345;
my $retval = funk_moi() ; #or die errorno $?\n;
print got back retval $retval\n;

$?= 3 ;
$retval = funk_moi() ; #or die errorno $?\n;
print got back retval $retval\n;

#
#
sub funk_moi
{
  if ( $?  8 ) {
   print error case: $?\n;
   0;
  } else {
   print is ok: $?\n;
   1;
  }

} # end of funk_moi
which generated for me:

error case: 12345
got back retval 0
is ok: 3
got back retval 1
so there are a couple of places where things
could be breaking down in strange and twisted manners.
What did you see when you ran it in the perl debugger?

ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Sharing instances of objects between packages

2004-01-05 Thread drieux
On Jan 5, 2004, at 12:44 PM, Shawn McKinley wrote:

Hello all,
  I am wondering if you can have object inherited between
packages when the child packages have their own object
creation without explicitly setting the parent object in
the child?  Is there a way to inherit the parent object?
Example below (sorry for the length).
[..]
Shawn,
Thank you for the illustrative code it was interesting
but it also presented a part of the problem you might
want to go back and re-think - in your illustration
you have established a requirement for A::B inside
of A - which is a fast track to having your object
model turn into a Jeff Foxworthy Skit real fast.
you can simplify your basic new() down to simply
sub new
{
my $class = shift;
my $self = {};
bless $self, $class;

} # end of our simple new
note: http://www.perlmonks.org/index.pl?node_id=52089
since your B.pm

  package A::B;
  A::B::ISA=qw(A);
  use strict;
it will be able to find the 'new' in the parent class
and hence
	my $b = new A::B;

will know that it is a blessed reference to the class A::B
vice mutating itself into an A.
At about that point your code gets a bit WAKKA-WAKKA
as to why you want to be defining/redefining methods
based upon an object inclusion foo
I mean what would

	$b-set_A(joe bob briggs);

mean to begin with, and worse yet
what happens with
	$b-func();

mean since last I heard Joe Bob was
reviewing movies and not an Object of A...
have you peeked at the

	perldoc perltoot

to begin with???



ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Sharing instances of objects between packages

2004-01-05 Thread drieux
On Jan 5, 2004, at 2:51 PM, James Edward Gray II wrote:

On Jan 5, 2004, at 2:44 PM, Shawn McKinley wrote:

Hello all,
  I am wondering if you can have object inherited between
packages when the child packages have their own object
creation without explicitly setting the parent object in
the child?  Is there a way to inherit the parent object?
Example below (sorry for the length).
[..]
If this isn't what you're looking for though, you might try explaining 
the problem to us again, because frankly I didn't understand what you 
were asking.
[..]
Replace the above with something like:

sub new {
my $class = shift;
my $self = $class-SUPER::new( @_ }; # call class A constructor
--^
oopsie should have been a  )
	# class B setup goes here...

return $self;
}
Hope that helps.
What I am wondering is if the OP is asking about
how does one go about creating a wrapper class
that will allow one to stuff objects into other
objects without actually getting into the whole
multiple class inheritence thing:
cf:

http://www.wetware.com/drieux/pbl/perlTrick/OO/Object_in_Object.html

So I too look forward to which is the issue set the OP
wants to look at and deal with.
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: passing datastructure from one.pl to other.pl

2004-01-05 Thread drieux
On Jan 5, 2004, at 1:48 PM, Johan Meskens CS3 jmcs3 wrote:
[..]
i create a datastructure in one.pl
and would like to make it travel to other.pl
so i can process the datastructure there
how do i go about it ?

a direction to point me to ?

pipe ? module ?
[..]

the first part of the problem is whether
what is created in one.pl at run time needs
to be shared with other.pl - or is the
'data structure' more a matter of a general
phrame work - akin to say a generic object,
or C structure.
If one.pl is dynamically creating information
that will need to be shared then you clearly
need to start with
	perldoc perlipc

since the stock solutions are basically

a. write to a file the other will read
b. open a pipe to the other
c. open a socket to the other
d. have one piece of code which if called as
one.pl will fork itself as other.pl and
do a pipe between the two - but if called
as other.pl would execute on 
one of the simplests ways to do this:

	./one.pl | ./other.pl

would be a simple unix pipe in which the stdout
of one.pl becomes the stdin of other.pl - and all
you need is to 'serialize' your data.
The more complex way would be your basic
pipe and exec trick say something like:
http://www.wetware.com/drieux/pbl/Sys/gen_sym_big_dog.txt

so you will need to be a bit more clear about whether
it is really run time data - or the fact that both codes
will need a common perl module that understands how to
create a given data structure ( object ) and how to access
the data in that object but with different parameters at run time...
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Making A Library of Perl Subroutines

2004-01-04 Thread drieux
On Jan 4, 2004, at 6:18 PM, r huber wrote:

I am writing several subroutines that I want to make
available to other programs without directly including
the code in those programs. Can anyone explain how to
do this or where to go to find out how to do it.
Tim and Owen have offered the quick look answer.

I personally would start with

	perldoc h2xs

since that will help frame out your perl module
in a way that will allow you to install it either
canonically like any other CPAN module -
cf:
	http://www.wetware.com/drieux/CS/Proj/Wetware_ps/ 
index.html#id3154425254

for the perl 5.8.1 stype generation of a simple
perl module frame work.
then of course you will also want to read

	perldoc
   perlmod Perl modules: how they work
   perlmodlib  Perl modules: how to write and use
   perlmodstylePerl modules: how to write modules with  
style
   perlmodinstall  Perl modules: how to install from CPAN
   perlnewmod  Perl modules: preparing a new module for  
distribu
tion

My basic template for a perl module is:

package Foo::Bar;

use 5.006;
use strict;
use warnings;

#our @ISA = qw(PARENT_CLASS);

our $VERSION = '0.01';
#-
# Our Stock Constructor
# note: http://www.perlmonks.org/index.pl?node_id=52089
sub new
{
my $class = shift;
my $self = {};
bless $self, $class;

} # end of our simple new

#-
# so that AUTOLOAD finds one here

sub DESTROY {}

#
# your methods here
#

1; # so that the 'use Foo::Bar'
   # will know we are happy
this way I can do the shorter set up of

	use Foo::Bar;

	my $foo = new Foo::Bar;

	my @responses = $foo-function_name_here(@arglist);

and all I would do to shift a standard 'function' that
I already had as say
sub function_name_here
{
my ( $first, $second, $third ) = @_ ;
...
}
would be to pull off the class or instance reference:

sub function_name_here
{
my $me = shift;
my ( $first, $second, $third ) = @_ ;
...
}
so that I can avoid the whole question of exporting
fundtion names, that is detailed in
	perldoc Exporter

I of course would recommend that you
pick up a copy of
http://www.oreilly.com/catalog/lrnperlorm/
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Hacks via Slow regular expressions

2004-01-02 Thread drieux
On Jan 2, 2004, at 11:53 AM, Dan Anderson wrote:
[..]
Can anyone provide  me  with  more  information
then  O'Reilly's  some  regular
expressions take an exponential time to execute?
What you want to do is read knuth
on searching algorithms - since what
is a Regular Expression, but an effort
to search something for a specific pattern.
Most RegEx that the average user uses
can be awkward and cumbersome, but will
not do a lot of Replace this Token with that
Token that will be expanded again into some
other sets of tokens... Most of what the
average user will be of the form
	s/foo/bar/g

You might want to take a look at the illustrative
code provided from O'Reilly with the Mastering
Regular Expressions, where it is trying to resolve
for 'legitimate email address' as being one of the
more complex problems.
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: piped system commands

2003-12-31 Thread drieux
On Dec 31, 2003, at 9:04 AM, deb wrote:

Drieux,

Vladimir???
yes, named after vladimir ilyich,
it is my Sparc Box.
:-)

Thanks for the hints.  :-)


Personally I would be doing it with something like

	http://www.wetware.com/drieux/CS/Proj/Wetware_ps/

Which of course first started out as

	http://www.wetware.com/drieux/CS/Proj/PID/

Which of course started out with

	http://www.wetware.com/drieux/pbl/Sys/psGrovellor.txt

as the demonstration code for the idea, since if
one is going to be using Perl, why not do the
proc table munging in perl rather than outside of it
in a set of forked processes in a pipeline???
The alternative of course is to buy the learning
curve moment, pick up POE and 'be all that you can be'.
Or get the Proc::Table module from the CPAN.
ciao
drieux
we Blog, therefore we exist:

http://www.wetware.com/drieux/PR/blog2/

--

This space left intentionally blank.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: command line search and replace

2003-12-31 Thread drieux
On Dec 31, 2003, at 8:22 AM, Randy Brown wrote:

Ah yes, now the real stumper:

The line:
	perl -pi -e 's/provider-urlfile:.*\/provider-url/REPLACED/' 
testfile.txt
does in fact work fine from the commandline in unix.

However, when it is called from a ksh script, it does not function.
Any ideas? I have tried many possible combinations that I can think of.
[..]

Well the obvious part of the problem is

	how married are you to the ksh script?

The problem you are going to be running into
in these issues remains
who did which interpolation when,
and where to what?
As well as which is the real problem that
you are bumping your head into.
Allow me to illustrate:

meatbop: 60:] ./smack.ksh
./smack.ksh: Command not found.
meatbop: 61:] which ksh
ksh: Command not found.
meatbop: 66:]
vladimir: 55:] ./smack*
vladimir: 56:]  cat *.ksh
#!/bin/ksh
perl -pi -e 's/provider-urlfile:.*\/provider-url/REPLACED/' 
testfile.txt

vladimir: 57:] cat *.txt
REPLACED
vladimir: 58:]
Is the problem that you do not have ksh on the
machine that you tried to run the perl in the ksh script?
since that smack.ksh has no problem running the command
and doing the dance on a host where there is both perl and ksh.
ciao
drieux
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Hi a question

2003-12-31 Thread drieux
On Dec 31, 2003, at 8:28 AM, John McKown wrote:

For only 4 variables, I thought it was overkill to have an ini file.
However as I continue to mess around with my code, I'm adding more and
more externalized variables. Use of an ini is becoming more 
appealing.
john,

for what it is worth - cf:
http://www.wetware.com/drieux/PR/blog2/Code/200312.html#id3155628391
in it I have references to two pieces of demonstration
code that you might want to think about as tactics in
this type of problem.


ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Cosolidate multiple regular expression

2003-12-30 Thread drieux
On Dec 30, 2003, at 8:45 AM, Kevin Old wrote:
[..]
$ko =~ s/\r/\\page/g; # change returns to \page
$ko =~ s/\f//g; # remove formfeeds
$ko =~ s/\t/\\tab/g; # change tabs to \tab
$ko =~ s//\\/g; # escape backslashes
$ko =~ s/{/\\{/g; # escape left curly
$ko =~ s/}/\\}/g; # escape right curly
$ko =~ s/\n/\n\\par /g; # replace newlines with \n\par
$ko =~ s/\\par\s+\n\\par\s+\n\\par\s+\n+/\\par \n/migs; # cosolidate
blank lines
$ko =~ s/\\f0\\fs22\n\\page/\\f0\\fs22\n\\par /migs; # remove first 
page
break

This is not so much for laziness, but is more for learning what/how to
consolidate.
Sometimes 'consolidation' does not save the nation.

but the lines that amuse me are

$ko =~ s/\n/\n\\par /g; # replace newlines with \n\par
$ko =~ s/\\par\s+\n\\par\s+\n\\par\s+\n+/\\par \n/migs; # cosolidate
first we put some stuff in and then decide to rip it out...

What if we tried to solve the 'blank line' problem first?

There is also that minor buggaboo about
\r\n - our friends CRLF
that first line in the package would take say

	Joe\r\n\r\nBob

and convert it into

	Joe\page\n\page\nBob

and then we hit the \\par packer
and would get to
	Joe\page\n\par\page\n\parBob

and now we do not see our 'empty line'

So I would always start with the

take out what we want to remove
then dither with what is left.
Say something along the line of

	$ko =~ s/\r\n\s*\r\n/\r\n/mig ;

that would take us from our initial state to

	Joe\r\nBob

and perchance a bit more sanity in the process.

Logically the next line would do the remove
of things like the \f and then we start
worrying about the rest of the substitutions.
I presume you have already peeked

	perldoc perlretut

as well as picked up the book on mastering
regular expressions.
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: make problem with xs file (Time::Object)

2003-12-30 Thread drieux
On Dec 29, 2003, at 11:00 AM, Will Glass-Husain wrote:
[..]
P.S.  In case anyone else has hit this error, this was pulled directly 
from
cpan install Time::Object.

[EMAIL PROTECTED] Time-Object-1.00]# make
gcc -c   -D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBUGGING 
-fno-str
ict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE 
-D_FILE_OFFSET_BITS=64
 -I/usr/include/gdbm -DPERL_POLLUTE  -O2 -march=i386 -mcpu=i686 -g   
-DVERSI
ON=\1.00\ -DXS_VERSION=\1.00\ -fPIC
-I/usr/lib/perl5/5.8.0/i386-linux-thread-multi/CORE   Object.c
Object.xs:34: parse error before '(' token
[..]

folks are probably not going to believe what I think
is the Problem here is a bit convoluted to try to explain.
What seems to have happened in 5.8.X is that now the
embed.h is there and it is being called out by perl.h
and it would be really nice if there were some form of
#ifndef PERL_EMB_H
#define PERL_EMB_H

#endif
then one could modify the Makefile.PL for Time::Object

'XSPROTOARG' = ' -prototypes',
'DEFINE' = '-D PERL_EMB_H',
and it would prevent the compiler from picking up where
it is re-defining bouth init_tm() and mini_mktime()
meatbop: 65:] grep init_tm *.h
embed.h:#define init_tm Perl_init_tm
embed.h:#define init_tm(a)  Perl_init_tm(aTHX_ a)
proto.h:PERL_CALLCONV void  Perl_init_tm(pTHX_ struct tm *ptm);
meatbop: 66:] grep mini_mktime *.h
embed.h:#define mini_mktime Perl_mini_mktime
embed.h:#define mini_mktime(a)  Perl_mini_mktime(aTHX_ a)
proto.h:PERL_CALLCONV void  Perl_mini_mktime(pTHX_ struct tm *pm);
meatbop: 67:] pwd
/usr/lib/perl5/5.8.1/i586-linux-thread-multi/CORE
meatbop: 68:]
so the trick is to edit the Object.xs file so that
one commits the two tolks to being really the ones
that are local to the code that it will be creating
1,$s/init_tm/time_object_init_tm/g
1,$s/mini_mktime/time_object_mini_mktime/g
and now your code will not have function names that will
get into an argument. I have cc'd matt into this, in the
hope that he may have a better fix.
ciao
drieux


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



  1   2   3   4   5   6   7   8   9   10   >