Re: Using Getopt::Std

2004-01-13 Thread Hacksaw
> 
> 
> > Hi,
> >   i am using the Getopt::Std package in my code.
> > 
> > 
> > use Getopt::Std;
> > 
> > getopts('s:');
> > 
> > $a = $opt_s

By the way, you don't really need to assign the $opt_x variables to a new 
variable. $opt_s will be persistant, unless you run getopt again, which would 
be odd.

There's nothing special about the $opt_x variables, other than that getopt 
packages makes them for you.

By the way, mark II: A round of applause for the author of this clever and 
elegant package Getopt::Std. Whoever it is. :-)
-- 
Just below the surface of our everyday world lie riches.
http://www.hacksaw.org -- http://www.privatecircus.com -- KB1FVD



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: strange sort order

2004-01-13 Thread Dan
Hi Shawn,

Thanks for your script. I tried it out, and its not exactly right, so 
the data in my file appears not to conform to the numeric ordering.

Your numeric sort gets all the examples I gave right except Set 5. The 
original ordering in the file is:

0908
09088122595
09088122595
0909-114
whereas the output of your script on set 5 is:

0908
0909-114
09088122595
09088122595
which is incidentally the answer your script gives for the *ASCII* 
comparison. So, this is kind of wierd. Do you have an idea what is going 
on?

I did write a comparison function that seems to work on all examples in 
my file, but I'm reluctant to post it because its naive, fairly long, 
and its very slow, which is the reason for my initial post. I tested it 
by running through each line in my file and making sure my comparison 
function returned -1 when that was compared to the next line in the file.

Thanks again for your help. Any other hints?

Dan

Shawn McKinley wrote:
Hello Dan,
  To come up with the sort order you have here, you are sorting on a
numeric comparison (not ASCII).  If you want to sort in the 'normal'
fashion, just use the default ASCII sort.  Here is a simple demo:
use strict;
my $sets=
  {
set1=>['0-CELEBRITY-0','0-CELEBRITY'],
set2=>['0-0-7','0-0'],
set3=>['000-AAA','000'],
set4=>['000',''],
set5=>['0908','09088122595','09088122595','0909-114']
  };
print 'Sorting on numeric comparison',$/,$/;
for(sort keys %$sets) {
  print '  ',$_,$/;
  # Numeric sort below
  for(sort { $a <=> $b } @{$sets->{$_}}) { print '',$_,$/; }
  print $/;
}
print $/,'Sorting on ASCII comparison',$/,$/;
for(sort keys %$sets) {
  print '  ',$_,$/;
  # ASCII sort (same as sort { $a cmp $b })
  for(sort @{$sets->{$_}}) { print '',$_,$/; }
  print $/;
}
exit;
Shawn

-Original Message-
From: Dan LaFlamme [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 13, 2004 6:13 PM
To: [EMAIL PROTECTED]
Subject: strange sort order

Hi,

I have a file that appears to be somewhat sorted, but is not sorted 
according to the traditional unix sort. I'll give some examples, and if 
anyone recgonizes the way in which the file is sorted, please let me 
know. Also, since I may have to write a comparator function for use on 
this "sorted" file, any tips on doing that in the most efficient way 
possible would be helpful. Thanks.

Examples. I give some sets of strings to indicate which comes before the

other in the "sorted" file. The first one in each pair is less than the 
second. Each set is independent of the others. set x doesnt necessarily 
come before set y in the file if x < y.

Set 1:
0-CELEBRITY-0
0-CELEBRITY
Set 2:
0-0-7
0-0
Set 3:
000-AAA
000
Set 4:
000

Set 5:
0908
09088122595
09088122595
0909-114





--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: redirect with cgi.pm

2004-01-13 Thread Randal L. Schwartz
> "Jdavis" == Jdavis  <[EMAIL PROTECTED]> writes:

Jdavis>  I have been able to use redirects with cgi.pm as long 
Jdavis> as the redirect is the only thing in the script.

First, this should be in the perl-cgi-beginners list instead of this list.

Jdavis> i.e.
Jdavis> #!/usr/bin/perl
Jdavis> use CGI qw(:standard);
Jdavis> print redirect('http://google.com/');


Jdavis> but what i need to do is print a bunch of html , have perl do
Jdavis> a few jobs on my system, and then do a redirect when its done.

Jdavis> is this possible?

You can't "print a bunch of html" and then "redirect".

Choose one.  You either want the browser here, or somewhere else.
Which is it?

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




strange sort order

2004-01-13 Thread Dan LaFlamme
Hi,

I have a file that appears to be somewhat sorted, but is not sorted 
according to the traditional unix sort. I'll give some examples, and if 
anyone recgonizes the way in which the file is sorted, please let me 
know. Also, since I may have to write a comparator function for use on 
this "sorted" file, any tips on doing that in the most efficient way 
possible would be helpful. Thanks.

Examples. I give some sets of strings to indicate which comes before the 
other in the "sorted" file. The first one in each pair is less than the 
second. Each set is independent of the others. set x doesnt necessarily 
come before set y in the file if x < y.

Set 1:
0-CELEBRITY-0
0-CELEBRITY
Set 2:
0-0-7
0-0
Set 3:
000-AAA
000
Set 4:
000

Set 5:
0908
09088122595
09088122595
0909-114


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



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  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]
 



mod_perl error

2004-01-13 Thread Kyle Sexton
I'm getting an error with a mod_perl script I'm working on that says 
this:

error:

[Tue Jan 13 10:59:17 2004] [error] 25297: ModPerl::Registry: 
Image::Imlib2 load error: No loader for file format at find.pl line 19.

The script runs fine when it is at the command line, but when I run it 
from the web browser I get an Internal Server Error.

The code looks like this (don't laugh, I'm really new to perl):

code:

#!/usr/bin/perl -w
#
# Last modificatied on:
# Time-stamp: <2004-01-13 10:54:28 ks>
use strict;
use CGI qw/:standard/;
use Image::Imlib2;
print "Content-type:text/html\n\n";

my $xcoord = param('where.x');
my $ycoord = param('where.y');
print "X is $xcoord";
print "Y is $ycoord";
my $image = Image::Imlib2->load("image.png");
my $cropped_image = $image->crop($xcoord, $ycoord, 50, 50);
$cropped_image->save("image-cropped.png");
print "http://www.hostname.org/image-cropped.png\";>";


Does anyone have any ideas on why I might be getting this error?


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]
 



redirect with cgi.pm

2004-01-13 Thread jdavis
Hello,
 I have been able to use redirects with cgi.pm as long 
as the redirect is the only thing in the script.

i.e.
#!/usr/bin/perl
use CGI qw(:standard);
print redirect('http://google.com/');


but what i need to do is print a bunch of html , have perl do
a few jobs on my system, and then do a redirect when its done.

is this possible?

thanks,
-- 
jdavis <[EMAIL PROTECTED]>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Inheritance - was Re: RFC: Package == class == object type

2004-01-13 Thread James Edward Gray II
On Jan 13, 2004, at 3:44 PM, Gary Stainburn wrote:

Did that make any sense?
Yes. While driving home I think I've discovered my biggest conceptual 
block.
The idea of a Trainset class is as you know new.  The idea was 
originally to
have all code relating to track in the Trainset::Track class.

What I've realised is that only the code relating to the insides of a 
single
block belongs in there (constructor, update etc) while use use of, or 
the
grouping of multiple blocks belongs in the container.

This way, linking blocks together etc. all happens within the 
container code.

I will still need to link blocks to each other directly, so that the 
effects
on one block will ripple down to it's neighbours, and link levers to 
signals
and points to change their states, but again this will happen within 
the
container class and should not be a problem.

One thing that both you and Rob will be happy with is that I will 
finally let
go of the $owner.
"You've taken your first steps into a larger world."  ;)

I really hope we are helping you.  I think your project, while quite 
grand, is interesting and want to see it come together for you.  There 
have been some excellent ideas in this thread by many people.  
Assimilate them and take the next few steps.  I expect good things.  If 
you get stuck, you know where to find us...  Good luck!

James

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Inheritance - was Re: RFC: Package == class == object type

2004-01-13 Thread Gary Stainburn
On Tuesday 13 January 2004 6:17 pm, James Edward Gray II wrote:
> On Jan 13, 2004, at 11:32 AM, Gary Stainburn wrote:
> > I'm starting to confuse myself again now.
>
> Yes, you are.

But hopefully lifting the vail a little at last.

>
> > I've got it into my head that I'm  going to have an instance of
> > Trainset as a holder to contain track, signals etc, so I'll do
> > something line:
> >
> > my $tset=Trainset->new;
> > $tset->add_track('TCB',['TCB1','TCB2']);
>
> Everything you've said to here is correct.
>
> > The problem here is that I'm using a Trainset object to call a method
> > of
> > Trainset::Track.
>
> If that's what you are doing, yes that is the design flaw.  Now I
> understand why you were using "base" in the earlier example.  That's
> bad and you don't want to go that way.
>
> Trainset isn't a child object of all your other objects, it's a master
> object that provides an interface for using all those other objects.
> Trainset needs and add_track() method which calls Trainset::Track's
> constructor, does any other needed initialization (linking for
> example), and stores the references in some Trainset instance variable
> for future reference.
>
> Did that make any sense?

Yes. While driving home I think I've discovered my biggest conceptual block.  
The idea of a Trainset class is as you know new.  The idea was originally to 
have all code relating to track in the Trainset::Track class.

What I've realised is that only the code relating to the insides of a single 
block belongs in there (constructor, update etc) while use use of, or the 
grouping of multiple blocks belongs in the container.

This way, linking blocks together etc. all happens within the container code.

I will still need to link blocks to each other directly, so that the effects 
on one block will ripple down to it's neighbours, and link levers to signals 
and points to change their states, but again this will happen within the 
container class and should not be a problem.

One thing that both you and Rob will be happy with is that I will finally let 
go of the $owner.

>
> This is probably why you have also been so insistent about keeping the
> $owner objects everywhere.  You get all this fixed up and you may not
> even need them at all, which is what I've always suspected would be the
> case.

;)

>
> James

-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: RFC: Package == class == object type

2004-01-13 Thread Gary Stainburn
On Tuesday 13 January 2004 6:38 pm, James Edward Gray II wrote:
> On Jan 13, 2004, at 12:05 PM, Rob Dixon wrote:
> >>> use base (Trainset::Trains Trainset::Track Trainset::Signals
> >>>   Trainset::Levers Trainset::Boxes);
> >>>
> >>> inside Trainset.pm. Is this the correct way to call in the other
> >>> classes?
> >>
> >> No it's not.
> >>
> >> use Trainset::Trains;
> >> use Trainset::Track;
> >> use Trainset::Signals;
> >> use Trainset::Levers;
> >> use Trainset::Boxes;
> >
> > Yes it is (sorry James). 'use' on it's own doesn't build the object
> > dependencies. 'use base' is the right way to go, although I prefer
> >
> >   our @ISA; # read 'is a'
> >   @ISA = qw/
> > Trainset::Train
> > Trainset::Track
> > Trainset::Signal
> > Trainset::Box
> > Trainset::Box::Lever
> >   /;
>
> Rob and I obviously view this differently.  :D
>
> I'm also beginning to understand a lot of the confusion in this thread.
>   You two are thinking about this completely opposite the way I am.  No
> problem, there's many solutions to every problem.
>
> Gary and Rob, you two have been envisioning bringing all these methods
> together under one package using inheritance.  I've been thinking of
> uniting these objects with an interface object that keeps track of all
> the gory details for the users.
>
> I do prefer my line of thinking.  I think it's pretty clear that the
> above is poor object oriented design (sorry Rob) since you are
> literally saying:
>
> Trainset IS A Trainset::Train AND IS A Trainset::Track AND IS A ...
>
> That's certainly not true in real life and I don't think we want it
> true in our code, pitfalls of multiple inheritance arguments not even
> needed.
>
> The real problem I have with this whole line of thinking though is that
> you have to learn the details of six (or so) objects whens I think
> you're really only interested in them as a single entity.  How you
> implement all of these internals is complex and I don't want to care
> about it when it's time for me to sit down and do something practical
> with a Trainset.  I don't want to remember which constructor to call
> for what and which object's link() method will help me hook these
> things up.  I just want to tell Trainset what I want and get some work
> done.
>
> "Of course, that's just my opinion.  I could be wrong."  --Dennis Miller
>
> James

Hi James,

You're right about my pre-coceptions, and you're also right about them being 
wrong.  Rob's also right in that I'm going to have to lose a lot of my code 
so far.

See my post in the inhertitance thread.
-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




decoding a base64 file?

2004-01-13 Thread Tino Arellano

Hello folks,

If I encode a file with MIME::Base64 with the following script, encode_base64.pl. The 

question is; how do I decode the file?  I use the following script, decode_base64.pl 
to 

decode back to the original source but that did not work.

Thank you...



-encode_base64.pl

#! /usr/bin/perl
   
   
   
   use MIME::Base64 ();
   

open(FILE_R, "rap_arms.blend") or die "$!";
open(FILE_W, ">rap_arms.bas64") or die "$!";
   
   while (read(FILE_R, $buf, 60*57)) {
   $encoded = MIME::Base64::encode($buf);
   print FILE_W $encoded ;
   
   }  
close(FILE_R);
close(FILE_W);
   
   print "Done ... \n";


-decode_base64.pl

#! /usr/bin/perl
   
   
   
   use MIME::Base64 ();
   

open(FILE_W, ">rap_arms.new.blend") or die "$!";
open(FILE_R, "rap_arms.bas64") or die "$!";
   
   while (read(FILE_R, $buf, 60*57 )) {
   $encoded = MIME::Base64::decode($buf);
   print FILE_W $encoded ;
   
   }  
close(FILE_R);
close(FILE_W);
   
   print "Done ... \n";



--
-- 
__
Check out the latest SMS services @ http://www.linuxmail.org 
This allows you to send and receive SMS through your mailbox.


Powered by Outblaze

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




remove log files on win 2000 by date

2004-01-13 Thread zhaoxu zhang
Hi, 

does anyone have perl code to remove logfiles in log
fold by date on wind 2000. I need to remove yeaterday
and before yesterday logfiles on win 2000.

your help is great appreciate.

thanks
jack


__
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




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

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]
 



Upgrading Perl linux 5.6 rpm to 5.8.2 source

2004-01-13 Thread Paul Kraus
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?

 Paul Kraus
 ---
 PEL Supply Company
 Network Administrator
 ---
 800 321-1264 Toll Free
 216 267-5775 Voice
 216 267-6176 Fax
 www.pelsupply.com
 ---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 


Re: Oreilly's "Learning Perl 3rd Edition"

2004-01-13 Thread Jan Eden

Randal L. Schwartz wrote:

>> "Wiggins" == Wiggins D Anconia <[EMAIL PROTECTED]> writes:
>
>Wiggins> The two above overlap a good deal. 
>
>The Alpaca and the Panther overlap in that they cover some similar
>ground.  But the Alpaca is designed to be a step-by-step tutorial: in
>fact, it's a transcript of the course we teach (both onsite and
>open-enrollment) for people who have completed the Llama course and
>want more.  The Panther is closer to a reference book.

I worked through the LLama and used the Camel for some additional information at 
certain stages. Now I ordered the Alpaca but not the Panther since it seems a bit 
outdated (1997) to me.

I am looking forward to reading the second Learning book, since I really enjoyed 
Learning Perl. Thanks Randal!

- Jan
-- 
Either this man is dead or my watch has stopped. - Groucho Marx

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




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]
 



Re: Using Getopt::Std

2004-01-13 Thread William.Ampeh




Put quotes around your arguments.  Use single quotes if you are not doing
variable substitution, and double quotes if otherwise.

That is:

my_program.pl -s 'will[1]'   "$will"

__

William Ampeh (x3939)
Federal Reserve Board


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: decoding MIME:Base64 question?

2004-01-13 Thread Wiggins d Anconia
> 
> Hello folks,
> 
> If I encode a file with MIME::Base64 with the following script, 
encode_base64.pl. The question is; how do I decode 
> the file?  I use the following script, decode_base64.pl to decode back
to the original source but that did not work because 
> they are different from each other. 
> 
> Thank you...
> 

Naturally you should use strict and warnings...

To get your code snippets to work for me I needed to 'binmode' the read
handle in the first script, 'binmode' the output handle in the second,
and read a line at a time rather than chunks in the second.  The binmode
may be system or file dependent I am not clear about this. In the case
of the base64 encoded data there is no need to read it chunked like that
I suspect the newlines are being included in $buf which is being base64
decoded and included as data rather than being removed as they would
when the record separator is allowed to do its thing, though this isn't
clear to me either since it should drop them or skip them or something
since newlines aren't in the base64 character set.  You might try
enabling the diagnostic messages and see what they provide...



perldoc -f binmode

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




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:

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

	

and

	

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]
 



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]
 



Re: Using Getopt::Std

2004-01-13 Thread Wiggins d Anconia


> Hi,
>   i am using the Getopt::Std package in my code.
> 
> 
> use Getopt::Std;
> 
> getopts('s:');
> 
> $a = $opt_s
> 
> 
> this is how i run my program from command line "
> 
> > my_program.pl -s pattern
> 
> now if "pattern" is something like abcd[12] how do i
> make my program accept the index 12 as a part of the
> string for option -s ?
> 
> i would appreciate if anybody can help me on this.
> 

I believe your problem is that the shell is trying to interpret the [12]
 itself rather than letting it pass through as an argument string. Try
quoting the whole string on the command line:

my_program -s 'abcd[12]'

tcsh appears to have this problem providing a 'No match', however bash
does what you expect. 

You may also want to check out Getopt::Long for a more robust interface
and documentation. And I assume your snippet dropped "use strict" and
"use warnings" for brevity?

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: RFC: Package == class == object type

2004-01-13 Thread James Edward Gray II
On Jan 13, 2004, at 12:05 PM, Rob Dixon wrote:

use base (Trainset::Trains Trainset::Track Trainset::Signals
  Trainset::Levers Trainset::Boxes);
inside Trainset.pm. Is this the correct way to call in the other
classes?
No it's not.

use Trainset::Trains;
use Trainset::Track;
use Trainset::Signals;
use Trainset::Levers;
use Trainset::Boxes;
Yes it is (sorry James). 'use' on it's own doesn't build the object
dependencies. 'use base' is the right way to go, although I prefer
  our @ISA; # read 'is a'
  @ISA = qw/
Trainset::Train
Trainset::Track
Trainset::Signal
Trainset::Box
Trainset::Box::Lever
  /;
Rob and I obviously view this differently.  :D

I'm also beginning to understand a lot of the confusion in this thread. 
 You two are thinking about this completely opposite the way I am.  No 
problem, there's many solutions to every problem.

Gary and Rob, you two have been envisioning bringing all these methods 
together under one package using inheritance.  I've been thinking of 
uniting these objects with an interface object that keeps track of all 
the gory details for the users.

I do prefer my line of thinking.  I think it's pretty clear that the 
above is poor object oriented design (sorry Rob) since you are 
literally saying:

Trainset IS A Trainset::Train AND IS A Trainset::Track AND IS A ...

That's certainly not true in real life and I don't think we want it 
true in our code, pitfalls of multiple inheritance arguments not even 
needed.

The real problem I have with this whole line of thinking though is that 
you have to learn the details of six (or so) objects whens I think 
you're really only interested in them as a single entity.  How you 
implement all of these internals is complex and I don't want to care 
about it when it's time for me to sit down and do something practical 
with a Trainset.  I don't want to remember which constructor to call 
for what and which object's link() method will help me hook these 
things up.  I just want to tell Trainset what I want and get some work 
done.

"Of course, that's just my opinion.  I could be wrong."  --Dennis Miller

James

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Oreilly's "Learning Perl 3rd Edition"

2004-01-13 Thread Wiggins d Anconia


> > "Wiggins" == Wiggins D Anconia <[EMAIL PROTECTED]> writes:
> 
> Wiggins> The two above overlap a good deal. 
> 
> The Alpaca and the Panther overlap in that they cover some similar
> ground.  But the Alpaca is designed to be a step-by-step tutorial: in
> fact, it's a transcript of the course we teach (both onsite and
> open-enrollment) for people who have completed the Llama course and
> want more.  The Panther is closer to a reference book.
> 

Well put, and I agree (naturally).  I guess I hadn't thought about the
Panther as a reference, because at the time it acted as both for lack of
other resources, but the newer is definitely in the same vain as the
Learning style, and I definitely enjoyed its easy flow.

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Prototyping, do or don't?

2004-01-13 Thread Rob Dixon
Dan Anderson wrote:
>
> I am somewhat confused as to when to prototype a subroutine.  Under the
> tips section Programming Perl makes the following points:
>
> 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?

Everybody who has an opinion on this will have a different one, so
here's mine:

- Forget about optimising your program until you've found that it's
  too slow.

- Only ever prototype well-established functions that you want to
  write /very/ well (including optimisation and parameter
  verification) and then forget about them.

- As far as possible, code all calls to prototyped subroutines without
  brackets around the parameter list. Like this:

noproto('A', 1);
withproto 'A', 1;

  so that the difference is clear.

- A special case is prototyping the subroutine for a call to 'sort'
  which will allow you to pass the two parameters in the @_ parameter
  list instead of in package variables $a and $b.

Like I said, read what others have to say and adopt your own policy,
but be consistent.

Rob



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Mysql.pm

2004-01-13 Thread Rob Dixon
Joe Stuart wrote:
>
> I'm having problems with the Mysql.pm module. When I have the two
> statements
>
> $dbh = Mysql->connect($host,$database,$username,$password);
> my $sth = $dbh->query("insert into users values(NULL, 'Jon',
> 'Sterling', 'Doe', 24, '[EMAIL PROTECTED]')");

You don't need to escape the 'at' with single quotes - only with
double ones.

> My problem is when I run it as root it works fine, but when I run it as
> a regular user I get

Clue: this must eb a permissions problem!

> Mysql connect('database=userdb;host=localhost','joe_stuart',...)
> failed: Can't connect to local MySQL server through socket
> '/var/lib/mysql/mysql.sock' (13) at ./SendQuery.pl line 43

... so the Mysql->connect call returns 'undef', causing ...

> Can't call method "query" on an undefined value at ./SendQuery.pl line
> 81.

First of all, check the return from the 'connect' call:

  $dbh = Mysql->connect($host,$database,$username,$password)
  or die Mysql->errmsg;

and, depending on the error message, talk to your sysadmin about
access to the database.

HTH,

Rob




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Inheritance - was Re: RFC: Package == class == object type

2004-01-13 Thread James Edward Gray II
On Jan 13, 2004, at 11:32 AM, Gary Stainburn wrote:

I'm starting to confuse myself again now.
Yes, you are.

I've got it into my head that I'm  going to have an instance of 
Trainset as a holder to contain track, signals etc, so I'll do 
something line:

my $tset=Trainset->new;
$tset->add_track('TCB',['TCB1','TCB2']);
Everything you've said to here is correct.

The problem here is that I'm using a Trainset object to call a method 
of
Trainset::Track.
If that's what you are doing, yes that is the design flaw.  Now I 
understand why you were using "base" in the earlier example.  That's 
bad and you don't want to go that way.

Trainset isn't a child object of all your other objects, it's a master 
object that provides an interface for using all those other objects.  
Trainset needs and add_track() method which calls Trainset::Track's 
constructor, does any other needed initialization (linking for 
example), and stores the references in some Trainset instance variable 
for future reference.

Did that make any sense?

This is probably why you have also been so insistent about keeping the 
$owner objects everywhere.  You get all this fixed up and you may not 
even need them at all, which is what I've always suspected would be the 
case.

James

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Problem with dereferencing of $_

2004-01-13 Thread Duan Toh
Hello all, 

testing the use of DBI. Having a problem (highlighted in red) with using
"@$_" as the topic. When I use @row the program writes records as
expected to test.txt but when I use the topic it only writes ...

""

""

""

in the file.  I have reread documentation to see if I am using @$_
correctly and it seems OK to me can anyone help ?

 

thanks,

 

 

Duan.

 

 

Source code 

 

use warnings;

use strict;

 

use DBI;

use Data::Dumper; 

 

 

my $destination = "test.txt";

my $dbh = DBI->connect( "dbi:ODBC:Northwind", "", "",

{RaiseError => 1, PrintError => 1, AutoCommit => 1} ) or

die "Unable to connect: " . $DBI::errstr . "\n"; 

 

open OUTPUT, ">$destination" or die $!;

 

# OK, connected, now select from Customers table. 

 

my $sel = $dbh->prepare( "select CustomerID,CompanyName,Country from
Customers where CustomerID like ?" ); 

 

$sel->execute( qq{%} );

 

if ($ARGV[0]) {

while ($sel->fetchrow_array) {

print OUTPUT '"';

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

print OUTPUT '"',"\n";

}

}

else {

while (my @row = $sel->fetchrow_array) {

print OUTPUT '"';

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

print OUTPUT '"',"\n";

}

}


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 


Re: Oreilly's "Learning Perl 3rd Edition"

2004-01-13 Thread Randal L. Schwartz
> "Wiggins" == Wiggins D Anconia <[EMAIL PROTECTED]> writes:

Wiggins> The two above overlap a good deal. 

The Alpaca and the Panther overlap in that they cover some similar
ground.  But the Alpaca is designed to be a step-by-step tutorial: in
fact, it's a transcript of the course we teach (both onsite and
open-enrollment) for people who have completed the Llama course and
want more.  The Panther is closer to a reference book.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




decoding MIME:Base64 question?

2004-01-13 Thread Tino Arellano

Hello folks,

If I encode a file with MIME::Base64 with the following script,  encode_base64.pl. The 
question is; how do I decode 
the file?  I use the following script, decode_base64.pl to decode back to the original 
source but that did not work because 
they are different from each other. 

Thank you...



-encode_base64.pl

#! /usr/bin/perl
   
   
   
   use MIME::Base64 ();
   

open(FILE_R, "rap_arms.blend") or die "$!";
open(FILE_W, ">rap_arms.bas64") or die "$!";
   
   while (read(FILE_R, $buf, 60*57)) {
   $encoded = MIME::Base64::encode($buf);
   print FILE_W $encoded ;
   
   }  
close(FILE_R);
close(FILE_W);
   
   print "Done ... \n";


-decode_base64.pl

#! /usr/bin/perl
   
   
   
   use MIME::Base64 ();
   

open(FILE_W, ">rap_arms.new.blend") or die "$!";
open(FILE_R, "rap_arms.bas64") or die "$!";
   
   while (read(FILE_R, $buf,60*57)) {
   $encoded = MIME::Base64::decode($buf);
   print FILE_W $encoded ;
   
   }  
close(FILE_R);
close(FILE_W);
   
   print "Done ... \n";








-- 
__
Check out the latest SMS services @ http://www.linuxmail.org 
This allows you to send and receive SMS through your mailbox.


Powered by Outblaze

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: RFC: Package == class == object type

2004-01-13 Thread Rob Dixon
Thanks, Gary and James, for this input: there's something to work with now.

Beware though, Gary, you may have to steel yourself to throw away a lot
of what you've written! Also, you've chosen something quite complex
to model as an introduction to OO, so don't expect to make rapid
progress!

All of the following IMO only. Others will have different OO models.

James Edward Gray II wrote:
>
> On Jan 13, 2004, at 6:24 AM, Gary Stainburn wrote:
>
> [snip background]
>
> > 3) As everything else will be created from the Trainset instance, they
> > will
> > have a link to it. This will be stored as $self->{_OWNER}. This will
> > then
> > (hopefully) provide quick direct access to the Trainset variables
> > (were Class
> > globals). I think I should be able to simply call something like
> > $self->{_OWNER}{_BLOCKS}
>
> Or you could always do something like $self->{_Trainset}->get_blocks(),
> which is probably a little better style.  Always use methods when you
> can.

I don't like this. The code in 'main' should keep track of which trainset
it's currently talking about. If nothing else, the back reference means we
have to write a DESTROY method :-/

The program should look something like this:

  use strict;
  use warnings;

  use Trainset;

  my $tset = new Trainset;

and thereafter use $tset as the 'current' trainset.

> > The example code (not tested yet) will create a long length of track
> > (TCB1 and
> > TCB2), and a siding (S1).  It will then create a switch (Y-shape)
> > point and
> > connect that to TCB2 and S1.
> >
> > It will then create a signalbox, and in that signalbox create a lever
> > to
> > control the set of points.
> >
> > my $tset=Trainset->new;
> > $tset->add_track('TCB1','TCB'); # create 1st block of track
> > $tset->add_track('TCB2','TCB'); # create 2nd block of track
> > $tset->add_track('S1','TCB'); # create Siding 1
>
> An add_tracks() method might be handy.  What's that second parameter,
> if I may ask?

I echo that: what's 'TCB'? Also, my code would read:

  foreach (qw/ TCB1 TCB2 S1 /) {
my $track = new Trainset::Track($_);
$tset->add($track);
  }

> > $points=$tset->add_point('GSP1','SWITCH'); # create switch point to
> > siding
> > $tset->add_link('TCB1',0,'TCB2',0); # link TCB1 (rear) to TCB2
> > (advance)
> > $tset->add_link('TCB2',0,'GSP1',0); # link TCB2 to points GSP1
> > $tset->add_link('S1',0,'GSP1',1); # link Siding1 to points GSP1
> > (offset1)
>
> Again, what are the number parameters?
>
> In my opinion the above could probably be done in one method call,
> which would make for a much nicer interface.  Heck, have it create
> tracks too if the don't exist.

Yes. And I wonder if a 'link' should be a separate object or just
a relationship between two 'track' things?

My idea of how this code should look:

  {
my $point = new Trainset::Point('GSP1');
$tset->add($point);
$tset->link('TCB1', 'TCB2');
$tset->link('S1', 'GSP1');
  }

> > $box=$tset->add_signalbox('Grosmont'); # Create Grosmont signalbox
> > $lever=$tset->add_lever('GS1'); # Create lever GS1
> > $box->use_lever($lever,0); # Put lever1 in signalbox
>
> Again, too much work.  The whole point of using the Trainset object as
> the code interface is to hide all these ugly details from users.  Does
> a signal box always have at least one lever?  Create it in the signal
> box constructor then.  Or modify add_signalbox() to accept a list of
> levers to add to it.  Do all that in the Trainset code.  That's what
> it's for.

I hope you're getting my drift by now. I'm wondering about
boxes being instances of Trainset::Box::Lever instead, like this:

  {
my $box = new Trainset::Box('Grosmont');
my $lever = new Trainset::Box::Lever('GS1');
$box->add($lever);
$tset->add($box);
  }

or, with additional methods:

  my $box = $tset->add_box('Grosmont');
  $box->add_lever('GS1');

> > # would be nice if I could replace the above with a shortcut like
> >
> > #  $box=$tset->add_signalbox('Grosmont'); # create signalbox
> > #  $lever=$box->add_lever('GS1',0); # create lever and put in s'box

> Yes it would, but think bigger on the simplification scale.  Maybe you
> even leave all these low-level methods in place as there may be a time
> when I need them, but give me a high-level interface that makes my life
> easier most of the time.

Wow! Didn't I just write that? You're catching on!

> > $lever->set_use(0,$points,'TCB2'); # position 0 = select TCB2
> > $lever->set_use(1,$points,'S1'); # position 1 = select S1
> >
> > $lever->throw(0); # throw lever

Or, so that it looks cute, use the alternative syntax:

  throw $lever;

> > I hope that this has shown (a) what I am hoping to aim for with this
> > project
> > and (b) that I've taken on board the comments and hopefully
> > implemented the
> > suggestions correctly.

Yep. I think we're on a roll here.

> > Now the new questions.
> >
> > 1) I've put:
> >
> > use base (Trainset::Trains Trainset::Track Trainset::Signals
> >   Trainset::Levers Trains

Using Getopt::Std

2004-01-13 Thread Perl
Hi,
  i am using the Getopt::Std package in my code.


use Getopt::Std;

getopts('s:');

$a = $opt_s


this is how i run my program from command line "

> my_program.pl -s pattern

now if "pattern" is something like abcd[12] how do i
make my program accept the index 12 as a part of the
string for option -s ?

i would appreciate if anybody can help me on this.



__
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Inheritance - was Re: RFC: Package == class == object type

2004-01-13 Thread Gary Stainburn
On Tuesday 13 Jan 2004 4:39 pm, Gary Stainburn wrote:
> On Tuesday 13 Jan 2004 3:04 pm, James Edward Gray II wrote:
> > On Jan 13, 2004, at 6:24 AM, Gary Stainburn wrote:
[snip]
> > > 1) I've put:
> > >
> > > use base (Trainset::Trains Trainset::Track Trainset::Signals
> > > Trainset::Levers Trainset::Boxes);
> > >
> > > inside Trainset.pm. Is this the correct way to call in the other
> > > classes?
> >
> > No it's not.
> >
> > use Trainset::Trains;
> > use Trainset::Track;
> > use Trainset::Signals;
> > use Trainset::Levers;
> > use Trainset::Boxes;
> >
> > > If  so, would this also give Trainset::Boxes access to
> > > Trainset::Levers::add_lever to enable the shortcut I mentioned above?
> >
> > After you switch to the code above sure, but I'm not sure it needs to.
> > Trainset is the glue object.  Use it that way.  Trainsets'
> > add_signalbox() should create the box, create the lever(s) and link
> > them together.  Trainset::Boxes just needs to worry about itself, in
> > construction at least.
>
> So basically, within the add_signalbox would simply call $owner->add_lever
> asuming $owner points to the $tset object?
>

I'm starting to confuse myself again now.  I've got it into my head that I'm 
going to have an instance of Trainset as a holder to contain track, signals 
etc, so I'll do something line:

my $tset=Trainset->new;
$tset->add_track('TCB',['TCB1','TCB2']);

The problem here is that I'm using a Trainset object to call a method of 
Trainset::Track.  Now I thought that this would work because of inheritance, 
but it doesn't seem to work that way, and the only way I seem to be able to 
get it working is to use the exporter within Trainset::Track.  Isn't this 
defeating the object of inheritance, or am I missing something?

[snip]
-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: RFC: Package == class == object type

2004-01-13 Thread James Edward Gray II
On Jan 13, 2004, at 10:39 AM, Gary Stainburn wrote:

On Tuesday 13 Jan 2004 3:04 pm, James Edward Gray II wrote:
On Jan 13, 2004, at 6:24 AM, Gary Stainburn wrote:

3) As everything else will be created from the Trainset instance, 
they
will have a link to it. This will be stored as $self->{_OWNER}. This 
will
then (hopefully) provide quick direct access to the Trainset 
variables
(were Class globals). I think I should be able to simply call 
something
like$self->{_OWNER}{_BLOCKS}
Or you could always do something like 
$self->{_Trainset}->get_blocks(),
which is probably a little better style.  Always use methods when you
can.
This then gets back to the speed vs control discussion in the OOP 
perldocs.
For the sake of speed I've made the decision to stick with direct 
access to
variables within my code, but will eventually write methods for the 
external
interface.
And it's still a bad idea for you to be worrying about this problem at 
this point.  ;)  Do you see what you're doing here?  You're making 
things harder because you're inventing problems you haven't run into 
yet.  If you run into speed issues down the road, this might be the 
right place to start optimizing, but you're not there yet.

The documentation you refer to suggest using variables over method 
calls INSIDE THE CLASS/PACKAGE.  You're using variables INSIDE OTHER 
CLASSES.  While this isn't always wrong, it's probably not the way to 
go here.  Trainset is the interface object.  So get_blocks() should 
take parameters and return the exact subset of blocks you are currently 
interested in, nothing more.

Think good design.  You'll have plenty of time to think speed later.

The example code (not tested yet) will create a long length of track
(TCB1 and > > TCB2), and a siding (S1).  It will then create a switch
 (Y-shape) point and connect that to TCB2 and S1.
It will then create a signalbox, and in that signalbox create a lever
to control the set of points.
my $tset=Trainset->new;
$tset->add_track('TCB1','TCB');  # create 1st block of track
$tset->add_track('TCB2','TCB');  # create 2nd block of track
$tset->add_track('S1','TCB');# create Siding 1
An add_tracks() method might be handy.  What's that second parameter,
if I may ask?
TCB = Track Circuit Block, a block that can detect the presence of a 
vehicle
(via an residual eltrical current which passes through the metal axle 
of the
vehicle) as oposed to a normal 'Block' section.

I could reverse the parameter sequence so that the block type is 
first, then
allow multiple block names to be specified, thus reducing the work 
involved.
I'll probably make it so that it creates the links between the blocks 
too.
Now you're talking.

$points=$tset->add_point('GSP1','SWITCH'); # create switch point to
siding
$tset->add_link('TCB1',0,'TCB2',0);  # link TCB1 (rear) to TCB2
(advance)
$tset->add_link('TCB2',0,'GSP1',0);  # link TCB2 to points GSP1
$tset->add_link('S1',0,'GSP1',1);# link Siding1 to points GSP1
(offset1)
Again, what are the number parameters?
To model a switch, I've got a simple block of track which has two 
connections
at one end, specifically an array to hold links to the adjacent 
blocks, so
that the onward link from TCB2 connects to position '0' on switch 
GSP1, while
the link from siding S1 connects to position '1' on switch GSP1.  This 
way,
to set the route, I simply set a subscript to '0' or '1'.

I could possibly do something like:

$tset->add_point('GSP1','SWITCH',['TCB2','S1'],[]);
I definitely think you can come up with a better interface than the 
numbers, yes.  You're exposing those nasty subscripts to the users of 
your code.  Those should be an implementation detail I don't need to 
know anything about.  Is order of the links even significant?  Can the 
first one mentioned go in subscript 0, the next one mentioned in 1, 
etc?

I would try to refer to tracks (and everything else for that matter) by 
name, as much as humanly possible.  Keep it simple.

In my opinion the above could probably be done in one method call,
which would make for a much nicer interface.  Heck, have it create
tracks too if the don't exist.
$box=$tset->add_signalbox('Grosmont');   # Create Grosmont signalbox
$lever=$tset->add_lever('GS1');  # Create lever GS1
$box->use_lever($lever,0);   # Put lever1 in signalbox

I could do something like:

$tset->add_signalbox('Grosmont','GS1');

where add_signalbox could call add_lever for any lever that doesn't 
already
exist (I'd still need to define the actions for the lever seperately).
Yes.  Progress.  You're staring to think along the right lines.

Again, too much work.  The whole point of using the Trainset object as
the code interface is to hide all these ugly details from users.  Does
a signal box always have at least one lever?  Create it in the signal
box constructor then.  Or modify add_signalbox() to accept a list of
levers to add to it.  Do all that in the Trainset code.  Tha

Re: RFC: Package == class == object type

2004-01-13 Thread Wiggins d Anconia
> On Tuesday 13 Jan 2004 3:04 pm, James Edward Gray II wrote:
> > On Jan 13, 2004, at 6:24 AM, Gary Stainburn wrote:



> 
> I could reverse the parameter sequence so that the block type is
first, then 
> allow multiple block names to be specified, thus reducing the work
involved.  
> I'll probably make it so that it creates the links between the blocks too.
> 



THis is the one point that I was going to remark on earlier. As your
system and objects, etc. become more complex there is a good chance you
are going to find that using a flat list as method parameter passing is
a nightmare, you may want to consider passing arguments in a named list
manner, so that they can be unordered, optional, etc. This adds to the
complexity of argument verification but in the long run adds flexibility
to the interface. Some examples:

my $object = new Class ("value 1", "value 2", "value 3");

In the above the new constructor takes three values that *must* be in
the proper order (unless their type can be gleaned in other ways such as
with ref or isa) and must all exist. For instance if you didn't need nor
have 'value 2' you still must specify a place holder, like:

my $object = new Class ("value 1", undef, "value 3");

etc. Which makes the interface less flexible in the future, and harder
to remember how it may(must) be used.  I tend to advocate named
parameter passing such as,

my $object = new Class (key1 => "value 1", key2 => "value 2", key3 =>
"value 3");

Then when "value 2" is needed or isn't known simply drop the key/value
pair and nothing else in the method should need changing, assuming it
wasn't required before.

Certainly there are times when an interface needs to be simple and isn't
likely to expand greatly, or a particular argument must *always* be
provided, in which case this may be overkill but I thought I would
mention it. Using named parameters may also make it easier to pass
lists, which need to be passed as references, in which case explicitly
naming them may help on both sides of the interface.  

As a side note to the list, I posted a message to Gary (trying to
prevent the previous thread from becoming cluttered, which it has now
anyways :-)) stating that I think his application (aside from the "real
time" need) is perfectly suited for experiments into POE. The
description of the system's needs jive exactly with what POE was meant
to handle...

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: RFC: Package == class == object type

2004-01-13 Thread Gary Stainburn
On Tuesday 13 Jan 2004 3:04 pm, James Edward Gray II wrote:
> On Jan 13, 2004, at 6:24 AM, Gary Stainburn wrote:
>
> [snip background]
>
> > 3) As everything else will be created from the Trainset instance, they
> > will have a link to it. This will be stored as $self->{_OWNER}. This will
> > then (hopefully) provide quick direct access to the Trainset variables
> > (were Class globals). I think I should be able to simply call something 
> > like$self->{_OWNER}{_BLOCKS}
>
> Or you could always do something like $self->{_Trainset}->get_blocks(),
> which is probably a little better style.  Always use methods when you
> can.

This then gets back to the speed vs control discussion in the OOP perldocs.  
For the sake of speed I've made the decision to stick with direct access to 
variables within my code, but will eventually write methods for the external 
interface.

>
> > The example code (not tested yet) will create a long length of track
> > (TCB1 and > > TCB2), and a siding (S1).  It will then create a switch
> >  (Y-shape) point and connect that to TCB2 and S1.
> >
> > It will then create a signalbox, and in that signalbox create a lever
> > to control the set of points.
> >
> > my $tset=Trainset->new;
> > $tset->add_track('TCB1','TCB'); # create 1st block of track
> > $tset->add_track('TCB2','TCB'); # create 2nd block of track
> > $tset->add_track('S1','TCB');   # create Siding 1
>
> An add_tracks() method might be handy.  What's that second parameter,
> if I may ask?

TCB = Track Circuit Block, a block that can detect the presence of a vehicle 
(via an residual eltrical current which passes through the metal axle of the 
vehicle) as oposed to a normal 'Block' section.

I could reverse the parameter sequence so that the block type is first, then 
allow multiple block names to be specified, thus reducing the work involved.  
I'll probably make it so that it creates the links between the blocks too.

>
> > $points=$tset->add_point('GSP1','SWITCH'); # create switch point to
> > siding
> >
> > $tset->add_link('TCB1',0,'TCB2',0); # link TCB1 (rear) to TCB2
> > (advance)
> > $tset->add_link('TCB2',0,'GSP1',0); # link TCB2 to points GSP1
> > $tset->add_link('S1',0,'GSP1',1);   # link Siding1 to points GSP1
> > (offset1)
>
> Again, what are the number parameters?

To model a switch, I've got a simple block of track which has two connections 
at one end, specifically an array to hold links to the adjacent blocks, so 
that the onward link from TCB2 connects to position '0' on switch GSP1, while 
the link from siding S1 connects to position '1' on switch GSP1.  This way, 
to set the route, I simply set a subscript to '0' or '1'.

I could possibly do something like:

$tset->add_point('GSP1','SWITCH',['TCB2','S1'],[]);

>
> In my opinion the above could probably be done in one method call,
> which would make for a much nicer interface.  Heck, have it create
> tracks too if the don't exist.
>
> > $box=$tset->add_signalbox('Grosmont');  # Create Grosmont signalbox
> > $lever=$tset->add_lever('GS1'); # Create lever GS1
> > $box->use_lever($lever,0);  # Put lever1 in signalbox
>

I could do something like:

$tset->add_signalbox('Grosmont','GS1');

where add_signalbox could call add_lever for any lever that doesn't already 
exist (I'd still need to define the actions for the lever seperately).

> Again, too much work.  The whole point of using the Trainset object as
> the code interface is to hide all these ugly details from users.  Does
> a signal box always have at least one lever?  Create it in the signal
> box constructor then.  Or modify add_signalbox() to accept a list of
> levers to add to it.  Do all that in the Trainset code.  That's what
> it's for.
>
> > # would be nice if I could replace the above with a shortcut like
> >
> > #  $box=$tset->add_signalbox('Grosmont'); # create signalbox
> > #  $lever=$box->add_lever('GS1',0); # create lever and put in s'box
>
> Yes it would, but think bigger on the simplification scale.  Maybe you
> even leave all these low-level methods in place as there may be a time
> when I need them, but give me a high-level interface that makes my life
> easier most of the time.

Eventually, I intend to have:

my $tset=Trainset->new('');

and $tset->save('');

at which point I can write a seperate route editor program, but I'm getting a 
bit ahead here.

>
> > $lever->set_use(0,$points,'TCB2');  # position 0 = select TCB2
> > $lever->set_use(1,$points,'S1');# position 1 = select S1
> >
> > $lever->throw(0);   # throw lever
> >
> > I hope that this has shown (a) what I am hoping to aim for with this
> > project
> > and (b) that I've taken on board the comments and hopefully
> > implemented the
> > suggestions correctly.
> >
> > Now the new questions.
> >
> > 1) I've put:
> >
> > use base (Trainset::Trains Trainset::Track Trainset::Signals
> >   Trainset::Levers Trainset::Boxes);
> >
> > inside Train

Re: New to PERL and Need Help

2004-01-13 Thread Tim
Once you get the AS PERL working, use ppm or ppm3 (Perl Package Manager) to 
get DBI/DBD modules (DBD::Oracle) on your system. Connect and you're on 
your way. There is a book on this subject that will help,

I've always found this link to help describe the length of the tunnel...
http://www.yapc.org/America/previous-years/19100/schedule/author/njt_mastery.html
At 07:57 AM 1/13/04 -0600, you wrote:
I am new to the world of PERL and need help to get started.  I have the 
book: "PERL for Oracle DBA's".  But this has not helped me get 
started.  My background is Oracle as a DBA.  I have a good background with 
SQL*Plus and PL/SQL.  On my home PC I have XP Prof. and Oracle 9.2.  My 
Oracle supports PERL but I cannot get it to work.  It is not the latest 
release of PERL, but that is not a problem.  When I can get it to work I 
can update at that time.

Any help with books for beginners or web sites will be greatly 
appreciated.  Keep it very simple.

Thanks much,
Ken Janusz, CPIM


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



no digest

2004-01-13 Thread Dr. Irina Campbell
Hi-
I subscribed to the beginners digest and receive a list of individual email 
attachments (~50) but none of them open with text...
This is not the usual format for a digest listserve...
can anyone debug this problem.
many thnaks.
Irina Campbell 


Re: RFC: Package == class == object type

2004-01-13 Thread Paul Johnson

>> 2) What I do with the data will obviously depend on the program using
>> my
>> object, but would probably be things like update the screen (Term, TK,
>> Win32), or to send instructions to a control system (e.g. throw points
>> on
>> model railway).
>>
>> What is the best method to pass control back to the program from
>> within a
>> method?
>
> I don't think I understand this question.  The obvious answer to me is
> return (exit the method).  Control will pass back to the caller at this
> point, as it always does.  If I misunderstood, please try explaining it
> again.

I expect you are looking for callbacks here.  The caller passes in a sub
(reference) which you call from within the method.

$obj->meth(sub { my ($oomph, $time) = @_; print "Oomph is $oomph at $time" })

and in the module

sub meth
{
my $self = shift;
my ($callback) = @_;
my ($oomph, $time) = ...
$callback->($oomph, $time);
}

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Oreilly's "Learning Perl 3rd Edition"

2004-01-13 Thread Wiggins d Anconia


> 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?
> 

In the past I would have suggested Programming Perl, the cookbook is
more for examples of specific items, an excellent resource to be sure,
but not necessarily learning material. Recently I would suggest the
Llama's new soul mate, 

http://www.oreilly.com/catalog/lrnperlorm/

It will take you to the next level for sure.  The old soul mate, which I
really enjoyed at the time seems to have lost some of its luster, at
least in that ORA seems to have replaced it with the above,

http://www.oreilly.com/catalog/advperl/

The two above overlap a good deal. 

Having said that, the Camel is indispensable and should be on every Perl
programmers shelf. Naturally there is also Safari if you aren't into
being a zoo keeper like some of us (or don't have the funds)

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




threads in perl

2004-01-13 Thread Igor Ryaboy
Hi All!

I am running a multithread program and threads may stuck. I need to be able to 
terminate those threads after some defined period of time. I can't use a detach 
because I don't want to leave this thread run forever and I can't use join because the 
thread never ends. Any ideas? Please help :)

Igor

-Original Message-
From: zentara [mailto:[EMAIL PROTECTED]
Sent: Monday, October 13, 2003 8:19 PM
To: [EMAIL PROTECTED]
Subject: Re: FW: threads in perl


On Mon, 13 Oct 2003 18:29:09 +0200, [EMAIL PROTECTED] (Igor
Ryaboy) wrote:

>Very Nice , 
>There is only one unsolved issue here: Your program may exit with other threads are 
>still running , beside this I liked it very much. The actual solution you supplied is 
>the
> use of threads->self function.

Yeah I fixed this.
>#cleanup leftover running threads
>print "data exhausted, waiting for threads to finish\n";
>threads->list()->join;

Replace the above with:

#cleanup leftover running threads 
print "data exhausted, waiting for threads to finish\n";
while (1){
@running_threads = threads->list;
if (scalar(@running_threads) < 1){print "\nFinished\n";exit}else{next}
}

#


>Thanks you very much!!!
Your welcome, it was a learning experience for me too. :-)
>Igor
>BTW where can I get some documentation about threads::Pool?

Download the module from cpan. But I just checked out the latest
version of Threads::Pool and it only works with perl5.8.0-RC3 or
later. I installed 5.81 to test it, but 5.81 broke some other modules
I'm playing with. So.it's up to you.



Our body's 20 milligrams of beta radioactive Potassium 40
emit about 340 million neutrinos per day, which go at
lightspeed to the ends of the universe!..even thru the earth. 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Problems with Text::Iconv

2004-01-13 Thread Jan Eden
James Edward Gray II wrote:

>Since you mentioned earlier that you forgot to install the developer  
>tools, let me just mention that I've ran into problems building things  
>without them, because of missing header files and the like.  I'm not  
>saying that's your problem, I'm just sharing information.
>
>Were they not on a separate CD in Panther?  I honestly can't remember,  
>but they always have been before, I know.

I already got advice off-list about the developer tools and installed them from the 
separate CD. The main requisite for installing Perl modules is the make program, which 
is part of the developer tools.

Anyway, installing HTML::Parser worked fine, but Text::Iconv does not seem to be aware 
of the OS X file system.

Thanks,

Jan
-- 
The day Microsoft makes something that doesn't suck is the day they start selling 
vacuum cleaners.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Oreilly's "Learning Perl 3rd Edition"

2004-01-13 Thread u235sentinel
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?

Thanks!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: RFC: Package == class == object type

2004-01-13 Thread James Edward Gray II
On Jan 13, 2004, at 6:24 AM, Gary Stainburn wrote:

[snip background]

3) As everything else will be created from the Trainset instance, they 
will
have a link to it. This will be stored as $self->{_OWNER}. This will 
then
(hopefully) provide quick direct access to the Trainset variables 
(were Class
globals). I think I should be able to simply call something like
$self->{_OWNER}{_BLOCKS}
Or you could always do something like $self->{_Trainset}->get_blocks(), 
which is probably a little better style.  Always use methods when you 
can.

The example code (not tested yet) will create a long length of track 
(TCB1 and
TCB2), and a siding (S1).  It will then create a switch (Y-shape) 
point and
connect that to TCB2 and S1.

It will then create a signalbox, and in that signalbox create a lever 
to
control the set of points.

my $tset=Trainset->new;
$tset->add_track('TCB1','TCB');  # create 1st block of track
$tset->add_track('TCB2','TCB');  # create 2nd block of track
$tset->add_track('S1','TCB');# create Siding 1
An add_tracks() method might be handy.  What's that second parameter, 
if I may ask?

$points=$tset->add_point('GSP1','SWITCH'); # create switch point to 
siding

$tset->add_link('TCB1',0,'TCB2',0);	# link TCB1 (rear) to TCB2 
(advance)
$tset->add_link('TCB2',0,'GSP1',0);	# link TCB2 to points GSP1
$tset->add_link('S1',0,'GSP1',1);	# link Siding1 to points GSP1 
(offset1)
Again, what are the number parameters?

In my opinion the above could probably be done in one method call, 
which would make for a much nicer interface.  Heck, have it create 
tracks too if the don't exist.

$box=$tset->add_signalbox('Grosmont');   # Create Grosmont signalbox
$lever=$tset->add_lever('GS1');  # Create lever GS1
$box->use_lever($lever,0);   # Put lever1 in signalbox
Again, too much work.  The whole point of using the Trainset object as 
the code interface is to hide all these ugly details from users.  Does 
a signal box always have at least one lever?  Create it in the signal 
box constructor then.  Or modify add_signalbox() to accept a list of 
levers to add to it.  Do all that in the Trainset code.  That's what 
it's for.

# would be nice if I could replace the above with a shortcut like

#  $box=$tset->add_signalbox('Grosmont'); # create signalbox
#  $lever=$box->add_lever('GS1',0);  # create lever and put in s'box
Yes it would, but think bigger on the simplification scale.  Maybe you 
even leave all these low-level methods in place as there may be a time 
when I need them, but give me a high-level interface that makes my life 
easier most of the time.

$lever->set_use(0,$points,'TCB2');   # position 0 = select TCB2
$lever->set_use(1,$points,'S1'); # position 1 = select S1
$lever->throw(0);			# throw lever

I hope that this has shown (a) what I am hoping to aim for with this 
project
and (b) that I've taken on board the comments and hopefully 
implemented the
suggestions correctly.

Now the new questions.

1) I've put:

use base (Trainset::Trains Trainset::Track Trainset::Signals
  Trainset::Levers Trainset::Boxes);
inside Trainset.pm. Is this the correct way to call in the other 
classes?
No it's not.

use Trainset::Trains;
use Trainset::Track;
use Trainset::Signals;
use Trainset::Levers;
use Trainset::Boxes;
If  so, would this also give Trainset::Boxes access to
Trainset::Levers::add_lever to enable the shortcut I mentioned above?
After you switch to the code above sure, but I'm not sure it needs to.  
Trainset is the glue object.  Use it that way.  Trainsets' 
add_signalbox() should create the box, create the lever(s) and link 
them together.  Trainset::Boxes just needs to worry about itself, in 
construction at least.

2) What I do with the data will obviously depend on the program using 
my
object, but would probably be things like update the screen (Term, TK,
Win32), or to send instructions to a control system (e.g. throw points 
on
model railway).

What is the best method to pass control back to the program from 
within a
method?
I don't think I understand this question.  The obvious answer to me is 
return (exit the method).  Control will pass back to the caller at this 
point, as it always does.  If I misunderstood, please try explaining it 
again.

James

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



RFC: Prototyping, do or don't?

2004-01-13 Thread Dan Anderson
I am somewhat confused as to when to prototype a subroutine.  Under the
tips section Programming Perl makes the following points:

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?

Thanks in advance,

Dan



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Mysql.pm

2004-01-13 Thread Joe Stuart
I'm having problems with the Mysql.pm module. When I have the two
statements 

$dbh = Mysql->connect($host,$database,$username,$password);
my $sth = $dbh->query("insert into users values(NULL, 'Jon',
'Sterling', 'Doe', 24, '[EMAIL PROTECTED]')");

My problem is when I run it as root it works fine, but when I run it as
a regular user I get 
Mysql connect('database=userdb;host=localhost','joe_stuart',...)
failed: Can't connect to local MySQL server through socket
'/var/lib/mysql/mysql.sock' (13) at ./SendQuery.pl line 43
Can't call method "query" on an undefined value at ./SendQuery.pl line
81.

Any help would be appreciated

Thanks


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Problems with Text::Iconv

2004-01-13 Thread Wiggins d Anconia


> On Jan 13, 2004, at 8:10 AM, Jan Eden wrote:
> 
> > Hi,
> >
> > I just managed two install my first two modules, among them  
> > Text::Iconv. Now while the iconv utility works fine on my system, the  
> > module complains:
> >
> > dyld: perl Undefined symbols:
> > /Library/Perl/5.8.1/darwin-thread-multi-2level/auto/Text/Iconv/ 
> > Iconv.bundle undefined reference to _libiconv expected to be defined  
> > in a dynamic image
> > /Library/Perl/5.8.1/darwin-thread-multi-2level/auto/Text/Iconv/ 
> > Iconv.bundle undefined reference to _libiconv_close expected to be  
> > defined in a dynamic image
> > /Library/Perl/5.8.1/darwin-thread-multi-2level/auto/Text/Iconv/ 
> > Iconv.bundle undefined reference to _libiconv_open expected to be  
> > defined in a dynamic image
> > Trace/BPT trap
> >
> > Somehow it seems to miss the libraries. I am on Mac OS X (10.3.2). Any  
> > idea how I could fix the problem?
> 
> Since you mentioned earlier that you forgot to install the developer  
> tools, let me just mention that I've ran into problems building things  
> without them, because of missing header files and the like.  I'm not  
> saying that's your problem, I'm just sharing information.
> 
> Were they not on a separate CD in Panther?  I honestly can't remember,  
> but they always have been before, I know.
> 
> Good luck.
> 
> James
> 

Good point I didn't realize at first that the posts were from the same
person. You will need the developer tools installed, they are on a
separate CD in Panther (as before), but they renamed the CD from
developer tools, to XCode. Who knows why?  Surprised they didn't call it
iCode ;-)...  You should not need to reinstall the OS to install these
separate packages.

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Question about subroutines....

2004-01-13 Thread NYIMI Jose (BMB)
Yes it is !

C:\>perldoc -q "How do I pass filehandles between subroutines"
Found in C:\Perl\lib\pod\perlfaq5.pod
  How can I make a filehandle local to a subroutine?  How do I pass
filehandles between subroutines?  How do I make
 an array of filehandles?
As of perl5.6, open() autovivifies file and directory handles as
references if you pass it an uninitialized scalar variable. You can
then
pass these references just like any other scalar, and use them in
the
place of named handles.

open my$fh, $file_name;

open local $fh, $file_name;

print $fh "Hello World!\n";

process_file( $fh );

Before perl5.6, you had to deal with various typeglob idioms which
you
may see in older code.

open FILE, "> $filename";
process_typeglob(   *FILE );
process_reference( \*FILE );

sub process_typeglob  { local *FH = shift; print FH
"Typeglob!" }
sub process_reference { local $fh = shift; print $fh
"Reference!" }

If you want to create many anonymous handles, you should check out
the
Symbol or IO::Handle modules.


C:\>

-Original Message-
From: Gabor Urban [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 13, 2004 3:46 PM
To: [EMAIL PROTECTED]
Subject: Question about subroutines


Hi,

Is it possible to write a subroutine in Perl which accepts an open file
handle as parameter? At the moment it seems hopeless, but is it?

Regards

Gabaux
Linux is like a wigwam: no gates, no windows, and an apache inside!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




 DISCLAIMER 

"This e-mail and any attachment thereto may contain information which is confidential 
and/or protected by intellectual property rights and are intended for the sole use of 
the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, total or 
partial reproduction, communication or distribution in any form) by other persons than 
the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either by 
telephone or by e-mail and delete the material from any computer".

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our website at 
http://www.proximus.be or refer to any Proximus agent.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: New to PERL and Need Help

2004-01-13 Thread Thomas Bätzler
KENNETH JANUSZ <[EMAIL PROTECTED]> asked:

> Sent: Tuesday, January 13, 2004 2:57 PM
> I am new to the world of PERL and need help to get started.
[...]
> Any help with books for beginners or web sites will be 
> greatly appreciated.  Keep it very simple.

Go grab ActiveState's Perl port for windows at
http://www.activestate.com/Products/Download/Download.plex?id=ActivePerl
if you haven't done so already. You'll want the MSI package.

Once you've got it on your HD, open the installation
directory in the Explorer, find the HTML folder and
double click on index.html. Bookmark this page; it's 
your complete Perl documentation.

Search in the right pane for perlfaq2 and click it.
There's a list of recommended books on that page.

HTH,
Thomas

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Problems with Text::Iconv

2004-01-13 Thread James Edward Gray II
On Jan 13, 2004, at 8:10 AM, Jan Eden wrote:

Hi,

I just managed two install my first two modules, among them  
Text::Iconv. Now while the iconv utility works fine on my system, the  
module complains:

dyld: perl Undefined symbols:
/Library/Perl/5.8.1/darwin-thread-multi-2level/auto/Text/Iconv/ 
Iconv.bundle undefined reference to _libiconv expected to be defined  
in a dynamic image
/Library/Perl/5.8.1/darwin-thread-multi-2level/auto/Text/Iconv/ 
Iconv.bundle undefined reference to _libiconv_close expected to be  
defined in a dynamic image
/Library/Perl/5.8.1/darwin-thread-multi-2level/auto/Text/Iconv/ 
Iconv.bundle undefined reference to _libiconv_open expected to be  
defined in a dynamic image
Trace/BPT trap

Somehow it seems to miss the libraries. I am on Mac OS X (10.3.2). Any  
idea how I could fix the problem?
Since you mentioned earlier that you forgot to install the developer  
tools, let me just mention that I've ran into problems building things  
without them, because of missing header files and the like.  I'm not  
saying that's your problem, I'm just sharing information.

Were they not on a separate CD in Panther?  I honestly can't remember,  
but they always have been before, I know.

Good luck.

James

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Question about subroutines....

2004-01-13 Thread Gabor Urban
Hi,

Is it possible to write a subroutine in Perl which accepts an open
file handle as parameter? At the moment it seems hopeless, but is it?

Regards

Gabaux
Linux is like a wigwam: no gates, no windows, and an apache
inside!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Problems with Text::Iconv

2004-01-13 Thread Wiggins d Anconia


> Hi,
> 
> I just managed two install my first two modules, among them
Text::Iconv. Now while the iconv utility works fine on my system, the
module complains:
> 
> dyld: perl Undefined symbols:
>
/Library/Perl/5.8.1/darwin-thread-multi-2level/auto/Text/Iconv/Iconv.bundle
undefined reference to _libiconv expected to be defined in a dynamic image
>
/Library/Perl/5.8.1/darwin-thread-multi-2level/auto/Text/Iconv/Iconv.bundle
undefined reference to _libiconv_close expected to be defined in a
dynamic image
>
/Library/Perl/5.8.1/darwin-thread-multi-2level/auto/Text/Iconv/Iconv.bundle
undefined reference to _libiconv_open expected to be defined in a
dynamic image
> Trace/BPT trap
> 
> Somehow it seems to miss the libraries. I am on Mac OS X (10.3.2). Any
idea how I could fix the problem?
> 
> Thanks,
> 
> Jan
>

You may want to start with the archives of the Mac OS X list here:

http://www.mail-archive.com/macosx%40perl.org/

These kind of installation issues come up very frequently there. Sorry I
can't provide specific help I haven't been paying close enough attention
to the installation threads...

http://danconia.org


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: New to PERL and Need Help

2004-01-13 Thread NYIMI Jose (BMB)
A good starting place is :
http://learn.perl.org/

HTH,

José.

-Original Message-
From: KENNETH JANUSZ [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 13, 2004 2:57 PM
To: PERL Beginners
Subject: New to PERL and Need Help


I am new to the world of PERL and need help to get started.  I have the book: "PERL 
for Oracle DBA's".  But this has not helped me get started.  My background is Oracle 
as a DBA.  I have a good background with SQL*Plus and PL/SQL.  On my home PC I have XP 
Prof. and Oracle 9.2.  My Oracle supports PERL but I cannot get it to work.  It is not 
the latest release of PERL, but that is not a problem.  When I can get it to work I 
can update at that time.

Any help with books for beginners or web sites will be greatly appreciated.  Keep it 
very simple.

Thanks much,
Ken Janusz, CPIM


 DISCLAIMER 

"This e-mail and any attachment thereto may contain information which is confidential 
and/or protected by intellectual property rights and are intended for the sole use of 
the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, total or 
partial reproduction, communication or distribution in any form) by other persons than 
the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either by 
telephone or by e-mail and delete the material from any computer".

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our website at 
http://www.proximus.be or refer to any Proximus agent.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: New to PERL and Need Help

2004-01-13 Thread Paul Kraus
Start with http://safari.oreilly.com

Read learning perl. Quick and easy read.

Perl dbi

And programming perl.

Read all of the perldoc FAQ's.

 Paul Kraus
 ---
 PEL Supply Company
 Network Administrator

> -Original Message-
> From: KENNETH JANUSZ [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, January 13, 2004 8:57 AM
> To: PERL Beginners
> Subject: New to PERL and Need Help
> 
> I am new to the world of PERL and need help to get started.  I have the
> book: "PERL for Oracle DBA's".  But this has not helped me get started.
> My background is Oracle as a DBA.  I have a good background with SQL*Plus
> and PL/SQL.  On my home PC I have XP Prof. and Oracle 9.2.  My Oracle
> supports PERL but I cannot get it to work.  It is not the latest release
> of PERL, but that is not a problem.  When I can get it to work I can
> update at that time.
> 
> Any help with books for beginners or web sites will be greatly
> appreciated.  Keep it very simple.
> 
> Thanks much,
> Ken Janusz, CPIM


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Problems with Text::Iconv

2004-01-13 Thread Jan Eden
Hi,

I just managed two install my first two modules, among them Text::Iconv. Now while the 
iconv utility works fine on my system, the module complains:

dyld: perl Undefined symbols:
/Library/Perl/5.8.1/darwin-thread-multi-2level/auto/Text/Iconv/Iconv.bundle undefined 
reference to _libiconv expected to be defined in a dynamic image
/Library/Perl/5.8.1/darwin-thread-multi-2level/auto/Text/Iconv/Iconv.bundle undefined 
reference to _libiconv_close expected to be defined in a dynamic image
/Library/Perl/5.8.1/darwin-thread-multi-2level/auto/Text/Iconv/Iconv.bundle undefined 
reference to _libiconv_open expected to be defined in a dynamic image
Trace/BPT trap

Somehow it seems to miss the libraries. I am on Mac OS X (10.3.2). Any idea how I 
could fix the problem?

Thanks,

Jan
-- 
There are 10 kinds of people:  those who understand binary, and those who don't

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




New to PERL and Need Help

2004-01-13 Thread KENNETH JANUSZ
I am new to the world of PERL and need help to get started.  I have the book: "PERL 
for Oracle DBA's".  But this has not helped me get started.  My background is Oracle 
as a DBA.  I have a good background with SQL*Plus and PL/SQL.  On my home PC I have XP 
Prof. and Oracle 9.2.  My Oracle supports PERL but I cannot get it to work.  It is not 
the latest release of PERL, but that is not a problem.  When I can get it to work I 
can update at that time.

Any help with books for beginners or web sites will be greatly appreciated.  Keep it 
very simple.

Thanks much,
Ken Janusz, CPIM

RE: Clearing Arrays

2004-01-13 Thread Paul Kraus
I have read several perl books and that is a legitimate question. Why have a
resource like this list if your going persuade people not to use it. I have
ever seen this question asked.

@array = ();# empty array

Now it wouldn't hurt to check out learning perl or programming perl at
http://safari.oreilly.com


 HTH,
 
 Paul Kraus
 ---
 PEL Supply Company
 Network Administrator

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, January 13, 2004 8:32 AM
> To: Ramprasad A Padmanabhan
> Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Re: Clearing Arrays
> 
> 
> I thought this newsgroup was for beginners!
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>   Ramprasad A
>   Padmanabhan  To:
> [EMAIL PROTECTED], [EMAIL PROTECTED]
>   <[EMAIL PROTECTED]cc:
>   e.co.in> Subject:  Re: Clearing
> Arrays
> 
>   13/01/2004 10:37
> 
> 
> 
> 
> 
> 
> Support wrote:
> > Hi All
> > I have this little memory blockage again.
> > If I 'push' data from a database into an array to look/manipulate the
> > data and then using the same array name, 'push' data into the array from
> > another database, the data from the second DB file is added to the data
> > of the first. How can I clear the first lot of data and start a fresh
> > with an empty array ??
> > Cheers
> > Colin (from the future)
> >
> 
> I dont think you should use this newsgroup inlieu of a perl book.
> Please considering buying a good perl book and read about 'arrays' ,
> 'my' etc.
> 
> 
> Ram
> 
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>  
> 
> 
> 
> 
> 
> 
> 
> 
> 
> IMPORTANT NOTICE  This email (including any attachments) is meant only for
> the intended recipient. It may also contain confidential and privileged
> information.  If you are not the intended recipient, any reliance on, use,
> disclosure, distribution or copying of this email or attachments is
> strictly prohibited. Please notify the sender immediately by email if you
> have received this message by mistake and delete the email and all
> attachments.
> 
> Any views or opinions in this email are solely those of the author and do
> not necessarily represent those of Trinity Mirror PLC or its associated
> group companies (hereinafter referred to as "TM Group"). TM Group accept
> no liability for the content of this email, or for the consequences of any
> actions taken on the basis of the information provided, unless that
> information is subsequently confirmed in writing. Although every
> reasonable effort is made to keep its network free from viruses, TM Group
> accept no liability for any virus transmitted by this email or any
> attachments and the recipient should use up-to-date virus checking
> software. Email to or from this address may be subject to interception or
> monitoring for operational reasons or for lawful business practices.
> 
> Trinity Mirror PLC is the parent  company of the Trinity Mirror group of
> companies and is registered in England No 82548, with its address at One
> Canada Square, Canary Wharf, London E14 5AP.
> 
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>  



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Clearing Arrays

2004-01-13 Thread neill . taylor

I thought this newsgroup was for beginners!









   

  Ramprasad A  

  Padmanabhan  To:   [EMAIL PROTECTED], [EMAIL 
PROTECTED]
  <[EMAIL PROTECTED]cc:
 
  e.co.in> Subject:  Re: Clearing Arrays   

   

  13/01/2004 10:37 

   

   





Support wrote:
> Hi All
> I have this little memory blockage again.
> If I 'push' data from a database into an array to look/manipulate the
> data and then using the same array name, 'push' data into the array from
> another database, the data from the second DB file is added to the data
> of the first. How can I clear the first lot of data and start a fresh
> with an empty array ??
> Cheers
> Colin (from the future)
>

I dont think you should use this newsgroup inlieu of a perl book.
Please considering buying a good perl book and read about 'arrays' ,
'my' etc.


Ram


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 









IMPORTANT NOTICE  This email (including any attachments) is meant only for the 
intended recipient. It may also contain confidential and privileged information.  If 
you are not the intended recipient, any reliance on, use, disclosure, distribution or 
copying of this email or attachments is strictly prohibited. Please notify the sender 
immediately by email if you have received this message by mistake and delete the email 
and all attachments. 

Any views or opinions in this email are solely those of the author and do not 
necessarily represent those of Trinity Mirror PLC or its associated group companies 
(hereinafter referred to as "TM Group"). TM Group accept no liability for the content 
of this email, or for the consequences of any actions taken on the basis of the 
information provided, unless that information is subsequently confirmed in writing. 
Although every reasonable effort is made to keep its network free from viruses, TM 
Group accept no liability for any virus transmitted by this email or any attachments 
and the recipient should use up-to-date virus checking software. Email to or from this 
address may be subject to interception or monitoring for operational reasons or for 
lawful business practices. 

Trinity Mirror PLC is the parent  company of the Trinity Mirror group of companies and 
is registered in England No 82548, with its address at One Canada Square, Canary 
Wharf, London E14 5AP. 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: RFC: Package == class == object type

2004-01-13 Thread Gary Stainburn
On Monday 12 Jan 2004 9:48 pm, James Edward Gray II wrote:
> On Jan 12, 2004, at 2:42 PM, Rob Dixon wrote:
> > Hi Gary.
> >
> > I'm quite concerned about this thread. I think we could help you a
> > lot more if we had a better grasp of the problem: instead we've been
> > answering individual questions that you've raised, hoping that they
> > help you to achieve your goal but without any real idea of where
> > you're headed.
>
> and
>
> > Finally, throughout this thread we've been working with our imaginings
> > of your design and code. It would help you as well as the group if you
> > were to post some actual code - this will be much more descriptive of
> > your ideas than you may imagine, and will help us to address the real
> > problems you're facing.
>
> Rob's always so much smarter than I am.  Darn him!  :P
>
> I just wanted to say that I think this is an excellent idea.  I think
> if you could get across to us how a small Trainset works on minimal
> level (using each of your objects once or twice), we might be able to
> critique code you provide or roll some of our own.  I bet you would
> learn a lot more for that than all these guesses we've been making,
> just like Rob said.
>
> James

The primary purpose of this excercise is to learn OOP and for this reason I'm 
taking on board the comments passed in these threads, including creating a 
Trainset object and moving the other object types into seperate 
classes/packages - more below.

The purpose of the Trainset is to allow a railway to be modelled on a 
computer.  

Initial uses are:
* to emulate and eventually control a OO guage model train set.
* to provide a training environment to train signalmen.
* Possibly combine the both to allow training of signalmen through the use of 
a model train set.

I am currently learning to be a locomotive fireman on the North Yorkshire 
Moors Railway, a 18 mile preserved steam railway in North Yorkshire, England.  
On this railway are 4 quite complex signalboxes, the biggest one covering 
Grosmont station and approach has 3 platforms, 32 signals and 52 levers.  At 
any one time we can have 3 8-coach service trains running, plus other 
shunting activities goining on within station limits.

As you can imageine, it takes a very long time to be passed out as a 
signalman, and each person has to be passed seperately for each box.

I intend to build a Hornby OO guage model of the railway in the loft once I 
get time :), and would like a method of being able to run the full service 
over the model.  I therefore need a means of automating the control of the 
signals, points etc., as well as being able to drive the trains.

The ultimate goal would be to have a model of a signalbox's control space, and 
then connect that to the PC on which a signalman is being instructed.  I 
believe that the visual feedback would aid the training. (It would also be a 
great interactive display for the general public).

Now that I've given a glimpse at my goal, here's a glimpse of what I've 
gleened from these threads.

1) I'm going to organise the modules as:

Trainset.pm
Trainset/Track.pm
Trainset/Points.pm
Trainset/Signals.pm
Trainset/Levers.pm
Trainset/Boxes.pm

2) I'm going to create a Trainset object and have the instance own everything 
else

3) As everything else will be created from the Trainset instance, they will 
have a link to it. This will be stored as $self->{_OWNER}. This will then 
(hopefully) provide quick direct access to the Trainset variables (were Class 
globals). I think I should be able to simply call something like 
$self->{_OWNER}{_BLOCKS}


The example code (not tested yet) will create a long length of track (TCB1 and 
TCB2), and a siding (S1).  It will then create a switch (Y-shape) point and 
connect that to TCB2 and S1.

It will then create a signalbox, and in that signalbox create a lever to 
control the set of points.

my $tset=Trainset->new;
$tset->add_track('TCB1','TCB'); # create 1st block of track
$tset->add_track('TCB2','TCB'); # create 2nd block of track
$tset->add_track('S1','TCB');   # create Siding 1
$points=$tset->add_point('GSP1','SWITCH'); # create switch point to siding

$tset->add_link('TCB1',0,'TCB2',0); # link TCB1 (rear) to TCB2 (advance)
$tset->add_link('TCB2',0,'GSP1',0); # link TCB2 to points GSP1
$tset->add_link('S1',0,'GSP1',1);   # link Siding1 to points GSP1 (offset1)

$box=$tset->add_signalbox('Grosmont');  # Create Grosmont signalbox
$lever=$tset->add_lever('GS1'); # Create lever GS1
$box->use_lever($lever,0);  # Put lever1 in signalbox

# would be nice if I could replace the above with a shortcut like

#  $box=$tset->add_signalbox('Grosmont'); # create signalbox
#  $lever=$box->add_lever('GS1',0); # create lever and put in s'box

$lever->set_use(0,$points,'TCB2');  # position 0 = select TCB2
$lever->set_use(1,$points,'S1');# position 1 = select S1

$lever->throw(0);   # throw lever

I hope tha

Re: Clearing Arrays

2004-01-13 Thread Ramprasad A Padmanabhan
Support wrote:
Hi All
I have this little memory blockage again.
If I 'push' data from a database into an array to look/manipulate the 
data and then using the same array name, 'push' data into the array from 
another database, the data from the second DB file is added to the data 
of the first. How can I clear the first lot of data and start a fresh 
with an empty array ??
Cheers
Colin (from the future)

I dont think you should use this newsgroup inlieu of a perl book.
Please considering buying a good perl book and read about 'arrays' , 
'my' etc.

Ram

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



RE: beginners Digest 10 Jan 2004 18:25:16 -0000 Issue 1962

2004-01-13 Thread Dar, Imran
Please cancel my subscription

Imran Dar
Service Cost Management,
Centrica IS, London Road, Staines.
 
>  -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] 
> Sent: 10 January 2004 18:25
> To:   [EMAIL PROTECTED]
> Subject:  beginners Digest 10 Jan 2004 18:25:16 - Issue 1962
> 
>  << File: ATT775844.txt >>  << Message: RE: Use of FOR statement (OT and
> apologies)   >>  << Message: Re: Writing style >>  << Message: Re: Writing
> style >>  << Message: RE: sockets on an HPUX (thanks for the port
> scanner!)  >>  << Message: Re: sockets on an HPUX (thanks for the port
> scanner!) >>  << Message: RE: How to parse Microsoft Outlook Inbox >>  <<
> Message: RE: How to parse Microsoft Outlook Inbox >>  << Message: Image
> Magick >>  << Message: Re: Image Magick >>  << Message: Re: Image Magick
> >>  << Message: Re: Image Magick >>  << Message: Re: printf sprintf >>  <<
> Message: Re: sockets on an HPUX >>  << Message: Matching invalid
> characters in a URL >>  << Message: Re: Matching invalid characters in a
> URL >>  << Message: Re: Matching invalid characters in a URL >>  <<
> Message: Re: Matching invalid characters in a URL >>  << Message:
> Equivalent to iconv for encoding conversion >>  << Message: Re: Equivalent
> to iconv for encoding conversion >>  << Message: Re: pod::usage example
> help >>  << Message: qn about the reg expression. >>  << Message: Re: qn
> about the reg expression. >>  << Message: perl question >>  << Message:
> perl error - please help I'm lost >>  << Message: Leading zeroes >>  <<
> Message: Re: Leading zeroes >>  << Message: Re: Leading zeroes >>  <<
> Message: Cobol format conversion >>  << Message: Perl mapping solution >>
> << Message: Re: Perl mapping solution >> 



The information contained in or attached to this email is
intended only for the use of the individual or entity to
which it is addressed. If you are not the intended
recipient, or a person responsible for delivering it to the
intended recipient, you are not authorised to and must not
disclose, copy, distribute, or retain this message or any
part of it. It may contain information which is confidential
and/or covered by legal professional or other privilege (or
other rules or laws with similar effect in jurisdictions
outside England and Wales).
The views expressed in this email are not necessarily the
views of Centrica plc, and the company, its directors,
officers or employees make no representation or accept any
liability for its accuracy or completeness unless expressly
stated to the contrary.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Perl modules on Mac OS X

2004-01-13 Thread Jan Eden
Hi fellows,

I have a funny problem: When installing my OS (Mac OS 10.3), I did not realize that 
the 'make' utility was part of the developer tools (which I did not install).

Now neither the CPAN module nor the manual installation process for Perl modules work 
on my system - due to the missing 'make'. First idea: do a quick install for make! 
Good idea, but: The Mac OS X installation process (from CD) requires a complete 
reinstall since I already updated the OS to 10.3.2 in the meantime.

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,

Jan
-- 
How many Microsoft engineers does it take to screw in a lightbulb? None. They just 
redefine "dark" as the new standard.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]