From td3201 at gmail.com Tue Sep 7 11:50:12 2004 From: td3201 at gmail.com (Terry) Date: Tue Sep 7 11:50:23 2004 Subject: [Omaha.pm] ignoring undefined subroutines Message-ID: <8ee06101040907095046167270@mail.gmail.com> I want to ignore undefined subroutines. Right now, my collection of text ( not worthy of being called a perl script ) calls subroutines but I want it to NOT die when it comes across a subroutine that is not defined. How can I do this? For example: &{"header_$who"}; if $who is not defined or contains a goofy value, my script dies, I do not want this. Thanks! Terry From m0ntar3 at cox.net Tue Sep 7 12:21:34 2004 From: m0ntar3 at cox.net (=?ISO-8859-1?Q?m=D8ntar3?=) Date: Tue Sep 7 12:21:38 2004 Subject: [Omaha.pm] ignoring undefined subroutines In-Reply-To: <8ee06101040907095046167270@mail.gmail.com> References: <8ee06101040907095046167270@mail.gmail.com> Message-ID: <413DEE1E.4060800@cox.net> You might try capturing a reference and then varifying whether or not the reference is defined (or some such): $coderef = \&{"header_$who"}; if(defined $coderef) { &$coderef; }; Terry wrote: >I want to ignore undefined subroutines. Right now, my collection of >text ( not worthy of being called a perl script ) calls subroutines >but I want it to NOT die when it comes across a subroutine that is not >defined. How can I do this? For example: > >&{"header_$who"}; > >if $who is not defined or contains a goofy value, my script dies, I do >not want this. > >Thanks! >Terry >_______________________________________________ >Omaha-pm mailing list >Omaha-pm@mail.pm.org >http://www.pm.org/mailman/listinfo/omaha-pm > > > From sswilliams at mail.unomaha.edu Tue Sep 7 14:28:52 2004 From: sswilliams at mail.unomaha.edu (Shemshon S Williams) Date: Tue Sep 7 14:25:07 2004 Subject: [Omaha.pm] help!! Message-ID: I was given an assignment to work on but i'm totally lost as to how to put this stuff together to get it to work properly. here is the file if someone could help that would be cool. I ran it thru vim now i have to copy it over to unix so i can run the program but it's just not working right -------------- next part -------------- A non-text attachment was scrubbed... Name: runme.pl~ Type: application/octet-stream Size: 1328 bytes Desc: not available Url : http://mail.pm.org/pipermail/omaha-pm/attachments/20040907/8692cec0/runme.obj From td3201 at gmail.com Tue Sep 7 14:40:07 2004 From: td3201 at gmail.com (Terry) Date: Tue Sep 7 14:40:10 2004 Subject: [Omaha.pm] help!! In-Reply-To: References: Message-ID: <8ee0610104090712401b3d2f44@mail.gmail.com> Looks fine to my novice eye....other than I don't have /home/q8050_1/fixed_assets.dat to copy to the other file. On Tue, 7 Sep 2004 14:28:52 -0500, Shemshon S Williams wrote: > > > I was given an assignment to work on but i'm totally lost as to how to put > this stuff together to get it to work properly. here is the file if someone > could help that would be cool. I ran it thru vim now i have to copy it over > to unix so i can run the program but it's just not working right > > > _______________________________________________ > Omaha-pm mailing list > Omaha-pm@mail.pm.org > http://www.pm.org/mailman/listinfo/omaha-pm > > > > From jay at jays.net Tue Sep 7 15:02:08 2004 From: jay at jays.net (Jay Hannah) Date: Tue Sep 7 15:01:41 2004 Subject: [Omaha.pm] help!! In-Reply-To: References: Message-ID: On Sep 7, 2004, at 2:28 PM, Shemshon S Williams wrote: > I was given an assignment to work on but i'm totally lost as to how to > put > this stuff together to get it to work properly. here is the file if > someone > could help that would be cool. I ran it thru vim now i have to copy it > over > to unix so i can run the program but it's just not working > right What error(s) are you getting? j http://www.catb.org/~esr/faqs/smart-questions.html From td3201 at gmail.com Tue Sep 7 15:15:04 2004 From: td3201 at gmail.com (Terry) Date: Tue Sep 7 15:15:12 2004 Subject: [Omaha.pm] ignoring undefined subroutines In-Reply-To: <413DEE1E.4060800@cox.net> References: <8ee06101040907095046167270@mail.gmail.com> <413DEE1E.4060800@cox.net> Message-ID: <8ee061010409071315598df385@mail.gmail.com> The reference still exists whether $who exists or not......if $who isn't defined $coderef would still exist with '&header_'. :\ On Tue, 07 Sep 2004 12:21:34 -0500, m?ntar3 wrote: > You might try capturing a reference and then varifying whether or not > the reference is defined (or some such): > > $coderef = \&{"header_$who"}; > if(defined $coderef) { &$coderef; }; > > > > Terry wrote: > > >I want to ignore undefined subroutines. Right now, my collection of > >text ( not worthy of being called a perl script ) calls subroutines > >but I want it to NOT die when it comes across a subroutine that is not > >defined. How can I do this? For example: > > > >&{"header_$who"}; > > > >if $who is not defined or contains a goofy value, my script dies, I do > >not want this. > > > >Thanks! > >Terry > >_______________________________________________ > >Omaha-pm mailing list > >Omaha-pm@mail.pm.org > >http://www.pm.org/mailman/listinfo/omaha-pm > > > > > > > From jay at jays.net Tue Sep 7 15:26:26 2004 From: jay at jays.net (Jay Hannah) Date: Tue Sep 7 15:25:58 2004 Subject: [Omaha.pm] ignoring undefined subroutines In-Reply-To: <8ee061010409071315598df385@mail.gmail.com> References: <8ee06101040907095046167270@mail.gmail.com> <413DEE1E.4060800@cox.net> <8ee061010409071315598df385@mail.gmail.com> Message-ID: <31BF0E34-010C-11D9-9DD4-000A95E317B8@jays.net> Terry wrote: > I want to ignore undefined subroutines. Right now, my collection of > text ( not worthy of being called a perl script ) calls subroutines > but I want it to NOT die when it comes across a subroutine that is not > defined. How can I do this? For example: > > &{"header_$who"}; > > if $who is not defined or contains a goofy value, my script dies, I do > not want this. use vars qw( $AUTOLOAD ); &{"header_$who"}; sub AUTOLOAD { print "No such sub $AUTOLOAD\n"; } HTH, j From td3201 at gmail.com Tue Sep 7 15:33:59 2004 From: td3201 at gmail.com (Terry) Date: Tue Sep 7 15:34:01 2004 Subject: [Omaha.pm] ignoring undefined subroutines In-Reply-To: <31BF0E34-010C-11D9-9DD4-000A95E317B8@jays.net> References: <8ee06101040907095046167270@mail.gmail.com> <413DEE1E.4060800@cox.net> <8ee061010409071315598df385@mail.gmail.com> <31BF0E34-010C-11D9-9DD4-000A95E317B8@jays.net> Message-ID: <8ee061010409071333591dfef2@mail.gmail.com> Thanks Jay, worked fine. Thinking outside the box with regards to scripting isn't on my resume for a good reason. On Tue, 7 Sep 2004 15:26:26 -0500, Jay Hannah wrote: > > Terry wrote: > > I want to ignore undefined subroutines. Right now, my collection of > > text ( not worthy of being called a perl script ) calls subroutines > > but I want it to NOT die when it comes across a subroutine that is not > > defined. How can I do this? For example: > > > > &{"header_$who"}; > > > > if $who is not defined or contains a goofy value, my script dies, I do > > not want this. > > use vars qw( $AUTOLOAD ); > &{"header_$who"}; > > sub AUTOLOAD { > print "No such sub $AUTOLOAD\n"; > } > > HTH, > > j From sswilliams at mail.unomaha.edu Tue Sep 7 16:05:54 2004 From: sswilliams at mail.unomaha.edu (Shemshon S Williams) Date: Tue Sep 7 16:02:10 2004 Subject: [Omaha.pm] help!! Message-ID: i don't know the commands to change it to executable or how to run and save the output From jay at jays.net Tue Sep 7 16:07:12 2004 From: jay at jays.net (Jay Hannah) Date: Tue Sep 7 16:06:43 2004 Subject: [Omaha.pm] help!! In-Reply-To: References: Message-ID: > i don't know the commands to change it to executable or how to run and > save > the output What operating system are you on? Windows? Linux? Unix (which Unix?)? What commands are you trying? j From td3201 at gmail.com Tue Sep 7 16:07:16 2004 From: td3201 at gmail.com (Terry) Date: Tue Sep 7 16:07:18 2004 Subject: [Omaha.pm] help!! In-Reply-To: References: Message-ID: <8ee061010409071407539f2d48@mail.gmail.com> chmod +x runme.pl && ./runme.pl OR perl runme.pl On Tue, 7 Sep 2004 16:05:54 -0500, Shemshon S Williams wrote: > > > i don't know the commands to change it to executable or how to run and save > the output > > > > _______________________________________________ > Omaha-pm mailing list > Omaha-pm@mail.pm.org > http://www.pm.org/mailman/listinfo/omaha-pm > From sswilliams at mail.unomaha.edu Tue Sep 7 16:13:40 2004 From: sswilliams at mail.unomaha.edu (Shemshon S Williams) Date: Tue Sep 7 16:09:55 2004 Subject: [Omaha.pm] help!! Message-ID: right now i'm using windows From td3201 at gmail.com Tue Sep 7 16:12:17 2004 From: td3201 at gmail.com (Terry) Date: Tue Sep 7 16:12:19 2004 Subject: [Omaha.pm] help!! In-Reply-To: References: Message-ID: <8ee0610104090714122cd66cfd@mail.gmail.com> oh...mmm, havent seen that in a while....lol On Tue, 7 Sep 2004 16:13:40 -0500, Shemshon S Williams wrote: > > > right now i'm using windows > > > > _______________________________________________ > Omaha-pm mailing list > Omaha-pm@mail.pm.org > http://www.pm.org/mailman/listinfo/omaha-pm > From hostetlerm at gmail.com Tue Sep 7 16:13:59 2004 From: hostetlerm at gmail.com (Mike Hostetler) Date: Tue Sep 7 16:14:01 2004 Subject: [Omaha.pm] help!! In-Reply-To: References: Message-ID: On Tue, 7 Sep 2004 14:28:52 -0500, Shemshon S Williams wrote: > > > I was given an assignment to work on but i'm totally lost as to how to put > this stuff together to get it to work properly. here is the file if someone > could help that would be cool. I ran it thru vim now i have to copy it over > to unix so i can run the program but it's just not working right I present to you a long article that we should all read over from time to time http://www.catb.org/~esr/faqs/smart-questions.html This section would be especially helpful for you: http://www.catb.org/~esr/faqs/smart-questions.html#beprecise I'm not trying to be a pompous jerk. I'm trying to help you help us so we can help you. ;) -- Mike Hostetler thehaas@binary.net http://www.binary.net/thehaas From sswilliams at mail.unomaha.edu Tue Sep 7 16:30:54 2004 From: sswilliams at mail.unomaha.edu (Shemshon S Williams) Date: Tue Sep 7 16:27:10 2004 Subject: [Omaha.pm] help!! Message-ID: i used vim to change it to a pl. now i have to load it to putty so i can copy it to whatever version of unix that this school is using From jay at jays.net Tue Sep 7 16:27:56 2004 From: jay at jays.net (Jay Hannah) Date: Tue Sep 7 16:27:29 2004 Subject: [Omaha.pm] ignoring undefined subroutines In-Reply-To: <8ee061010409071333591dfef2@mail.gmail.com> References: <8ee06101040907095046167270@mail.gmail.com> <413DEE1E.4060800@cox.net> <8ee061010409071315598df385@mail.gmail.com> <31BF0E34-010C-11D9-9DD4-000A95E317B8@jays.net> <8ee061010409071333591dfef2@mail.gmail.com> Message-ID: On Sep 7, 2004, at 3:33 PM, Terry wrote: > Thanks Jay, worked fine. Thinking outside the box with regards to > scripting isn't on my resume for a good reason. "I think I'm going to need a bigger box." -- Taco Bell Chihuaha AUTOLOAD is very slick. You can program anything you want to have happen if an undefined sub/method is called. Like if you had 10 header_xxx sub/methods that were almost all exactly the same, you could use AUTOLOAD to call a single, central sub/method, passing in an argument for the tweak (instead of having to explicitly declare 10 sub/methods)... See "perldoc perltoot". Looks like this would work for you too? &{"header_$who"} if (defined &{"header_$who"}); My test: [jhannah-mac:~] jhannah% cat j.pl #!/usr/bin/perl my @subs = qw( one two three ); foreach (@subs) { &$_ if (defined &$_); } sub one { print "1\n"; } sub three { print "3\n"; } [jhannah-mac:~] jhannah% ./j.pl 1 3 HTH, j From jay at jays.net Tue Sep 7 16:50:10 2004 From: jay at jays.net (Jay Hannah) Date: Tue Sep 7 16:49:42 2004 Subject: [Omaha.pm] help!! In-Reply-To: References: Message-ID: On Sep 7, 2004, at 4:30 PM, Shemshon S Williams wrote: > i used vim to change it to a pl. now i have to load it to putty so i > can > copy it to whatever version of unix that this school is using By the way you phrased that it appears to me that you're not having a Perl problem. It sounds like you're struggling with telnet/ssh/vim/file extensions/Windows/Unix file permissions/how to execute programs on Win/Unix/how to move files around (ftp? scp?)/etc... This forum won't be able to help until you have the above stuff sorted out. We don't know anything about the computers/networks you're using, we just know the programming language Perl. Is there a help desk @ school you can call to get your program(s) wherever you need them to be and get them executable? Once you can successfully execute your Perl program(s) then we can try to help. Cheers, j From ranorton at cox.net Tue Sep 7 17:17:29 2004 From: ranorton at cox.net (Richard Norton) Date: Tue Sep 7 17:17:26 2004 Subject: [Omaha.pm] help!! In-Reply-To: References: Message-ID: Can't help much on the getting it to your unix box question (that depends on how your network is set up, as I think someone else already mentioned.) But as far as making it executable, running it, and saving the output, all of that info is actually in the comment block at the top of your program. Richard On Tue, 7 Sep 2004 16:05:54 -0500, Shemshon S Williams wrote: > > > > > i don't know the commands to change it to executable or how to run and > save > the output > > _______________________________________________ > Omaha-pm mailing list > Omaha-pm@mail.pm.org > http://www.pm.org/mailman/listinfo/omaha-pm From hjarce2001 at yahoo.com Wed Sep 8 04:57:17 2004 From: hjarce2001 at yahoo.com (Hugh Jarce) Date: Wed Sep 8 04:57:19 2004 Subject: [Omaha.pm] ignoring undefined subroutines In-Reply-To: <8ee06101040907095046167270@mail.gmail.com> Message-ID: <20040908095717.47205.qmail@web90002.mail.scd.yahoo.com> Terry wrote: > I want to ignore undefined subroutines. Right now, my collection of > text ( not worthy of being called a perl script ) calls subroutines > but I want it to NOT die when it comes across a subroutine that is > not defined. How can I do this? For example: > > &{"header_$who"}; > > if $who is not defined or contains a goofy value, my script dies, > I do not want this. Jay's AUTOLOAD seems a good solution. However, because variety is the spice of life, here are two different approaches: sub header_hugh { print "in hugh\n" } for my $who ( 'dummy', 'hugh' ) { eval { &{"header_$who"} }; print "$who died\n" if $@; } which simply traps die with eval. Notice that this will also catch _any_ die inside the called routine (I suppose you could tell the difference by examining the contents of $@) which may be a bug or a feature depending on your needs. Alternatively, you might peek at the symbol table before attempting to call the function (if you knew which package it was defined in). For example: use strict; sub header_hugh { print "in hugh\n" } for my $who ( 'dummy', 'hugh' ) { if (exists($main::{"header_$who"})) { &{$main::{"header_$who"}}; } else { print "no such function $who\n"; } } Hugh. __________________________________ Do you Yahoo!? Yahoo! Mail - You care about security. So do we. http://promotions.yahoo.com/new_mail From hjarce2001 at yahoo.com Wed Sep 8 04:57:17 2004 From: hjarce2001 at yahoo.com (Hugh Jarce) Date: Wed Sep 8 04:57:19 2004 Subject: [Omaha.pm] ignoring undefined subroutines In-Reply-To: <8ee06101040907095046167270@mail.gmail.com> Message-ID: <20040908095717.47205.qmail@web90002.mail.scd.yahoo.com> Terry wrote: > I want to ignore undefined subroutines. Right now, my collection of > text ( not worthy of being called a perl script ) calls subroutines > but I want it to NOT die when it comes across a subroutine that is > not defined. How can I do this? For example: > > &{"header_$who"}; > > if $who is not defined or contains a goofy value, my script dies, > I do not want this. Jay's AUTOLOAD seems a good solution. However, because variety is the spice of life, here are two different approaches: sub header_hugh { print "in hugh\n" } for my $who ( 'dummy', 'hugh' ) { eval { &{"header_$who"} }; print "$who died\n" if $@; } which simply traps die with eval. Notice that this will also catch _any_ die inside the called routine (I suppose you could tell the difference by examining the contents of $@) which may be a bug or a feature depending on your needs. Alternatively, you might peek at the symbol table before attempting to call the function (if you knew which package it was defined in). For example: use strict; sub header_hugh { print "in hugh\n" } for my $who ( 'dummy', 'hugh' ) { if (exists($main::{"header_$who"})) { &{$main::{"header_$who"}}; } else { print "no such function $who\n"; } } Hugh. __________________________________ Do you Yahoo!? Yahoo! Mail - You care about security. So do we. http://promotions.yahoo.com/new_mail From sswilliams at mail.unomaha.edu Wed Sep 8 16:02:46 2004 From: sswilliams at mail.unomaha.edu (Shemshon S Williams) Date: Wed Sep 8 15:59:00 2004 Subject: [Omaha.pm] help!! Message-ID: thanks everyone for attempting to help me, i did manage to work it all out i was missing a comand and the code i attempted to add to fix the problem was wrong. From jay at jays.net Wed Sep 8 19:09:15 2004 From: jay at jays.net (Jay Hannah) Date: Wed Sep 8 19:08:46 2004 Subject: [Omaha.pm] ignoring undefined subroutines In-Reply-To: <20040908095717.47205.qmail@web90002.mail.scd.yahoo.com> References: <20040908095717.47205.qmail@web90002.mail.scd.yahoo.com> Message-ID: <7C7F2095-01F4-11D9-9CB3-000A95E317B8@jays.net> On Sep 8, 2004, at 4:57 AM, Hugh Jarce wrote: > if (exists($main::{"header_$who"})) { > &{$main::{"header_$who"}}; How would you know that header_$who is a sub and not just an errant scalar defined in the package "main"? The code below blows up unless you take the $two = line out... j ----------- % cat j.pl #!/usr/bin/perl my @subs = qw( one two three ); $two = "kaboom!"; # Comment this line out and everything is fine foreach (@subs) { if (exists($main::{$_})) { &$_; } } sub one { print "1\n"; } sub three { print "3\n"; } % ./j.pl 1 Undefined subroutine &main::two called at ./j.pl line 7. -------------- From jay at jays.net Wed Sep 8 19:57:06 2004 From: jay at jays.net (Jay Hannah) Date: Wed Sep 8 19:56:41 2004 Subject: [Omaha.pm] Re: LWP form posts In-Reply-To: <6.1.2.0.2.20040908115750.0279aec0@mail.aurora-e-solutions.com> References: <6.1.2.0.2.20040908115750.0279aec0@mail.aurora-e-solutions.com> Message-ID: <2BDBB172-01FB-11D9-9CB3-000A95E317B8@jays.net> On Sep 8, 2004, at 12:08 PM, Michael D. Maynard wrote: > I've got a Perl question for you.? Don't know if you have much > experience with form posts through Perl or not, but I thought I would > give it a shot.? LWP is the standard for doing form posts with Perl.? > However, it expects a response from the other side.? This is where I > am running into trouble.? I need to pass the data off to the other > side and let their server take over.? I am posting to an external CGI > that returns HTML.? I need their server to handle that rather than > processing it myself.? I can't redirect because I lose the > relationship to the data i just posted.? Is there anyway to post and > go without a response? Hmm... I'm not sure I follow what you're trying to do. Are there 3 computers in your scenario? Can you explain what computers A, B, and C are each supposed to each be doing? Which of the computers do you control w/ Perl? With any http(s) POST action, the client needs to wait for the server to hang up (w/ or w/o output) to know that the POST actually reached the server, right? Have you looked at WWW::Mechanize? j From hjarce2001 at yahoo.com Thu Sep 9 04:54:51 2004 From: hjarce2001 at yahoo.com (Hugh Jarce) Date: Thu Sep 9 04:54:54 2004 Subject: [Omaha.pm] ignoring undefined subroutines In-Reply-To: <7C7F2095-01F4-11D9-9CB3-000A95E317B8@jays.net> Message-ID: <20040909095451.32231.qmail@web90009.mail.scd.yahoo.com> Jay Hannah wrote: > How would you know that header_$who is a sub and not just an errant > scalar defined in the package "main"? > > The code below blows up unless you take the $two = line out... > > j > > ----------- > % cat j.pl > #!/usr/bin/perl > > my @subs = qw( one two three ); > $two = "kaboom!"; # Comment this line out and everything is fine > foreach (@subs) { > if (exists($main::{$_})) { > &$_; > } > } > sub one { print "1\n"; } > sub three { print "3\n"; } > > % ./j.pl > 1 > Undefined subroutine &main::two called at ./j.pl line 7. Your solutions are better, but since you asked... ;-) h ----------- % cat h.pl #!/usr/bin/perl my @subs = qw( one two three ); $two = "kaboom!"; foreach (@subs) { local *sym = $main::{$_}; defined($sym) and print "jay is trying to break hugh's code\n"; defined(*sym{CODE}) and &$_; } sub one { print "1\n"; } sub three { print "3\n"; } % ./h.pl 1 jay is trying to break hugh's code 3 See also Devel::Symdump. __________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail From jay at jays.net Thu Sep 9 08:53:52 2004 From: jay at jays.net (Jay Hannah) Date: Thu Sep 9 08:53:24 2004 Subject: [Omaha.pm] ignoring undefined subroutines In-Reply-To: <20040909095451.32231.qmail@web90009.mail.scd.yahoo.com> References: <20040909095451.32231.qmail@web90009.mail.scd.yahoo.com> Message-ID: On Sep 9, 2004, at 4:54 AM, Hugh Jarce wrote: > local *sym = $main::{$_}; > defined($sym) and print "jay is trying to break hugh's code\n"; > defined(*sym{CODE}) and &$_; OOooo... That's neat. That's probably what I was trying to find in my book and couldn't figure out where it lived... Symbol tables? > See also Devel::Symdump. I'll check it out. Thanks, j From td3201 at gmail.com Thu Sep 9 14:23:39 2004 From: td3201 at gmail.com (Terry) Date: Thu Sep 9 14:23:48 2004 Subject: [Omaha.pm] converting dates Message-ID: <8ee06101040909122334a09a99@mail.gmail.com> I want to be able to take an number which is the # of days since 1/1/70 and convert it into a user-friendly date. Like 12594 for example. Date::Manip doesn't seem to have much love in this area....have any other ideas? From dan at linder.org Thu Sep 9 14:52:15 2004 From: dan at linder.org (Daniel Linder) Date: Thu Sep 9 14:48:21 2004 Subject: [Omaha.pm] converting dates In-Reply-To: <8ee06101040909122334a09a99@mail.gmail.com> References: <8ee06101040909122334a09a99@mail.gmail.com> Message-ID: <5637.12.160.138.62.1094759535.squirrel@12.160.138.62> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 > I want to be able to take an number which is the # of days since > 1/1/70 and convert it into a user-friendly date. > > Like 12594 for example. > > Date::Manip doesn't seem to have much love in this area....have any other > ideas? Since the "epoc" is just number of seconds since midnight 1/1/1970, how about this: $datenum = 12594; $datenum *= (24*60*60); $date = &ParseDateString("epoch $datenum"); printf "$date\n"; Returns this output: 2004062419:00:00 (i.e. 2004 06 24 @ 19:00:00 ?) So, is this close? I assume that leap years/seconds make up for the time being off by 5 hours (19:00 vs. 00:00) You could then run $date through the Date::Manip routines to clean it up further. I guess you could toy around with this routine going the other way: $secs = Date_SecsSince1970($m,$d,$y,$h,$mn,$s); Dan - - - - - "I do not fear computer, I fear the lack of them." -- Isaac Asimov -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQFBQLRvNiBNyqUzGb8RAlAzAJ4r4V/hk1GWEzX28CDz1fwmiFjizwCeORhs s5fEKG9ilv4reqQ/cTMNUH8= =4aXm -----END PGP SIGNATURE----- From jhannah at omnihotels.com Thu Sep 9 16:13:29 2004 From: jhannah at omnihotels.com (Jay Hannah) Date: Thu Sep 9 16:13:47 2004 Subject: [Omaha.pm] Rename all files in a directory Message-ID: <000c01c496b1$db88f420$4722000a@omarests2> Another 5 minute hack... j #!/usr/bin/perl opendir DIR, "."; @files = grep /^ppm/, readdir DIR; closedir DIR; foreach (@files) { $new = $_; $new =~ s/^ppm/its/; print "rename $_ $new\n"; rename $_, $new; } From scott.l.miller at hp.com Thu Sep 9 16:35:25 2004 From: scott.l.miller at hp.com (Miller, Scott L (Omaha Networks)) Date: Thu Sep 9 16:35:39 2004 Subject: [Omaha.pm] Rename [x] files in a directory Message-ID: <1F7C0C8F4BD7C54A8BC55012FEF3DF6D0302E6B5@omaexc11.americas.cpqcorp.net> Eh, you have to modify yours for every situation. Here's a more generic approach: > less -x4 ~/rename.pl #!/bin/perl if( -t && scalar(@ARGV)==0 ) { print " Usage: rename 'glob' operation\n"; print " where 'glob' is a glob file selector\n"; print " and operation is typically a substitution command\n"; print "\n example:\n rename '*.cfg' 's/\\.cfg/\\.xyz/'\n"; } my @files=glob($ARGV[0]); while ($fname=shift @files) { $new=$fname; eval "\$new =~ $ARGV[1]"; print "$fname -> $new\n"; rename $fname, $new; } -Scott -----Original Message----- From: omaha-pm-bounces@mail.pm.org [mailto:omaha-pm-bounces@mail.pm.org]On Behalf Of Jay Hannah Sent: Thursday, September 09, 2004 4:13 PM To: omaha-pm@pm.org Subject: [Omaha.pm] Rename all files in a directory Another 5 minute hack... j #!/usr/bin/perl opendir DIR, "."; @files = grep /^ppm/, readdir DIR; closedir DIR; foreach (@files) { $new = $_; $new =~ s/^ppm/its/; print "rename $_ $new\n"; rename $_, $new; } _______________________________________________ Omaha-pm mailing list Omaha-pm@mail.pm.org http://www.pm.org/mailman/listinfo/omaha-pm From scott.l.miller at hp.com Thu Sep 9 16:35:25 2004 From: scott.l.miller at hp.com (Miller, Scott L (Omaha Networks)) Date: Thu Sep 9 16:35:45 2004 Subject: [Omaha.pm] Rename [x] files in a directory Message-ID: <1F7C0C8F4BD7C54A8BC55012FEF3DF6D0302E6B5@omaexc11.americas.cpqcorp.net> Eh, you have to modify yours for every situation. Here's a more generic approach: > less -x4 ~/rename.pl #!/bin/perl if( -t && scalar(@ARGV)==0 ) { print " Usage: rename 'glob' operation\n"; print " where 'glob' is a glob file selector\n"; print " and operation is typically a substitution command\n"; print "\n example:\n rename '*.cfg' 's/\\.cfg/\\.xyz/'\n"; } my @files=glob($ARGV[0]); while ($fname=shift @files) { $new=$fname; eval "\$new =~ $ARGV[1]"; print "$fname -> $new\n"; rename $fname, $new; } -Scott -----Original Message----- From: omaha-pm-bounces@mail.pm.org [mailto:omaha-pm-bounces@mail.pm.org]On Behalf Of Jay Hannah Sent: Thursday, September 09, 2004 4:13 PM To: omaha-pm@pm.org Subject: [Omaha.pm] Rename all files in a directory Another 5 minute hack... j #!/usr/bin/perl opendir DIR, "."; @files = grep /^ppm/, readdir DIR; closedir DIR; foreach (@files) { $new = $_; $new =~ s/^ppm/its/; print "rename $_ $new\n"; rename $_, $new; } _______________________________________________ Omaha-pm mailing list Omaha-pm@mail.pm.org http://www.pm.org/mailman/listinfo/omaha-pm From jay at jays.net Thu Sep 9 17:11:32 2004 From: jay at jays.net (Jay Hannah) Date: Thu Sep 9 17:11:03 2004 Subject: [Omaha.pm] converting dates In-Reply-To: <8ee06101040909122334a09a99@mail.gmail.com> References: <8ee06101040909122334a09a99@mail.gmail.com> Message-ID: <3503677C-02AD-11D9-B5F5-000A95E317B8@jays.net> On Sep 9, 2004, at 2:23 PM, Terry wrote: > I want to be able to take an number which is the # of days since > 1/1/70 and convert it into a user-friendly date. > > Like 12594 for example. % cat j.pl #!/usr/bin/perl use Date::Calc qw( Add_Delta_Days Date_to_Text_Long ); print Date_to_Text_Long( Add_Delta_Days(1970, 1, 1, $ARGV[0]) ), "\n"; % perl j.pl 12594 Friday, June 25th 2004 HTH, j From ranorton at cox.net Thu Sep 9 17:44:22 2004 From: ranorton at cox.net (Richard Norton) Date: Thu Sep 9 17:44:16 2004 Subject: [Omaha.pm] converting dates In-Reply-To: <8ee06101040909122334a09a99@mail.gmail.com> References: <8ee06101040909122334a09a99@mail.gmail.com> Message-ID: Wouldn't this work too? print scalar localtime($ARGV[0] * 24 * 60 * 60),"\n"; On Thu, 9 Sep 2004 14:23:39 -0500, Terry wrote: > I want to be able to take an number which is the # of days since > 1/1/70 and convert it into a user-friendly date. > > Like 12594 for example. > > Date::Manip doesn't seem to have much love in this area....have any > other ideas? > _______________________________________________ > Omaha-pm mailing list > Omaha-pm@mail.pm.org > http://www.pm.org/mailman/listinfo/omaha-pm From hjarce2001 at yahoo.com Thu Sep 9 18:43:12 2004 From: hjarce2001 at yahoo.com (Hugh Jarce) Date: Thu Sep 9 18:43:13 2004 Subject: [Omaha.pm] Rename all files in a directory In-Reply-To: <000c01c496b1$db88f420$4722000a@omarests2> Message-ID: <20040909234312.51299.qmail@web90003.mail.scd.yahoo.com> Jay Hannah wrote: > > Another 5 minute hack... > > j > > #!/usr/bin/perl > > opendir DIR, "."; > @files = grep /^ppm/, readdir DIR; > closedir DIR; > > foreach (@files) { > $new = $_; > $new =~ s/^ppm/its/; > print "rename $_ $new\n"; > rename $_, $new; > } Great minds think alike. A certain larry also solved this problem with a little Perl script (not sure if he did it in less than five minutes though ;-): h __________________________________ Do you Yahoo!? Yahoo! Mail Address AutoComplete - You start. We finish. http://promotions.yahoo.com/new_mail From hjarce2001 at yahoo.com Thu Sep 9 18:43:12 2004 From: hjarce2001 at yahoo.com (Hugh Jarce) Date: Thu Sep 9 18:43:19 2004 Subject: [Omaha.pm] Rename all files in a directory In-Reply-To: <000c01c496b1$db88f420$4722000a@omarests2> Message-ID: <20040909234312.51299.qmail@web90003.mail.scd.yahoo.com> Jay Hannah wrote: > > Another 5 minute hack... > > j > > #!/usr/bin/perl > > opendir DIR, "."; > @files = grep /^ppm/, readdir DIR; > closedir DIR; > > foreach (@files) { > $new = $_; > $new =~ s/^ppm/its/; > print "rename $_ $new\n"; > rename $_, $new; > } Great minds think alike. A certain larry also solved this problem with a little Perl script (not sure if he did it in less than five minutes though ;-): h __________________________________ Do you Yahoo!? Yahoo! Mail Address AutoComplete - You start. We finish. http://promotions.yahoo.com/new_mail From jay at jays.net Fri Sep 10 04:33:13 2004 From: jay at jays.net (Jay Hannah) Date: Fri Sep 10 04:32:45 2004 Subject: [Omaha.pm] Re: LWP form posts In-Reply-To: <6.1.2.0.2.20040909085124.02d24640@mail.aurora-e-solutions.com> References: <6.1.2.0.2.20040908115750.0279aec0@mail.aurora-e-solutions.com> <2BDBB172-01FB-11D9-9CB3-000A95E317B8@jays.net> <6.1.2.0.2.20040909085124.02d24640@mail.aurora-e-solutions.com> Message-ID: <6FB1FF2E-030C-11D9-852E-000A95E317B8@jays.net> On Sep 9, 2004, at 9:26 AM, Michael D. Maynard wrote: > I have looked at WWW::Mechanize and I think that it might do what I am > trying to do, however, it is not installed on the 3rd party server > that the application will run on. I am looking into getting it > installed or having them switch to my server. > > I am doing a PayPal IPN integration into our shopping cart system. I > have the callback working (as well as it can, I guess. From what I > have read in the forum, it is pretty buggy.). The way it works is you > do a from post to their server with the merchant's info and the > transactions details, the user logs into PayPal, does their thing and > PayPal sends them back to your site and updates you with the payment > status. > > Server A is my server w/ Perl 5.8. Server B is 3rd party, but we > won't worry about them for now. Server C is PayPal (Apache/1.3.27 > (Unix) mod_ssl/2.8.12 OpenSSL/0.9.7a) scripting language unknown. > When I do a standard HTML form post everything works fine, except I > would like to do the form post with PERL and save the user a click > (Gee, how thoughtful...). When I use Perl from Server A to Server C, > the post goes OK. Server C responds with HTML, the PayPal login page. > They have everything written as relative to Server C so you get > broken images and JavaScript errors because Server A is now displaying > the content. > > Every example that I have found for LWP assumes that Server A will be > handling the content, but I need to have Server C handle the content > returned. Authorize.net and PayFuse work great because they simple > reply with a Pass/Fail status, but PayPal requires login, etc. that > has to be done through their srever. > > Clear as mud? Any thoughts? Hmmm... We left out one computer, right? D = web browser of customer who's actually needs to log into PayPal and authorize the transaction. So, what you're trying to do is: 1) D -> A Customer is cruising around on your server w/ their browser. They do something and now they need to pay $$$ w/ PayPal 2) A -> C You submit whatever step 1 of PayPal IPN is to PayPal to initiate the payment 3) C -> A PayPal throws HTML back to your server saying "Hi PayPal customer! Log in!" 4) A -> D You redirect that HTML out to your customer's web browser so the human can, indeed, log into PayPal. 5) D -> C Your customer is now clicking around on PayPal's server, logging in, pushing buttons, whatever. Eventually they Do The Right Thing, authorizing you to be paid. PayPal now redirects the customer back to your server. 6) D -> A Customer is cruising around on your server again. You're paid, everybody's happy. Capitalism continues to make the world go 'round. Is that right, or am I drunk? If that's what you're trying to do, then probably the trickiest thing is getting steps 1-4 to flow in a single run of your Perl program. That program would probably flow like this: orderform.pl - Customer has just clicked something. You need their money now. You know their PayPal login ID and whatever else you need for PayPal IPN. - orderform.pl uses LWP or WWW::Mechanize or whatever to hit PayPal IPN on the back end. The customer has no idea this is occuring. - PayPal responds with a bunch of HTML which happens to be a login page. You slurp that HTML into $paypal_response, but you still haven't returned anything to the customer. They still have no idea anything is going on. - orderform.pl examines $paypal_response. If it's a login page, then we're happy. Spit $paypal_response out to STDOUT. This is the first and only thing the customer web browser ever saw. - orderform.pl exits, safe in the knowledge that PayPal will do the Right Thing and re-direct the customer back to orderform.pl (or whatever URL you want) whenever they're done clicking around in PayPal. Does that help? -ponder- Take care, j From jhannah at omnihotels.com Wed Sep 15 13:24:35 2004 From: jhannah at omnihotels.com (Jay Hannah) Date: Wed Sep 15 13:24:51 2004 Subject: [Omaha.pm] How can I log to metalog from Perl? Message-ID: <001201c49b51$417db470$4722000a@omarests2> Hola -- I'm trying to log to metalog from Perl w/o forking a call to "logger". (I'm worried about performance since my app will be high volume). I use this program: ----------------------------------------- #!/usr/bin/perl use Sys::Syslog qw(:DEFAULT setlogsock); setlogsock("unix"); openlog("ProgramX", 'ndelay', 'user'); syslog('notice', 'Test 1'); syslog('notice', 'What?: Test 2'); closelog; ----------------------------------------- And, in a syslogd log, I see this: Sep 15 10:34:25 king ProgramX: Test 1 Sep 15 10:34:25 king ProgramX: What?: Test 2 Which is great. In a metalog log, I see this: ProgramX: [What?] Test 2_ Questions: 1) Where did the datetime stamp go? I can't figure out how to get a stamp in metalog from Perl. 2) Why do I have to have a colon in the message or no log occurs? 3) What's the _ at the end of the log entry that did work? 4) Should I be using something other than Sys::Syslog? I can't find any metalog stuff in CPAN or metalog anywhere? And, on a different note: Is network logging likely to happen anytime soon? http://sourceforge.net/tracker/index.php?func=detail&aid=563753&group_id=30635&atid=399905 Thanks! Jay Hannah Director of Development Omni Hotels Reservation Center Tel: (402) 952-6573 Mobile: (402) 578-3976 Email: jhannah@omnihotels.com The Omni Majestic -- a unique boutique concept -- takes you back in time with concierge style service in the heart of St. Louis. Learn more at www.omnimajestic.com. From jhannah at omnihotels.com Wed Sep 15 13:41:52 2004 From: jhannah at omnihotels.com (Jay Hannah) Date: Wed Sep 15 13:42:08 2004 Subject: [Omaha.pm] RE: Net::Dev::Tools::Syslog -- local? Message-ID: <001901c49b53$aaf4fe70$4722000a@omarests2> Yikes... Just stumbled into an ugly hack where I can do networked syslog from inside Sys::Syslog... ----------------- #!/usr/bin/perl use Sys::Syslog qw(:DEFAULT setlogsock); $Sys::Syslog::host = "king"; # <--- Ugly hack setlogsock("inet"); openlog("ProgramX", 'ndelay', 'user'); syslog('notice', 'Test 1'); syslog('notice', 'What?: Test 2'); closelog; ---------------- Ponder... Perhaps I need to throw an doc/code patch at perl5-porters for Sys::Syslog... j > -----Original Message----- > From: Jay Hannah [mailto:jhannah@omnihotels.com] > Sent: Tuesday, September 14, 2004 6:05 PM > To: 'sparsons@cpan.org' > Cc: 'root@omnihotels.com' > Subject: Net::Dev::Tools::Syslog -- local? > > > > Hi Scott -- > > I'm trying to write an abstraction for syslog'ing for our > company (local and remote, many servers). Sometimes I'm > remote, UDP port 514 is open, and in those cases > Net::Dev::Tools::Syslog works great. Thanks! > > Other times, though, I'm local and UDP port 514 is not open. > "logger" from the command line still works, and I assume > Sys::Syslog would also work using types 'unix' or 'stream'... > > It appears to me that I need to use *both* > Net::Dev::Tools::Syslog and Sys::Syslog in my environment. I > can't seem to find any package that does what both do in a > single bundle. Am I missing something obvious to you? > > Thanks, > > Jay Hannah > Director of Development > Omni Hotels Reservation Center > Tel: (402) 952-6573 > Mobile: (402) 578-3976 > Email: jhannah@omnihotels.com > > The Omni Majestic -- a unique boutique concept -- takes you > back in time with concierge style service in the heart of St. > Louis. Learn more at www.omnimajestic.com. > From hostetlerm at gmail.com Wed Sep 15 13:51:18 2004 From: hostetlerm at gmail.com (Mike Hostetler) Date: Wed Sep 15 13:51:30 2004 Subject: [Omaha.pm] How can I log to metalog from Perl? In-Reply-To: <001201c49b51$417db470$4722000a@omarests2> References: <001201c49b51$417db470$4722000a@omarests2> Message-ID: On Wed, 15 Sep 2004 13:24:35 -0500, Jay Hannah wrote: > > Hola -- > > I'm trying to log to metalog from Perl w/o forking a call to "logger". (I'm worried about > performance since my app will be high volume). That is a good thing . . . Sys::Syslog is a wonderful. > > I use this program: > [snip] > > And, in a syslogd log, I see this: > > Sep 15 10:34:25 king ProgramX: Test 1 > Sep 15 10:34:25 king ProgramX: What?: Test 2 > > Which is great. In a metalog log, I see this: > > ProgramX: [What?] Test 2_ I got the same thing . . . A google brought me to this thread: http://www.mail-archive.com/beginners@perl.org/msg50054.html Upgrading Metalog to the latest my Gentoo box has (0.8_pre20031130) showed the same thing. >From the thread I linked to above, they seem to say that Unix::Syslog works better with metalog. I haven't tried it at all. Methinks that metalog is broken somehow. My $0.02 . . . -- Mike Hostetler thehaas@binary.net http://www.binary.net/thehaas From jhannah at omnihotels.com Wed Sep 15 14:51:42 2004 From: jhannah at omnihotels.com (Jay Hannah) Date: Wed Sep 15 14:51:58 2004 Subject: [Omaha.pm] [patch] Sys::Syslog POD - $Sys::Syslog::host Message-ID: <002001c49b5d$6d0d79c0$4722000a@omarests2> You can change $Sys::Syslog::host and the package will happily go connect (TCP or UDP) to a remote server. Works great. However, here is no interface to change $Sys::Syslog::host, and the feature isn't documented. Instead of changing openlog(), connect(), connect_udp(), connect_tcp(), and documenting all of that; I thought it would just be easier to document changing $Sys::Syslog::host. Objections? j --- Syslog.pm 2004-03-06 15:30:08.000000000 -0600 +++ new_Syslog.pm 2004-09-15 14:11:19.000000000 -0500 @@ -128,6 +128,12 @@ $! = 55; syslog('info', 'problem was %m'); # %m == $! in syslog(3) + # Log to UDP port on $remotehost instead of logging locally + setlogsock('udp'); + $Sys::Syslog::host = $remotehost; + openlog($program, 'ndelay', 'user'); + syslog('info', 'something happened over here'); + =head1 SEE ALSO L From jhannah at omnihotels.com Wed Sep 15 17:35:00 2004 From: jhannah at omnihotels.com (Jay Hannah) Date: Wed Sep 15 17:35:13 2004 Subject: [Omaha.pm] Mtg tomorrow night Message-ID: <002701c49b74$3d2e69a0$4722000a@omarests2> Don't forget -- Perl Monger meetings are held the 3rd Thr of every month. That's tomorrow night. http://omaha.pm.org I'm not in the mood for any heavy lifting, so I vote we meet up at Reboot The User (RTU), then head out to dinner @ Old Chicago around 7:30. Show up at RTU to vote me down and send us somewhere else or lock us in an intense Perl lab. -grin- Hope to see you there! j From jay at jays.net Thu Sep 16 00:00:57 2004 From: jay at jays.net (Jay Hannah) Date: Thu Sep 16 00:00:28 2004 Subject: [Omaha.pm] http://perl.meetup.com - Omaha is #2! Message-ID: <65658CA4-079D-11D9-BC1C-000A95E317B8@jays.net> Straight to Omaha: http://perl.meetup.com/2/ Well, don't ask me how this happened, but out of the 88 perl.meetup.com groups, we somehow got ID # 2! Further, they made me the group organizer. Scary. I say we drive down to College Station TX (group #1) and TP them. Ya gotta love web portals w/ 1,000,000 features and no content. Oh wait, that's not right. Gotta hate them. Ya, that's it. Hate. -grin- j From jay at jays.net Thu Sep 16 01:54:41 2004 From: jay at jays.net (Jay Hannah) Date: Thu Sep 16 01:54:11 2004 Subject: [Omaha.pm] Re: LWP form posts In-Reply-To: <6.1.2.0.2.20040910100451.02399980@mail.aurora-e-solutions.com> References: <6.1.2.0.2.20040908115750.0279aec0@mail.aurora-e-solutions.com> <2BDBB172-01FB-11D9-9CB3-000A95E317B8@jays.net> <6.1.2.0.2.20040909085124.02d24640@mail.aurora-e-solutions.com> <6FB1FF2E-030C-11D9-852E-000A95E317B8@jays.net> <6.1.2.0.2.20040910100451.02399980@mail.aurora-e-solutions.com> Message-ID: <48BD9B2F-07AD-11D9-BC1C-000A95E317B8@jays.net> On Sep 10, 2004, at 10:14 AM, Michael D. Maynard wrote: > Step 3 is where the process breaks down. PayPal throws back some > HTML. Step 3 needs to be C -> D rather than C -> A. I could add Step > 3.5) Parse HTML converting relative URL's to absolute URL's. This > presents two problems. 1) should PayPal change their HTML, URL > conversion may no longer catch everything. What you're doing isn't a normal chain of events for PayPal? I'd think all their URLs would be absolute in order to facilitate what you're trying to do? > 2) Server A is not running https for this host and Computer D is not > entering login information on insecure connection. The HTML you'll be echoing to D will post to PayPal's https URL, so you should be fine, shouldn't you? Or does IE complain if a non-secured HTML form posts to an https URL? > There may not be any way to do it. On the contrary, hopefully TMTOWTDI. Grin, j From Kent.Tegels at hdrinc.com Thu Sep 16 06:53:54 2004 From: Kent.Tegels at hdrinc.com (Tegels, Kent) Date: Thu Sep 16 06:56:48 2004 Subject: [Omaha.pm] http://perl.meetup.com - Omaha is #2! Message-ID: <8046479841F5F84C9BD1F5CF4AD4379E035C38@OMA-G-L.intranet.hdr> Don't hate the Perlers. Hate their Content. ________________________________ From: omaha-pm-bounces@mail.pm.org on behalf of Jay Hannah Sent: Thu 9/16/2004 12:00 AM To: Omaha Nebraska USA Perl Mongers Subject: [Omaha.pm] http://perl.meetup.com - Omaha is #2! Straight to Omaha: http://perl.meetup.com/2/ Well, don't ask me how this happened, but out of the 88 perl.meetup.com groups, we somehow got ID # 2! Further, they made me the group organizer. Scary. I say we drive down to College Station TX (group #1) and TP them. Ya gotta love web portals w/ 1,000,000 features and no content. Oh wait, that's not right. Gotta hate them. Ya, that's it. Hate. -grin- j _______________________________________________ Omaha-pm mailing list Omaha-pm@mail.pm.org http://www.pm.org/mailman/listinfo/omaha-pm -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/omaha-pm/attachments/20040916/245ee379/attachment.htm From sswilliams at mail.unomaha.edu Thu Sep 16 13:54:55 2004 From: sswilliams at mail.unomaha.edu (Shemshon S Williams) Date: Thu Sep 16 13:50:52 2004 Subject: [Omaha.pm] (no subject) Message-ID: hi all, i have a question for everyone. I not good enough with perl to know how to design a balanced line algorithm can someone run thru the logic for me and explain how they work. shon From jay at jays.net Thu Sep 16 15:32:34 2004 From: jay at jays.net (Jay Hannah) Date: Thu Sep 16 15:32:03 2004 Subject: [Omaha.pm] (no subject) In-Reply-To: References: Message-ID: <8A48F7E6-081F-11D9-90B3-000A95E317B8@jays.net> On Sep 16, 2004, at 1:54 PM, Shemshon S Williams wrote: > i have a question for everyone. I not good enough with perl to know > how to > design a balanced line algorithm can someone run thru the logic for me > and > explain how they work. What's a balanced line algorithm? Would this help? http://search.cpan.org/~dconway/Text-Balanced-1.95/lib/Text/Balanced.pm j From sswilliams at mail.unomaha.edu Fri Sep 17 09:03:12 2004 From: sswilliams at mail.unomaha.edu (Shemshon S Williams) Date: Fri Sep 17 08:59:08 2004 Subject: [Omaha.pm] (no subject) Message-ID: that was my question..lol as far as i know it's something you can use perl to design i guess. I've just never done one so i'm not sure how to do it. shon From jay at jays.net Sun Sep 19 15:40:25 2004 From: jay at jays.net (Jay Hannah) Date: Sun Sep 19 15:39:55 2004 Subject: [Omaha.pm] Emergency Tutoring Monday night Message-ID: <2252716D-0A7C-11D9-9C01-000A95E317B8@jays.net> A UNO student named Shemshon Williams contacted me this weekend. He and his classmates are struggling with a Perl assignment. I helped him along a little, and agreed to meet with him to walk him through some of the programming. If you want to join this emergency tutoring session, feel free to give me a call. Tomorrow (Monday) @ 6:30 Omni Hotels 11819 Miami St (SE of 120th & Maple) 3rd Floor Jay's mobile: 578-3976 Level of complexity: novice/beginner If you need help, or want to give it, join us! Cheers, j From IrishMASMS at olug.org Sun Sep 19 22:55:33 2004 From: IrishMASMS at olug.org (OBrien, Timothy (Omaha Linux Users Group - OLUG)) Date: Sun Sep 19 22:55:33 2004 Subject: [Omaha.pm] http://perl.meetup.com - Omaha is #2! In-Reply-To: <65658CA4-079D-11D9-BC1C-000A95E317B8@jays.net> References: <65658CA4-079D-11D9-BC1C-000A95E317B8@jays.net> Message-ID: <1344.68.229.175.143.1095652533.squirrel@admin.olug.org> > > Straight to Omaha: > http://perl.meetup.com/2/ > > Well, don't ask me how this happened, but out of the 88 perl.meetup.com > groups, we somehow got ID # 2! Further, they made me the group > organizer. Scary. > > I say we drive down to College Station TX (group #1) and TP them. [snipped] Good for you - I am the group organizer for some other meetup events. Welcome to the club! ;) BTW, I have a good friend that just moved to College Station, TX that may be more than willing to take on the task if I asked her. -- Timothy "Irish" O'Brien Publicity & Social activities chairperson Omaha Linux User's Group (OLUG) ---------------------------------------------- A: No. Q: Should I include e-mail quotations after my reply? ===================================================== An often repeated quote on news.admin.net-abuse.email: "Spam is not about content, it is about consent". -------------------------------- Microsoft: Where do you want to go today? Linux: Where do you want to go tomorrow? FreeBSD: Are you guys coming or what? From jay at jays.net Sun Sep 19 23:17:53 2004 From: jay at jays.net (Jay Hannah) Date: Sun Sep 19 23:17:23 2004 Subject: [Omaha.pm] http://perl.meetup.com - Omaha is #2! In-Reply-To: <1344.68.229.175.143.1095652533.squirrel@admin.olug.org> References: <65658CA4-079D-11D9-BC1C-000A95E317B8@jays.net> <1344.68.229.175.143.1095652533.squirrel@admin.olug.org> Message-ID: <0ABF4A04-0ABC-11D9-BF8A-000A95E317B8@jays.net> On Sep 19, 2004, at 10:55 PM, OBrien, Timothy (Omaha Linux Users Group - OLUG) wrote: > BTW, I have a good friend that just moved to College Station, TX that > may > be more than willing to take on the task if I asked her. Excellent. TPing by proxy. I like it. Tell them to hand over meetup ID #1 or suffer the wrath of your "good friend". Is she intimidating? j From jhannah at omnihotels.com Mon Sep 20 11:27:44 2004 From: jhannah at omnihotels.com (Jay Hannah) Date: Mon Sep 20 11:27:59 2004 Subject: [Omaha.pm] Re: Net::Dev::Tools::Syslog -- local? Message-ID: <003a01c49f2e$c288be30$4722000a@omarests2> -ponder- j -----Original Message----- From: Scott Parsons [mailto:scott.parsons@marconi.com] Sent: Monday, September 20, 2004 10:14 AM To: jhannah@omnihotels.com Subject: Re: Net::Dev::Tools::Syslog -- local? Jay (Sorry for late reply, was out of office last week.) I do not think you are missing anything in your use of Net::Dev::Tools::Syslog. It does not account for local messages, All it does is open a socket to listen for messages: (line 1315) # open socket $sock = IO::Socket::INET->new( LocalPort => $listen->{port}, Proto => $listen->{proto}, ); My intent when writing this was not for someone to make a syslog daemon but to use the listen function when testing for syslog messages arriving at a device. Thus did not account for local messages. Actually my main goal was to write a syslog parser, in doing that needed a quick/simple generator/anaylzer, that became send/listen function. For just syslog functionality you should not need both modules, just Sys::Syslog, it looks like it tries to handle streams. Thanks for the feedback, guess I should add to my doc about the intent of the functions, since its limiting. Scott Parsons At 06:05 PM 9/14/2004 -0500, you wrote: >Hi Scott -- > >I'm trying to write an abstraction for syslog'ing for our company (local >and remote, many servers). Sometimes I'm remote, UDP port 514 is open, and >in those cases Net::Dev::Tools::Syslog works great. Thanks! > >Other times, though, I'm local and UDP port 514 is not open. "logger" from >the command line still works, and I assume Sys::Syslog would also work >using types 'unix' or 'stream'... > >It appears to me that I need to use *both* Net::Dev::Tools::Syslog and >Sys::Syslog in my environment. I can't seem to find any package that does >what both do in a single bundle. Am I missing something obvious to you? > >Thanks, > >Jay Hannah >Director of Development >Omni Hotels Reservation Center >Tel: (402) 952-6573 >Mobile: (402) 578-3976 >Email: jhannah@omnihotels.com > >The Omni Majestic -- a unique boutique concept -- takes you back in time >with concierge style service in the heart of St. Louis. Learn more at >www.omnimajestic.com. From jhannah at omnihotels.com Mon Sep 20 11:41:12 2004 From: jhannah at omnihotels.com (Jay Hannah) Date: Mon Sep 20 11:42:08 2004 Subject: [Omaha.pm] RE: Net::Dev::Tools::Syslog -- local? In-Reply-To: <5.2.1.1.0.20040920105046.0293cb40@whq-msgusr-03> Message-ID: <004001c49f30$a44c58d0$4722000a@omarests2> From: Scott Parsons [mailto:scott.parsons@marconi.com] > For just syslog functionality you should not need both modules, just > Sys::Syslog, it looks like it tries to handle streams. Yes. Sys::Syslog works great for local and remote delivery until I want to log locally and simultaneously log to multiple remote machines, depending on the message / facility / priority / what have you. Since it's procedural code, calls to openlog() and closelog() are unilateral and I don't have granular control of open/close on multiple simultaeous sessions. If it was OO, I could just have as many $syslog objects as I wanted and do whatever. Unless I'm missing something, which wouldn't surprise me. FWIW, below is a snippet of POD from one of my classes talking about the various Syslog'y packages... > Thanks for the feedback, guess I should add to my doc about the intent of > the functions, since its limiting. Sure. Thanks for all your work on the module! It's slick! I'm using it to log to mutiple remote machines. (err.... I *will be* using it soon... -grin-) Take care, j =item B Procedural. Works great to local and remote syslogd processes. Local delivery can be accomplished via "setlogsock 'unix';", which avoids the overhead of UDP/TCP delivery. This is the B that works like this. Remote delivery via UDP or TCP can be used by setting $Sys::Syslog::host. (Jay sent a POD patch to perl5-porters.) =item B OO. Needs an open UDP port. =item B OO. Needs an open UDP port. Very verbose interface w/ lots of fancy dials and switches. Does parsing too, and is actively maintained. =item B Procedural. Sys::Syslog does everything Unix::Syslog does anyway? The docs for Unix::Syslog make claims that don't seem true anymore while comparing itself to Sys::Syslog. =item B Little command line utility that works great. Logs to syslog and metalog with no problems. You can even open a filehandle to it, turn on autoflushing, and just leave it running, which should avoid the overhead of forking it every time. =item B So... it's decision time. Let's do this: local server metalog /usr/bin/logger syslog /usr/bin/logger central server(s) syslog - these have to be syslog. metalog won't listen. One Net::Dev::Tools::Syslog instance per server From jhannah at omnihotels.com Mon Sep 20 14:39:00 2004 From: jhannah at omnihotels.com (Jay Hannah) Date: Mon Sep 20 14:39:17 2004 Subject: [Omaha.pm] Anyone ever configured a bundle? Message-ID: <006801c49f49$7af2fbb0$4722000a@omarests2> So I'm installing yet another dependency on yet another server. It should would be neat if we created a local bundle called Omni::ProjectX and CPAN.pm would just install the requisite 15 packages automatically. Anyone played with bundles? That would be a neat demo for a mtg... j From sswilliams at mail.unomaha.edu Mon Sep 20 16:16:08 2004 From: sswilliams at mail.unomaha.edu (Shemshon S Williams) Date: Mon Sep 20 16:12:00 2004 Subject: [Omaha.pm] Emergency Tutoring Monday night Message-ID: Jay, we still on for 6:30? Am i supplying pizza and question or just questions..lol shon From jay at jays.net Mon Sep 20 16:15:45 2004 From: jay at jays.net (Jay Hannah) Date: Mon Sep 20 16:15:14 2004 Subject: [Omaha.pm] Emergency Tutoring Monday night In-Reply-To: References: Message-ID: <3C7B4BAE-0B4A-11D9-9590-000A95E317B8@jays.net> On Sep 20, 2004, at 4:16 PM, Shemshon S Williams wrote: > we still on for 6:30? Am i supplying pizza and question or just > questions..lol Yup, we're on. If you want to bring food, that'd be great. I eat anything. -grin- If not, don't worry about it. (No beer allowed @ my work, by the way. -grin-) j From jay at jays.net Mon Sep 20 21:41:55 2004 From: jay at jays.net (Jay Hannah) Date: Mon Sep 20 21:41:26 2004 Subject: [Omaha.pm] misc notes In-Reply-To: References: Message-ID: Here's the fruits of our labor... # =============================================================== #!/usr/bin/perl #unless (open INP_MASTER, "master.out") { die "Cannot open the master output file."; } unless (open INP_TRANS, ") { my $line = $_; chomp $line; my @columns; # <-- each line of data will go in here temporarily foreach my $length (@master_field_lengths) { my $column = substr $line, 0, $length, undef; $column =~ s/\s+$//; push @columns, $column; } # Debug info: #print "I just read this into memory:\n"; #print join "|", @columns; #print "\n"; # Bug: Check for dupes in master.in before memorizing this! # Remember this line of data for later. $master{$columns[0]} = [ @columns ]; } # ------------------------------------ # Step 2: Read trans.in and do stuff # ------------------------------------ my %counts; while () { my $line = $_; chomp $line; $line =~ s/[^ -~]//g; # Remove non-printable characters! print "[$line]\n"; my $code = substr $line, 0, 2; my $key = substr $line, 2, 10; $key =~ s/\s+$//; my $data = substr $line, 12; if ($code eq "00") { print " Deleting $key.\n"; delete $master{$key}; } elsif ($code eq "01") { if (defined $master{$key}) { print " ERROR! You attempted to add key '$key', "; print "but that key already exists.\n"; } else { print " Adding $key.\n"; $master{$key} = [$key]; } } elsif ($code eq "AA") { print " Changing location for $key from '$master{$key}[1]' to '$data'.\n"; $master{$key}[1] = $data; } elsif ($code eq "AB") { print " Changing model number for $key from '$master{$key}[2]' to '$data'.\n"; $master{$key}[2] = $data; } elsif ($code eq "AC") { print " Changing the memory configuration for $key from '$master{$key}[3]' to '$data'.\n"; $master{$key}[3] = $data } $counts{$code} = $counts{$code} + 1; } print "\nHere are your counts:\n"; foreach $x (sort keys %counts) { print "$x: $counts{$x}\n"; } # ------------------------------------ # Step 3: Dump %master out to master.out # ------------------------------------ my $format; foreach my $length (@master_field_lengths) { $format = $format . '%-' . $length . 's'; } foreach $key (sort keys %master) { my $dataref = $master{$key}; my @data = @$dataref; printf OUT_MASTER $format, @data; print OUT_MASTER "\n"; } close INP_MASTER; close OUT_MASTER; close INP_TRANS; # =============================================================== [jhannah-mac:~/Desktop/tmp] jhannah% more j4.pl my $one = 0; my $two = 0; my $three = 0; for (1..10) { my $num = int(rand(3)) + 1; print "$num\n"; if ($num == 1) { $one = $one + 1; } elsif ($num == 2) { $two = $two + 1; } elsif ($num == 3) { $three = $three + 1; } } print "Ones: $one\n"; print "Twos: $two\n"; print "Threes: $three\n"; [jhannah-mac:~/Desktop/tmp] jhannah% more j5.pl my %counts; for (1..1000) { my $num = int(rand(9)) + 1; print "$num "; $counts{$num} = $counts{$num} + 1; } print "\nHere are your counts:\n"; foreach $key (sort keys %counts) { print "$key: $counts{$key}\n"; } [jhannah-mac:~/Desktop/tmp] jhannah% more j6.pl my @master_field_lengths = ( 10, 25, 15, 25, 15, 15, 15, 15, 15, 15, 15, 15, 100, 15, 5, 15 ); my $format; foreach my $length (@master_field_lengths) { $format = "$format $length "; print "$format\n"; } # %-10s%-25s%-15s... $format = $format . " $length "; $format .= " $length "; $format = $format . '%-' . $length . 's'; [jhannah-mac:~/Desktop/tmp/tmp] jhannah% more j.pl #!/usr/bin/perl my %hash = ( "monthone" => 'Jan', "monthtwo" => 'Feb', 3 => 'Mar' ); print " $hash{'monthone'} $hash{3} \n"; $hash{3} = "March Madness"; print " $hash{'monthone'} $hash{3} \n"; my @array = ( "Jun", "Jul", "Aug" ); print " $array[0] $array[2] \n"; $array[2] = "Augusto!"; print " $array[0] $array[2] \n"; print "$array[1] $hash{'monthtwo'} \n"; $hash{'Jay'} = "Hannah"; $hash{3} = "Three"; print "$hash{'Jay'} $hash{3} $array[2] \n"; [jhannah-mac:~/Desktop/tmp/tmp] jhannah% more j2.pl my %hash = ( 'chair' => 'pizza', 'monitor' => 'screen', 'TV' => 'football' ); my $key; foreach $key (keys %hash) { print "KEY: $key VALUE: $hash{$key}\n"; } delete $hash{chair}; if (defined $hash{chair}) { print "There is a chair!\n"; } else { print "There is NO chair!\n"; } delete $hash{'TV'}; $hash{'Jay'} = "Motorcycle"; [jhannah-mac:~/Desktop/tmp/tmp] jhannah% more j3.pl if ($a) { # ...do something... } elsif ($b) { # ...do something... # ...do something... if ($x) { print "Blah!\n"; } else { if ($y) { print "yargh!\n"; if ($myval) { die "Can't do that!"; } } } } elsif ($c) { # ...do something... } else { # ...do something... } [jhannah-mac:~/Desktop/tmp/tmp] jhannah% more j4.pl $var = "Jay"; print "blah\n"; print 'blah\n'; print "\n"; print "$var\n"; print '$var\n'; print "\n"; print " '$var' \n"; [jhannah-mac:~/Desktop/tmp/tmp] jhannah% more prog.pl #!/usr/bin/perl open (IN, "infile.txt"); open (OUT, ">outfile.txt"); while () { my $line = $_; print OUT "I just read this line: $line"; } -------------- $a FALSE $b TRUE $x FALSE $y TRUE $myval FALSE my $string = "Jay Hannah"; $string =~ s/a/A/; "JAy HAnnAh"; Regular expressions $string =~ s/ / /; \s a space \s+ one or more spaces $ end of string [abc] a or b or c [^abc] NOT a or b or c [ -~] ASCII characters -space- through ~ [^ -~] NOT ACII -space- through ~ perldoc perl perldoc perlre s/a/b/; Change one a to b s/a/b/g; Change ALL as to bs s/a/b/i; Change as or As to bs s/a/b/gi; Change ALL as or As to bs s/a/b/ig; Change ALL as or As to bs From dan at linder.org Mon Sep 20 23:04:55 2004 From: dan at linder.org (Daniel Linder) Date: Mon Sep 20 23:00:41 2004 Subject: [Omaha.pm] Debugging running Perl code on Windows. Message-ID: <18205.68.227.169.15.1095739495.squirrel@68.227.169.15> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I'm trying to debug hung perl processes running on a Windows 2003 server. It is running the pre-compiled ActiveState perl, and the perl program runs once every five minutes processing e-mail from a remote POP3 server. Occasionaly the perl interperter gets stuck and will wait forever. Does anyone know of a way to hook into the running perl process under Windows to see what it is really waiting for? If it helps, I'm using the Open Perl IDE (http://open-perl-ide.sourceforge.net/). My last resort is to put a ton of debug logging into the script and let it run but I'd rather not add that overhead... Dan - - - - - "I do not fear computer, I fear the lack of them." -- Isaac Asimov -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQFBT6hnNiBNyqUzGb8RArfAAJ90O9HegSVw8is8dK/rdFLM7tVbwACfZWa5 wJEazoVbFYf9TIS75IBhihA= =5zLc -----END PGP SIGNATURE----- From jay at jays.net Tue Sep 21 08:16:39 2004 From: jay at jays.net (Jay Hannah) Date: Tue Sep 21 08:16:11 2004 Subject: [Omaha.pm] Debugging running Perl code on Windows. In-Reply-To: <18205.68.227.169.15.1095739495.squirrel@68.227.169.15> References: <18205.68.227.169.15.1095739495.squirrel@68.227.169.15> Message-ID: <79064A2C-0BD0-11D9-ADAC-000A95E317B8@jays.net> On Sep 20, 2004, at 11:04 PM, Daniel Linder wrote: > Occasionaly the perl interperter gets stuck and will wait forever. > Does > anyone know of a way to hook into the running perl process under > Windows > to see what it is really waiting for? If it helps, I'm using the Open > Perl IDE (http://open-perl-ide.sourceforge.net/). My last resort is to > put a ton of debug logging into the script and let it run but I'd > rather > not add that overhead... I'd add the debugging information and send it to a log. Debugging info is good to have in any program, regardless. If you don't want all the debug all the time, add a command line --debug parameter or something to activate it. If it sticks frequently I'd run it through the debugger: perl -d myprog.pl c # "continue". Run the program until I stop you. # process runs for a while then hangs ^C # break # now you can see what line number the program stopped on. v # print several lines of source w/ ==> pointing at the current line . # print the current line again HTH, j From dan at linder.org Tue Sep 21 09:22:24 2004 From: dan at linder.org (Daniel Linder) Date: Tue Sep 21 09:18:31 2004 Subject: [Omaha.pm] Debugging running Perl code on Windows. In-Reply-To: <79064A2C-0BD0-11D9-ADAC-000A95E317B8@jays.net> References: <18205.68.227.169.15.1095739495.squirrel@68.227.169.15> <79064A2C-0BD0-11D9-ADAC-000A95E317B8@jays.net> Message-ID: <23373.12.160.138.51.1095776544.squirrel@12.160.138.51> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 > I'd add the debugging information and send it to a log. Debugging info > is good to have in any program, regardless. If you don't want all the > debug all the time, add a command line --debug parameter or something > to activate it. > > If it sticks frequently I'd run it through the debugger: > perl -d myprog.pl Thanks, I'll keep that in mind. This program will run every five minutes for weeks at a time and only get a couple "stuck" processes after a week so it's not predictable enough to debug interactively. What I'll probably do is create a pseudo-random logfile in c:\temp\ each time the process runs, then upon successfull completion of the script I'll issue a cleanup command that will erase that log file. Unless the perl script is breaking in some other odd way, this should allow me to view logs of stuck processes without consuming disk resources should this need to run for months at a time. ObPerlNote: The "END" directive is great for this -- I just found this about two months ago and really like this "catch all" for the termination of my scripts. Dan - - - - - "I do not fear computer, I fear the lack of them." -- Isaac Asimov -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQFBUDkgNiBNyqUzGb8RAncNAJ4iEiOnayJvCluD3oZZJ6XWtYFMsgCdGk7h QJ3qZRpG7Bm12nMrfbNInJY= =Hfla -----END PGP SIGNATURE----- From jay at jays.net Tue Sep 21 11:05:14 2004 From: jay at jays.net (Jay Hannah) Date: Tue Sep 21 11:04:49 2004 Subject: [Omaha.pm] Debugging running Perl code on Windows. In-Reply-To: <23373.12.160.138.51.1095776544.squirrel@12.160.138.51> References: <18205.68.227.169.15.1095739495.squirrel@68.227.169.15> <79064A2C-0BD0-11D9-ADAC-000A95E317B8@jays.net> <23373.12.160.138.51.1095776544.squirrel@12.160.138.51> Message-ID: <05D05842-0BE8-11D9-AE16-000A95E317B8@jays.net> On Sep 21, 2004, at 9:22 AM, Daniel Linder wrote: > ObPerlNote: The "END" directive is great for this -- I just found this > about two months ago and really like this "catch all" for the > termination > of my scripts. How does that work? j From jay at jays.net Tue Sep 21 11:16:05 2004 From: jay at jays.net (Jay Hannah) Date: Tue Sep 21 11:15:34 2004 Subject: [Omaha.pm] The Perl Review Message-ID: <8A14DE0C-0BE9-11D9-AE16-000A95E317B8@jays.net> If anyone wants cheap hard copies of the Perl Review let me know. j > ----- Forwarded message from brian d foy ----- > > Date: Sun, 12 Sep 2004 16:45:45 -0400 (EDT) > From: brian d foy > To: Dave Cross > Subject: Re: TPR for User Groups > > Dear Perl Mongers Groups, > > I'm offering to any active Perl Mongers group a special bulk deal on > The > Perl Review: I'll send you up to 5 copies for the price of shipping. > Some > groups have donated a $1 an issue, and although I am not going to turn > away money, you don't have to give me anything for them. > > We can work out the payment arrangements individually (check, money > order, > PayPal, Amazon Honors), and you can pay me after you get the issues > > At some point I should have the money to give you more copies and no > shipping fee, but right now it's a relatively small operation and I > have a > limited number of copies. > > Some of you may remember I did this with The Perl Journal since Jon > would > send me several hundred free issues, but then, he had a print run > around > 20,000 then. I'm an order of magnitude below that at the moment. :) > > -- > brian d foy > Publisher, The Perl Review > http://www.theperlreview.com > From dan at linder.org Tue Sep 21 13:14:30 2004 From: dan at linder.org (Daniel Linder) Date: Tue Sep 21 13:10:16 2004 Subject: [Omaha.pm] Debugging running Perl code on Windows. In-Reply-To: <05D05842-0BE8-11D9-AE16-000A95E317B8@jays.net> References: <18205.68.227.169.15.1095739495.squirrel@68.227.169.15> <79064A2C-0BD0-11D9-ADAC-000A95E317B8@jays.net> <23373.12.160.138.51.1095776544.squirrel@12.160.138.51> <05D05842-0BE8-11D9-AE16-000A95E317B8@jays.net> Message-ID: <38583.12.160.138.51.1095790470.squirrel@12.160.138.51> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Sep 21, 2004, at 9:22 AM, Daniel Linder wrote: > ObPerlNote: The "END" directive is great for this -- I just found this > about two months ago and really like this "catch all" for the > termination of my scripts. > How does that work? Glad you asked... ;) If you've ever written a perl script with multiple possible exit locations you've probably written some sort of cleanup-code and tried to call it right before the actual "exit" or "die" command. But what happens if your script dies unexpectedly at someother point in the code? This is where the END "package destructor" comes into play. Just add code like the following to your program and it will execute the code as the last steps when exiting. Say you had a logfile you wanted to cleanup after each successfull run, but your code has many exit points. Rather than trying to find all the exit points and put in your cleanup subroutines -- say "WriteFinalInfoToLogFile()" -- then call "close(LOGFILE)", then finally "exit" (with the apropriate exit code for that section). You can do this instead: END { WriteFinalInfoToLogFile(); close(LOGFILE); } When a branch of your code wants to exit with code "0", the "exit 0" is called, the END section is envoked, and finally the "exit 0" is completed and the program drops back to the shell with an exit code of 0 (normally an "OK" signal). When another branch wants to exit with "code 1" (an error or other meaning), the "exit 1" is called, the END section is envoked, and finally the "exit 1" is completed and the program drops back to the shell, but this time the "exit code" of the program is set to 1. Clear? :) Check out "http://www.perl.com/doc/manual/html/pod/perlmod.html" or "http://www.perldoc.com/perl5.8.0/pod/perlmod.html" I read somewhere that the order in which the END statements are called *is* important -- some modules may use them for their own cleanup. They are run in the reverse order as the Perl interperter sees them. If you want yours to run at the very end after all the other modules have done their cleanup, then you will need to place your END { } block at the head of your program, before all other "use" or "include" statements. Dan - - - - - "I do not fear computer, I fear the lack of them." -- Isaac Asimov -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQFBUG+GNiBNyqUzGb8RAgIMAJsFtckKsEElou/2ngkPRruFG0fANACfWN6X kyM51IUfF9l0L33u3reeXlM= =4tMq -----END PGP SIGNATURE----- From hjarce2001 at yahoo.com Tue Sep 21 17:53:47 2004 From: hjarce2001 at yahoo.com (Hugh Jarce) Date: Tue Sep 21 19:33:21 2004 Subject: [Omaha.pm] Debugging running Perl code on Windows. In-Reply-To: <18205.68.227.169.15.1095739495.squirrel@68.227.169.15> Message-ID: <20040921225347.33936.qmail@web90004.mail.scd.yahoo.com> Daniel Linder wrote: > I'm trying to debug hung perl processes running on a Windows 2003 server. > It is running the pre-compiled ActiveState perl, and the perl program > runs once every five minutes processing e-mail from a remote POP3 server. > > Occasionaly the perl interperter gets stuck and will wait forever. Does > anyone know of a way to hook into the running perl process under Windows > to see what it is really waiting for? If it helps, I'm using the Open > Perl IDE (http://open-perl-ide.sourceforge.net/). My last resort is to > put a ton of debug logging into the script and let it run but I'd rather > not add that overhead... You might also try downloading various tools. For example, pslist will tell you how many threads and what state they are in when the process hangs, while handle will tell you you about the handles the process has open. Running pslist -d should tell you about the state of all threads (e.g. Wait:UserReq) -- if they are all waiting, you have a deadlock. Alternatively, watching the CPU time should tell you if the process has got stuck in an infinite loop. For intermittent hangs, you may need to break into a Windows debugger. To do that, from the Windows Task Manager, right click on the hung process and select Debug. Of course, for this to work you will need to have installed a debugger; WinDbg (freely downloadable from Microsoft web site) is a good one. If you are inexperienced in Windows C-level debugging, there is a bit of a learning curve. In case it helps, here are some useful WinDbg commands for tracking process deadlocks: ~* kv stack trace of all threads in the process !locks dump of locks !cs dump of critical sections For best results, recompile Perl from the ActiveState C sources. Doing C-level debugging is a last resort, and Jay's excellent advice of adding logging is worthwhile whether or not you go down that route. BTW, is this a Intel hyper-threaded machine? This is a long shot, but if you are running a hyper-threaded machine, you might try upgrading the BIOS to the latest version (downloadable from Intel web site). Early versions of hyper-threaded machines had some BIOS bugs that could cause intermittent hangs. Hugh. __________________________________ Do you Yahoo!? Yahoo! Mail - You care about security. So do we. http://promotions.yahoo.com/new_mail From dan at linder.org Wed Sep 22 00:13:25 2004 From: dan at linder.org (Daniel Linder) Date: Wed Sep 22 00:09:09 2004 Subject: [Omaha.pm] A less greedy regular expression... Message-ID: <20146.68.227.169.15.1095830005.squirrel@68.227.169.15> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Ok, another regexp question. I have a variable with content that looks like this: $a = "AAAbbbCCCAAAdddCCCAAAdddCCCAAAdddCCC"; Basically the "AAA" and "CCC" strings are begin and end markers for the text I am interested in (specifically the "bbb" or "ddd" strings). When I use this command to strip off the "markers" $a =~ s/AAA(.*)CCC/$1/; The $a variable ends up containing "bbbCCCAAAdddCCCAAAdddCCCAAAddd" (i.e. the first "AAA" and the last "CCC" were removed). What I had hoped for was to have the first "bbb" returned. I think the cause of this is that the =~ command is 'greedy' and will match the longest string it can find. Since the number and pattern of the remaining markers are random, is there a flag I can pass via the regexp to have it match on the first/smallest match? A work around I am looking at involves the "split" command like this: ($foo, $a, $bar) = split ("AAA|CCC", $a); Other ideas? Dan - - - - - "I do not fear computer, I fear the lack of them." -- Isaac Asimov -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQFBUQn1NiBNyqUzGb8RAvEUAJ9HwXHn1tEBitaWeo7jRXXAslwjLgCfTePa b5mUm2LIEEDW+3ElqmLF1nc= =lBRP -----END PGP SIGNATURE----- From jay at jays.net Wed Sep 22 01:31:56 2004 From: jay at jays.net (Jay Hannah) Date: Wed Sep 22 01:31:26 2004 Subject: [Omaha.pm] A less greedy regular expression... In-Reply-To: <20146.68.227.169.15.1095830005.squirrel@68.227.169.15> References: <20146.68.227.169.15.1095830005.squirrel@68.227.169.15> Message-ID: <194E37C2-0C61-11D9-B2E0-000A95E317B8@jays.net> On Sep 22, 2004, at 12:13 AM, Daniel Linder wrote: > I have a variable with content that looks like this: > > $a = "AAAbbbCCCAAAdddCCCAAAdddCCCAAAdddCCC"; > > Basically the "AAA" and "CCC" strings are begin and end markers for the > text I am interested in (specifically the "bbb" or "ddd" strings). > > When I use this command to strip off the "markers" > $a =~ s/AAA(.*)CCC/$1/; > > The $a variable ends up containing "bbbCCCAAAdddCCCAAAdddCCCAAAddd" > (i.e. > the first "AAA" and the last "CCC" were removed). What I had hoped for > was to have the first "bbb" returned. > > I think the cause of this is that the =~ command is 'greedy' and will > match the longest string it can find. Since the number and pattern of > the > remaining markers are random, is there a flag I can pass via the > regexp to > have it match on the first/smallest match? Negative. '=~' isn't greedy. '*' is. If you want to do "minimal matching" you need to use '*?'. Like so: $a =~ s/AAA(.*?)CCC/$1/; > A work around I am looking at involves the "split" command like this: > ($foo, $a, $bar) = split ("AAA|CCC", $a); > > Other ideas? 1) I've heard Text::Balanced is neat. I've never used it. 2) Use matching operator (m//g) instead of substitute (s//$1/) to get all your strings in one fell swoop: $a = "AAAbbbCCCAAAdddCCCAAAdddCCCAAAdddCCC"; @strings = ($a =~ /AAA(.*?)CCC/g); print join "|", @strings; 3) Go home because it's 01:30 and you're tired of telco crap. Grin, j From jay at jays.net Wed Sep 22 19:42:07 2004 From: jay at jays.net (Jay Hannah) Date: Wed Sep 22 19:41:39 2004 Subject: [Omaha.pm] Re: [olug] perl cpan problem In-Reply-To: <20040922181115.IUVE3430.lakermmtao05.cox.net@smtp.east.cox.net> References: <20040922181115.IUVE3430.lakermmtao05.cox.net@smtp.east.cox.net> Message-ID: <65C33615-0CF9-11D9-BA31-000A95E317B8@jays.net> On Sep 22, 2004, at 1:11 PM, wrote: > Maybe there are some Perl gurus lurking... Omaha Perl Mongers: http://omaha.pm.org If this is purely a Perl thread, we should probably take it over to that mailing list instead of OLUG. > I was trying to install XML and RSS modules from CPAN. This didn't > work correctly, but the procedure suggested upgrading CPAN and > installing the libnet bundle. OK, fine. When these didn't work > either because of an "out of memory" error, I started looking closer > by running top. What were you running when you got the error? perl -MCPAN -e ... ? Or some package manager? Or installing from source? > While the process is running, it slowly uses more and more RAM until > all physical memory (80 MB) on the system is exhausted, then it dies. > I have 192 MB of swap that is barely touched - about 8 MB in use when > Perl starts, still the same when it dies. While what process is running? Can you give us the exact command(s) you're having problems with? > Using Perl 5.6.1. Any ideas or random thoughts? Random thoughts: Computers suck. But not as much as telco. "I'd rather be sleeping." j From jhannah at omnihotels.com Thu Sep 23 16:16:17 2004 From: jhannah at omnihotels.com (Jay Hannah) Date: Thu Sep 23 16:16:26 2004 Subject: [Omaha.pm] ||= quickie Message-ID: <000101c4a1b2$916c48e0$4722000a@omarests2> Before: $airline_status_desc = $airline_status_desc ? $airline_status_desc : "NO STATUS"; After: $airline_status_desc ||= "NO STATUS"; j From hjarce2001 at yahoo.com Thu Sep 23 18:45:54 2004 From: hjarce2001 at yahoo.com (Hugh Jarce) Date: Thu Sep 23 19:04:37 2004 Subject: [Omaha.pm] ||= quickie In-Reply-To: <000101c4a1b2$916c48e0$4722000a@omarests2> Message-ID: <20040923234554.68487.qmail@web90003.mail.scd.yahoo.com> Jay Hannah wrote: > Before: > > $airline_status_desc = $airline_status_desc ? > $airline_status_desc > : "NO STATUS"; > > After: > > $airline_status_desc ||= "NO STATUS"; Very nice. I don't often see ||= used. One place I remember seeing it is the Orcish Maneuver: Hugh. __________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - 100MB free storage! http://promotions.yahoo.com/new_mail From hjarce2001 at yahoo.com Thu Sep 23 18:45:54 2004 From: hjarce2001 at yahoo.com (Hugh Jarce) Date: Thu Sep 23 19:04:44 2004 Subject: [Omaha.pm] ||= quickie In-Reply-To: <000101c4a1b2$916c48e0$4722000a@omarests2> Message-ID: <20040923234554.68487.qmail@web90003.mail.scd.yahoo.com> Jay Hannah wrote: > Before: > > $airline_status_desc = $airline_status_desc ? > $airline_status_desc > : "NO STATUS"; > > After: > > $airline_status_desc ||= "NO STATUS"; Very nice. I don't often see ||= used. One place I remember seeing it is the Orcish Maneuver: Hugh. __________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - 100MB free storage! http://promotions.yahoo.com/new_mail From sswilliams at mail.unomaha.edu Fri Sep 24 09:26:40 2004 From: sswilliams at mail.unomaha.edu (Shemshon S Williams) Date: Fri Sep 24 09:22:22 2004 Subject: [Omaha.pm] Re: [olug] perl cpan problem Message-ID: Jay, You won't believe what happened, we took all that time working on completing that project and then my instructor up and canceled class...lol and he said he would give people a little more time. You know i was getting some funky errors when i tried to copy it to the server but, i think i got it worked out. I think i need to add my print statements because the program will run thur everything right now and won't show anything on screen and i get the feeling he'll want to see something..lol next time beers on me shon From jhannah at omnihotels.com Tue Sep 28 18:53:14 2004 From: jhannah at omnihotels.com (Jay Hannah) Date: Tue Sep 28 18:53:24 2004 Subject: [Omaha.pm] du -k --max-depth 1 Message-ID: <000201c4a5b6$528279d0$4722000a@omarests2> AIX bugs me. For instance du -k --max-depth 1 works fine on Linux, but AIX's du is stupid. So here's the Perl equivalent of "--max-depth 1": du -k | perl -ne 'print if (tr#/#/# == 1)' Grin, j From jhannah at omnihotels.com Thu Sep 30 10:34:42 2004 From: jhannah at omnihotels.com (Jay Hannah) Date: Thu Sep 30 10:34:56 2004 Subject: [Omaha.pm] Randomize an array Message-ID: <001101c4a703$020ea070$4722000a@omarests2> Neat. I can't remember every wanting to randomize an array. Now I need to to see if my message pair groking routing works under load. 60 seconds on Google, and I hit this array randomizer. Yay! ( It also reminded me of this class I was looking at a couple weekends ago: http://search.cpan.org/~simon/Games-Poker-TexasHold-em-1.4/em.pm http://use.perl.org/~petdance/journal/20904 ) j ############################################################################### # # Function: shuffle # Purpose: Randomize an array # # Comments: This routine was ripped from 'Perl Cookbook' pg 121-122 # ############################################################################### sub shuffle { my $array = shift; my $i = scalar(@$array); my $j; foreach $item (@$array ) { --$i; $j = int rand ($i+1); next if $i == $j; @$array [$i,$j] = @$array[$j,$i]; } return @$array; }