Log::Log4perl and Log::Dispatch::Email

2004-08-25 Thread Christopher J. Bottaro
hello, i'm having trouble understanding how to make an appender send an email? appearently, i'm suppose to make an appender based on Log::Dispatch::Email*. the problem is which one? there are 4: Log::Dispatch::Email Log::Dispatch::Email::MailSendmail Log::Dispatch::Email::MailSender Log::Dispat

Re: direct string manipulation (like in c)

2004-08-19 Thread Christopher J. Bottaro
James Edward Gray II wrote: > Then you didn't read the documentation I sent you the link for. ;) > > A negative index counts backwards from the end of the string. i did read it. maybe i should have asked my question like this: "why is the 3rd argument negative when you can simply say: substr($

Re: direct string manipulation (like in c)

2004-08-19 Thread Christopher J. Bottaro
Gunnar Hjalmarsson wrote: > You can use substr() as an rvalue: > > substr($str1, 4, 8 - length $str1, $str2); > > or if the length of $str1 is given: > > substr($str1, 4, -4, $str2);# probably fastest i don't understand why the 3rd argument is negative. given $str1 = 'xxx

direct string manipulation (like in c)

2004-08-19 Thread Christopher J. Bottaro
say i have two strings "" and "". i want to replace characters 4-7 in the first string with the second string with an emphasis on speed. basically i want to do what can be done in c with the following: char str1[13] = ""; char *str2 = ""; strncpy(str1+4, str2, 4);

Re: set operations on arrays

2004-08-13 Thread Christopher J. Bottaro
thank you both, that was just what i was looking for. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

set operations on arrays

2004-08-13 Thread Christopher J. Bottaro
is it possible to do set opperations on arrays? any cpan module or anything? i want to do something like the following: @intersection = set_intersection(@ar1, @ar2, @ar3); @ar1 = set_difference(@ar1, @intersection); @ar2 = set_difference(@ar2, @intersection); @ar3 = set_difference(@ar3, @interse

Re: iterate over the fields of a struct?

2004-08-09 Thread Christopher J. Bottaro
Randy W. Sims wrote: > If you're using version 5.8 or later you can use restricted hashes. See > `perldoc Hash::Util` heh, that was exactly what i'm looking for, thanks. ugh, now i gotta rewrite 3 days worth of code with restricted hashes instead of Class::Struct ...=/ -- To unsubscribe, e-mai

Re: Assignment for Perl Class- hurting my brain

2004-08-09 Thread Christopher J. Bottaro
William Paoli wrote: > $obj => {Title} =""; #Is this initilizing the > attribute? > I dont know why I am just not getting this stuff. > Please help me. your syntax is wrong, thats all. so your assignment is make some kinda rudimentary database lookup program thingie? your program reads the file

iterate over the fields of a struct?

2004-08-06 Thread Christopher J. Bottaro
is there a way to iterate over the fields of a Class::Struct (in the order they were declared)? something like: foreach my $i (@{my_struct->fields()}) { print "$i = my_struct->value($i)\n"; } yeah i know its a long shot, but perl sometimes does things for me that i never would have beli

Re: RE : cryptic error messages in modules

2004-08-06 Thread Christopher J. Bottaro
Jose Nyimi wrote: > 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. >

cryptic error messages in modules

2004-08-05 Thread Christopher J. Bottaro
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

RE: using Class::Struct in a module

2004-08-05 Thread Christopher J. Bottaro
From: news [mailto:[EMAIL PROTECTED] On Behalf Of >> Christopher J. Bottaro >> Sent: Thursday, August 05, 2004 12:35 AM >> To: [EMAIL PROTECTED] >> Subject: using Class::Struct in a module >> >> >> package My::Module; >> use Class::Struct; > >

Re: Choosing only numbers from the output

2004-08-04 Thread Christopher J. Bottaro
this is an interesting question in that its not about syntax or a specific problem in perl. here's the algorithm: while there are lines to read from the input read a line split the line into two seperate strings around the colon if both strings are numbers

using Class::Struct in a module

2004-08-04 Thread Christopher J. Bottaro
package My::Module; use Class::Struct; struct Blah => { field1 => '$', field2 => '$' }; sub new { # normal constructor } sub f { my $s = new Blah; # this calls new() defined above $s->field1 = 1; $s->field2 = 2; return $s; } package main

Re: use vs. require in modules

2004-08-04 Thread Christopher J. Bottaro
heh, that was it, thanks a bunch. Randal L. Schwartz wrote: >>>>>> "Christopher" == Christopher J Bottaro >>>>>> <[EMAIL PROTECTED]> writes: > > Christopher> My::Utils > Christopher> use Exporter; > > Do you have &

use vs. require in modules

2004-08-04 Thread Christopher J. Bottaro
i have 4 packages: PackageA use IO::File; require My::Utils::Reader PackageB use IO::File; use XML::Writer; My::Utils::Reader use My::Utils; My::Utils use Exporter; in my perl program, i dynamically load PackageA and PackageB like this: eval("require $package_name1"); eval("require $package_n

where does IO::File come from?

2004-07-20 Thread Christopher J. Bottaro
i use IO::File all the time in my perl scripts. i never installed any IO::File module from cpan.org and i don't see it anywhere in /usr/lib/perl. also, its not listed in my book "programming perl" as a standard module. so where does it come from and how am i able to use it? thanks for the help.

Re: delete vs undef

2004-07-09 Thread Christopher J. Bottaro
perl.org wrote: > Wait a second...I always thought undef was a constant value. Is it always > a > function or are there both? I don't know that it matters but I prefer to > show the parens when I invoke a function, but everywhere in my code I have > $var = undef; its a function. it always retur

Re: delete vs undef

2004-07-09 Thread Christopher J. Bottaro
ahh great, you all cleared it up perfectly for me, thank you. that perlfaq section was great also. Philipp Traeder wrote: > On Friday 09 July 2004 19:25, Gunnar Hjalmarsson wrote: >> Philipp Traeder wrote: >> > I don't know what an expert would say, >> >> Neither do I. :) > > I think this is a

delete vs undef

2004-07-09 Thread Christopher J. Bottaro
i want to remove items from a hash then later see if they exist using defined(). for example: delete($hash{MYKEY}); # blah blah if (defined($hash{MYKEY})) { # do blah blah } which should i use? delete() or undef()? obviously i could write a small script to test this (which i'm goi

Re: where to put modules?

2004-07-09 Thread Christopher J. Bottaro
thank you everyone for the replies. one quick question though. is it customary to thank people for replies? or does it just cause more unecessary traffic on the newsgroup? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

where to put modules?

2004-07-08 Thread Christopher J. Bottaro
lets say i made a module called cjb::string. where would i put cjb/string.pm? i'm using fedora core 1 and the default perl installation. i've read in my book about modules and a little bit about them on perldoc.com, but i couldn't find the answer to this. thanks. -- To unsubscribe, e-mail: [

Re: deallocating?

2003-12-21 Thread christopher j bottaro
"Does that clear things up?" yes, very much so...thank you...=) -- christopher On Sunday 21 December 2003 10:39 pm, James Edward Gray II wrote: > Perl uses a reference counting system. That usually does the right > thing, like most things Perl. It's not magic, but it sure is handy. > Let's loo

Re: where to look for modules?

2003-12-21 Thread christopher j bottaro
On Saturday 20 December 2003 05:05 am, Owen wrote: > I think the easiest for you would be to; > > use Modules; # as found in /usr/lib/perl5/5.8.0/ > > use lib '/home/cjb/perlmodules'; #followed by > use MyModule; #and/or any other module you have there great, that worked perfectly...=) i'm hav

Re: deallocating?

2003-12-21 Thread christopher j bottaro
On Sunday 21 December 2003 11:07 am, R. Joseph Newton wrote: > Nope.  Try > $root = undef; interesting.  so perl is smart enough to know that once root is undef, the user has no way of reaching any of the nodes in the tree, even if those nodes still have references to them (i.e. the parent nodes

deallocating?

2003-12-20 Thread christopher j bottaro
just for practice, i made a class BinaryTree. its just a blessed reference to a hash that contains two things: size and root. root gets assigned to a BinaryTree::Node which is just a bless reference containing: key, value, left, right. perl deallocates according to reference counts. so if i

where to look for modules?

2003-12-20 Thread christopher j bottaro
on my system, perl looks for modules in /usr/lib/perl5/5.8.0/. how can i specify an additional path to look for modules in? say for instance, /home/cjb/perlmodules/ in addition to the aforementioned path. thank you, -- christopher -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional c

Re: diff between packages and modules

2003-12-19 Thread christopher j bottaro
thanks for the reply. i think i'm understanding it a little better now. but i haven't really got a firm grasp on OO perl, so that example is a bit over my head still. On Friday 19 December 2003 05:40 pm, drieux wrote: > ok, I bite, what is a vbulletin, I'm an OldGuy > and use to do this with u

Re: diff between packages and modules

2003-12-19 Thread christopher j bottaro
er 2003 03:51 pm, Bob Showalter wrote: > christopher j bottaro wrote: > > i'm reading "Programming Perl" and i'm on the chapter about packages. > > it says that packages and modules are very similar and that novices > > can think of packages, modules, and clas

diff between packages and modules

2003-12-19 Thread christopher j bottaro
i'm reading "Programming Perl" and i'm on the chapter about packages. it says that packages and modules are very similar and that novices can think of packages, modules, and classes as the same thing, but i wanna know exactly what the differences between packages and modules are (i'm a c++ prog

replacing parts of a string

2003-06-09 Thread christopher j bottaro
hello, i want to do something like: $line =~ s/M (\d+) (\d+)/M $1+100 $2+200/; obviously adding 100 to $1 and 200 to $2, not adding the text '+100' and '+200'. thanks for the help, -- christopher -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

replacing text in a file

2003-06-09 Thread christopher j bottaro
hello, what is the easiest way to replace text in a file? say i have file blah.txt and i want to replace some regular expression found in that file with something. also, i want to do this from within the perl program, not by invoking perl with the -e option. thanks, -- christopher -- To uns

Re: equivalent of static vars?

2003-02-02 Thread christopher j bottaro
ahh, perldoc -q...thats neat...thanks...=) -- christopher On Saturday 01 February 2003 07:49 pm, John W. Krahn wrote: > Christopher J Bottaro wrote: > > hello, > > Hello, > > > what are the equivalent of static vars in c code? for instance... > > > > void

equivalent of static vars?

2003-02-01 Thread christopher j bottaro
hello, what are the equivalent of static vars in c code? for instance... void myfunc() { static int first_call = 1; if (first_call) { /* do some intialization of something */ first_call = 0; } } i want to be able to do something like tha

Re: parsing a program's output as its running (in perl)

2003-01-04 Thread christopher j bottaro
the help, christopher On Saturday 04 January 2003 06:03 pm, Ken Irving wrote: > On Sat, Jan 04, 2003 at 05:45:00PM -0600, christopher j bottaro wrote: > > hello, > > i'm writing a little dvd to divx perl script using mencoder and a 3 pass > > method. i want to allow aut

Re: parsing a program's output as its running (in perl)

2003-01-04 Thread christopher j bottaro
hmm, i guess i can open it as a pipe...hmm, yes, that is exactly what i was looking for... On Saturday 04 January 2003 05:45 pm, christopher j bottaro wrote: > hello, > i'm writing a little dvd to divx perl script using mencoder and a 3 pass > method. i want to allow auto cro

parsing a program's output as its running (in perl)

2003-01-04 Thread christopher j bottaro
hello, i'm writing a little dvd to divx perl script using mencoder and a 3 pass method. i want to allow auto cropdetection and cropping. to find the crop parameters, you gotta run mplayer and watch the output for the crop parameters. well, i suppose in perl i can capture mplayer's output with

Re: couple questions about refs

2002-12-17 Thread christopher j bottaro
On Tuesday 17 December 2002 04:38 am, Paul Johnson wrote: > I think Perl actually made me a better C programmer, but it is sometimes > frustrating going down to the level of C. Keep your hand in with XS > programming :-) what is XS programming? > Yes. And occassionally even if there isn't. Per

Re: couple questions about refs

2002-12-16 Thread christopher j bottaro
fact;) christopher On Tuesday 17 December 2002 12:21 am, John W. Krahn wrote: > Christopher J Bottaro wrote: > > hmm, something is going off in my head that says this is scary. > > Calm down Christopher. :-) > > > @array is > > local to the function (lexically sco

Re: couple questions about refs

2002-12-16 Thread christopher j bottaro
On Monday 16 December 2002 08:50 am, Jenda Krynicky wrote: > > i know what i really should do is this: > > sub myfunc(){ > > my @array; > > if ( some_cond ) { > > return undef; > > } > > else { > > #populate @array > > return [ @array ]; > > } > > } > > Well ... I would u

couple questions about refs

2002-12-16 Thread christopher j bottaro
hello again, all my c instincts tell me i shouldn't write a function like this: sub myfunc(){ my $aref = []; if ( some_cond ){ return undef; } else{ #populate @{$aref} return $aref; } } but its c

Re: file handle as a sub arg in perl

2002-12-14 Thread christopher j bottaro
nm, figured it out. you can pass open a scalar like this: open($myfile, "blah"); ParseOneItem($myfile); and use it in the sub like this: sub ParseOneItem() { my $fh = shift(); my $line = <$fh>; } =) -- christopher On Saturday 14 December 2002 03:10 a

Re: [mail_lists] Re: perl script to convert dos newlines to unix newlines...

2002-12-14 Thread christopher j bottaro
yes...thank you. i was going to post exactly that, but didn't know how to phrase it. i'm very capable of producing a script/program in whatever language that reads a line from input, edits the line, then writes the edited line to a new file (or stdout or whatever). but like Jim said, the ques

passing a file handle as a sub arg...?

2002-12-13 Thread christopher j bottaro
hello, i want to make a sub that is to be used like this: my @array; open(INFILE, "blah"); ParseOneItem (INFILE, \@array); i know how to pass the array reference, but how do i pass the file handle? can i do it just like that? thanks, christopher -- To unsubscribe, e-mail: [EMAIL PROTECTED] Fo

perl script to convert dos newlines to unix newlines...

2002-12-13 Thread christopher j bottaro
hey, i wanna make a perl script that will convert those stupid "\r\n" dos newlines to good unix "\n" newlines...=) the problem isn't really a perl problem, but a general programming problem that i've always kinda wondered about. so i guess what i'm gunna do is open the file, read in a line, sea

Re: help with classes...

2002-12-10 Thread christopher j bottaro
hmm, i have more questions now. how does one make class methods vs object methods? using the example from the tutorial... package Person; use strict; sub new { my $self = {}; $self->{NAME} = undef; $self->{AGE}= undef; $self->{PEERS} = [];

Re: help with classes...

2002-12-10 Thread christopher j bottaro
thanks to both of yall for the explanations. so bless() is is where the magic happens? once something is given a type, then those subs become methods and a ref of the calling object is implicitly giving as the first arg? i see now, thats what i was missing before. everything is much more cle

help with classes...

2002-12-10 Thread christopher j bottaro
hey, i'm a c/c++ programmer struggling to pick up OO perl. i've been reading the perltoot and i have question about the following: package Person; use strict; sub new { my $self = {}; $self->{NAME} = undef; $self->{AGE}= undef; $self->{PEERS} = []

func to see if an item exists in an array?

2002-12-08 Thread christopher j bottaro
hey, perl's got so many nifty little functions to make my life easier, i wonder if it has anything that lets you see if an item exists in an array or if two arrays are disjoint or the set difference of two arrays or anything like that. sure i could write my own func, but hey, if its already the

weird problems (dunno a good subject)

2002-12-08 Thread christopher j bottaro
hello again, i wrote a perl script to compile and install kde for me. compiling kde from scratch can be an all day affair so its nice to have an automated script to do it overnight or whatever. it works great if it finishes the whole way thru, but the problem arises when i kill the script befo

Re: references in perl...

2002-12-06 Thread christopher j bottaro
cool thanks. and yes i'm reading perlreftut but not perlref. perlref looks a bit too exhaustive for my purposes now. perhaps in the future when i become more advanced in the ways of perl. and Timothy, yeah i'm sure there are difference of course, but i guess i was asking very generally if it

references in perl...

2002-12-06 Thread christopher j bottaro
hello, i'm a c/c++ programmer trying to learn perl. there are just some things that are much more easily done in a language like perl than in c/c++ i've found out...=) anyways, i'm reading a short tutorial about references. am i wrong in thinking they are like pointers in c/c++? -- christoph