RE : GD Module

2004-11-22 Thread Jose Nyimi
A few secondes search on word "GD"
from perl.com gives me the following link:
http://www.oreilly.com/openbook/cgi/ch06_03.html

HTH,

José.

> -Message d'origine-
> De : Custard, Carol N. [mailto:[EMAIL PROTECTED]
> Envoyé : lundi 22 novembre 2004 17:21
> À : [EMAIL PROTECTED]
> Objet : GD Module
> 
> Anyone have any tutorials on the GD Module - Graphing?
> 
> 
> 
> Carol Custard
> 
> West Interactive Corporation
> 
> Programmer Analyst
> 
> Direct: 402-716-0720
> 
> Ext: 116-0720
> 
> Stop Code W100-WIC-3W
> 
> [EMAIL PROTECTED] 
> 
> 




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




RE : Is try-catch a better method for handling errors ?

2004-12-04 Thread Jose Nyimi


> -Message d'origine-
> De : Jonathan Paton [mailto:[EMAIL PROTECTED]
> Envoyé : samedi 4 décembre 2004 20:08
> À : Nilay Puri, Noida; [EMAIL PROTECTED]
> Objet : Re: Is try-catch a better method for handling errors ?
> 
> Dear Nilay,
> 
> I strongly recommend using exceptions (what you call "try-catch"),
since
> you need to do something more complicated upon failure.
> 
> You can implement exceptions using eval, die and checking the return
> value of eval.  This is a rather ugly way to implement exceptions, but
> commonly used.  A better way is to use the Error module.
> 
> perldoc Error
> 
> Sidenote: Consider transactions if your DB supports them, depending on
> what you are doing.
> 
> Jonathan Paton

I don't like the Error module, it's to verbose ...
(remind me the eternal java debat on: checked and unchecked exceptions).

Though this is just my humble opinion.

I'm using eval and never heard around me that it's ugly :)

José.




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




Generate XML Schema from a relational table

2004-12-24 Thread Jose Nyimi
Hello,
 
Input : Oracle table
Output : XML Schema document file
 
I’m looking for information (module) on how to do this with Perl.
 
Any idea is welcome.
 
Thanks and Merry Chrismas 2005 !
 
José.


RE : Copying a hash-of-hashes

2004-12-30 Thread Jose Nyimi


> -Message d'origine-
> De : Peter Rabbitson [mailto:[EMAIL PROTECTED]
> Envoyé : jeudi 30 décembre 2004 04:58
> À : beginners@perl.org
> Objet : Copying a hash-of-hashes
> 
> Hello List,
> To explain the problem I am having, I wrote a simple snipet that
doesn't
> do
> anything meaningful other than illustrating the behaviour I want to
avoid:
> 
> my %hoh = (
> 1 => {
> a => 5, b => 5
> },
> 
> 2 => 5
>);
> 
> 
> my @res = &RANDOMSUB;  #call a random subroutine
> 
> print "$hoh{1}{a}  $hoh{2} \n";
> 
> 
> sub RANDOMSUB {
> my %hohcopy = %hoh;
> 
> $hohcopy{1}{a} = 2;
> $hohcopy{2} = 2;
> }
> 
> >From my understanding since in the subroutine I am working with a
local
> hash
> %hohcopy all the values assigned to it have no meaning in the main
body.
> However the print produces 2, 5 instead of the desired 5, 5. As far as
my
> understanding goes this is due to the fact that $hohcopy{1} holds a
> reference to $hoh{1} instead of recreating it's internal structure
> entirely
> from the root to the leaves while performing a copy.
> 
> The question is whether there is an elegant way to produce a complete
copy
> of a hash-of-hashes-of-hashes-...-of-hashes for internal subroutine
> purposes
> and make sure that all references will be translated properly as well,
> leaving the subroutine no ability to modify the main hash.
> 
> Thank you.
> 

Hello,

This is well known behavior.
Try google on "deep copy" ...

On elegant way I know to do a "deep copy" in Perl
is to use dclone method of Storable module.

Something à la:

use Storable qw(dclone);
my $hohcopy_ref = dclone \%hoh;

HTH,

José.



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




RE : xml

2005-01-04 Thread Jose Nyimi


> -Message d'origine-
> De : Todd W [mailto:[EMAIL PROTECTED]
> Envoyé : mardi 4 janvier 2005 18:49
> À : beginners@perl.org
> Objet : Re: xml
> 
> 
> "Brent Clark" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Hi
> >
> > I have been trying to get my perl to work with an xml doc (about 2
hours
> > new to xml).
> > I basically just want all the elements
> >
> > would anyone be so kind as too share a link of doc etc as how I can
> > takle this.
> >
> > Kind Regards and thanks in advance
> > Brent Clark
> >
> > =
> > my $file = get("http://currencysource.com/RSS/ZAR.xml";);
> >
> > foreach my $element ($file){
> > if ($element =~ /title/i){
> > print "$element";
> > }
> > }
> 
> Piece of cake whith XML::XPath:
> 
> [EMAIL PROTECTED] misc]$ cat parserss.pl
> use warnings;
> use strict;
> 
> use LWP::Simple;
> use XML::XPath;
> 
> my $url = 'http://currencysource.com/RSS/ZAR.xml';
> my $xml = LWP::Simple::get( $url );
> 
> my $xp  = XML::XPath->new( xml => $xml );
> 
> my $nodeset = $xp->find( '/rss/channel/item' );
> foreach my $node ( $nodeset->get_nodelist ) {
>   print $xp->findvalue( './title', $node ), "\n";
> }
> [EMAIL PROTECTED] misc]$ perl parserss.pl
> 1 ZAR = AED (0.649063)
> 1 ZAR = ARS (0.523159)
> 1 ZAR = AUD (0.226934)
> 1 ZAR = BHD (0.066453)
> ...
> 
> How cool is that?
> 

Yes it's cool !, but :)
Some issues may require caution:
1) you have to know in advance how the XML file is strutured
to pass this info ("/rss/channel/item" in this case) to Xpath.
2) you may need to validate the XML before processing it.
In that case an additional file beeing DTD or "XML Schema" will be
necessary.

Regards,

José.





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




RE : Perl program to convert system date to yymmdd

2005-03-03 Thread Jose Nyimi


> -Message d'origine-
> De : Wagner, David --- Senior Programmer Analyst --- WGO
> [mailto:[EMAIL PROTECTED]
> Envoyé : jeudi 3 mars 2005 21:40
> À : Nishi Prafull
> Cc : beginners@perl.org
> Objet : RE: Perl program to convert system date to yymmdd
> 
> Nishi Prafull wrote:
> > On Thu, 3 Mar 2005 12:12:35 -0800, Wagner, David --- Senior
Programmer
> > Analyst --- WGO <[EMAIL PROTECTED]> wrote:
> >> Nishi Prafull wrote:
> >>> HI:
> >>>
> >>> I want to write a perl script that would compute the date in the
> >>> format yymmdd(050303) and subsitute it for a variable in the perl
> >>> script. This variable is thereafter subsituted in a command that
> >>> will be run inside the script.
> >>>
> >>> myTest.pl
> >>>
> >>> var aDate;
> >>You can do it a number of ways, here is a start on one way:
> >>
> >> my @MyDateTime = ();
> >> @MyTime = localtime( time );
> >> $MyDateTime[4]++;   #months start at zero, so must add
1
> >> # # Now the array has the date and time info in the following
> >> elements: #012 3 45 6 7 8
> >> #   (sec, min, hour, mday, mon, year, wday, yday, isdst) # mday is
> >> Day of Month # year is number of eyars from 1900
> >> # wday is day of week: 0:Sun and 6: Sat
> >> # yday is number of days from 1 Jan
> >> # isdst if true then Daylight savings time is on
> >>So to get your date in the format:
> >> my $aDate = sprintf "%02d%02d%02d",
> >>$MyDateTime[5] % 100,
> >>% does a modulo against the
> >>year, so 105 comes out as 5,
> >> 106 as 6 $MyDateTime[4], $MyDateTime[4];
> >>
> >> $aDate should now have 050303
> >>
> >> Wags ;)
> > Hi:
> > Thanks.
> > I tried the above but it did not return the correct result
> > my @MyDateTime = ();
> > @MyTime = localtime(time);
>   Missed this and it should be @MyDateTime and not @MyTime
> 
> Also as part of your code, you should always use:
> 
> use strict;
> use warnings;
> 
>   By doing this it will cut down on the number of problems you run
> into.
> I made the program as :
> 
> #!perl
> 
> use strict;
> use warnings;
> 
> my @MyDateTime = ();
> @MyDateTime = localtime(time);
> $MyDateTime[4]++;
> my $someDate = sprintf "%02d%02d%02d",
> $MyDateTime[5]%100,
> $MyDateTime[4],$MyDateTime[4];

Typo ?
You twice $MyDateTime[4]
Souldn't be: $MyDateTime[4],$MyDateTime[3]; ?

You just lucky that today the month and day have same value 03 :-)

Regards,
José.



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




RE : RE : Perl program to convert system date to yymmdd

2005-03-03 Thread Jose Nyimi


> -Message d'origine-
> De : Nishi Prafull [mailto:[EMAIL PROTECTED]
> Envoyé : jeudi 3 mars 2005 23:12
> À : Wagner, David --- Senior Programmer Analyst --- WGO
> Cc : Jose Nyimi; beginners@perl.org
> Objet : Re: RE : Perl program to convert system date to yymmdd
> 
> Hi All:
> 
> Thanks for the replies.It works correctly.
> I need to do similar thing for extracting the time in the format hhmm
> ie if it 2:05 pm then i need to display 1405
> 
> If the date command returns
> Thu Mar  3 13:56:24 PST 2005
> then
> i need to convert the time format to
> 1356
> 
> Please let me know how I can do this.
> Thanks.

David has implicitly replied to this ;)

Anyway try this:

#!perl

use strict;
use warnings;

my($sec,$min,$hour)= localtime(time);
my $someTime = sprintf "%02d%02d",$hour,$min;
print "$someTime\n";

Regards,
José.



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




RE : Design Plugin System

2005-03-10 Thread Jose Nyimi


> -Message d'origine-
> De : Santiago Hirschfeld [mailto:[EMAIL PROTECTED]
> Envoyé : jeudi 10 mars 2005 21:58
> À : beginners@perl.org
> Objet : Design Plugin System
> 
> Hi everyone,
> 
> I'm pretty new to perl and i'm doing a program to organize music, I'd
> like to make a plugin system for the file formats, so i can just use
> the formats y ussually have, and not include a long list of "use" in
> my main program.
> I was thinking in create modules in MyProg/AudioFormats/ with names as
> Ogg.pm and then call them automattically in my main program (which
> should check for all existing files and then create a hash containing
> the extentions the plugin module manages and the module name (like
> ('ogg'  => 'Ogg', 'mp3' => 'Mp3',) )  and use some standard subs in
> every module (get_file_tag, get_know_extentions, set_file_tag).
> My idea is to call the right get_file_tag for every file, so
> MyProg::AudioFormats::Ogg::get_file_tag is called when an ogg file is
> used. And that is  what i don't know how to do =)
> 
> Any ideas?
> 
> Sorry for the bad english and the long post.
> 
> Thanks in advance.
> 

If You don't like a long list of "use Foo.pm",
you can dynamically load your module like this:

eval "require $plugin";
if($@){
die qq/Couldn't load plugin "$plugin", "$@"/;
}
else{
my $obj = $plugin->new();
$obj->$method($args);
}

Yes! $plugin, $obj, $method, $args can all be known only at runtime ;)

Cheers,
José.



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




RE : RE : Design Plugin System

2005-03-12 Thread Jose Nyimi


> -Message d'origine-
> De : Jose Nyimi [mailto:[EMAIL PROTECTED]
> Envoyé : jeudi 10 mars 2005 23:03
> À : 'Santiago Hirschfeld'; beginners@perl.org
> Objet : RE : Design Plugin System
> 
> 
> 
> > -Message d'origine-
> > De : Santiago Hirschfeld [mailto:[EMAIL PROTECTED]
> > Envoyé : jeudi 10 mars 2005 21:58
> > À : beginners@perl.org
> > Objet : Design Plugin System
> >
> > Hi everyone,
> >
> > I'm pretty new to perl and i'm doing a program to organize music,
I'd
> > like to make a plugin system for the file formats, so i can just use
> > the formats y ussually have, and not include a long list of "use" in
> > my main program.
> > I was thinking in create modules in MyProg/AudioFormats/ with names
as
> > Ogg.pm and then call them automattically in my main program (which
> > should check for all existing files and then create a hash
containing
> > the extentions the plugin module manages and the module name (like
> > ('ogg'  => 'Ogg', 'mp3' => 'Mp3',) )  and use some standard subs in
> > every module (get_file_tag, get_know_extentions, set_file_tag).
> > My idea is to call the right get_file_tag for every file, so
> > MyProg::AudioFormats::Ogg::get_file_tag is called when an ogg file
is
> > used. And that is  what i don't know how to do =)
> >
> > Any ideas?
> >
> > Sorry for the bad english and the long post.
> >
> > Thanks in advance.
> >
> 
> If You don't like a long list of "use Foo.pm",
> you can dynamically load your module like this:
> 
> eval "require $plugin";
> if($@){
>   die qq/Couldn't load plugin "$plugin", "$@"/;
> }
> else{
>   my $obj = $plugin->new();
>   $obj->$method($args);
> }
> 
> Yes! $plugin, $obj, $method, $args can all be known only at runtime ;)
> 
> Cheers,
> José.

If you don't like the "eval" approach, here is an alternative:

use UNIVERSAL::require;
$plugin->require;
#exception handling goes here

For more info have a look to the UNIVERSAL::require module at:
http://search.cpan.org/~mschwern/UNIVERSAL-exports-0.03/lib/UNIVERSAL/re
quire.pm

No need to install the module yourself, it comes with your Perl dist.
(at least I found it in my perl5.8.6 from activestate)

BR,
José.




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




RE : build perl modules

2005-03-16 Thread Jose Nyimi


> -Message d'origine-
> De : Charles K. Clarkson [mailto:[EMAIL PROTECTED]
> Envoyé : mercredi 16 mars 2005 19:27
> À : beginners@perl.org
> Objet : RE: build perl modules
> 
> What you are describing is called "exporting" (or "importing" --
> depending on how you look at it.). There is a module which probably
> came with your perl distribution. It is named Exporter.pm and it will
> ease building modules like the one you describe. Read its
> documentation for more details.
> 
> 
> Let's begin writing our new module with a subroutine we will
> probably rarely use, but hate to have to rewrite each time we need
> it. The truth is, it is not hard to write, just hard to remember.
> 
> sub Identity {
> return @_;
> }
> 
> Wow. That's a long one. We are now ready to create the module.
> 
> package SpecialSubs;
> 
> sub Identity {
> return @_;
> }
> 
> 1;
> 
> This module is all we really need. Create a file like this
> and name it "SpecialSubs.pm". Come back when your done. The "1;" at
> the end is very important. It is needed on all modules.
> 
> =
> 
> Okay, you're back. Now let's create a script in our favorite
> editor and run it.
> 
> #!/usr/bin/perl
> 
> use strict;
> use warnings;
> 
> use SpecialSubs;
> 
> print SpecialSubs::Identity( 'foo' );
> 
> __END__
> 
> 
> Prefixing every sub with "SpecialSubs::" could get old quick.
> When we "use" a module a series of events occur. One of those events
> is running a subroutine named "import" if it is present.
> 
> Let's go back to the module and add an "import" sub
> 
> package SpecialSubs;
> 
> sub import {
>   print "This is the import sub running automatically\n";;
> }
> 
> 
> sub Identity {
> return  @_;
> }
> 
> 1;
> 
> We'll also change our script.
> 
> #!/usr/bin/perl
> 
> use strict;
> use warnings;
> 
> use SpecialSubs;
> 
> __END__
> 
> Run this and you'll see that the import sub is called
> automatically. We can use the import sub to "import"
> subroutines into your script.
> 
> 
> The caller() function from perl will tell us the details
> about how this module was called.
> 
> package SpecialSubs;
> 
> sub import {
> my( $name_space, $script, $line_number ) = caller();
> printf qq(%s "use"d by %s on line %s in package "%s".\n),
> 'SpecialSubs::import()',
> $script,
> $line_number,
> $name_space;
> }
> 
> 
> sub Identity {
> return  @_;
> }
> 
> 1;
> 
> Running our script now reveals which package has called
> SpecialSubs.pm. We can get just the name space of the caller
> with this.
> 
> package SpecialSubs;
> 
> sub import {
> my $name_space = caller();
> print $name_space;
> }
> 
> 
> sub Identity {
> return  @_;
> }
> 
> 1;
> 
> Knowing the name space of the caller, we can import items
> into it's name space. We need to use symbolic references here.
> Usually, new perl programmers should avoid symbolic references.
> 
> package SpecialSubs;
> 
> sub import {
> my $caller = caller();
> *{$caller . '::Identity'} = \&Identity;
> }
> 
> 
> sub Identity {
> return  @_;
> }
> 
> 1;
> 
> If there were 100 subs in the module this could get a
> little long and sometimes we need more control. For example,
> we might need just two subs and are now stuck with 98 subs we
> don't need. We also didn't do any error checking.
> 
> Exporter.pm comes to the rescue. Using this module to
> build our modules makes life more simple.
> 
> 
> package SpecialSubs;
> 
> require Exporter;
> @ISA = qw(Exporter);
> 
> @EXPORT_OK = qw( Identity );
> 
> sub Identity {
> return  @_;
> }
> 
> 1;
> 
> 
> 
> #!/usr/bin/perl
> 
> use strict;
> use warnings;
> 
> use SpecialSubs qw( Identity );
> 
> print Identity( 'foo' );
> 
> __END__
> 
> 
> If you'd rather use strict and warnings in the module
> you'll need this.
> 
> package SpecialSubs;
> 
> use strict;
> use warnings;
> 
> use vars qw( @ISA @EXPORT_OK );
> 
> require Exporter;
> @ISA = qw(Exporter);
> 
> @EXPORT_OK = qw( Identity );
> 
> sub Identity {
> return  @_;
> }
> 
> 1;
> 
> 
> OR:
> 
> package SpecialSubs;
> 
> use strict;
> use warnings;
> 
> our( qw( @ISA @EXPORT_OK ) );
> 
> require Exporter;
> @ISA = qw(Exporter);
> 
> @EXPORT_OK = qw( Identity );
> 
> sub Identity {
> return  @_;
> }
> 
> 1;
> 
> 
> HTH,
> 
> Charles K. Clarkson
> --
> Mobile Homes Specialist
> 254 968-8328

+1
Nicely explained ;)

Someone who want to avoid writing inheritance (@ISA) from Exporter,
can write something like:

package SpecialSubs;

use strict;
use warnings;
use UNIVERSAL::exports;

@EXPORT_OK = qw( Identity );

sub Identity {
return  @_;
}

1;

for more info, see:
http://search.cpan.org/~mschwern/UNIVERSAL-exports-0.03


José.



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




RE : Problems matching or parsing with delimiters in text

2005-03-28 Thread Jose Nyimi


> -Message d'origine-
> De : KEVIN ZEMBOWER [mailto:[EMAIL PROTECTED]
> Envoyé : lundi 28 mars 2005 18:13
> À : beginners@perl.org
> Objet : Problems matching or parsing with delimiters in text
> 
> I'm trying to read in text lines from a file that look like this:
> "B-B01","Eng","Binder for Complete Set of Population Reports",13,0
> "C-CD01","Eng","The Condoms CD-ROM",12,1
> "F-J41a","Fre",,13,1
> "F-J41a","SPA",,13,1
> "M-FC01","Eng","Africa Flip Charts- Planning Your Family (E,F,
> Swahili)(12""x9"")",7,1
> "M-FC01","Fre","Africa Flip Charts- Planning Your Family (E,F,
> Swahili)(12""x9"")",7,1
> 
> The first two lines are typical of most of the file. The second two
have a
> blank third field and the last two show embedded commas and escaped
double
> quotes in the third field. This is an output of another program, but I
can
> filter it and make substitutions if that makes anything easier.
> 
> I'm trying to parse it with these statements:
> while (<>) { # While there are more records in the inventory export
file

I heven't read the complete post but ;)
your file seems to have a well known format called
CSV (Comma Separated Value).
You don't need to reinvent the wheel writing yourself a parser
for such files, since proven solutions (modules) already exist
doing it for you.

Have a look to CPAN (http://search.cpan.org) search for Text::CVS.

Text::CVS::Simple seems interesting 
http://search.cpan.org/~tmtm/Text-CSV-Simple-0.20/

Install and try ...

HTH,
José.




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




RE : simple server app

2005-03-29 Thread Jose Nyimi


> -Message d'origine-
> De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Envoyé : mardi 29 mars 2005 16:48
> À : Peter Rabbitson
> Cc : beginners@perl.org
> Objet : Re: simple server app
> 
> 
> 
> - Original Message -
> From: Peter Rabbitson <[EMAIL PROTECTED]>
> Date: Tuesday, March 29, 2005 5:04 am
> Subject: simple server app
> 
> > Hi everyone,
> Hello,
> 
> >Here is my situation. I have a windows system which
> > continuoslyruns a perl script, which utilizing Win32::Process and
> > Win32::Setupsup is
> > controlling a windows only app and when triggered makes it spit
> > export files
> > to a samba network share. From there on my main process which runs
> > off a CGI
> > under linux uses those files for internal purposes and so on and
> > so forth. I
> > would like to be able to trigger all exports remotely from the linux
> > machine. In order to do this I need to communicate 4 strings to
> > the process
> > running on the windows machine. No information should be returned
> > back,except maybe a 0/1 flag signifying failure/completion. I
> > looked into SOAP
> > and since I am not running Apache or IIS or anything else on the
> > windows box
> > for increased stability I started thinking about something like
> > SOAP::Transport::TCP (not much docs to look at unfortunately). It
> > seems to
> > be able to do the job, however I feel it is an overkill for
> > communicating 4
> > strings one way and 1 string the other way...  I would appreciate
> > if more
> > seasoned programmers share suggestions on how would they approach
> > such a
> > problem (maybe there is something way simpler than SOAP that I
> > simply do not
> > know about).
>  If it's just a bit of data exchange you can use a simple server to
> accomplish this task, and possibly build your own protocol for data
> exchange. Below is a simple server example.
> 
> #!PERL
> 
> use warnings;
> use strict;
> use IO::Socket::INET;
> $|=1;
> my $sock = IO::Socket::INET->new( Listen=> 5,
>  LocalAddr => '127.0.0.1',
>  LocalPort => 9000,
>  Proto => 'tcp') or die "ERROR:
$!\n";
> 
> 
> if( my $session = $sock->accept() ){
> 
>   print "connection from: ",$session->peerhost,"\n";
>   my $msg=<$session>;
>   print "Received: $msg";
> }
> else{
>   die "Error on Socket $!\n";
> }
> 
> 
> >
> > Thank you
> your welcome, hope it helps let us know if you have more issue's at
hand.
> Mar G.
> 
> >

+1
I second this approach.
Going for the full RPC::XML (or SOAP::Lite) just to exchange
4 strings seems an overkill to me.
You don't need HTTP transport since I suppose your two boxes
(Linux and Windows) belong to the same LAN ...
A simple server like the one suggested here should be enough.

Just my 0.02

BR,
José.



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




RE : simple server app

2005-03-29 Thread Jose Nyimi


> -Message d'origine-
> De : Peter Rabbitson [mailto:[EMAIL PROTECTED]
> Envoyé : mardi 29 mars 2005 12:05
> À : beginners@perl.org
> Objet : simple server app
> 
> Hi everyone, Here is my situation. I have a windows system which
> continuosly
> runs a perl script, which utilizing Win32::Process and Win32::Setupsup
is
> controlling a windows only app and when triggered makes it spit export
> files
> to a samba network share. From there on my main process which runs off
a
> CGI
> under linux uses those files for internal purposes and so on and so
forth.
> I
> would like to be able to trigger all exports remotely from the linux
> machine. In order to do this I need to communicate 4 strings to the
> process
> running on the windows machine. No information should be returned
back,
> except maybe a 0/1 flag signifying failure/completion. I looked into
SOAP
> and since I am not running Apache or IIS or anything else on the
windows
> box
> for increased stability I started thinking about something like
> SOAP::Transport::TCP (not much docs to look at unfortunately). It
seems to
> be able to do the job, however I feel it is an overkill for
communicating
> 4
> strings one way and 1 string the other way...  I would appreciate if
more
> seasoned programmers share suggestions on how would they approach such
a
> problem (maybe there is something way simpler than SOAP that I simply
do
> not
> know about).
> 
> Thank you
> 
> Peter
> 

Net::EasyTCP is an other alternative ...
http://search.cpan.org/~mnaguib/EasyTCP-0.26

BR,
José.



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




RE : trying to create my first exe with pp

2005-04-09 Thread Jose Nyimi


> -Message d'origine-
> De : Matthew Ryan [mailto:[EMAIL PROTECTED] 
> Envoyé : samedi 9 avril 2005 01:19
> À : beginners@perl.org
> Objet : trying to create my first exe with pp
> 
> 
> I am trying to use pp to create an exe file. I have installed 
> PAR with ppm and installed ScanDeps.pm from cpan with nmake, 
> all tests worked and install went fine. Now when running pp 
> with the following code I get the following error. Can some 
> one please tell me what is happening here.
> 
> C:\>pp -o printit print.pl
> Compress::Zlib object version 1.22 does not match bootstrap 
> parameter 1.16 at /loader/0x9c1194/DynaLoader.pm line 225. 
> Compilation failed in require at 
> /loader/0x9c1194/Archive/Zip.pm line 24. BEGIN 
> failed--compilation aborted at 
> /loader/0x9c1194/Archive/Zip.pm line 24. Compilation failed 
> in require at par.pl line 252. 
> 
> When DynaLoader comes up everything starts to look like a 
> foreign language.

Better ask to PAR list
http://www.mail-archive.com/par@perl.org/info.html

Or search its archive.
I have tried a search on
"does not match bootstrap parameter"
Here is the result:
http://www.mail-archive.com/cgi-bin/htsearch?method=and&format=short&con
fig=par_perl_org&restrict=&exclude=&words=does+not+match+bootstrap+param
eter

So your problem seems to be a well known one that has been fixed.

HTH,
José.



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




Re: sub declarations

2005-04-09 Thread Jose Nyimi
Manish Sapariya a écrit :
Thanks fxn,
This certainly should help.
List,
Is there a search tool which can give me perldoc pages
given a string.
Try
http://www.perldoc.com
or
http://www.perlpod.com
BR,
José.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



RE : Capturing the integer return value of a "C" program, called inside perl script

2005-04-10 Thread Jose Nyimi


> -Message d'origine-
> De : Ambikesh Chaurasia [mailto:[EMAIL PROTECTED] 
> Envoyé : dimanche 10 avril 2005 18:30
> À : perl
> Objet : Capturing the integer return value of a "C" program, 
> called inside perl script
> 
> 
> Hi Guys,
> 
> I want to capture the return value of a "C" program
> called inside a perl script. How to do this??
> 
> Let say I have a "C" program named "val_100.c" .
> 
> //val_100.c
> #include 
> int main()
> {
>   return 100;
> }
> 
> I want to call this program from a perl script and
> want to store the return value "100" in the perl
> script. (Please note that I do not want to capture the
> running status of the program).
> 
> Please guide me how to do this in a perl script.

perldoc -q backticks

my $ret_val = `c_prog_call`;

HTH,
José.



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




RE : Anyone using AJAX

2005-04-15 Thread Jose Nyimi


> -Message d'origine-
> De : Ramprasad A Padmanabhan [mailto:[EMAIL PROTECTED] 
> Envoyé : vendredi 15 avril 2005 08:32
> À : perl beginners
> Objet : Anyone using AJAX
> 
> 
> Hi, 
>   I am trying to learn using Ajax instead of form-oriented 
> perl-cgi. ( fascinated with gmail :-) ) I have already 
> started with  CPAN modules Catalyst::Plugin::Ajax and 
> HTML::Ajax. Do we have any good documenation / tool that can help me
> 

Ajax is an appealing concept
but i haven't got yet an opportunity to use it.

I would like just to warn you that Sebastian (Author of Catalyst)
Has recently announced that HTML::Ajax is obsolete
As you can read at
http://lists.rawmode.org/pipermail/catalyst/2005-April/000204.html

Apparently Ruby on Rails people are very active on
that area already so no need to re-invent the wheel.
HTML::Ajax will be replaced by HTML::Prototype

For those of you asking what Ajax is all about,
here some links I found usefull:
http://www.adaptivepath.com/publications/essays/archives/000385.php
https://bpcatalog.dev.java.net/nonav/ajax/ajax.html
http://theserverside.com/news/thread.tss?thread_id=33319

Cheers,
José.




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




RE : basic class problem

2005-04-24 Thread Jose Nyimi


> -Message d'origine-
> De : Graeme McLaren [mailto:[EMAIL PROTECTED] 
> Envoyé : dimanche 24 avril 2005 19:01
> À : beginners@perl.org
> Objet : basic class problem
> 
> 
> Hi all I'm trying to write a basic class that will contain some 
> configuration details, unfortunately it bombs out and doesn't 
> do anything.
> 
> ### start of class 
> ### #configuration.pm package 
> configuration; use strict;
> 
> 
> sub new{
> my $class=shift;
> my $self=shift;
> 
> bless($self, $class);
> return $self;
> }
> 
> sub get_conf{
> my $self=shift;
> my %conf=(
>   db_name="bla1",
> username="bla2",
> password="bla3"
> 
> );
> 
> return \%conf;
> 
> }
> 
> 1;
>  end of class 
> 
> 
> Mt CGI script is this:
> 
> # CGI Script ### 
> #!/usr/bin/perl -w use strict; use configuration;
> 
> print "Content-type: text/html\n\n";
> 
> my $conf=configuration->new;
> my $conf->get_conf;
> 
> print "$conf->{'db_name'}"; 

my $obj=configuration->new;
my $conf=$obj->get_conf; 
print $conf->{'db_name'};#perldoc Data::Dumper BTW

HTH,
José.



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




RE : what is the MVC all about

2005-06-14 Thread Jose Nyimi


> -Message d'origine-
> De : Ramprasad A Padmanabhan [mailto:[EMAIL PROTECTED] 
> Envoyé : mardi 14 juin 2005 16:39
> À : beginners@perl.org
> Objet : what is the MVC all about
> 
> 
> hi,
>I have been lately reading a lot of stuff about perl 
> catalyst with MVC I am still not clear about practical use of 
> MVC's Can someone provide pointers about MVC and where they 
> are best used ?
> 

I liked a lot thoughts on MVC from Andy Wardly (Template Toolkit Author,
tt2.org):

"I suggest that a clear separation of concerns is what is really
important, and while MVC is one way of achieving it, it is not the only
way. By concentrating too closely on an MVC architecture, it is possible
to overlook other important aspects of the system that warrant clear
separation."

"What the MVC-for-the-web crowd are really trying to achieve is a clear
separation of concerns. Put your database code in one place, your
application code in another, your presentation code in a third place.
That way, you can chop and change different elements at will, hopefully
without affecting the other parts (depending on how well your concerns
are separated, of course). This is common sense and good practice. MVC
achieves this separation of concerns as a by-product of clearly
separating inputs (controls) and outputs (views).
So in my opinion, it is the separation of concerns that is important
rather than the MVC design pattern in particular."

Quoted from
http://wardley.org/computers/web/mvc.html

HTH,
José.



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




RE : route STDOUT to file

2005-06-25 Thread Jose Nyimi


> -Message d'origine-
> De : [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] De la part de zentara
> Envoyé : samedi 25 juin 2005 13:36
> À : beginners@perl.org
> Objet : Re: route STDOUT to file
> 
> 
> There are a whole bunch of different ways, ...
> 

Here yet another one ;)

#!/usr/bin/perl
use strict;
use warnings;
use IO::Handle;

{
 local *STDOUT;
 local *STDERR;
 local *FILE;

 open FILE, ">log.txt" || die "Cannot write to log file!";
 open STDOUT, ">&FILE" || die "Cannot redirect STDOUT";
 open STDERR, ">&FILE" || die "Cannot redirect STDERR";

 STDOUT->autoflush(1);
 STDERR->autoflush(1);

 print STDOUT "A\n"; #to log.txt
 print STDERR "B\n"; #to log.txt
}

#after above {}, STDOUT and STDERR
#go back their original condition
print STDOUT "C\n"; #on the console
print STDERR "D\n"; #on the console

R,
José.



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




Catalyst movies!

2005-07-15 Thread Jose Nyimi
Hi,
Maybe you are interested as well ;)

Rgds,
José.

-Message d'origine-
De : [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] De la part de
Sebastian Riedel
Envoyé : vendredi 15 juillet 2005 17:42
À : [EMAIL PROTECTED]
Cc : mason-Users; templates@template-toolkit.org; 
cgiapp@lists.erlbaum.net; [EMAIL PROTECTED]
Objet : [Maypole] Catalyst movies!
 
 
Hi,
Maybe you are interested in seeing some more about Catalyst 
too, just  in case you're not on the Catalyst list or PerlMonks.
Here are some movies showing it in action.
 
http://dev.catalyst.perl.org/wiki/Movies

http://breen.irt.drexel.edu/mirrors/catalyst/vid/catalyst_auto_complete_
take1.mov
http://www.dunkelheit.at/catalyst/catalyst_auto_complete_take1.mov

http://users.ox.ac.uk/~oliver/data/files/catalyst_scaffolding_with_cruds
_take1.mov
http://www.dunkelheit.at/catalyst/catalyst_scaffolding_with_cruds_take1.
mov


Have fun!

--
sebastian

___
Catalyst mailing list
[EMAIL PROTECTED] 
http://lists.rawmode.org/mailman/listinfo/catalyst



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




RE : Forcing array context

2005-08-20 Thread Jose Nyimi
Try this:

echo hello: world | perl -lne '$aref = [ split(/:/, $_) ]; print $aref'

[] synthax gives a ref to the array returned by split()

HTH,
José.

-Message d'origine-
De : Binish A R [mailto:[EMAIL PROTECTED] 
Envoyé : samedi 20 août 2005 17:15
À : Perl Beginners
Objet : Forcing array context


How can I force array context ... 
like

# echo hello: world | perl -lne '$aref = split(/:/, $_); print $aref'

but thatz giving the length of the array ... I want $aref to be a
reference ...
How is that possible ??

A workaround is to use the following

# echo hello: world | perl -lne '@ar = split(/:/, $_); $aref = [EMAIL 
PROTECTED];'

But I'm not satisfied with that as I've to use an extra variable @ar ...
:(

Any help ...
 
 

-- 



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




RE : Is it possible to force a particular order in a hash?

2005-09-22 Thread Jose Nyimi


> -Message d'origine-
> De : John W. Krahn [mailto:[EMAIL PROTECTED] 
> Envoyé : jeudi 22 septembre 2005 23:26
> À : Perl Beginners
> Objet : Re: Is it possible to force a particular order in a hash?
> 
> 
> Dave Adams wrote:
> > I have a hash that I need to use later and display some values in a 
> > particular order.  Perl comes up with its own way of 
> ordering it but I 
> > am wondering if I can instruct perl to have it listed in 
> the way that 
> > I want.
> 
> You could store the ordered keys in a separate array or you 
> could use the Tie::IxHash module.

I'm wondering if Tie::IxHash is suitable here.
Indeed, from the module doc i'm reading the following:

"This Perl module implements Perl hashes that preserve
the order in which the hash elements were added".

It seems that the OP here wants to "customize" the order,
not only preserve the order in which elements were added during hash
contruction.

Input order: AUTHOR LANGUAGE TITLE
Desired output order: TITLE AUTHOR LANGUAGE

Suggestion from Waldemar Jankowski looks promizing ...

Regards,
José.



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




RE : LLama and camels books

2005-10-13 Thread Jose Nyimi


> -Message d'origine-
> De : Dion Markus [mailto:[EMAIL PROTECTED] 
> Envoyé : jeudi 13 octobre 2005 23:09
> À : beginners@perl.org
> Objet : LLama and camels books
> 
> 
> Hi all I am totaly new to Perl and programming.
> I am Dion Markus from the netherlands and i would like to 
> learn perl. I have the llama and camel books but when i 
> reached the second chapter 
> of learning perl i went "insane" (more confused bytheway").
> I didnt get the clue of all of it and i found i really really hard to 
> read and understand.
> I googled and googled alot for beginners perl tuts and notes but i 
> really dont know where to start.
> Maybe some of you want to show me some online books are tuts where to 
> start and read and. Until i can start with the Llama and Perl 
> books. I dont have any any experiance with programming. So i 
> really dont know 
> what the heck variables, loops, subroutines, and arrays are and other 
> programming basics.
> Programmings sounds like a lot of fun to me and I would like 
> to learn it.
> 
> I hope you guys help me.
> Masoool (bye)
> 

http://www.perl.org/books/beginning-perl/

HTH,
José.


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




RE : DBD for SQL Server?

2004-05-12 Thread Jose Nyimi


> -Message d'origine-
> De : Richard Crawford [mailto:[EMAIL PROTECTED]
> Envoyé : mercredi 12 mai 2004 22:17
> À : NYIMI Jose (BMB)
> Cc : Alok Bhatt; [EMAIL PROTECTED]
> Objet : Re: DBD for SQL Server?
> 
> NYIMI Jose (BMB) wrote:
> 
> >
> >>-Original Message-
> >>From: Alok Bhatt [mailto:[EMAIL PROTECTED]
> >>Sent: Wednesday, May 12, 2004 11:49 AM
> >>To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> >>Subject: Re: DBD for SQL Server?
> >>
> >>
> >>
> >>--- Richard Crawford <[EMAIL PROTECTED]>
> >>wrote:
> >>
> >>>Is there a DBD for SQL Server so that I can connect
> >>>to our SQL Server
> >>>2000 database with DBI?  I've hunted all over CPAN
> >>>but I can't seem to
> >>>find one.
> >>
> >>Windows uses the Open Database Connectivity (ODBC)
> >>Model. You can connect to an MS-SQL server using
> >>Win32::ODBC, available at
> >
> >
> > Then you will no longer be using DBI API (what OP wanted) !
> >
> > The advantage of DBD::ODBC (or DBD::ADO )
> > Is the portability of your code since you
> > Will be using the same api syntax regarless the
> > The database driver (DBD) you are dealing with behind DBI.
> >
> > The connection is always
> > my $dbh=DBI->connect(...);
> >
> > Not a new api like:
> > $Data = new Win32::ODBC(...);
> > Which obviously will not work if you need
> > To use your same code on a database running on unix box.
> >
> > HTH,
> >
> > José.
> 
> I've learned that in order to use DBD::ODBC I will still need to
install
> an ODBC driver on the machine (which is actually running Solaris 9).
> Not a problem, if I can find one.

http://www.unixodbc.org/

José.



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




RE : Extracting attachment from mail

2004-05-13 Thread Jose Nyimi


> -Message d'origine-
> De : Wiggins d Anconia [mailto:[EMAIL PROTECTED]
> Envoyé : jeudi 13 mai 2004 18:02
> À : NYIMI Jose (BMB); [EMAIL PROTECTED]
> Objet : RE: Extracting attachment from mail
> 
> > > -Original Message-
> > > From: NYIMI Jose (BMB)
> > > Sent: Thursday, May 13, 2004 11:23 AM
> > > To: [EMAIL PROTECTED]
> > > Subject: Extracting attachment from mail
> > >
> > >
> > > Hello,
> > >
> > > I need to write a perl script that will run on solaris and
> > > the job of this script will be :
> > >
> > > - read a mail from a predefined shared mail box
> > > (Outlook/Exchange Server)
> > > - extract the mail attachment (text file)
> > > - parse the content
> > > - create an excel sheet (same content)
> > >
> > > Any input is welcome ...
> > >
> > > José.
> > >
> > >
> >
> >
> > One more info about the flow:
> >
> > * the original mail comes from an external user (outside our
company):
> no problem to that ...
> > * a MS Outlook rule will be set to forward this mail (with
attachment)
> to an unix user (solaris): good ?
> > * mails received by this unix user are all stored in the file named
> /var/mail/username
> > * a perl script will be scheduled once per day to:
> 
> It sounds like you have a fair amount of control. Out of curiousity
have
> you considered having an alias established on the solaris box that
> rather than dumps the message to a mail box, instead pipes it to a
> program (aka your perl program).  That program can then parse the
> message directly on STDIN.  This cuts out the need for the scheduler,
> cleaning up the mail folder (since the message is handled directly and
> then discarded (if desired)), and allows the file to be handled closer
> to real time.

Nice! I will investigate on that.

José.



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




RE : Perl Newbie Question

2004-05-18 Thread Jose Nyimi


> -Message d'origine-
> De : Perl Mail User [mailto:[EMAIL PROTECTED]
> Envoyé : mardi 18 mai 2004 20:10
> À : [EMAIL PROTECTED]
> Objet : Perl Newbie Question
> 
> Hello All,
> 
> I have a question, I am looking to read the name of the file that I am
> passing as an argument to the perl script through the while (<>) part
of
> the script.
> 
> Example: perl script.pl 1.txt 2.txt 3.txt
> Each file has information that I am parsing to put into a report but I
> need
> to get the name of the file that I parsed and print that information
as
> well,
> so that way I know what values I am getting from each file associates
with
> what file.
> 
> So the output would look like
> 
> 1.txt (parsed information)
> 2.txt (parsed information)
> 3.txt (parsed information)
> 
> Any assistance would be great.
> Thanks

In addition to
perldoc perlvar
suggested in previous posts you may also give a look to
perldoc perlop
and search for "null filehandle".

It's said there :



The null filehandle <> is special: it can be used to emulate the
behavior of sed and awk. Input from <> comes either from standard input,
or from each file listed on the command line. Here's how it works: the
first time <> is evaluated, the @ARGV array is checked, and if it is
empty, $ARGV[0] is set to ``-'', which when opened gives you standard
input. The @ARGV array is then processed as a list of filenames. The
loop
while (<>) {
... # code for each line
}
is equivalent to the following Perl-like pseudo code:

unshift(@ARGV, '-') unless @ARGV;
while ($ARGV = shift) {
open(ARGV, $ARGV);
while () {
... # code for each line
}
}
except that it isn't so cumbersome to say, and will actually work. It
really does shift the @ARGV array and put the current filename into the
$ARGV variable.





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




RE : Module to validate credit cards

2004-05-18 Thread Jose Nyimi


> -Message d'origine-
> De : Mike Blezien [mailto:[EMAIL PROTECTED]
> Envoyé : mardi 18 mai 2004 21:32
> À : Perl List
> Objet : Module to validate credit cards
> 
> Hello,
> 
> can someone recommend a decent perl module or a reliabe routine to
check
> credit
> cards and expiration dates formats... not to actual check if the card
is
> valid,
> stolen,... etc, but just the format for the common cards used today.

I discovered Business::CreditCard
http://search.cpan.org/~ivan/Business-CreditCard-0.27/CreditCard.pm

while reading this article from perl.com
http://www.perl.com/lpt/a/2004/04/29/maypole.html

Check if it's what you want.

HTH,

José.




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




RE : E-mail Parsing

2004-08-04 Thread Jose Nyimi


> -Message d'origine-
> De : Brian Gerard [mailto:[EMAIL PROTECTED]
> Envoyé : mercredi 4 août 2004 19:40
> À : Perls of Wisdom
> Objet : Re: E-mail Parsing
> 
> And the clouds parted, and Wiggins d Anconia said...
> >
> > > I'm have a email in a text file. From this file I would like to
get
> the
> > > sender information, the attached files and the body of the e-mail.
> > >
> > > Is there something simple to do this?
> > >
> >
> > Check out the MIME::Parser or Mail::Box modules from CPAN. There are
> > others probably but these two I have used.
> >
> 
> I'll second the nomination for Mail::Box.  I'm using it to parse a
> collection of emails for processing on the headers and body and it
works
> like a charm!
> 

I'm using Mail::Box as well ...
It is great !

José.


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




RE : DBI Install

2004-08-04 Thread Jose Nyimi


> -Message d'origine-
> De : Witzke, Rob [mailto:[EMAIL PROTECTED]
> Envoyé : mercredi 4 août 2004 19:36
> À : Bob Showalter; PerlBeginners (E-mail)
> Objet : RE: DBI Install
> 
> Unfortunately, this does indeed seem to be the case and I can't
rebuild
> perl without jeopardizing our primary system
> 

You could considere building your own perl and modules.
If for instance the primary perl of your system is /usr/bin/perl then
you could choose making an other one as /usr/local/bin/perl and force
your script using the later.

All of this assum that your are in alignment with your organization
policy.
Convincing sysadmin is not always possible :-)

José.



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




RE : cryptic error messages in modules

2004-08-05 Thread Jose Nyimi


> -Message d'origine-
> De : news [mailto:[EMAIL PROTECTED] De la part de Christopher J.
Bottaro
> Envoyé : jeudi 5 août 2004 19:39
> À : [EMAIL PROTECTED]
> Objet : cryptic error messages in modules
> 
> package My::Class;
> use strict;
> use warnings;
> use Class::Struct;
> use IO::File;
> 
> struct MyStruct => {
> f1 => '$',
> f2 => '$'
> };
> 
> sub new {
> my ($class, $ifname) = @_;
> my $s = {};
> $class = ref($class) || $class;
> bless ($s, $class);
> $s->{FILE} = new IO::File($ifname, "r");
> if ( !defined($s->{FILE}) )  {
> print("ERROR: $class: cannot open $ifname for
reading\n");
> exit(-1);
> }
> return $s;
> }
> 
> sub f   {
> return MyStruct->new();
> }
> 
> sub DESTROY {
> $s->{FILE}->close();
> }
> 
>

--
> 
> 
> if i make a perl script that uses My::Class and i construct an
instance of
> My::Class and then call My::Class::f(), i get the following error:
> Can't locate object method "new" via package "MyStruct" (perhaps you
> forgot
> to load "MyStruct"?)
> 
> now obviously the problem is not that no new() method exists for
MyStruct,
> but rather that i forgot to declare $s in DESTROY().
> 
> it took me literally hours to figure out what the problem was.  i
mean,
> could the error message be anymore unrelated to the real problem?
what
> the
> hell does $s not being declared in DESTROY() have anything to do with
the
> error message i was given?
> 
> thanks for the help and advice.
> 
>

I made a copy-paste of your above code, added the following to call f():

package main;
My::Class::f();

And got the error message below:
Global symbol "$s" requires explicit package name at try.pl line 31.
Execution of try.pl aborted due to compilation errors.

Which tells exactly what is going wrong: missing to declare $s in
DESTROY().
I'm wondering why you have got an other message.
Double check ...

José.

 


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




RE : iterate over the fields of a struct?

2004-08-07 Thread Jose Nyimi


> -Message d'origine-
> De : Randy W. Sims [mailto:[EMAIL PROTECTED]
> Envoyé : samedi 7 août 2004 02:50
> À : [EMAIL PROTECTED]
> Cc : [EMAIL PROTECTED]
> Objet : Re: iterate over the fields of a struct?
> 
> Christopher J. Bottaro wrote:
> > is there a way to iterate over the fields of a Class::Struct (in the
> order
> > they were declared)?
> 
> No. You could store the data used to generate the struct, and then use
> it later.
> 
> my @struct_data = [
>key1 => 'type',
>key2 => 'type',
> ];
> 
> struct Name => [EMAIL PROTECTED];
> 
> then iterate of @struct_data...
> 

did you meant:

my $struct_data = [ #array_ref
key1 => 'type',
key2 => 'type',
];

struct Name => $struct_data;
then iterate of @$struct_data ...

?

array = array_ref is confusing to me ...
could you explain please ?

> >
> > yeah i know its a long shot, but perl sometimes does things for me
that
> i
> > never would have believed...much less knew to expect...;)
> >
> > also, i know you can do this with hashes (although in "random"
order,
> unless
> > you sort the keys), but hashes are too error prone for my liking.
i.e.
> > $my_hash{TYPO} = $blah; does not result in an error...=(
> 
> If you're using version 5.8 or later you can use restricted hashes.
See
> `perldoc Hash::Util`
> 

helpfull module !
Hash vivification is a nightmare, really ...

José.


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




RE : Data comparision analysis

2004-08-18 Thread Jose Nyimi


> -Message d'origine-
> De : Gunnar Hjalmarsson [mailto:[EMAIL PROTECTED]
> Envoyé : mercredi 18 août 2004 17:18
> À : [EMAIL PROTECTED]
> Objet : Re: Data comparision analysis
> 
> Marcos Rebelo wrote:
> > Gunnar Hjalmarsson wrote:
> >> Or a little shorter:
> >>
> >> #!/usr/bin/perl
> >> use strict;
> >> use warnings;
> >> open my $GROUPS, 'File1' or die $!;
> >> open my $USERS, 'File2' or die $!;
> >>
> >> my %groups;
> >> chomp and $groups{$_} = [] for <$GROUPS>;
> >>
> >> while ( <$USERS> ) {
> >> my ($user, @groups) = split;
> >> $groups{$_} and push @{ $groups{$_} }, $user for @groups;
> >> }
> >>
> >> for ( sort keys %groups ) {
> >> print "$_:\n", ( join "\n", @{ $groups{$_} } ), "\n\n";
> >> }
> >>
> >> __END__
> >
> > It seems to me that Olakunle Banjo shall not be an Perl Expert.
> 
> What's your point? Are you assuming he is here for some other reason
> but learning Perl?
> 
> > Can you also explain him the code?
> 
> If there is anything specific in the code that you, Olakunle or
> somebody else do not understand by help of the Perl docs, I'll be
> happy to explain.
> 
> > Note: Usually is good policy closeing the opened files.
> 
> If I have understood it correctly (please correct me if I'm wrong),
> when you use a my() declared filehandle reference, closing is done
> automatically when you go out of scope (in this case: when the script
> exits), and since I'm not interested in possible error messages, I'm
> not aware of any good reason for closing the filehandles explicitly.
> 

Gunnar, your code is clean, powerfull and maintainable ...
I wouldn't write it in an other way even though TIMTOWTDI :-)
It's not good pratice avoid using perl's flexibility and
write "bad" code just to make your code "understandable" to non perl
experts.
In contrary use good perl's features that will allow non experts to
learn from you.
Just my opinion.

José.



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




RE : Is my DB code bad?

2004-09-01 Thread Jose Nyimi


> -Message d'origine-
> De : Dave Kettmann [mailto:[EMAIL PROTECTED]
> Envoyé : mercredi 1 septembre 2004 22:42
> À : Perl List (E-mail)
> Objet : RE: Is my DB code bad?
> 
> First off, Thanks to Jenda and Wiggins for their quick response. I
have
> found the answer to my question in Jenda's help (the missing "'"'s)
> 
> Sorry for not being more specific earlier it has been a hectic day
here :)
> 
> This page is on a internal server that 3 people have access to.
(myself
> and 2 others) Making this ultra secure is not a big deal at this
point.
> The way this is built is there is one cgi script (radius.cgi) that all
> this is in, and they are reference by subroutine via the 'action'
> parameter. The $self variable is a variable that points back to this
> script (so $self?action=remove would get me to
> http:///radius.cgi?action=remove ) Is easier to use a
> variable like that than to type out the other. There may be better
ways to
> do that but, hey, this works and im a perl beginner :).
> 
> That being said (even though it may not have been necessary), can I
get a
> link to a good description of the object oriented syntax if one
exists? I
> know I can do a perldoc and find what it does and how to use it, but
the
> variable names confuse me. (i.e.: $sth etc) I'm sure I could
understand it
> alot better if someone (or a webpage) could explain it to me, the
> documentation just tells you how to use it, but I need to know what it
> means :).

Just a hint about dbi variables naming:
$sth : st(statement) h(handler)
$dbh : db(database) h(handler)

Give a look to Fig4-3: DBI handles
at http://www.oreilly.com/catalog/perldbi/chapter/ch04.html
you will get a good overview about those handlers.

José.


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




RE : Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-10-02 Thread Jose Nyimi


> -Message d'origine-
> De : Nicolay A. Vasiliev [mailto:[EMAIL PROTECTED]
> Envoyé : vendredi 1 octobre 2004 22:39
> À : Perl Beginners List
> Objet : Re: Becoming Disenheartened - Everyone talks about Python and
says
> Perl is old news.
> 
> I didn't mean CGI, only standart types.
> 

s.replace(...) is a consequence of "everything is object" thinking.

Look at the following:

import re;
m = re.match(r"(?P\d+)\.(\d*)", '3.14');
//After performing this match
//m.group(1) is '3', as is m.group('int')
//and m.group(2) is '14'. 

There is a similar ugly thing in Java.
All of this because you want everything to be an object.

Can you tell us how will you perform the above
matching without import re; :).

In Perl you don't absolutely need a kind of use RE; to be able
performing regular expression macthing.

So, don't force my $s = "I am Perl Guru"; to be an object and contain a
replace() method.

$s is a string will be treated as is in Perl.

José.



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




RE : Sourcing Configuration files

2004-11-02 Thread Jose Nyimi


> -Message d'origine-
> De : Ramprasad A Padmanabhan [mailto:[EMAIL PROTECTED]
> Envoyé : mardi 2 novembre 2004 09:44
> À : Gavin Henry
> Cc : perl beginners
> Objet : Re: Sourcing Configuration files
> 
> On Tue, 2004-11-02 at 13:41, Gavin Henry wrote:
> > Hi all,
> >
> > What is the easiest way to move variable declarations out into a
file in
> > /etc/ and requiring a perl program to read them in at startup. If
they
> are
> > not there, then the program must complain.
> >
> > Thanks.
> >
> 
> You cannot source shell style in perl. You can write a perl file and
> "require" it.

Umh ... have a look to Shell::Source module from CPAN.
http://search.cpan.org/~pjcj/Shell-Source-0.01/Source.pm

José.




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




RE : start http request and move on

2004-11-05 Thread Jose Nyimi


> -Message d'origine-
> De : Bob Showalter [mailto:[EMAIL PROTECTED]
> Envoyé : vendredi 5 novembre 2004 19:40
> À : 'JupiterHost.Net'; [EMAIL PROTECTED]
> Objet : RE: start http request and move on
> 
> JupiterHost.Net wrote:
> > Bob Showalter wrote:
> ...
> > > Use something like the following:
> ...
> > Thanks Bob, That works great! Now the next step is to play with that
> > in a peristent  environment without killing the persistent process
> > with the exit() Perhapst the system + & will do better in a
persistent
> > environement...
> 
> You don't need to call exit if you just put the other stuff in an else
{}
> block so the parent doesn't execute it. If you're running under
> Apache::Registry though, calling exit is OK.
> 

Nice approach, I have learned today an easy to do it :)
Though care should be taken to not fork many *uncontrolled* childs.

Rgds,
José. 



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