From zoffix at zoffix.com Fri Aug 1 02:53:15 2008 From: zoffix at zoffix.com (Zoffix Znet) Date: Fri, 01 Aug 2008 05:53:15 -0400 Subject: [tpm] WWW::Mechanize and setting cookies In-Reply-To: <48928C85.7050405@alteeve.com> References: <48922C5D.6050100@alteeve.com> <20080731190634.wpy8j7x9oo4k4kko@webmail.utoronto.ca> <48926557.3000801@alteeve.com> <1217556712.9161.14.camel@zoflap> <48928C85.7050405@alteeve.com> Message-ID: <1217584395.9161.17.camel@zoflap> Well {cookie_jar} is not defined when you call a method on it later on. As for "debuging", I just said that if you see "use base qw/Foo Bar/;" than make sure you check out Foo and Bar modules for the methods which you are looking for, same goes for "our @ISA = qw/Foo Bar/;" On Fri, 2008-08-01 at 00:09 -0400, Madison Kelly wrote: > Zoffix Znet wrote: > > Yes, that won't work, because WWW::Mechanize doesn't actually set > > {cookie_jar} element in its blessed hashref. Take a look at Mech's > sub > > new {}.. > > > > Now why it doesn't error out, as you've said, with " Can't call > method > > "set_cookie" on an undefined value at LINE" with your code below I > don't > > really understand.. but anyway.. use ->cookie_jar method to obtain > the > > HTTP::Cookies object and always check the "use base" or @ISA > assignments > > when you can't find the documented method in the code ^_^ > > > > Cheers. > > I think it didn't error out because 'cookie_jar' is a hash key in the > blessed 'self', which '$agent' is a reference to. > > I have to claim ignorance now; how would I use 'use base' or check the > @ISA assignments to debug? I understand that these control the order of > method lookups... > > Madi From zoffix at zoffix.com Fri Aug 1 02:57:03 2008 From: zoffix at zoffix.com (Zoffix Znet) Date: Fri, 01 Aug 2008 05:57:03 -0400 Subject: [tpm] WWW::Mechanize and setting cookies In-Reply-To: <48928C0B.8030600@alteeve.com> References: <48922C5D.6050100@alteeve.com> <1217552179.9161.1.camel@zoflap> <48928C0B.8030600@alteeve.com> Message-ID: <1217584623.9161.20.camel@zoflap> You are not setting the cookie "domain". This works just fine: #!/usr/bin/env perl use strict; use warnings; use WWW::Mechanize; my $mech = WWW::Mechanize->new; $mech->get('http://zoffix.com/new/cookies.pl'); print "BEFORE:\n", $mech->content, "\n"; $mech->cookie_jar->set_cookie( 0, 'foo', 'bar', '/', 'zoffix.com' ); $mech->get('http://zoffix.com/new/cookies.pl'); print "AFTER:\n", $mech->content, "\n"; Prints: BEFORE: Cookies: AFTER: Cookies: foo => bar If you are interested in the source code of that cookies.pl script see: http://www.zoffix.com/new/cookies.pl?source Cheers On Fri, 2008-08-01 at 00:07 -0400, Madison Kelly wrote: > Zoffix Znet wrote: > > WWW::Mechanize uses LWP::UserAgent as base class, thus you'd call > > $mech->cookie_jar to get the HTTP::Cookies object. Which comes to > > $mech->cookie_jar->set_cookie( $version, $key, $val, $path, $domain, > > $port, $path_spec, $secure, $maxage, $discard, \%rest ); > > > > Cheers. > > Hi, > > Thanks for this! It seems to make more sense but it still doesn't > seem to work for me. Here is how I've updated the code I originally > quoted in my reply to Adam: > > # Removed the 'HTTP::Cookies' reference > my $agent = WWW::Mechanize->new(autocheck => 1); > ... > # Changed this to your recommendation. > $agent->cookie_jar->set_cookie(0, $variable, $value, $path); > > *sigh* > > Madi From zoffix at zoffix.com Fri Aug 1 03:06:14 2008 From: zoffix at zoffix.com (Zoffix Znet) Date: Fri, 01 Aug 2008 06:06:14 -0400 Subject: [tpm] WWW::Mechanize and setting cookies In-Reply-To: <1217584395.9161.17.camel@zoflap> References: <48922C5D.6050100@alteeve.com> <20080731190634.wpy8j7x9oo4k4kko@webmail.utoronto.ca> <48926557.3000801@alteeve.com> <1217556712.9161.14.camel@zoflap> <48928C85.7050405@alteeve.com> <1217584395.9161.17.camel@zoflap> Message-ID: <1217585174.9161.26.camel@zoflap> I stand corrected, this code (yours originally) works just fine: The reason it works is because LWP::UserAgent sets the {cookie_jar} element to what you've passed as 'cookie_jar' argument to the constructor: $self->{cookie_jar} = $jar; I never looked at LWP::UserAgent source code last night, thus I missed it. Once again, the reason it didn't work for you is because you weren't setting the domain for the cookie. #!/usr/bin/env perl use strict; use warnings; use WWW::Mechanize; use HTTP::Cookies; my $mech = WWW::Mechanize->new( cookie_jar => HTTP::Cookies->new ); $mech->get('http://zoffix.com/new/cookies.pl'); print "BEFORE:\n", $mech->content, "\n"; $mech->{cookie_jar}->set_cookie( 0, 'foo', 'bar', '/', 'zoffix.com' ); $mech->get('http://zoffix.com/new/cookies.pl'); print "AFTER:\n", $mech->content, "\n"; BEFORE: Cookies: AFTER: Cookies: foo => bar Cheers. On Fri, 2008-08-01 at 05:53 -0400, Zoffix Znet wrote: > Well {cookie_jar} is not defined when you call a method on it later on. > > As for "debuging", I just said that if you see "use base qw/Foo Bar/;" > than make sure you check out Foo and Bar modules for the methods which > you are looking for, same goes for "our @ISA = qw/Foo Bar/;" > > > > On Fri, 2008-08-01 at 00:09 -0400, Madison Kelly wrote: > > Zoffix Znet wrote: > > > Yes, that won't work, because WWW::Mechanize doesn't actually set > > > {cookie_jar} element in its blessed hashref. Take a look at Mech's > > sub > > > new {}.. > > > > > > Now why it doesn't error out, as you've said, with " Can't call > > method > > > "set_cookie" on an undefined value at LINE" with your code below I > > don't > > > really understand.. but anyway.. use ->cookie_jar method to obtain > > the > > > HTTP::Cookies object and always check the "use base" or @ISA > > assignments > > > when you can't find the documented method in the code ^_^ > > > > > > Cheers. > > > > I think it didn't error out because 'cookie_jar' is a hash key in the > > blessed 'self', which '$agent' is a reference to. > > > > > > > > > I have to claim ignorance now; how would I use 'use base' or check the > > @ISA assignments to debug? I understand that these control the order of > > method lookups... > > > > Madi > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm From linux at alteeve.com Fri Aug 1 03:51:46 2008 From: linux at alteeve.com (Madison Kelly) Date: Fri, 01 Aug 2008 06:51:46 -0400 Subject: [tpm] WWW::Mechanize and setting cookies In-Reply-To: <1217584623.9161.20.camel@zoflap> References: <48922C5D.6050100@alteeve.com> <1217552179.9161.1.camel@zoflap> <48928C0B.8030600@alteeve.com> <1217584623.9161.20.camel@zoflap> Message-ID: <4892EAC2.6050706@alteeve.com> Zoffix Znet wrote: > You are not setting the cookie "domain". This works just fine: > > #!/usr/bin/env perl > > use strict; > use warnings; > use WWW::Mechanize; > > my $mech = WWW::Mechanize->new; > > $mech->get('http://zoffix.com/new/cookies.pl'); > print "BEFORE:\n", $mech->content, "\n"; > > $mech->cookie_jar->set_cookie( 0, 'foo', 'bar', '/', 'zoffix.com' ); > > $mech->get('http://zoffix.com/new/cookies.pl'); > print "AFTER:\n", $mech->content, "\n"; > > > Prints: > BEFORE: > Cookies: > > AFTER: > Cookies: > foo => bar > > > If you are interested in the source code of that cookies.pl script see: > http://www.zoffix.com/new/cookies.pl?source > > > Cheers Bingo! I thought the domain was an optional method of letting a cookie work across sub-domains, so I left it off. Doh! Thank you very kindly! Madi From abram.hindle at softwareprocess.us Fri Aug 1 07:32:49 2008 From: abram.hindle at softwareprocess.us (Abram Hindle) Date: Fri, 01 Aug 2008 10:32:49 -0400 Subject: [tpm] WWW::Mechanize and setting cookies In-Reply-To: <1217556712.9161.14.camel@zoflap> (sfid-20080731_222106_419807_36480EAE) References: <48922C5D.6050100@alteeve.com> <20080731190634.wpy8j7x9oo4k4kko@webmail.utoronto.ca> <48926557.3000801@alteeve.com> <1217556712.9161.14.camel@zoflap> (sfid-20080731_222106_419807_36480EAE) Message-ID: <48931E91.3090008@softwareprocess.us> Sorry, this is late, I sent this under an unsubscribed email before. $ua->cookie_jar({}); or WWW::Mechanize->new(cookie_jar=>{}); Will initialize a cookie jar for you This is helpful: $ua->cookie_jar(new HTTP::Cookies()); $ua->default_headers(getDefaultHeader()); sub getDefaultHeaders { my $header = HTTP::Headers->new( User_Agent => "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050920 Firefox/1.0.7", Accept => "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5", Accept_Language => "en-us,en;q=0.5", Accept_Encoding => "gzip,deflate", Accept_Charset => "ISO-8859-1,utf-8;q=0.7,*;q=0.7", Keep_Alive => 300, Connection => "keep-alive", ); #$header->remove_header('TE'); return $header; } Also here are slides with tips at the end for using WWW::Mechanize http://presentation.abez.ca/victoriaPMJan2003Slides.pdf abram Zoffix Znet wrote: > Yes, that won't work, because WWW::Mechanize doesn't actually set > {cookie_jar} element in its blessed hashref. Take a look at Mech's sub > new {}.. > > Now why it doesn't error out, as you've said, with " Can't call method > "set_cookie" on an undefined value at LINE" with your code below I don't > really understand.. but anyway.. use ->cookie_jar method to obtain the > HTTP::Cookies object and always check the "use base" or @ISA assignments > when you can't find the documented method in the code ^_^ > > Cheers. > > > On Thu, 2008-07-31 at 21:22 -0400, Madison Kelly wrote: >> adam.prime at utoronto.ca wrote: >>> Quoting Madison Kelly : >>> >>>> Hi all, >>>> >>>> I've run into the need to set some cookies for a WWW::Mechanize >>>> object I am using. As I understand it, the default 'cookie_jar' is >>>> supposed to be an instance of HTTP::Cookies, but I can't see where that >>>> is implemented in the module. Despite that, I tried calling the >>>> 'set_cookie' method but, as I expected, got an error saying that is not >>>> a known method. >>>> >>>> So dear TPM, can someone clue me in on how to set a bunch of cookies >>>> using WWW::Mechanize? >>> Looking at the documentation it looks like Mechanize is designed such >>> that it will keep track of cookies that get set through a series of >>> requests. It looks to me like the only way to set it up to start with >>> cookies in the first place would be to Create an instance of >>> HTTP::Cookies with the stuff you want in it, and use that when you >>> create your initial Mechanize object. >> I've tried that, see below (to keep the message clean). >> >>>> Bonus round! >>>> >>>> If this is an HTTP::Cookies object, what pray tell is '$version' >>>> supposed to be when setting the cookie? Beyond setting it, there is no >>>> mention of it in the docs and the code merely shows it being set to '0' >>>> in undef. >>>> >>>> Thanks as always! >>> Looking at the code it seem to put "\$Version=$version" into your cookie >>> if you set it to a value larger than 0. I have no idea what that's >>> about, but i'd probably be passing in 0's. >>> >>> The interface for HTTP::Cookies looks pretty horrid :x >>> >>> Adam >> Indeed it is... >> >> At any rate, here is what I am doing. I connect to an HTTPS site that is >> made by a nameless "big company" which means the design is terribly >> inconsistent. For some reason, after doing a particular search, the site >> returns a redirect page that sets a pile of cookies using JS >> 'document.cookie="..."' calls, the a 'document.location' to follow the >> link, all of which is triggered by an 'onload' call. Now the problem is, >> all the 'document.cookie' values are needed to get the actual data I >> need. Seeing as WWW::Mechanize doesn't support JS, I need to find a way >> to set them manually. >> >> So here are the relevant bits: >> >> -=] Setting up my WWW::Mechanize object >> use HTTP::Cookies; >> my $agent = WWW::Mechanize->new( >> autocheck => 1, >> cookie_jar => HTTP::Cookies->new(), >> ); >> $agent->agent_alias("Linux Mozilla"); >> >> # I do a pile of work, following links, submitting forms and such, until >> # I get to the JS redirect page I described, where I try to follow the >> # redirect after setting cookies. **This Fails**. >> >> -=] Process the JS redirect bastardization >> # Process the results. >> my $processing_page=$agent->content; >> foreach my $cookie ($processing_page=~/document.cookie="(.*?)"/gs) >> { >> my ($variable, $value, $path, $expires)=""; >> if ( $cookie =~ /expires/ ) >> { >> ($variable, $value, $path, $expires)=$cookie=~/(.*?)=(.*?); >> path=(.*?); expires=(.*?);/; >> print "Setting Cookie: [$variable]->[$value] \@ [$path] ($expires).\n"; >> } >> else >> { >> ($variable, $value, $path)=$cookie=~/(.*?)=(.*?); path=(.*?);/; >> print "Setting Cookie: [$variable]->[$value] \@ [$path].\n"; >> } >> $$agent{cookie_jar}->set_cookie(0, $variable, $value, $path); >> } >> my ($processing_link)=$processing_page=~/window.location="(.*?)"/; >> print "Following results link: [$processing_link]\n"; >> $agent->get($processing_link); >> -=-=-=-=-=-=-=-=- >> >> The closest I could figure to access the HTTP::Cookies methods was by >> calling it as I did, though I realize this is probably not smart as I am >> trying to access internal values, but it was as close as I could get. >> This doesn't error, but it also doesn't seem to work. >> >> Any further ideas? >> >> Madi >> _______________________________________________ >> toronto-pm mailing list >> toronto-pm at pm.org >> http://mail.pm.org/mailman/listinfo/toronto-pm > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 252 bytes Desc: not available URL: From linux at alteeve.com Fri Aug 1 07:50:53 2008 From: linux at alteeve.com (Madison Kelly) Date: Fri, 01 Aug 2008 10:50:53 -0400 Subject: [tpm] YARE (yet another regex) question Message-ID: <489322CD.9060700@alteeve.com> As an expansion to my earlier question on assigning values to new variables directly from a regular expression; I want to now use a similar technique to populate a 'foreach' loop. Specifically; This works: # WWW::Mechanize object. my $processing_page=$agent->content; foreach my $cookie ($processing_page=~/document.cookie="(.*?)"/gs) { my ($variable, $value, $path)=$cookie=~/(.*?)=(.*?); path=(.*?);/; print "Setting cookie: [$variable=$value, $path under $$conf{nexxia}{cookie_domain}]\n"; $agent->cookie_jar->set_cookie(0, $variable, $value, $path, $$conf{nexxia}{cookie_domain}); } However, this doesn't: my $results_page=$agent->content; my %results=(); foreach (my $variable, my $value) ($results_page=~//gs) { print "Storing: [$variable]\t->\t[$value]\n"; $results{$variable}=$value; } I'd like to grab two variables into a foreach loop. Perhaps this doesn't work at all, regardless of the source? Thanks, as always! Madi From fulko.hew at gmail.com Fri Aug 1 09:12:52 2008 From: fulko.hew at gmail.com (Fulko Hew) Date: Fri, 1 Aug 2008 12:12:52 -0400 Subject: [tpm] YARE (yet another regex) question In-Reply-To: <489322CD.9060700@alteeve.com> References: <489322CD.9060700@alteeve.com> Message-ID: <8204a4fe0808010912v36d92e76h8984e7c0344b59dd@mail.gmail.com> On Fri, Aug 1, 2008 at 10:50 AM, Madison Kelly wrote: > As an expansion to my earlier question on assigning values to new > variables directly from a regular expression; I want to now use a similar > technique to populate a 'foreach' loop. ... snip ... > However, this doesn't: > > my $results_page=$agent->content; > my %results=(); > foreach (my $variable, my $value) ($results_page=~/ type="hidden" value="(.*?)">/gs) > ^^ How about... you forgot the equal sign for the assignment! -------------- next part -------------- An HTML attachment was scrubbed... URL: From linux at alteeve.com Fri Aug 1 09:17:56 2008 From: linux at alteeve.com (Madison Kelly) Date: Fri, 01 Aug 2008 12:17:56 -0400 Subject: [tpm] YARE (yet another regex) question In-Reply-To: <8204a4fe0808010912v36d92e76h8984e7c0344b59dd@mail.gmail.com> References: <489322CD.9060700@alteeve.com> <8204a4fe0808010912v36d92e76h8984e7c0344b59dd@mail.gmail.com> Message-ID: <48933734.2080904@alteeve.com> Fulko Hew wrote: > > > On Fri, Aug 1, 2008 at 10:50 AM, Madison Kelly > wrote: > > As an expansion to my earlier question on assigning values to new > variables directly from a regular expression; I want to now use a > similar technique to populate a 'foreach' loop. > > > > ... snip ... > > > However, this doesn't: > > my $results_page=$agent->content; > my %results=(); > foreach (my $variable, my $value) ($results_page=~/ name="(.*?)" type="hidden" value="(.*?)">/gs) > > ^^ > > How about... you forgot the equal sign for the assignment! Doesn't look like this is the case (tried it to be sure), or if it is, I am note sure where the '=' would go for the assignment. As I understand the 'for'/'foreach' syntax is that is automatically pops a value off the array per iteration. Not that I am not often wrong. :) Madi From dave.s.doyle at gmail.com Fri Aug 1 10:07:22 2008 From: dave.s.doyle at gmail.com (Dave Doyle) Date: Fri, 1 Aug 2008 13:07:22 -0400 Subject: [tpm] YARE (yet another regex) question In-Reply-To: <48933734.2080904@alteeve.com> References: <489322CD.9060700@alteeve.com> <8204a4fe0808010912v36d92e76h8984e7c0344b59dd@mail.gmail.com> <48933734.2080904@alteeve.com> Message-ID: Hi Madision, I'm not sure I get what you're doing The foreach doesn't return a list for each iteration (which is what you're doing by trying to assign to (my $variable, my $value). It returns one scalar for each iteration of the loop. The foreach just iterates over an array. If you do a regex in a foreach with /g it returns what's captured as a list but you only get key OR value for each iteration. Why would you not just do this? (Apologies for the formatting) my $results_page = qq/ /; my %results = (); while ( $results_page =~ //gs ) { my ($var,$val) = ($1, $2); print "Storing: [$var]\t->\t[$val]\n"; $results{$var}=$val; } I don't see how the saved line is of any benefit in this instance. Further to this, regexes to parse html isn't ideal. There's any number of changes in the HTML that could break this (ordering of the attributes, case of the tags/attributes, using single instead of double quotes to delimit the values, etc...) D On Fri, Aug 1, 2008 at 12:17 PM, Madison Kelly wrote: > Fulko Hew wrote: > > >> >> On Fri, Aug 1, 2008 at 10:50 AM, Madison Kelly > linux at alteeve.com>> wrote: >> >> As an expansion to my earlier question on assigning values to new >> variables directly from a regular expression; I want to now use a >> similar technique to populate a 'foreach' loop. >> >> >> >> ... snip ... >> >> However, this doesn't: >> >> my $results_page=$agent->content; >> my %results=(); >> foreach (my $variable, my $value) ($results_page=~/> name="(.*?)" type="hidden" value="(.*?)">/gs) >> >> ^^ >> >> How about... you forgot the equal sign for the assignment! >> > > Doesn't look like this is the case (tried it to be sure), or if it is, I am > note sure where the '=' would go for the assignment. As I understand the > 'for'/'foreach' syntax is that is automatically pops a value off the array > per iteration. > > Not that I am not often wrong. :) > > > Madi > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm > -- dave.s.doyle at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From fulko.hew at gmail.com Fri Aug 1 10:21:38 2008 From: fulko.hew at gmail.com (Fulko Hew) Date: Fri, 1 Aug 2008 13:21:38 -0400 Subject: [tpm] YARE (yet another regex) question In-Reply-To: References: <489322CD.9060700@alteeve.com> <8204a4fe0808010912v36d92e76h8984e7c0344b59dd@mail.gmail.com> <48933734.2080904@alteeve.com> Message-ID: <8204a4fe0808011021w7cd10c5dm21018c52434c1a75@mail.gmail.com> On Fri, Aug 1, 2008 at 1:07 PM, Dave Doyle wrote: > Hi Madision, > > I'm not sure I get what you're doing > > The foreach doesn't return a list for each iteration > ... snip ... Of course Dave is right. I was wrong. My excuse is that I didn't spend the time to even see that this was in a loop. I just looked at the regex. (slap me silly!) -------------- next part -------------- An HTML attachment was scrubbed... URL: From linux at alteeve.com Fri Aug 1 10:44:31 2008 From: linux at alteeve.com (Madison Kelly) Date: Fri, 01 Aug 2008 13:44:31 -0400 Subject: [tpm] YARE (yet another regex) question In-Reply-To: References: <489322CD.9060700@alteeve.com> <8204a4fe0808010912v36d92e76h8984e7c0344b59dd@mail.gmail.com> <48933734.2080904@alteeve.com> Message-ID: <48934B7F.7090901@alteeve.com> Dave Doyle wrote: > Hi Madision, > > I'm not sure I get what you're doing > > The foreach doesn't return a list for each iteration (which is what > you're doing by trying to assign to (my $variable, my $value). It > returns one scalar for each iteration of the loop. The foreach just > iterates over an array. If you do a regex in a foreach with /g it > returns what's captured as a list but you only get key OR value for each > iteration. > > Why would you not just do this? > > (Apologies for the formatting) > > my $results_page = qq/ > > > /; > my %results = (); > while ( > $results_page =~ > //gs > ) { > my ($var,$val) = ($1, $2); > print "Storing: [$var]\t->\t[$val]\n"; > $results{$var}=$val; > } > > I don't see how the saved line is of any benefit in this instance. > > Further to this, regexes to parse html isn't ideal. There's any number > of changes in the HTML that could break this (ordering of the > attributes, case of the tags/attributes, using single instead of double > quotes to delimit the values, etc...) > > D Hi, Thanks for this, and it is what I will do. I had hoped to save a line of code, is all, so it's not a big deal. I am not terribly surprised that what I wanted to do wouldn't work. Oh well. :) Madi From Henry.Baragar at instantiated.ca Fri Aug 1 14:04:41 2008 From: Henry.Baragar at instantiated.ca (Henry Baragar) Date: Fri, 1 Aug 2008 17:04:41 -0400 Subject: [tpm] YARE (yet another regex) question In-Reply-To: <48934B7F.7090901@alteeve.com> References: <489322CD.9060700@alteeve.com> <48934B7F.7090901@alteeve.com> Message-ID: <200808011704.41522.Henry.Baragar@instantiated.ca> On Friday, August 01 2008 01:44 pm, Madison Kelly wrote: > Dave Doyle wrote: > > Hi Madision, > > > > I'm not sure I get what you're doing > > > > The foreach doesn't return a list for each iteration (which is what > > you're doing by trying to assign to (my $variable, my $value). It > > returns one scalar for each iteration of the loop. The foreach just > > iterates over an array. If you do a regex in a foreach with /g it > > returns what's captured as a list but you only get key OR value for each > > iteration. > > > > Why would you not just do this? > > > > (Apologies for the formatting) > > > > my $results_page = qq/ > > > > > > /; > > my %results = (); > > while ( > > $results_page =~ > > //gs > > ) { > > my ($var,$val) = ($1, $2); > > print "Storing: [$var]\t->\t[$val]\n"; > > $results{$var}=$val; > > } > > > > I don't see how the saved line is of any benefit in this instance. > > Hi, Perhaps the following saves the right number of lines and does a good job of showing the intent: my %results = $results_page =~ //g; print "Storing: [$_]\t->\t[$result[$_}\n" for keys %result; Note that this code has not been tested and probably prints the "Storing" messages in a different order. Cheers, Henry > > Further to this, regexes to parse html isn't ideal. There's any number > > of changes in the HTML that could break this (ordering of the > > attributes, case of the tags/attributes, using single instead of double > > quotes to delimit the values, etc...) > > > > D > > Hi, > > Thanks for this, and it is what I will do. I had hoped to save a line > of code, is all, so it's not a big deal. I am not terribly surprised > that what I wanted to do wouldn't work. Oh well. :) > > Madi > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm From fernandocorrea at gmail.com Tue Aug 5 09:31:00 2008 From: fernandocorrea at gmail.com (Fernando Oliveira) Date: Tue, 5 Aug 2008 13:31:00 -0300 Subject: [tpm] OT job in toronto, any one know? Message-ID: Hi, in 2 months i will go to toronto to study english, any one know a fob in perl in toronto? thanks -- Just another Perl Hacker, Fernando (SmokeMachine) http://perl-e.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From talexb at gmail.com Tue Aug 5 10:11:33 2008 From: talexb at gmail.com (Alex Beamish) Date: Tue, 5 Aug 2008 13:11:33 -0400 Subject: [tpm] OT job in toronto, any one know? In-Reply-To: References: Message-ID: On Tue, Aug 5, 2008 at 12:31 PM, Fernando Oliveira wrote: > Hi, in 2 months i will go to toronto to study english, any one know a fob in > perl in toronto? Hi Fernando, I think my grasp of English isn't as idiomatic as yours, because none of the obvious abbreviations or meanings for fob seem to make sense in the context you've used. Unless you missed the 'j' and meant 'job' instead. Yes? [] FOB is an abbreviation for Free On Board. .. [] FOB, a 1981 David Henry Hwang play, .. [] The Festival of the Babes (FOB) is a lesbian soccer festival .. [] Looks like Fall Out Boy will be heading to Paris, France as well! [] Flying Other Brothers .. If you are actually looking for a Perl position in Toronto, please feel free to contact me directly -- my employer OANDA is still in the market for a Perl developer or two. -- Alex Beamish Toronto, Ontario aka talexb From abram.hindle at softwareprocess.us Tue Aug 5 12:11:25 2008 From: abram.hindle at softwareprocess.us (Abram Hindle) Date: Tue, 05 Aug 2008 15:11:25 -0400 Subject: [tpm] OT job in toronto, any one know? In-Reply-To: (sfid-20080805_131412_562468_1891660F) References: (sfid-20080805_131412_562468_1891660F) Message-ID: <4898A5DD.4020903@softwareprocess.us> Alex Beamish wrote: > [] FOB is an abbreviation for Free On Board. .. > [] FOB, a 1981 David Henry Hwang play, .. > [] The Festival of the Babes (FOB) is a lesbian soccer festival .. > [] Looks like Fall Out Boy will be heading to Paris, France as well! > [] Flying Other Brothers .. > I'm sure he meant: FOB: Fresh Off the Boat. A little dated but fop was already used. abram P.S. Sorry if you were just making a joke instead. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 252 bytes Desc: OpenPGP digital signature URL: From psema4 at gmail.com Tue Aug 5 12:06:43 2008 From: psema4 at gmail.com (Scott Elcomb) Date: Tue, 5 Aug 2008 15:06:43 -0400 Subject: [tpm] OT job in toronto, any one know? In-Reply-To: <4898A5DD.4020903@softwareprocess.us> References: <4898A5DD.4020903@softwareprocess.us> Message-ID: <99a6c38f0808051206i759a2eb2wcfb757211cca1620@mail.gmail.com> On Tue, Aug 5, 2008 at 3:11 PM, Abram Hindle wrote: > FOB: Fresh Off the Boat. A little dated but fop was already used. Right... I knew I'd heard that somewhere; I've been bashing my head against the wall trying to remember what the acronym was. -- Scott Elcomb http://www.psema4.com/ http://www.google.com/reader/shared/14892828400785741937 From janes.rob at gmail.com Tue Aug 5 12:38:49 2008 From: janes.rob at gmail.com (Rob Janes) Date: Tue, 5 Aug 2008 15:38:49 -0400 Subject: [tpm] OT job in toronto, any one know? In-Reply-To: <99a6c38f0808051206i759a2eb2wcfb757211cca1620@mail.gmail.com> References: <4898A5DD.4020903@softwareprocess.us> <99a6c38f0808051206i759a2eb2wcfb757211cca1620@mail.gmail.com> Message-ID: <83eac04d0808051238t557cee48k4dd74ad5d716e150@mail.gmail.com> Is Fernando on the mailing list? If not, he wouldn't have seen any of this, including Alex's invitation to contact him directly. -rob On Tue, Aug 5, 2008 at 3:06 PM, Scott Elcomb wrote: > On Tue, Aug 5, 2008 at 3:11 PM, Abram Hindle > wrote: >> FOB: Fresh Off the Boat. A little dated but fop was already used. > > Right... I knew I'd heard that somewhere; I've been bashing my head > against the wall trying to remember what the acronym was. > > -- > Scott Elcomb > http://www.psema4.com/ > http://www.google.com/reader/shared/14892828400785741937 > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm > From fernandocorrea at gmail.com Tue Aug 5 12:43:59 2008 From: fernandocorrea at gmail.com (Fernando Oliveira) Date: Tue, 5 Aug 2008 16:43:59 -0300 Subject: [tpm] OT job in toronto, any one know? In-Reply-To: References: Message-ID: I am! and about the "fob", was just a typo... :) I want do a question. The TPM go out to drink beer? when? thanks 2008/8/5 Fernando Oliveira > Hi, in 2 months i will go to toronto to study english, any one know a fob > in perl in toronto? > thanks > > -- > Just another Perl Hacker, > Fernando (SmokeMachine) > http://perl-e.org > -- Just another Perl Hacker, Fernando (SmokeMachine) http://perl-e.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From janes.rob at gmail.com Tue Aug 5 12:45:18 2008 From: janes.rob at gmail.com (Rob Janes) Date: Tue, 5 Aug 2008 15:45:18 -0400 Subject: [tpm] OT job in toronto, any one know? In-Reply-To: References: <4898A5DD.4020903@softwareprocess.us> <99a6c38f0808051206i759a2eb2wcfb757211cca1620@mail.gmail.com> <83eac04d0808051238t557cee48k4dd74ad5d716e150@mail.gmail.com> Message-ID: <83eac04d0808051245j710f685dne14c80ea96dc465b@mail.gmail.com> Si! nosotros vamos a tomar cerveza cada mes On Tue, Aug 5, 2008 at 3:43 PM, Fernando Oliveira wrote: > I am! > and about the "fob", was just a typo... :) > I want do a question. The TPM go out to drink beer? > when? > thanks > > 2008/8/5 Rob Janes >> >> Is Fernando on the mailing list? If not, he wouldn't have seen any of >> this, including Alex's invitation to contact him directly. >> -rob >> >> On Tue, Aug 5, 2008 at 3:06 PM, Scott Elcomb wrote: >> > On Tue, Aug 5, 2008 at 3:11 PM, Abram Hindle >> > wrote: >> >> FOB: Fresh Off the Boat. A little dated but fop was already used. >> > >> > Right... I knew I'd heard that somewhere; I've been bashing my head >> > against the wall trying to remember what the acronym was. >> > >> > -- >> > Scott Elcomb >> > http://www.psema4.com/ >> > http://www.google.com/reader/shared/14892828400785741937 >> > _______________________________________________ >> > toronto-pm mailing list >> > toronto-pm at pm.org >> > http://mail.pm.org/mailman/listinfo/toronto-pm >> > >> _______________________________________________ >> toronto-pm mailing list >> toronto-pm at pm.org >> http://mail.pm.org/mailman/listinfo/toronto-pm > > > > -- > Just another Perl Hacker, > Fernando (SmokeMachine) > http://perl-e.org > From fulko.hew at gmail.com Tue Aug 5 12:46:47 2008 From: fulko.hew at gmail.com (Fulko Hew) Date: Tue, 5 Aug 2008 15:46:47 -0400 Subject: [tpm] OT job in toronto, any one know? In-Reply-To: References: Message-ID: <8204a4fe0808051246p120b77c2sc84db4fb318c7e78@mail.gmail.com> On Tue, Aug 5, 2008 at 3:43 PM, Fernando Oliveira wrote: > I am! > and about the "fob", was just a typo... :) > I want do a question. The TPM go out to drink beer? > when? > Yes... After our monthly meetings held on the last Thursday of each month (except December) The next meeting should be scheduled for Aug 28 -------------- next part -------------- An HTML attachment was scrubbed... URL: From talexb at gmail.com Tue Aug 5 12:47:39 2008 From: talexb at gmail.com (Alex Beamish) Date: Tue, 5 Aug 2008 15:47:39 -0400 Subject: [tpm] OT job in toronto, any one know? In-Reply-To: References: Message-ID: On Tue, Aug 5, 2008 at 3:43 PM, Fernando Oliveira wrote: > I am! > and about the "fob", was just a typo... :) > I want do a question. The TPM go out to drink beer? Pffffffffffffffffffft. Of course, after each monthly meeting. :) Alex -- Alex Beamish Toronto, Ontario aka talexb From fernandocorrea at gmail.com Tue Aug 5 13:23:40 2008 From: fernandocorrea at gmail.com (Fernando Oliveira) Date: Tue, 5 Aug 2008 17:23:40 -0300 Subject: [tpm] OT job in toronto, any one know? In-Reply-To: <8204a4fe0808051246p120b77c2sc84db4fb318c7e78@mail.gmail.com> References: <8204a4fe0808051246p120b77c2sc84db4fb318c7e78@mail.gmail.com> Message-ID: Here in rio de janeiro our meetings are in de second thursday, probably i will drink with you in Oct 30... 2008/8/5 Fulko Hew > > > On Tue, Aug 5, 2008 at 3:43 PM, Fernando Oliveira < > fernandocorrea at gmail.com> wrote: > >> I am! >> and about the "fob", was just a typo... :) >> I want do a question. The TPM go out to drink beer? >> when? >> > > Yes... After our monthly meetings held on the last Thursday of each month > (except December) The next meeting should be scheduled for Aug 28 > -- Just another Perl Hacker, Fernando (SmokeMachine) http://perl-e.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From fernandocorrea at gmail.com Tue Aug 5 13:19:44 2008 From: fernandocorrea at gmail.com (Fernando Oliveira) Date: Tue, 5 Aug 2008 17:19:44 -0300 Subject: [tpm] Fwd: OT job in toronto, any one know? In-Reply-To: References: <4898A5DD.4020903@softwareprocess.us> <99a6c38f0808051206i759a2eb2wcfb757211cca1620@mail.gmail.com> <83eac04d0808051238t557cee48k4dd74ad5d716e150@mail.gmail.com> <83eac04d0808051245j710f685dne14c80ea96dc465b@mail.gmail.com> Message-ID: ---------- Forwarded message ---------- From: Fernando Oliveira Date: 2008/8/5 Subject: Re: [tpm] OT job in toronto, any one know? To: Rob Janes 2008/8/5 Rob Janes > Si! nosotros vamos a tomar cerveza cada mes Thanks for tring, but I am brazilian, in Brazil we speak portuguese. :) pero entiendo espa?ol, los idiomas son muy similares. (spanish) mas entendo espanhol, os idiomas s?o muito parecidos (portuguese) > > On Tue, Aug 5, 2008 at 3:43 PM, Fernando Oliveira > wrote: > > I am! > > and about the "fob", was just a typo... :) > > I want do a question. The TPM go out to drink beer? > > when? > > thanks > > > > 2008/8/5 Rob Janes > >> > >> Is Fernando on the mailing list? If not, he wouldn't have seen any of > >> this, including Alex's invitation to contact him directly. > >> -rob > >> > >> On Tue, Aug 5, 2008 at 3:06 PM, Scott Elcomb wrote: > >> > On Tue, Aug 5, 2008 at 3:11 PM, Abram Hindle > >> > wrote: > >> >> FOB: Fresh Off the Boat. A little dated but fop was already used. > >> > > >> > Right... I knew I'd heard that somewhere; I've been bashing my head > >> > against the wall trying to remember what the acronym was. > >> > > >> > -- > >> > Scott Elcomb > >> > http://www.psema4.com/ > >> > http://www.google.com/reader/shared/14892828400785741937 > >> > _______________________________________________ > >> > toronto-pm mailing list > >> > toronto-pm at pm.org > >> > http://mail.pm.org/mailman/listinfo/toronto-pm > >> > > >> _______________________________________________ > >> toronto-pm mailing list > >> toronto-pm at pm.org > >> http://mail.pm.org/mailman/listinfo/toronto-pm > > > > > > > > -- > > Just another Perl Hacker, > > Fernando (SmokeMachine) > > http://perl-e.org > > > -- Just another Perl Hacker, Fernando (SmokeMachine) http://perl-e.org -- Just another Perl Hacker, Fernando (SmokeMachine) http://perl-e.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From arocker at vex.net Wed Aug 6 12:23:49 2008 From: arocker at vex.net (arocker at vex.net) Date: Wed, 6 Aug 2008 15:23:49 -0400 (EDT) Subject: [tpm] YARE (yet another regex) question In-Reply-To: <48934B7F.7090901@alteeve.com> References: <489322CD.9060700@alteeve.com> <8204a4fe0808010912v36d92e76h8984e7c0344b59dd@mail.gmail.com> <48933734.2080904@alteeve.com> <48934B7F.7090901@alteeve.com> Message-ID: <38815.192.30.202.22.1218050629.squirrel@webmail.vex.net> > I had hoped to save a line of code, is all, so it's not a big deal. I'm tempted to quote "Hoare's dictum" http://shreevatsa.wordpress.com/2008/05/16/premature-optimization-is-the-root-of-all-evil/ here. I think it especially applies to original lines of code. Get it working, then play (Perl) golf. From magog at the-wire.com Wed Aug 6 15:02:02 2008 From: magog at the-wire.com (Michael Graham) Date: Wed, 6 Aug 2008 18:02:02 -0400 Subject: [tpm] August Meeting - Thu 28 Aug, 2008 Message-ID: <20080806180202.187a4347@caliope> (These details are also on the TPM web site: http://to.pm.org/) The next meeting is this Thursday, 28 August. Speaker: Madison Kelly Title: D-Bus and Perl's Net::DBus binding Date: Thursday 28 Aug 2008 Time: 6:45pm Cost: Free! Where: 2 Bloor Street West (NW corner of Yonge/Bloor, skyscraper with the CIBC logo on top) Classroom TBA =================================================================== Description: D-Bus is a relatively new and very flexible system for IPC being used by many popular applications in the OSS family. It is used by Gnome to listen to HAL for hardware changes, by Pidgen for connection information and more. The talk will cover an introduction to D-Bus and then focus on the Net::DBus module; the perl D-Bus binding. Examples will be given on building methods for export on the D-Bus message bus, message broadcasting and retrieval, using existing and dedicated message buses and more. Note: The elevators in the building are "locked down" after 5:30pm to people without building access cards. Leading up to the meeting someone will come down to the main floor lobby every few minutes to ferry people upstairs. After 19:00, you can reach the access-card-carrying guy via a cell phone number that we'll leave with security in the front lobby. The room and floor numbers will be left with security too. -- Michael Graham _______________________________________________ toronto-pm mailing list toronto-pm at pm.org http://mail.pm.org/mailman/listinfo/toronto-pm -- Michael Graham From hanker at ifdsgroup.com Thu Aug 7 10:58:40 2008 From: hanker at ifdsgroup.com (Herman Anker) Date: Thu, 7 Aug 2008 13:58:40 -0400 Subject: [tpm] getopt question? Message-ID: How do I get "file2" into @local_files??? $ perl_script -i ftp.host.com -f file1 file2 -p 760 -d incoming file1 ---------------------------------------------------- Code: Getopt::Long::GetOptions( 'd:s' => \$dest_dir, 'P:s' => \$port, 'f=s@' => \@local_files, 'i=s' => \$dest_host, ); print "@local_files\n"; Any suggestions appriciated. ----------------------------------------- This e-mail and any attachments are intended only for the individual or company to which it is addressed and may contain information which is privileged, confidential and prohibited from disclosure or unauthorized use under applicable law. If you are not the intended recipient of this e-mail, you are hereby notified that any use, dissemination, or copying of this e-mail or the information contained in this e-mail is strictly prohibited by the sender. If you have received this transmission in error, please return the material received to the sender and delete all copies from your system. From james.a.graham at gmail.com Thu Aug 7 11:05:44 2008 From: james.a.graham at gmail.com (Jim Graham) Date: Thu, 7 Aug 2008 14:05:44 -0400 Subject: [tpm] getopt question? In-Reply-To: References: Message-ID: Hi Use multiple -f options $ perl_script -i ftp.host.com -f file1 -f files2 -p 760 - Jim On 7-Aug-08, at 1:58 PM, Herman Anker wrote: > > How do I get "file2" into @local_files??? > > $ perl_script -i ftp.host.com -f file1 file2 -p 760 -d incoming > file1 > > ---------------------------------------------------- > > Code: > Getopt::Long::GetOptions( > 'd:s' => \$dest_dir, > 'P:s' => \$port, > 'f=s@' => \@local_files, > 'i=s' => \$dest_host, > ); > > print "@local_files\n"; > > > Any suggestions appriciated. > > > ----------------------------------------- > This e-mail and any attachments are intended only for the > individual or company to which it is addressed and may contain > information which is privileged, confidential and prohibited from > disclosure or unauthorized use under applicable law. If you are > not the intended recipient of this e-mail, you are hereby notified > that any use, dissemination, or copying of this e-mail or the > information contained in this e-mail is strictly prohibited by the > sender. If you have received this transmission in error, please > return the material received to the sender and delete all copies > from your system. > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm From hanker at ifdsgroup.com Thu Aug 7 11:30:58 2008 From: hanker at ifdsgroup.com (Herman Anker) Date: Thu, 7 Aug 2008 14:30:58 -0400 Subject: [tpm] getopt question? In-Reply-To: Message-ID: Hi Jim, great suggestion, unfortunatly, I cannot split up that syntax because there are applications calling it with perl_script -i ftp.host.com -f file1 file2 -p 760 -d incoming Jim Graham To Sent by: toronto-pm at pm.org toronto-pm-bounce cc s+hanker=ifdsgrou p.com at pm.org Subject Re: [tpm] getopt question? 08/07/2008 02:05 PM Hi Use multiple -f options $ perl_script -i ftp.host.com -f file1 -f files2 -p 760 - Jim On 7-Aug-08, at 1:58 PM, Herman Anker wrote: > > How do I get "file2" into @local_files??? > > $ perl_script -i ftp.host.com -f file1 file2 -p 760 -d incoming > file1 > > ---------------------------------------------------- > > Code: > Getopt::Long::GetOptions( > 'd:s' => \$dest_dir, > 'P:s' => \$port, > 'f=s@' => \@local_files, > 'i=s' => \$dest_host, > ); > > print "@local_files\n"; > > > Any suggestions appriciated. > > > ----------------------------------------- > This e-mail and any attachments are intended only for the > individual or company to which it is addressed and may contain > information which is privileged, confidential and prohibited from > disclosure or unauthorized use under applicable law. If you are > not the intended recipient of this e-mail, you are hereby notified > that any use, dissemination, or copying of this e-mail or the > information contained in this e-mail is strictly prohibited by the > sender. If you have received this transmission in error, please > return the material received to the sender and delete all copies > from your system. > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm _______________________________________________ toronto-pm mailing list toronto-pm at pm.org http://mail.pm.org/mailman/listinfo/toronto-pm From zoffix at zoffix.com Thu Aug 7 11:35:51 2008 From: zoffix at zoffix.com (Zoffix Znet) Date: Thu, 07 Aug 2008 14:35:51 -0400 Subject: [tpm] getopt question? In-Reply-To: References: Message-ID: <1218134151.24049.11.camel@zoflap> Use this: Getopt::Long::GetOptions( 'd:s' => \$dest_dir, 'P:s' => \$port, 'f=s{,}' => \@local_files, 'i=s' => \$dest_host, ); print "@local_files\n"; Note the '{,}' syntax. Keep in mind that the docs mark it as "experimental feature" On Thu, 2008-08-07 at 14:30 -0400, Herman Anker wrote: > Hi Jim, > > great suggestion, > > unfortunatly, I cannot split up that syntax because there are applications > calling it with > > perl_script -i ftp.host.com -f file1 file2 -p 760 -d incoming > > > > > > > Jim Graham > mail.com> To > Sent by: toronto-pm at pm.org > toronto-pm-bounce cc > s+hanker=ifdsgrou > p.com at pm.org Subject > Re: [tpm] getopt question? > > 08/07/2008 02:05 > PM > > > > > > > > Hi > > Use multiple -f options > > $ perl_script -i ftp.host.com -f file1 -f files2 -p 760 > > - Jim > > > On 7-Aug-08, at 1:58 PM, Herman Anker wrote: > > > > > How do I get "file2" into @local_files??? > > > > $ perl_script -i ftp.host.com -f file1 file2 -p 760 -d incoming > > file1 > > > > ---------------------------------------------------- > > > > Code: > > Getopt::Long::GetOptions( > > 'd:s' => \$dest_dir, > > 'P:s' => \$port, > > 'f=s@' => \@local_files, > > 'i=s' => \$dest_host, > > ); > > > > print "@local_files\n"; > > > > > > Any suggestions appriciated. > > > > > > ----------------------------------------- > > This e-mail and any attachments are intended only for the > > individual or company to which it is addressed and may contain > > information which is privileged, confidential and prohibited from > > disclosure or unauthorized use under applicable law. If you are > > not the intended recipient of this e-mail, you are hereby notified > > that any use, dissemination, or copying of this e-mail or the > > information contained in this e-mail is strictly prohibited by the > > sender. If you have received this transmission in error, please > > return the material received to the sender and delete all copies > > from your system. > > _______________________________________________ > > toronto-pm mailing list > > toronto-pm at pm.org > > http://mail.pm.org/mailman/listinfo/toronto-pm > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm > > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm From james.a.graham at gmail.com Thu Aug 7 11:56:19 2008 From: james.a.graham at gmail.com (Jim Graham) Date: Thu, 7 Aug 2008 14:56:19 -0400 Subject: [tpm] getopt question? In-Reply-To: <1218134151.24049.11.camel@zoflap> References: <1218134151.24049.11.camel@zoflap> Message-ID: Nice one! Nothing like reinspecting the perldoc every once and a while to see new features. BTW, Herman, the original code had some extraneous markers: you don't need 'f=s@' if you are pointing to an array reference (\@local_files). You only need the '@' if you are pointing to a scalar reference (\ $local_files) to tell Getopt::Long to put an array reference into that scalar. Getopt::Long::GetOptions( 'd:s' => \$dest_dir, 'P:s' => \$port, 'f=s@' => \@local_files, #-- replace with 'f=s' => \@local_files, 'i=s' => \$dest_host, ); Jim On 7-Aug-08, at 2:35 PM, Zoffix Znet wrote: > Use this: > > Getopt::Long::GetOptions( > 'd:s' => \$dest_dir, > 'P:s' => \$port, > 'f=s{,}' => \@local_files, > 'i=s' => \$dest_host, > ); > > print "@local_files\n"; > > Note the '{,}' syntax. Keep in mind that the docs mark it as > "experimental feature" > > > > > > > > > > On Thu, 2008-08-07 at 14:30 -0400, Herman Anker wrote: >> Hi Jim, >> >> great suggestion, >> >> unfortunatly, I cannot split up that syntax because there are >> applications >> calling it with >> >> perl_script -i ftp.host.com -f file1 file2 -p 760 -d incoming >> >> >> >> >> >> >> Jim Graham >> > >> mail.com> To >> Sent by: toronto-pm at pm.org >> toronto-pm- >> bounce cc >> s+hanker=ifdsgrou >> p.com at pm.org >> Subject >> Re: [tpm] getopt question? >> >> 08/07/2008 02:05 >> PM >> >> >> >> >> >> >> >> Hi >> >> Use multiple -f options >> >> $ perl_script -i ftp.host.com -f file1 -f files2 -p 760 >> >> - Jim >> >> >> On 7-Aug-08, at 1:58 PM, Herman Anker wrote: >> >>> >>> How do I get "file2" into @local_files??? >>> >>> $ perl_script -i ftp.host.com -f file1 file2 -p 760 -d incoming >>> file1 >>> >>> ---------------------------------------------------- >>> >>> Code: >>> Getopt::Long::GetOptions( >>> 'd:s' => \$dest_dir, >>> 'P:s' => \$port, >>> 'f=s@' => \@local_files, >>> 'i=s' => \$dest_host, >>> ); >>> >>> print "@local_files\n"; >>> >>> >>> Any suggestions appriciated. >>> >>> >>> ----------------------------------------- >>> This e-mail and any attachments are intended only for the >>> individual or company to which it is addressed and may contain >>> information which is privileged, confidential and prohibited from >>> disclosure or unauthorized use under applicable law. If you are >>> not the intended recipient of this e-mail, you are hereby notified >>> that any use, dissemination, or copying of this e-mail or the >>> information contained in this e-mail is strictly prohibited by the >>> sender. If you have received this transmission in error, please >>> return the material received to the sender and delete all copies >>> from your system. >>> _______________________________________________ >>> toronto-pm mailing list >>> toronto-pm at pm.org >>> http://mail.pm.org/mailman/listinfo/toronto-pm >> >> _______________________________________________ >> toronto-pm mailing list >> toronto-pm at pm.org >> http://mail.pm.org/mailman/listinfo/toronto-pm >> >> >> _______________________________________________ >> toronto-pm mailing list >> toronto-pm at pm.org >> http://mail.pm.org/mailman/listinfo/toronto-pm > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm From a.anderson at utoronto.ca Fri Aug 8 08:38:29 2008 From: a.anderson at utoronto.ca (Alexander Anderson) Date: Fri, 8 Aug 2008 10:38:29 -0500 Subject: [tpm] hash naming convention: singular or plural Message-ID: <20080808153829.GA63995@upful.org> Hello Toronto Perl Mongers, Names of scalars are usually singular, for example, $month = 'Aug'; Names of arrays are usually plural, for example, @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); How do you name your hashes, for example, %months = ( Jan => 1, Feb => 2, ..., Dec => 12 ); or %month = ( Jan => 1, Feb => 2, ..., Dec => 12 ); Thanks. From fernandocorrea at gmail.com Fri Aug 8 07:44:37 2008 From: fernandocorrea at gmail.com (Fernando Oliveira) Date: Fri, 8 Aug 2008 11:44:37 -0300 Subject: [tpm] hash naming convention: singular or plural In-Reply-To: <20080808153829.GA63995@upful.org> References: <20080808153829.GA63995@upful.org> Message-ID: The PBP say to use hash named in singular. 2008/8/8 Alexander Anderson > Hello Toronto Perl Mongers, > > Names of scalars are usually singular, for example, > > $month = 'Aug'; > > Names of arrays are usually plural, for example, > > @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); > > How do you name your hashes, for example, > > %months = ( Jan => 1, Feb => 2, ..., Dec => 12 ); > or > %month = ( Jan => 1, Feb => 2, ..., Dec => 12 ); > > Thanks. > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm > -- Just another Perl Hacker, Fernando (SmokeMachine) http://perl-e.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From abram.hindle at softwareprocess.us Fri Aug 8 07:46:24 2008 From: abram.hindle at softwareprocess.us (Abram Hindle) Date: Fri, 08 Aug 2008 10:46:24 -0400 Subject: [tpm] hash naming convention: singular or plural In-Reply-To: <20080808153829.GA63995@upful.org> (sfid-20080808_104216_939852_2267924D) References: <20080808153829.GA63995@upful.org> (sfid-20080808_104216_939852_2267924D) Message-ID: <489C5C40.4040402@softwareprocess.us> Alexander Anderson wrote: > Hello Toronto Perl Mongers, > > Names of scalars are usually singular, for example, > > $month = 'Aug'; > > Names of arrays are usually plural, for example, > > @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); > > How do you name your hashes, for example, > > %months = ( Jan => 1, Feb => 2, ..., Dec => 12 ); > or > %month = ( Jan => 1, Feb => 2, ..., Dec => 12 ); > IMHO, You are already indicating scalar/vector by their first character. Just use a consistent lexicon for your project. Being consistent is more important than spending a lot of time worrying about how natural and english your variable name choices sound. abram From talexb at gmail.com Fri Aug 8 07:46:42 2008 From: talexb at gmail.com (Alex Beamish) Date: Fri, 8 Aug 2008 10:46:42 -0400 Subject: [tpm] hash naming convention: singular or plural In-Reply-To: <20080808153829.GA63995@upful.org> References: <20080808153829.GA63995@upful.org> Message-ID: On Fri, Aug 8, 2008 at 11:38 AM, Alexander Anderson wrote: > Hello Toronto Perl Mongers, > > Names of scalars are usually singular, for example, > > $month = 'Aug'; > > Names of arrays are usually plural, for example, > > @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); > > How do you name your hashes, for example, > > %months = ( Jan => 1, Feb => 2, ..., Dec => 12 ); > or > %month = ( Jan => 1, Feb => 2, ..., Dec => 12 ); As arrays and hashes are usually used to contain multiple elements, I usually use the plural of the word for the variable names. However, that's only 'usually' -- if the hash is actually an object with a variety of attributes, then I would use a singular word. So I'd use $months{'Jan'} but $config{'httpd_dir'} Just run an eye over some code and see if it's as clear as possible before writing it out. If it looks a little weird or cute, it's probably safer (if a little more boring) to clean it up. Remember, the worst thing that can possibly happen is looking over some code you wrote six months ago and being unable to parse what the heck is going on. That's embarassing. Alex -- Alex Beamish Toronto, Ontario aka talexb From linux at alteeve.com Fri Aug 8 07:51:56 2008 From: linux at alteeve.com (Madison Kelly) Date: Fri, 08 Aug 2008 10:51:56 -0400 Subject: [tpm] hash naming convention: singular or plural In-Reply-To: <20080808153829.GA63995@upful.org> References: <20080808153829.GA63995@upful.org> Message-ID: <489C5D8C.5050209@alteeve.com> Alexander Anderson wrote: > Hello Toronto Perl Mongers, > > Names of scalars are usually singular, for example, > > $month = 'Aug'; > > Names of arrays are usually plural, for example, > > @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); > > How do you name your hashes, for example, > > %months = ( Jan => 1, Feb => 2, ..., Dec => 12 ); > or > %month = ( Jan => 1, Feb => 2, ..., Dec => 12 ); > > Thanks. Personally, I tend to use singular as I more often type the hash with the key, so it makes more sense to say "$month{'Aug'}" many times over 'my %months=()' once. Personal preference though, of course. I do the same for SQL tables and such, with a few notable exceptions (ie: 'users' instead of 'user', which usually has an internal value). Madi From shijialeee at yahoo.com Fri Aug 22 05:16:31 2008 From: shijialeee at yahoo.com (James.Q.L) Date: Fri, 22 Aug 2008 05:16:31 -0700 (PDT) Subject: [tpm] what's up from beijing Message-ID: <709634.26766.qm@web50103.mail.re2.yahoo.com> hi, in case that people wondering why i am missing from the monthly monger meeting (james the chinese guy from YorkU), I am in beijing, china right now. with some free time, i just wrote a simple app and launched it at http://www.wordpine.com. It helps me to organize my reading digest, highlights and such. i am not sure if it is useful to other people but i would love to hear feedback from you. and of course, it is written in Perl using CGI::Application, Template-Toolkit and DBIx::Class. ok, drop me a line if you are visiting beijing, china :) ciao, James. From linux at alteeve.com Fri Aug 22 21:30:23 2008 From: linux at alteeve.com (Madison Kelly) Date: Sat, 23 Aug 2008 00:30:23 -0400 Subject: [tpm] GD::Graph question Message-ID: <48AF925F.2000007@alteeve.com> Hi all, I am trying to plot some data (historical bandwidth info). I've got a basic graph working with the left Y-axis representing kbps and the right Y-axis representing a percentage value (relative capacity occupancy, if you're interested). So far as I've been able to tell so far, this "two_axes" option limits the graph to two data sets. In my experiment, I can see download speed and the RCO. However, I want to add a second pair of data; Upload speed and it's RCO percentage to the same graph. Is this possible? If not, what tool might I look at instead? Thanks! Madi From talexb at gmail.com Sun Aug 24 16:47:27 2008 From: talexb at gmail.com (Alex Beamish) Date: Sun, 24 Aug 2008 19:47:27 -0400 Subject: [tpm] GD::Graph question In-Reply-To: <48AF925F.2000007@alteeve.com> References: <48AF925F.2000007@alteeve.com> Message-ID: Hi Madison, My first Perl gig ten years ago was doing graphs, and I used Gnuplot quite successfully to draw graphs-- it's a very flexible package. Alex On Sat, Aug 23, 2008 at 12:30 AM, Madison Kelly wrote: > Hi all, > > I am trying to plot some data (historical bandwidth info). I've got a basic > graph working with the left Y-axis representing kbps and the right Y-axis > representing a percentage value (relative capacity occupancy, if you're > interested). > > So far as I've been able to tell so far, this "two_axes" option limits the > graph to two data sets. In my experiment, I can see download speed and the > RCO. However, I want to add a second pair of data; Upload speed and it's RCO > percentage to the same graph. > > Is this possible? If not, what tool might I look at instead? > > Thanks! > > Madi > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm > -- Alex Beamish Toronto, Ontario aka talexb From psema4 at gmail.com Sun Aug 24 17:33:42 2008 From: psema4 at gmail.com (Scott Elcomb) Date: Sun, 24 Aug 2008 20:33:42 -0400 Subject: [tpm] GD::Graph question In-Reply-To: References: <48AF925F.2000007@alteeve.com> Message-ID: <99a6c38f0808241733u49e02b5ewe5619b9fc410536@mail.gmail.com> On Sun, Aug 24, 2008 at 7:47 PM, Alex Beamish wrote: > My first Perl gig ten years ago was doing graphs, and I used Gnuplot > quite successfully to draw graphs-- it's a very flexible package. Hmm. My first gig involved writing wrappers around GD::Graph. Since it was "my first gig" the code in my ... um... uh... library "SAL" definitely reflects that. One day I might even get around to modernizing it and making it useful. Unfortunately (fortunately?) I never had to deal with this particular problem. Madison, if you find a solution could I ask that you post it up for us? Many thanks. - Scott. -- Scott Elcomb http://www.psema4.com/ http://www.psema4.com/blog/ http://www.google.com/reader/shared/14892828400785741937 From linux at alteeve.com Mon Aug 25 13:26:29 2008 From: linux at alteeve.com (Madison Kelly) Date: Mon, 25 Aug 2008 16:26:29 -0400 Subject: [tpm] GD::Graph question In-Reply-To: <99a6c38f0808241733u49e02b5ewe5619b9fc410536@mail.gmail.com> References: <48AF925F.2000007@alteeve.com> <99a6c38f0808241733u49e02b5ewe5619b9fc410536@mail.gmail.com> Message-ID: <48B31575.2070508@alteeve.com> Scott Elcomb wrote: > On Sun, Aug 24, 2008 at 7:47 PM, Alex Beamish wrote: >> My first Perl gig ten years ago was doing graphs, and I used Gnuplot >> quite successfully to draw graphs-- it's a very flexible package. > > Hmm. My first gig involved writing wrappers around GD::Graph. Since > it was "my first gig" the code in my ... um... uh... library "SAL" > definitely reflects that. One day I might even get around to > modernizing it and making it useful. > > Unfortunately (fortunately?) I never had to deal with this particular > problem. Madison, if you find a solution could I ask that you post it > up for us? > > Many thanks. > - Scott. At this point, I've moved on from GD::Graph and am playing with SVG::TT::Graph. I'm having mixed luck; It seems like a much more flexible solution and I am getting cleaner graphs, but I have not yet been enable to figure out to create a dual Y-axis graph, assuming it is possible at all. Once I figure something out I will indeed post it to the list "for posterity". :) Madi From mfowle at navicominc.com Mon Aug 25 13:33:51 2008 From: mfowle at navicominc.com (Mark Fowle) Date: Mon, 25 Aug 2008 16:33:51 -0400 Subject: [tpm] GD::Graph question In-Reply-To: <48B31575.2070508@alteeve.com> References: <48AF925F.2000007@alteeve.com> <99a6c38f0808241733u49e02b5ewe5619b9fc410536@mail.gmail.com> <48B31575.2070508@alteeve.com> Message-ID: <759E3F14A23281479A85A082BBCFA5425200FD@sbsa.NavicomInc.local> If SVG is OK for you (client browser support wise) I'd go one of two routes: 1. draw a SVG graph with the first dataset and a second graph with almost everything 0% opaque so only the line shows up. 2. get into SVG Graph and change the code so y scale can be a scalar or an array. Then adjust the scaling code to use the array element corresponding to the dataset. Idea 2 is probably implementable in GD Graph. Mark Fowle -----Original Message----- From: toronto-pm-bounces+mfowle=navicominc.com at pm.org [mailto:toronto-pm-bounces+mfowle=navicominc.com at pm.org] On Behalf Of Madison Kelly Sent: Monday, August 25, 2008 4:26 PM To: Scott Elcomb Cc: tpm Subject: Re: [tpm] GD::Graph question Scott Elcomb wrote: > On Sun, Aug 24, 2008 at 7:47 PM, Alex Beamish wrote: >> My first Perl gig ten years ago was doing graphs, and I used Gnuplot >> quite successfully to draw graphs-- it's a very flexible package. > > Hmm. My first gig involved writing wrappers around GD::Graph. Since > it was "my first gig" the code in my ... um... uh... library "SAL" > definitely reflects that. One day I might even get around to > modernizing it and making it useful. > > Unfortunately (fortunately?) I never had to deal with this particular > problem. Madison, if you find a solution could I ask that you post it > up for us? > > Many thanks. > - Scott. At this point, I've moved on from GD::Graph and am playing with SVG::TT::Graph. I'm having mixed luck; It seems like a much more flexible solution and I am getting cleaner graphs, but I have not yet been enable to figure out to create a dual Y-axis graph, assuming it is possible at all. Once I figure something out I will indeed post it to the list "for posterity". :) Madi _______________________________________________ toronto-pm mailing list toronto-pm at pm.org http://mail.pm.org/mailman/listinfo/toronto-pm From ja_harris at rogers.com Tue Aug 26 08:15:10 2008 From: ja_harris at rogers.com (Jim Harris) Date: Tue, 26 Aug 2008 08:15:10 -0700 (PDT) Subject: [tpm] GD::Graph question In-Reply-To: <759E3F14A23281479A85A082BBCFA5425200FD@sbsa.NavicomInc.local> Message-ID: <324485.3066.qm@web88003.mail.re2.yahoo.com> #!/usr/bin/perl use strict; use GD::Graph::area; #use GD::Graph::lines; use Carp; use Time::Local; umask 0222; # #?????? set dimensions for graphics # our ($x,$y) =(500, 210); open CONFIG, $configfile ??????? or die "can't open $configfile: $!"; our %LOCATION; our %TTY; while () { ??????? if (/^(\d) (\S+) (\S.*)/) { ??????????????? $LOCATION{$1} = $2; ??????????????? $TTY{$1}????? = $3; ??????? } } my (@ttyi, at ttyt, at both, at label); #?????? $ttyi[$x] = $y; and so on #?????? $both[] = sum of tty's on the device, there's always two on each device my @data; my @legend; my @colors; if ($TTY{$switch} =~ /ttyt/) { ??????? @data = ( ??????????????? [ @label ], ??????????????? [ @both? ], ??????????????? [ @ttyt? ], ??????? ); ??????? @legend = ( ??????????????? 'ttyi', ??????????????? 'ttyt', ??????? ); ??????? @colors = ( ??????????????? 'red', ??????????????? 'blue', ??????????????? 'cyan', ??????? ); } else { ??????? die "cannot determine proper TTYs"; } $graph = GD::Graph::area->new($x,$y); $graph->set( #?????? x_label???????? => $dateLabel, ??????? x_label???????? => "$title?? $dateLabel? $weekday[$wday]", ??????? #x_label??????????????? => '', ??????? x_label_skip??? => 6 * 3, ??????? x_tick_offset?? => 6 * 3, #?????? x_all_ticks???? => 1, #?????? two_axes??????? => 1, ??????? y_label => 'completions / 10 minutes', ??????? y_min_value???? =>? 0, ??????? y_max_value???? => $speed, ??????? y_tick_number?? =>? $speed/20, ??????? y_label_skip??? => 2, ) or die $graph->error; $graph->set( dclrs => [ @colors ] ); $graph->set_legend(@legend); $graph->set( ??????? legend_placement??????? => 'RT', ); my $gd = $graph->plot(\@data) or die $graph->error; open (IMG, '>', $png) or die "can't open '$png': $!"; binmode IMG; print IMG $gd->png; close IMG; exit; --- On Mon, 8/25/08, Mark Fowle wrote: From: Mark Fowle Subject: Re: [tpm] GD::Graph question To: "Madison Kelly" Cc: "tpm" Received: Monday, August 25, 2008, 8:33 PM If SVG is OK for you (client browser support wise) I'd go one of two routes: 1. draw a SVG graph with the first dataset and a second graph with almost everything 0% opaque so only the line shows up. 2. get into SVG Graph and change the code so y scale can be a scalar or an array. Then adjust the scaling code to use the array element corresponding to the dataset. Idea 2 is probably implementable in GD Graph. Mark Fowle -----Original Message----- From: toronto-pm-bounces+mfowle=navicominc.com at pm.org [mailto:toronto-pm-bounces+mfowle=navicominc.com at pm.org] On Behalf Of Madison Kelly Sent: Monday, August 25, 2008 4:26 PM To: Scott Elcomb Cc: tpm Subject: Re: [tpm] GD::Graph question Scott Elcomb wrote: > On Sun, Aug 24, 2008 at 7:47 PM, Alex Beamish wrote: >> My first Perl gig ten years ago was doing graphs, and I used Gnuplot >> quite successfully to draw graphs-- it's a very flexible package. > > Hmm. My first gig involved writing wrappers around GD::Graph. Since > it was "my first gig" the code in my ... um... uh... library "SAL" > definitely reflects that. One day I might even get around to > modernizing it and making it useful. > > Unfortunately (fortunately?) I never had to deal with this particular > problem. Madison, if you find a solution could I ask that you post it > up for us? > > Many thanks. > - Scott. At this point, I've moved on from GD::Graph and am playing with SVG::TT::Graph. I'm having mixed luck; It seems like a much more flexible solution and I am getting cleaner graphs, but I have not yet been enable to figure out to create a dual Y-axis graph, assuming it is possible at all. Once I figure something out I will indeed post it to the list "for posterity". :) Madi _______________________________________________ toronto-pm mailing list toronto-pm at pm.org http://mail.pm.org/mailman/listinfo/toronto-pm _______________________________________________ toronto-pm mailing list toronto-pm at pm.org http://mail.pm.org/mailman/listinfo/toronto-pm -------------- next part -------------- An HTML attachment was scrubbed... URL: From magog at the-wire.com Tue Aug 26 19:09:23 2008 From: magog at the-wire.com (Michael Graham) Date: Tue, 26 Aug 2008 22:09:23 -0400 Subject: [tpm] August Meeting - This week - Thu 28 Aug, 2008 Message-ID: <20080826220923.683ae29b@caliope> (These details are also on the TPM web site: http://to.pm.org/) The next meeting is this Thursday, 28 August. Speaker: Madison Kelly Title: D-Bus and Perl's Net::DBus binding Date: Thursday 28 Aug 2008 Time: 6:45pm Cost: Free! Where: 2 Bloor Street West (NW corner of Yonge/Bloor, skyscraper with the CIBC logo on top) room 15 on the 8th floor =================================================================== Description: D-Bus is a relatively new and very flexible system for IPC being used by many popular applications in the OSS family. It is used by Gnome to listen to HAL for hardware changes, by Pidgen for connection information and more. The talk will cover an introduction to D-Bus and then focus on the Net::DBus module; the perl D-Bus binding. Examples will be given on building methods for export on the D-Bus message bus, message broadcasting and retrieval, using existing and dedicated message buses and more. Note: The elevators in the building are "locked down" after 5:30pm to people without building access cards. Leading up to the meeting someone will come down to the main floor lobby every few minutes to ferry people upstairs. After 19:00, you can reach the access-card-carrying guy via a cell phone number that we'll leave with security in the front lobby. The room and floor numbers will be left with security too. -- Michael Graham _______________________________________________ toronto-pm mailing list toronto-pm at pm.org http://mail.pm.org/mailman/listinfo/toronto-pm From linux at alteeve.com Wed Aug 27 08:00:33 2008 From: linux at alteeve.com (Madison Kelly) Date: Wed, 27 Aug 2008 11:00:33 -0400 Subject: [tpm] SVG to GIF converters? Message-ID: <48B56C11.9050204@alteeve.com> Hi all, I've got some SVG graphs I've created. I'd like to create GIF copies of these images though for browsers that don't support SVG. Is there a perl module or linux CLI tool for converting SVGs to GIFs? (or JPG, PNG, etc?) Madi From mfowle at navicominc.com Wed Aug 27 08:04:53 2008 From: mfowle at navicominc.com (Mark Fowle) Date: Wed, 27 Aug 2008 11:04:53 -0400 Subject: [tpm] SVG to GIF converters? In-Reply-To: <48B56C11.9050204@alteeve.com> References: <48B56C11.9050204@alteeve.com> Message-ID: <759E3F14A23281479A85A082BBCFA542520158@sbsa.NavicomInc.local> ImageMagick is wonderfull I havn't used it to do this but it says it supports SVG so should work Also ImageMagick has perl interfaces. -----Original Message----- From: toronto-pm-bounces+mfowle=navicominc.com at pm.org [mailto:toronto-pm-bounces+mfowle=navicominc.com at pm.org] On Behalf Of Madison Kelly Sent: Wednesday, August 27, 2008 11:01 AM To: Toronto Perl Mongers Subject: [tpm] SVG to GIF converters? Hi all, I've got some SVG graphs I've created. I'd like to create GIF copies of these images though for browsers that don't support SVG. Is there a perl module or linux CLI tool for converting SVGs to GIFs? (or JPG, PNG, etc?) Madi _______________________________________________ toronto-pm mailing list toronto-pm at pm.org http://mail.pm.org/mailman/listinfo/toronto-pm From samogon at gmail.com Wed Aug 27 08:09:28 2008 From: samogon at gmail.com (Ilia Lobsanov) Date: Wed, 27 Aug 2008 11:09:28 -0400 Subject: [tpm] SVG to GIF converters? In-Reply-To: <48B56C11.9050204@alteeve.com> References: <48B56C11.9050204@alteeve.com> Message-ID: <6885F312-164C-42F9-BDB2-45C09A50AD5A@gmail.com> ImageMagick compiled with rsvg seems to do it. ilia. On 27-Aug-08, at 11:00 AM, Madison Kelly wrote: > Hi all, > > I've got some SVG graphs I've created. I'd like to create GIF > copies of these images though for browsers that don't support SVG. > Is there a perl module or linux CLI tool for converting SVGs to > GIFs? (or JPG, PNG, etc?) > > Madi > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm From ibrayem at gmail.com Wed Aug 27 13:19:00 2008 From: ibrayem at gmail.com (Ibrahim Amin) Date: Wed, 27 Aug 2008 16:19:00 -0400 Subject: [tpm] changing password for multiple accounts Message-ID: Hello, I am looking for a secure and easy way for enabling users to change the password of his account before it expires. We use HP UX and some user have multiple logins in the form of xxlogin, where xx id two characters prefix and login is user login. 1 - I am looking for a way in which I can synchronize all the account expiration date. 2 - If a user change the password for one of his account that change also effect those accounts belongs to the same user. I hope this can be done by perl. Thank you -- Yours truly, Ibrahim Amin -------------- next part -------------- An HTML attachment was scrubbed... URL: From liam at holoweb.net Wed Aug 27 08:45:57 2008 From: liam at holoweb.net (Liam R E Quin) Date: Wed, 27 Aug 2008 11:45:57 -0400 Subject: [tpm] SVG to GIF converters? In-Reply-To: <48B56C11.9050204@alteeve.com> References: <48B56C11.9050204@alteeve.com> Message-ID: <1219851957.11129.180.camel@localhost> On Wed, 2008-08-27 at 11:00 -0400, Madison Kelly wrote: > Hi all, > > I've got some SVG graphs I've created. I'd like to create GIF copies > of these images though for browsers that don't support SVG. Note that there is also a jquery plugin to support SVG in most modern browsers, including IE -- see http://plugins.jquery.com/ If you are not using transparency, you'll get better-looking results with PNG, by the way, or with JPEG with a suitably high compression quality (i.e. don't compress too much, if it's a graph -- try 98% and smoothing of 12%, but it depends on the tool as to what the "percentage" means). PNG is lossless, compress at the highest level (usually called 9) to get the smallest file, but the JPEG file will still be smaller. PNG can do transparency but not properly in most IE versions, which is probably where you need it. Liam -- Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/ Pictures from old books: http://fromoldbooks.org/ Ankh: irc.sorcery.net irc.gnome.org www.advogato.org From desert_camelry at yahoo.com Wed Aug 27 16:41:14 2008 From: desert_camelry at yahoo.com (YueSong Xu) Date: Wed, 27 Aug 2008 16:41:14 -0700 (PDT) Subject: [tpm] How to retrieve post Message-ID: <823836.10562.qm@web52011.mail.re2.yahoo.com> Hello everyone, Instead of using CGI.pm, how can I write perl raw code to get all the HTTP post params as a whole string on Apache (mod_perl 1.29)? Any %ENV? Thanks a lot. From linux at alteeve.com Wed Aug 27 17:50:41 2008 From: linux at alteeve.com (Madison Kelly) Date: Wed, 27 Aug 2008 20:50:41 -0400 Subject: [tpm] Handout for tomorrow's talk (Aug. 28, 2008) Message-ID: <48B5F661.7010204@alteeve.com> Hi all, To save trees and my budget, I've uploaded the talk I will be giving tomorrow for download instead of printing a pile of copies on dead trees. http://wiki.tle-bu.org/index.php/D-Bus_Tutorial_and_References If you would like to follow along, please grab a copy for your laptop or print a copy for yourself if you prefer. Cheers all, see you tomorrow! Madi From adam.prime at utoronto.ca Thu Aug 28 05:39:03 2008 From: adam.prime at utoronto.ca (Adam Prime) Date: Thu, 28 Aug 2008 08:39:03 -0400 Subject: [tpm] How to retrieve post In-Reply-To: <823836.10562.qm@web52011.mail.re2.yahoo.com> References: <823836.10562.qm@web52011.mail.re2.yahoo.com> Message-ID: <48B69C67.3020305@utoronto.ca> under mod_perl, you should probably use Apache::Request, which is part of libapreq. Apache::Request is from what i understand quite a bit lighter than CGI.pm http://httpd.apache.org/apreq/ That doesn't mean that you couldn't write your own code to read the raw post data (which afaik you do just by reading from STDIN). Adam YueSong Xu wrote: > Hello everyone, > > Instead of using CGI.pm, how can I write perl raw code to get all the HTTP post params as a whole string on Apache (mod_perl 1.29)? Any %ENV? > Thanks a lot. > > > > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm From magog at the-wire.com Thu Aug 28 07:51:52 2008 From: magog at the-wire.com (Michael Graham) Date: Thu, 28 Aug 2008 09:51:52 -0500 Subject: [tpm] SVG to GIF converters? In-Reply-To: <48B56C11.9050204@alteeve.com> References: <48B56C11.9050204@alteeve.com> Message-ID: <20080828095152.19d135e9@Nokia-N810-51-3> We use rsvg-convert on the command line to convert from SVG to PNG. Michael > From: Madison Kelly > To: Toronto Perl Mongers > Subject: [tpm] SVG to GIF converters? > Date: Wed, 27 Aug 2008 11:00:33 -0400 > > Hi all, > > I've got some SVG graphs I've created. I'd like to create GIF > copies of these images though for browsers that don't support SVG. Is > there a perl module or linux CLI tool for converting SVGs to GIFs? > (or JPG, PNG, etc?) > > Madi > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm From indy at indigostar.com Wed Aug 27 21:07:52 2008 From: indy at indigostar.com (Indy Singh) Date: Thu, 28 Aug 2008 00:07:52 -0400 Subject: [tpm] How to retrieve post References: <823836.10562.qm@web52011.mail.re2.yahoo.com> Message-ID: <66D5C752984D464B96A84AD060383C0F@roadhog> > how can I write perl raw code to get all the HTTP post params as > a whole string on Apache (mod_perl 1.29)? Any %ENV? See example script below. It makes use of cgi-lib which is in the listing below. Sorry for the long post. Indy Singh IndigoSTAR Software -- www.indigostar.com #!/usr/bin/perl # Test cgi script, using cgi-lib # prints out the date, and environment variables $| = 1; print PrintHeader(); print HtmlTop("Test CGI output"); print "
\n"; $date = localtime(time()); print "Testcgi.pl 1.1 at $date
\n"; print "ARGS = ", join(" ", @ARGV), "
\n"; $cwd = $^O eq "MSWin32" ? Win32::GetCwd() . "\n" : `pwd`; chop $cwd; print "Current directory: $cwd
\n"; print "
\n"; print "

Environment variables

\n"; #print PrintEnv(); print "
";
foreach (sort keys %ENV) {   # conver form vars to $variables
    print "set $_=$ENV{$_}\n";
}
print "
"; print "
\n"; # cgi-lib hangs on multipart/form-data if ($ENV{'CONTENT_TYPE'} =~ m|^multipart/form-data|) { print "

Multipart/form-data not supported
Raw Data:

\n"; if ($ENV{CONTENT_LENGTH}) { $length = $ENV{CONTENT_LENGTH}; read(STDIN, $data, $length); #$data .= $_ while (); print "
data=\n$data\n
"; } print "
\n"; } else { ReadParse(); print "

Form Fields

\n"; print PrintVariables(); print "
\n"; } print HtmlBot(); exit; # Perl Routines to Manipulate CGI input # S.E.Brenner at bioc.cam.ac.uk # $Id: cgi-lib.pl,v 2.8 1996/03/30 01:36:33 brenner Rel $ # # Copyright (c) 1996 Steven E. Brenner # Unpublished work. # Permission granted to use and modify this library so long as the # copyright above is maintained, modifications are documented, and # credit is given for any use of the library. # # Thanks are due to many people for reporting bugs and suggestions # especially Meng Weng Wong, Maki Watanabe, Bo Frese Rasmussen, # Andrew Dalke, Mark-Jason Dominus, Dave Dittrich, Jason Mathews # For more information, see: # http://www.bio.cam.ac.uk/cgi-lib/ BEGIN { ($cgi_lib'version = '$Revision: 2.8 $') =~ s/[^.\d]//g; # Parameters affecting cgi-lib behavior # User-configurable parameters affecting file upload. $cgi_lib'maxdata = 1500000; # maximum bytes to accept via POST - 2^17 $cgi_lib'writefiles = 0; # directory to which to write files, or # 0 if files should not be written $cgi_lib'filepre = "cgi-lib"; # Prefix of file names, in directory above # Do not change the following parameters unless you have special reasons $cgi_lib'bufsize = 8192; # default buffer size when reading multipart $cgi_lib'maxbound = 100; # maximum boundary length to be encounterd $cgi_lib'headerout = 0; # indicates whether the header has been printed } # ReadParse # Reads in GET or POST data, converts it to unescaped text, and puts # key/value pairs in %in, using "\0" to separate multiple selections # Returns >0 if there was input, 0 if there was no input # undef indicates some failure. # Now that cgi scripts can be put in the normal file space, it is useful # to combine both the form and the script in one place. If no parameters # are given (i.e., ReadParse returns FALSE), then a form could be output. # If a reference to a hash is given, then the data will be stored in that # hash, but the data from $in and @in will become inaccessable. # If a variable-glob (e.g., *cgi_input) is the first parameter to ReadParse, # information is stored there, rather than in $in, @in, and %in. # Second, third, and fourth parameters fill associative arrays analagous to # %in with data relevant to file uploads. # If no method is given, the script will process both command-line arguments # of the form: name=value and any text that is in $ENV{'QUERY_STRING'} # This is intended to aid debugging and may be changed in future releases sub ReadParse { local (*in) = shift if @_; # CGI input local (*incfn, # Client's filename (may not be provided) *inct, # Client's content-type (may not be provided) *insfn) = @_; # Server's filename (for spooled files) local ($len, $type, $meth, $errflag, $cmdflag, $perlwarn); # Disable warnings as this code deliberately uses local and environment # variables which are preset to undef (i.e., not explicitly initialized) $perlwarn = $^W; $^W = 0; # Get several useful env variables $type = $ENV{'CONTENT_TYPE'}; $len = $ENV{'CONTENT_LENGTH'}; $meth = $ENV{'REQUEST_METHOD'}; if ($len > $cgi_lib'maxdata) { #' &CgiDie("cgi-lib.pl: Request to receive too much data: $len bytes\n"); } if (!defined $meth || $meth eq '' || $meth eq 'GET' || $type eq 'application/x-www-form-urlencoded') { local ($key, $val, $i); # Read in text if (!defined $meth || $meth eq '') { $in = $ENV{'QUERY_STRING'}; $cmdflag = 1; # also use command-line options } elsif($meth eq 'GET' || $meth eq 'HEAD') { $in = $ENV{'QUERY_STRING'}; } elsif ($meth eq 'POST') { $errflag = (read(STDIN, $in, $len) != $len); } else { &CgiDie("cgi-lib.pl: Unknown request method: $meth\n"); } @in = split(/[&;]/,$in); push(@in, @ARGV) if $cmdflag; # add command-line parameters foreach $i (0 .. $#in) { # Convert plus to space $in[$i] =~ s/\+/ /g; # Split into key and value. ($key, $val) = split(/=/,$in[$i],2); # splits on the first =. # Convert %XX from hex numbers to alphanumeric $key =~ s/%([A-Fa-f0-9]{2})/pack("c",hex($1))/ge; $val =~ s/%([A-Fa-f0-9]{2})/pack("c",hex($1))/ge; # Associate key and value $in{$key} .= "\0" if (defined($in{$key})); # \0 is the multiple separator $in{$key} .= $val; } } elsif ($ENV{'CONTENT_TYPE'} =~ m#^multipart/form-data#) { # for efficiency, compile multipart code only if needed ########################$errflag = !(eval <<'END_MULTIPART'); local ($buf, $boundary, $head, @heads, $cd, $ct, $fname, $ctype, $blen); local ($bpos, $lpos, $left, $amt, $fn, $ser); local ($bufsize, $maxbound, $writefiles) = ($cgi_lib'bufsize, $cgi_lib'maxbound, $cgi_lib'writefiles); # The following lines exist solely to eliminate spurious warning messages $buf = ''; ($boundary) = $type =~ /boundary="([^"]+)"/; #"; # find boundary ($boundary) = $type =~ /boundary=(\S+)/ unless $boundary; &CgiDie ("Boundary not provided") unless $boundary; $boundary = "--" . $boundary; $blen = length ($boundary); if ($ENV{'REQUEST_METHOD'} ne 'POST') { &CgiDie("Invalid request method for multipart/form-data: $meth\n"); } if ($writefiles) { local($me); stat ($writefiles); $writefiles = "/tmp" unless -d _ && -r _ && -w _; # ($me) = $0 =~ m#([^/]*)$#; $writefiles .= "/$cgi_lib'filepre"; } # read in the data and split into parts: # put headers in @in and data in %in # General algorithm: # There are two dividers: the border and the '\r\n\r\n' between # header and body. Iterate between searching for these # Retain a buffer of size(bufsize+maxbound); the latter part is # to ensure that dividers don't get lost by wrapping between two bufs # Look for a divider in the current batch. If not found, then # save all of bufsize, move the maxbound extra buffer to the front of # the buffer, and read in a new bufsize bytes. If a divider is found, # save everything up to the divider. Then empty the buffer of everything # up to the end of the divider. Refill buffer to bufsize+maxbound # Note slightly odd organization. Code before BODY: really goes with # code following HEAD:, but is put first to 'pre-fill' buffers. BODY: # is placed before HEAD: because we first need to discard any 'preface,' # which would be analagous to a body without a preceeding head. $left = $len; PART: # find each part of the multi-part while reading data while (1) { last PART if $errflag; $amt = ($left > $bufsize+$maxbound-length($buf) ? $bufsize+$maxbound-length($buf): $left); $errflag = (read(STDIN, $buf, $amt, length($buf)) != $amt); $left -= $amt; $in{$name} .= "\0" if defined $in{$name}; $in{$name} .= $fn if $fn; $name=~/([-\w]+)/; # This allows $insfn{$name} to be untainted if (defined $1) { $insfn{$1} .= "\0" if defined $insfn{$1}; $insfn{$1} .= $fn if $fn; } BODY: while (($bpos = index($buf, $boundary)) == -1) { if ($name) { # if no $name, then it's the prologue -- discard if ($fn) { print FILE substr($buf, 0, $bufsize); } else { $in{$name} .= substr($buf, 0, $bufsize); } } $buf = substr($buf, $bufsize); $amt = ($left > $bufsize ? $bufsize : $left); #$maxbound==length($buf); $errflag = (read(STDIN, $buf, $amt, $maxbound) != $amt); $left -= $amt; } if (defined $name) { # if no $name, then it's the prologue -- discard if ($fn) { print FILE substr($buf, 0, $bpos-2); } else { $in {$name} .= substr($buf, 0, $bpos-2); } # kill last \r\n } close (FILE); last PART if substr($buf, $bpos + $blen, 4) eq "--\r\n"; substr($buf, 0, $bpos+$blen+2) = ''; $amt = ($left > $bufsize+$maxbound-length($buf) ? $bufsize+$maxbound-length($buf) : $left); $errflag = (read(STDIN, $buf, $amt, length($buf)) != $amt); $left -= $amt; undef $head; undef $fn; HEAD: while (($lpos = index($buf, "\r\n\r\n")) == -1) { $head .= substr($buf, 0, $bufsize); $buf = substr($buf, $bufsize); $amt = ($left > $bufsize ? $bufsize : $left); #$maxbound==length($buf); $errflag = (read(STDIN, $buf, $amt, $maxbound) != $amt); $left -= $amt; } $head .= substr($buf, 0, $lpos+2); push (@in, $head); @heads = split("\r\n", $head); ($cd) = grep (/^\s*Content-Disposition:/i, @heads); ($ct) = grep (/^\s*Content-Type:/i, @heads); ($name) = $cd =~ /\bname="([^"]+)"/i; #"; ($name) = $cd =~ /\bname=([^\s:;]+)/i unless defined $name; ($fname) = $cd =~ /\bfilename="([^"]*)"/i; #"; # filename can be null-str ($fname) = $cd =~ /\bfilename=([^\s:;]+)/i unless defined $fname; $incfn{$name} .= (defined $in{$name} ? "\0" : "") . $fname; ($ctype) = $ct =~ /^\s*Content-type:\s*"([^"]+)"/i; #"; ($ctype) = $ct =~ /^\s*Content-Type:\s*([^\s:;]+)/i unless defined $ctype; $inct{$name} .= (defined $in{$name} ? "\0" : "") . $ctype; if ($writefiles && defined $fname) { $ser++; $fn = $writefiles . ".$$.$ser"; open (FILE, ">$fn") || &CgiDie("Couldn't open $fn\n"); } substr($buf, 0, $lpos+4) = ''; undef $fname; undef $ctype; } #################1; #################END_MULTIPART &CgiDie($@) if $errflag; } else { &CgiDie("cgi-lib.pl: Unknown Content-type: $ENV{'CONTENT_TYPE'}\n"); } $^W = $perlwarn; return ($errflag ? undef : scalar(@in)); } # PrintHeader # Returns the magic line which tells WWW that we're an HTML document sub PrintHeader { return "Content-type: text/html\n\n"; } # HtmlTop # Returns the of a document and the beginning of the body # with the title and a body

header as specified by the parameter sub HtmlTop { local ($title) = @_; return < $title

$title

END_OF_TEXT } # HtmlBot # Returns the , codes for the bottom of every HTML page sub HtmlBot { return "\n\n"; } # SplitParam # Splits a multi-valued parameter into a list of the constituent parameters sub SplitParam { local ($param) = @_; local (@params) = split ("\0", $param); return (wantarray ? @params : $params[0]); } # MethGet # Return true if this cgi call was using the GET request, false otherwise sub MethGet { return (defined $ENV{'REQUEST_METHOD'} && $ENV{'REQUEST_METHOD'} eq "GET"); } # MethPost # Return true if this cgi call was using the POST request, false otherwise sub MethPost { return (defined $ENV{'REQUEST_METHOD'} && $ENV{'REQUEST_METHOD'} eq "POST"); } # MyBaseUrl # Returns the base URL to the script (i.e., no extra path or query string) sub MyBaseUrl { local ($ret, $perlwarn); $perlwarn = $^W; $^W = 0; $ret = 'http://' . $ENV{'SERVER_NAME'} . ($ENV{'SERVER_PORT'} != 80 ? ":$ENV{'SERVER_PORT'}" : '') . $ENV{'SCRIPT_NAME'}; $^W = $perlwarn; return $ret; } # MyFullUrl # Returns the full URL to the script (i.e., with extra path or query string) sub MyFullUrl { local ($ret, $perlwarn); $perlwarn = $^W; $^W = 0; $ret = 'http://' . $ENV{'SERVER_NAME'} . ($ENV{'SERVER_PORT'} != 80 ? ":$ENV{'SERVER_PORT'}" : '') . $ENV{'SCRIPT_NAME'} . $ENV{'PATH_INFO'} . (length ($ENV{'QUERY_STRING'}) ? "?$ENV{'QUERY_STRING'}" : ''); $^W = $perlwarn; return $ret; } # MyURL # Returns the base URL to the script (i.e., no extra path or query string) # This is obsolete and will be removed in later versions sub MyURL { return &MyBaseUrl; } # CgiError # Prints out an error message which which containes appropriate headers, # markup, etcetera. # Parameters: # If no parameters, gives a generic error message # Otherwise, the first parameter will be the title and the rest will # be given as different paragraphs of the body sub CgiError { local (@msg) = @_; local ($i,$name); if (!@msg) { $name = &MyFullUrl; @msg = ("Error: script $name encountered fatal error\n"); }; if (!$cgi_lib'headerout) { #') print &PrintHeader; print "\n\n$msg[0]\n\n\n"; } print "

$msg[0]

\n"; foreach $i (1 .. $#msg) { print "

$msg[$i]

\n"; } $cgi_lib'headerout++; } # CgiDie # Identical to CgiError, but also quits with the passed error message. sub CgiDie { local (@msg) = @_; &CgiError (@msg); die @msg; } # PrintVariables # Nicely formats variables. Three calling options: # A non-null associative array - prints the items in that array # A type-glob - prints the items in the associated assoc array # nothing - defaults to use %in # Typical use: &PrintVariables() sub PrintVariables { local (*in) = @_ if @_ == 1; local (%in) = @_ if @_ > 1; local ($out, $key, $output); $output = "\n
\n"; foreach $key (sort keys(%in)) { foreach (split("\0", $in{$key})) { ($out = $_) =~ s/\n/
\n/g; $output .= "
$key\n
:$out:
\n"; } } $output .= "
\n"; return $output; } # PrintEnv # Nicely formats all environment variables and returns HTML string sub PrintEnv { &PrintVariables(*ENV); } # The following lines exist only to avoid warning messages $cgi_lib'writefiles = $cgi_lib'writefiles; $cgi_lib'bufsize = $cgi_lib'bufsize ; $cgi_lib'maxbound = $cgi_lib'maxbound; $cgi_lib'version = $cgi_lib'version; ----- Original Message ----- From: "YueSong Xu" To: Sent: Wednesday, August 27, 2008 7:41 PM Subject: [tpm] How to retrieve post > Hello everyone, > > Instead of using CGI.pm, how can I write perl raw code to get all the HTTP post params as a whole string on Apache (mod_perl 1.29)? Any %ENV? > Thanks a lot. > > > > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm -------------- next part -------------- An HTML attachment was scrubbed... URL: From samogon at gmail.com Thu Aug 28 19:12:34 2008 From: samogon at gmail.com (Ilia Lobsanov) Date: Thu, 28 Aug 2008 22:12:34 -0400 Subject: [tpm] java/perl opportunity Message-ID: <9B6A976B-7207-4B87-BD2D-2B21D72C7B22@gmail.com> Hi TPM, There's a job opening within my team. There's maybe 10% Perl to the job. The rest is Java. Here goes... Wanted: Junior to Intermediate Software Developer to work on cutting edge wireless network management platform Terms of employment: Contract Hours: full time Onsite: yes Company: Bluesocket http://www.bluesocket.com Must have skills: Java 5+, Ant, Mysql, Linux Nice to have: Struts 1, Jboss, Hibernate, Velocity, Log4J, Quartz, DWR, jFreeChart, XML-RPC, SNMP, SVN Bonus: familiarity with Linux build/debug tools, build/release experience, unit testing (jUnit), CruiseControl Description: You'll work closely with me to improve upon a solid product and make quantum leaps to take it past the competition. There is potential to upgrade to Struts 2. Regards, ilia. From talexb at gmail.com Thu Aug 28 20:46:59 2008 From: talexb at gmail.com (Alex Beamish) Date: Thu, 28 Aug 2008 23:46:59 -0400 Subject: [tpm] Pub discussion (1) Message-ID: Greetings, After Madison's presentation on Net::DBus tonight, we retreated to Burgundy's where a number of interesting technical discussions popped up. Among them were discussions as to whether my $self = shift; my $value = shift; would mean changes to $self would be reflected the same way than if $self and $value were collected in one fell swoop using my ( $self, $value ) = @_; My experiments consisted of three files, Obj1.pm: package Obj1; sub new { my $class = shift; my $self = {}; bless ( $self, $class ); return ( $self ); } sub add { my $self = shift; my $value = shift; $self->{value} = $value; } sub value { my $self = shift; return ( $self->{value} ); } 1; And the almost identical Obj2.pm: package Obj2; sub new { my $class = shift; my $self = {}; bless ( $self, $class ); return ( $self ); } sub add { my ( $self, $value ) = @_; $self->{value} = $value; } sub value { my $self = shift; return ( $self->{value} ); } 1; And finally the test script: #!/usr/bin/perl -w # # Test creating Obj1 and Obj2 to see if methods that access arguments # differently affect whether changes propogate back to the caller. # Specifically, does # # my $self = shift; # my ( $vars ) = @_; # # produce a different result than # # my ( $self, $vars ) = @_; use Obj1; use Obj2; { my $obj1 = Obj1->new(); $obj1->add("This is object one"); print "Obj1 value is " . $obj1->value() . "\n"; my $obj2 = Obj2->new(); $obj2->add("This is object two"); print "Obj2 value is " . $obj2->value() . "\n"; } The resulting output of running test12.pl is [alex at foo tpm-August2008]$ perl -w test12.pl Obj1 value is This is object one Obj2 value is This is object two This suggests that both methods (two shifts, or a single pull from @_) produce the same results. Have I misunderstood, or coded something incorrectly? I believe that both approaches mean pass by reference, meaning that changes are reflected. -- Alex Beamish Toronto, Ontario aka talexb From talexb at gmail.com Thu Aug 28 21:05:42 2008 From: talexb at gmail.com (Alex Beamish) Date: Fri, 29 Aug 2008 00:05:42 -0400 Subject: [tpm] Pub discussion (2) Message-ID: Further to my last, there was some discussion that passing numbered regexp parameters to a subroutine, and then doing a further regexp would pollute $1 and cause its value to change. My test code: #!/usr/bin/perl -w # # Another example. Does # # t($1,$2) # # sub t # { # my $a = shift; # m/(...)/; # return ($a); # } # # mean that $a now contains the new value of $1 because there's a new $1 # value? use strict; { my $line = "The quick brown fox jumped over .."; my ( $noun, $verb ) = ( $line =~ m/(\w+) (j\w+)/ ); print "Noun is $noun, verb is $verb.\n"; print "Noun is $1, verb is $2.\n"; my $return = t($1, $2); print "The return value is $return.\n"; } sub t { my $abc = shift; my $foo = "This is the last line of the test."; my ( $prep ) = ( $foo =~ /(th\w)/ ); print "OK, \$1 is $1 and abc is $abc.\n"; # Since the first parameter passed into this subroutine was $1, the # hypothesis is that by collecting a new $1, we will overwrite the # original value of $abc. return ( $abc ); } Running this script produces [alex at foo tpm-August2008]$ perl -w regexp.pl Noun is fox, verb is jumped. Noun is fox, verb is jumped. OK, $1 is the and abc is fox. The return value is fox. I would say that the hypothesis is disproved, unless I've misunderstood the example as it was presented to me. Corrections and clarifications gladly welcomed. -- Alex Beamish Toronto, Ontario aka talexb From ja_harris at rogers.com Thu Aug 28 21:08:30 2008 From: ja_harris at rogers.com (Jim Harris) Date: Thu, 28 Aug 2008 21:08:30 -0700 (PDT) Subject: [tpm] Pub discussion (1) Message-ID: <422455.93423.qm@web88002.mail.re2.yahoo.com> The variables get set the same either way.? The difference is that shift changes the value of @_, and the other way does not. --- On Fri, 8/29/08, Alex Beamish wrote: From: Alex Beamish Subject: [tpm] Pub discussion (1) To: "tpm" Received: Friday, August 29, 2008, 3:46 AM Greetings, After Madison's presentation on Net::DBus tonight, we retreated to Burgundy's where a number of interesting technical discussions popped up. Among them were discussions as to whether my $self = shift; my $value = shift; would mean changes to $self would be reflected the same way than if $self and $value were collected in one fell swoop using my ( $self, $value ) = @_; My experiments consisted of three files, Obj1.pm: package Obj1; sub new { my $class = shift; my $self = {}; bless ( $self, $class ); return ( $self ); } sub add { my $self = shift; my $value = shift; $self->{value} = $value; } sub value { my $self = shift; return ( $self->{value} ); } 1; And the almost identical Obj2.pm: package Obj2; sub new { my $class = shift; my $self = {}; bless ( $self, $class ); return ( $self ); } sub add { my ( $self, $value ) = @_; $self->{value} = $value; } sub value { my $self = shift; return ( $self->{value} ); } 1; And finally the test script: #!/usr/bin/perl -w # # Test creating Obj1 and Obj2 to see if methods that access arguments # differently affect whether changes propogate back to the caller. # Specifically, does # # my $self = shift; # my ( $vars ) = @_; # # produce a different result than # # my ( $self, $vars ) = @_; use Obj1; use Obj2; { my $obj1 = Obj1->new(); $obj1->add("This is object one"); print "Obj1 value is " . $obj1->value() . "\n"; my $obj2 = Obj2->new(); $obj2->add("This is object two"); print "Obj2 value is " . $obj2->value() . "\n"; } The resulting output of running test12.pl is [alex at foo tpm-August2008]$ perl -w test12.pl Obj1 value is This is object one Obj2 value is This is object two This suggests that both methods (two shifts, or a single pull from @_) produce the same results. Have I misunderstood, or coded something incorrectly? I believe that both approaches mean pass by reference, meaning that changes are reflected. -- Alex Beamish Toronto, Ontario aka talexb _______________________________________________ toronto-pm mailing list toronto-pm at pm.org http://mail.pm.org/mailman/listinfo/toronto-pm -------------- next part -------------- An HTML attachment was scrubbed... URL: From abram.hindle at softwareprocess.us Thu Aug 28 21:11:47 2008 From: abram.hindle at softwareprocess.us (Abram Hindle) Date: Fri, 29 Aug 2008 00:11:47 -0400 Subject: [tpm] Pub discussion (1) In-Reply-To: (sfid-20080828_234906_816035_BF529FCA) References: (sfid-20080828_234906_816035_BF529FCA) Message-ID: <48B77703.6010107@softwareprocess.us> I think you're totally correct. I think we were in the wrong here. as this: sub c { " lolcakes whatwhat " } c() =~ /([a-z]+)\s*([a-z]+)/g; print "t1 ".t1($1,$2),$/; c() =~ /([a-z]+)\s*([a-z]+)/g; print "t2 ".t2($1,$2),$/; c() =~ /([a-z]+)\s*([a-z]+)/g; print "t3 ".t3($1,$2),$/; c() =~ /([a-z]+)\s*([a-z]+)/g; print "t4 ".t4($1,$2),$/; sub t1 { ($a,$b) = @_; warn "$a $b"; $b =~ /(a+)/; return $a; } sub t2 { $a = shift; $b = shift; warn "$a $b"; $b =~ /(a+)/; return $a; } sub t3 { $a = $_[0]; $b = $_[1]; warn "$a $b"; $b =~ /(a+)/; return $a; } sub t4 { warn "$_[0] $_[1]"; $_[1] =~ /(a+)/; return $_[0]; } produces this: lolcakes whatwhat at ref.pl line 14. t1 lolcakes lolcakes whatwhat at ref.pl line 22. t2 lolcakes lolcakes whatwhat at ref.pl line 30. t3 lolcakes lolcakes whatwhat at ref.pl line 36. t4 a We were warning against using @_ directly since it is aliased. If you look in the last example $_[0] has changed. And for review form perlsub: Any arguments passed in show up in the array @_. Therefore, if you called a function with two arguments, those would be stored in $_[0] and $_[1]. The array @_ is a local array, but its elements are aliases for the actual scalar parameters. In particular, if an element $_[0] is updated, the corresponding argument is updated (or an error occurs if it is not updatable). If an argument is an array or hash element which did not exist when the function was called, that element is cre? ated only when (and if) it is modified or a reference to it is taken. (Some earlier versions of Perl created the element whether or not the element was assigned to.) Assigning to the whole array @_ removes that aliasing, and does not update any arguments. So we were wrong about case of using shift. abram Alex Beamish wrote: > Greetings, > > After Madison's presentation on Net::DBus tonight, we retreated to > Burgundy's where a number of interesting technical discussions popped > up. Among them were discussions as to whether > > my $self = shift; > my $value = shift; > > would mean changes to $self would be reflected the same way than if > $self and $value were collected in one fell swoop using > > my ( $self, $value ) = @_; > > My experiments consisted of three files, Obj1.pm: > > package Obj1; > > sub new > { > my $class = shift; > my $self = {}; > > bless ( $self, $class ); > return ( $self ); > } > > sub add > { > my $self = shift; > my $value = shift; > > $self->{value} = $value; > } > > sub value > { > my $self = shift; > return ( $self->{value} ); > } > > 1; > > And the almost identical Obj2.pm: > > package Obj2; > > sub new > { > my $class = shift; > my $self = {}; > > bless ( $self, $class ); > return ( $self ); > } > > sub add > { > my ( $self, $value ) = @_; > > $self->{value} = $value; > } > > sub value > { > my $self = shift; > return ( $self->{value} ); > } > > 1; > > And finally the test script: > > #!/usr/bin/perl -w > # > # Test creating Obj1 and Obj2 to see if methods that access arguments > # differently affect whether changes propogate back to the caller. > # Specifically, does > # > # my $self = shift; > # my ( $vars ) = @_; > # > # produce a different result than > # > # my ( $self, $vars ) = @_; > > use Obj1; > use Obj2; > > { > my $obj1 = Obj1->new(); > $obj1->add("This is object one"); > print "Obj1 value is " . $obj1->value() . "\n"; > > my $obj2 = Obj2->new(); > $obj2->add("This is object two"); > print "Obj2 value is " . $obj2->value() . "\n"; > } > > The resulting output of running test12.pl is > > [alex at foo tpm-August2008]$ perl -w test12.pl > Obj1 value is This is object one > Obj2 value is This is object two > > This suggests that both methods (two shifts, or a single pull from @_) > produce the same results. > > Have I misunderstood, or coded something incorrectly? I believe that > both approaches mean pass by reference, meaning that changes are > reflected. > -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 252 bytes Desc: OpenPGP digital signature URL: From janes.rob at gmail.com Fri Aug 29 01:55:08 2008 From: janes.rob at gmail.com (Rob Janes) Date: Fri, 29 Aug 2008 04:55:08 -0400 Subject: [tpm] Pub discussion (1) In-Reply-To: <48B77703.6010107@softwareprocess.us> References: (sfid-20080828_234906_816035_BF529FCA) <48B77703.6010107@softwareprocess.us> Message-ID: <48B7B96C.900@gmail.com> I've heard that this: 1. my ( $x, $y ) = @_; is better than this: 2. my ( $x, $y ) = ( shift, shift ); which is the same as: my $x = shift; my $y = shift; The advantages: a. number 1 is faster (this is what I've heard. Anybody profiled this?) b. number 1 leaves the aliased arguments still on the stack, available to be modified if need be. The disadvantages: a. if you want to assign to the alias, you have to leave it on the stack (you can't shift it off), and assign to it via $_[nnn] = "xoxoxox"; b. if you want to assign to the alias, it has to be writable. I cannot be an alias to "1234 tell me what you're looking for" (a string constant). Usually you'll get an error when you try to assign. Occasionally you'll get a core dump (unrecoverable error in perl). I forget the circumstances. Something about passing the alias to the read only to a core routine that expects a writable. c. the parameter must be supplied (undef isn't writable) d. to be safe, declare your parameters like in sub x($$$@) e. to be even more safe, check the SvREADONLY flag on the variable. Use readonly() from Scalar::Util or Scalar::Readonly. so, this is a possible usage: use Scalar::Util qw(readonly); ... sub do_logging($$$$) { my ( $self, $in_message, $out_result_code, $inout_filehandle ) = @_; ## "$out_result_code" is just a place holder you can't use ## the variable for it's purpose ... ## let's say the logfile gets full, and we want to close and reopen if ( !readonly( $_[3] ) ) { if ( $rotate_logfile_now ) { $inout_filehandle->close; ## compress it? $self->gen_new_logfile_name; $inout_filehandle = $_[3] = new IO::File "> $$self{LOGFILE}"; ## of course, if you keep the LOGFILE name in $self, you could ## keep the filehandle there too, but that would blow the ## example } } ... print $inout_filehandle "$level $timestamp $in_message\n" if $inout_filehandle; ... ## set to $out_result_code position if ( !readonly($_[2]) ) { if ( $problems ) { $_[2] = [ 0, 'OK', 'No Problems' ]; } else { $_[2] = 0; } } return $problems ? 0 : 1; } It only really works for scalars, although the scalars can be objects or references. It could be a shared memory handle, or a message, or an error trace stack. And there's no reason you couldn't put those in a $self, why have them on the parameter list? http://search.cpan.org/~gbarr/Scalar-List-Utils-1.19/lib/Scalar/Util.pm http://search.cpan.org/~gozer/Scalar-Readonly-0.02/lib/Scalar/Readonly.pm http://search.cpan.org/~roode/Readonly-1.03/Readonly.pm http://search.cpan.org/~roode/Readonly-XS-1.04/XS.pm Anyways, the filehandle example is kind of contrived. If I want to do something like that I put the filehandle in $self, not on the parameter list. I think a better scenario is where you want the subroutines or methods to return a simple boolean for success or fail, and put more complex diagnostics into a spot on @_. Test if the spot is there and writeable first. If not, don't bother giving up more revealing diagnostics. There's other cases where you can change the "parameters". in foreach, $_ will let you modify things in the foreach list. In map, $_ is an alias to the current item in the list, and it can be modified, changing the item in the list. -rob Abram Hindle wrote: > I think you're totally correct. I think we were in the wrong here. > > as this: > > sub c { " lolcakes whatwhat " } > c() =~ /([a-z]+)\s*([a-z]+)/g; > print "t1 ".t1($1,$2),$/; > c() =~ /([a-z]+)\s*([a-z]+)/g; > print "t2 ".t2($1,$2),$/; > c() =~ /([a-z]+)\s*([a-z]+)/g; > print "t3 ".t3($1,$2),$/; > c() =~ /([a-z]+)\s*([a-z]+)/g; > print "t4 ".t4($1,$2),$/; > > sub t1 { > ($a,$b) = @_; > warn "$a $b"; > $b =~ /(a+)/; > return $a; > } > > sub t2 { > $a = shift; > $b = shift; > warn "$a $b"; > $b =~ /(a+)/; > return $a; > } > > sub t3 { > $a = $_[0]; > $b = $_[1]; > warn "$a $b"; > $b =~ /(a+)/; > return $a; > } > > sub t4 { > warn "$_[0] $_[1]"; > $_[1] =~ /(a+)/; > return $_[0]; > } > > produces this: > lolcakes whatwhat at ref.pl line 14. > t1 lolcakes > lolcakes whatwhat at ref.pl line 22. > t2 lolcakes > lolcakes whatwhat at ref.pl line 30. > t3 lolcakes > lolcakes whatwhat at ref.pl line 36. > t4 a > > We were warning against using @_ directly > since it is aliased. If you look in the last example > $_[0] has changed. > > And for review form perlsub: > > Any arguments passed in show up in the array @_. Therefore, if you > called a function with two arguments, those would be stored in $_[0] > and $_[1]. The array @_ is a local array, but its elements are aliases > for the actual scalar parameters. In particular, if an element $_[0] > is updated, the corresponding argument is updated (or an error occurs > if it is not updatable). If an argument is an array or hash element > which did not exist when the function was called, that element is cre? > ated only when (and if) it is modified or a reference to it is taken. > (Some earlier versions of Perl created the element whether or not the > element was assigned to.) Assigning to the whole array @_ removes that > aliasing, and does not update any arguments. > > So we were wrong about case of using shift. > > abram > > > Alex Beamish wrote: >> Greetings, >> >> After Madison's presentation on Net::DBus tonight, we retreated to >> Burgundy's where a number of interesting technical discussions popped >> up. Among them were discussions as to whether >> >> my $self = shift; >> my $value = shift; >> >> would mean changes to $self would be reflected the same way than if >> $self and $value were collected in one fell swoop using >> >> my ( $self, $value ) = @_; >> >> My experiments consisted of three files, Obj1.pm: >> >> package Obj1; >> >> sub new >> { >> my $class = shift; >> my $self = {}; >> >> bless ( $self, $class ); >> return ( $self ); >> } >> >> sub add >> { >> my $self = shift; >> my $value = shift; >> >> $self->{value} = $value; >> } >> >> sub value >> { >> my $self = shift; >> return ( $self->{value} ); >> } >> >> 1; >> >> And the almost identical Obj2.pm: >> >> package Obj2; >> >> sub new >> { >> my $class = shift; >> my $self = {}; >> >> bless ( $self, $class ); >> return ( $self ); >> } >> >> sub add >> { >> my ( $self, $value ) = @_; >> >> $self->{value} = $value; >> } >> >> sub value >> { >> my $self = shift; >> return ( $self->{value} ); >> } >> >> 1; >> >> And finally the test script: >> >> #!/usr/bin/perl -w >> # >> # Test creating Obj1 and Obj2 to see if methods that access arguments >> # differently affect whether changes propogate back to the caller. >> # Specifically, does >> # >> # my $self = shift; >> # my ( $vars ) = @_; >> # >> # produce a different result than >> # >> # my ( $self, $vars ) = @_; >> >> use Obj1; >> use Obj2; >> >> { >> my $obj1 = Obj1->new(); >> $obj1->add("This is object one"); >> print "Obj1 value is " . $obj1->value() . "\n"; >> >> my $obj2 = Obj2->new(); >> $obj2->add("This is object two"); >> print "Obj2 value is " . $obj2->value() . "\n"; >> } >> >> The resulting output of running test12.pl is >> >> [alex at foo tpm-August2008]$ perl -w test12.pl >> Obj1 value is This is object one >> Obj2 value is This is object two >> >> This suggests that both methods (two shifts, or a single pull from @_) >> produce the same results. >> >> Have I misunderstood, or coded something incorrectly? I believe that >> both approaches mean pass by reference, meaning that changes are >> reflected. >> > > > > ------------------------------------------------------------------------ > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm From zoffix at zoffix.com Fri Aug 29 02:36:53 2008 From: zoffix at zoffix.com (Zoffix Znet) Date: Fri, 29 Aug 2008 05:36:53 -0400 Subject: [tpm] Pub discussion (1) In-Reply-To: <48B7B96C.900@gmail.com> References: (sfid-20080828_234906_816035_BF529FCA) <48B77703.6010107@softwareprocess.us> <48B7B96C.900@gmail.com> Message-ID: <1220002613.9307.12.camel@zoflap> Here are the "speed" results. The shift() is faster unless you are shifting off 10 or more parameters. It's because my ( $x ) = @_; makes a copy.: Three parameters: Rate @_ shift @_ 6633811/s -- -70% shift 22285677/s 236% -- Ten parameters: shift 1470972/s -- -17% @_ 1772951/s 21% -- But if you worry about speed on this level you should really be using a different language. Not sure why you list half of those things in "disadvantages". To me it seems obvious that if the sub is supposed to modify passed arguments those need to be writable. As long as this is documented let perl handle the errors if the user of your sub passes incorrect arguments. Personally, I stay far away from modifying aliased arguments. What I find useful though is that you could check whether or not your sub was called in void context (by using wantarray()) and if it was, modify passed arguments in place. By the way, instead of my ( $x, $y ) = ( shift, shift ); which was proposed below, I'd use my ( $x, $y ) = splice @_, 0, 2; for the purpose of removing those two arguments from @_ (same as shift does) Cheers. On Fri, 2008-08-29 at 04:55 -0400, Rob Janes wrote: > I've heard that this: > > 1. my ( $x, $y ) = @_; > > is better than this: > > 2. my ( $x, $y ) = ( shift, shift ); > > which is the same as: > my $x = shift; > my $y = shift; > > The advantages: > a. number 1 is faster (this is what I've heard. Anybody profiled this?) > b. number 1 leaves the aliased arguments still on the stack, available > to be modified if need be. > > The disadvantages: > a. if you want to assign to the alias, you have to leave it on the > stack (you can't shift it off), and assign to it via > $_[nnn] = "xoxoxox"; > b. if you want to assign to the alias, it has to be writable. I > cannot be an alias to "1234 tell me what you're looking for" > (a string constant). Usually you'll get an error when you try to > assign. Occasionally you'll get a core dump (unrecoverable > error in perl). I forget the circumstances. Something about > passing the alias to the read only to a core routine that > expects a writable. > c. the parameter must be supplied (undef isn't writable) > d. to be safe, declare your parameters like in sub x($$$@) > e. to be even more safe, check the SvREADONLY flag on > the variable. Use readonly() from Scalar::Util or Scalar::Readonly. > > so, this is a possible usage: > > use Scalar::Util qw(readonly); > > ... > > sub do_logging($$$$) { > my ( $self, $in_message, $out_result_code, $inout_filehandle ) = @_; > ## "$out_result_code" is just a place holder you can't use > ## the variable for it's purpose > > ... > ## let's say the logfile gets full, and we want to close and reopen > if ( !readonly( $_[3] ) ) { > if ( $rotate_logfile_now ) { > $inout_filehandle->close; > ## compress it? > $self->gen_new_logfile_name; > $inout_filehandle = $_[3] = new IO::File "> $$self{LOGFILE}"; > ## of course, if you keep the LOGFILE name in $self, you could > ## keep the filehandle there too, but that would blow the > ## example > } > } > > ... > print $inout_filehandle "$level $timestamp $in_message\n" > if $inout_filehandle; > > ... > ## set to $out_result_code position > if ( !readonly($_[2]) ) { > if ( $problems ) { > $_[2] = [ 0, 'OK', 'No Problems' ]; > } else { > $_[2] = 0; > } > } > > return $problems ? 0 : 1; > } > > It only really works for scalars, although the scalars can be objects or > references. It could be a shared memory handle, or a message, or an > error trace stack. And there's no reason you couldn't put those in a > $self, why have them on the parameter list? > > http://search.cpan.org/~gbarr/Scalar-List-Utils-1.19/lib/Scalar/Util.pm > http://search.cpan.org/~gozer/Scalar-Readonly-0.02/lib/Scalar/Readonly.pm > http://search.cpan.org/~roode/Readonly-1.03/Readonly.pm > http://search.cpan.org/~roode/Readonly-XS-1.04/XS.pm > > Anyways, the filehandle example is kind of contrived. If I want to do > something like that I put the filehandle in $self, not on the parameter > list. > > I think a better scenario is where you want the subroutines or methods > to return a simple boolean for success or fail, and put more complex > diagnostics into a spot on @_. Test if the spot is there and writeable > first. If not, don't bother giving up more revealing diagnostics. > > There's other cases where you can change the "parameters". in foreach, > $_ will let you modify things in the foreach list. In map, $_ is an > alias to the current item in the list, and it can be modified, changing > the item in the list. > > -rob > > Abram Hindle wrote: > > I think you're totally correct. I think we were in the wrong here. > > > > as this: > > > > sub c { " lolcakes whatwhat " } > > c() =~ /([a-z]+)\s*([a-z]+)/g; > > print "t1 ".t1($1,$2),$/; > > c() =~ /([a-z]+)\s*([a-z]+)/g; > > print "t2 ".t2($1,$2),$/; > > c() =~ /([a-z]+)\s*([a-z]+)/g; > > print "t3 ".t3($1,$2),$/; > > c() =~ /([a-z]+)\s*([a-z]+)/g; > > print "t4 ".t4($1,$2),$/; > > > > sub t1 { > > ($a,$b) = @_; > > warn "$a $b"; > > $b =~ /(a+)/; > > return $a; > > } > > > > sub t2 { > > $a = shift; > > $b = shift; > > warn "$a $b"; > > $b =~ /(a+)/; > > return $a; > > } > > > > sub t3 { > > $a = $_[0]; > > $b = $_[1]; > > warn "$a $b"; > > $b =~ /(a+)/; > > return $a; > > } > > > > sub t4 { > > warn "$_[0] $_[1]"; > > $_[1] =~ /(a+)/; > > return $_[0]; > > } > > > > produces this: > > lolcakes whatwhat at ref.pl line 14. > > t1 lolcakes > > lolcakes whatwhat at ref.pl line 22. > > t2 lolcakes > > lolcakes whatwhat at ref.pl line 30. > > t3 lolcakes > > lolcakes whatwhat at ref.pl line 36. > > t4 a > > > > We were warning against using @_ directly > > since it is aliased. If you look in the last example > > $_[0] has changed. > > > > And for review form perlsub: > > > > Any arguments passed in show up in the array @_. Therefore, if you > > called a function with two arguments, those would be stored in $_[0] > > and $_[1]. The array @_ is a local array, but its elements are aliases > > for the actual scalar parameters. In particular, if an element $_[0] > > is updated, the corresponding argument is updated (or an error occurs > > if it is not updatable). If an argument is an array or hash element > > which did not exist when the function was called, that element is cre? > > ated only when (and if) it is modified or a reference to it is taken. > > (Some earlier versions of Perl created the element whether or not the > > element was assigned to.) Assigning to the whole array @_ removes that > > aliasing, and does not update any arguments. > > > > So we were wrong about case of using shift. > > > > abram > > > > > > Alex Beamish wrote: > >> Greetings, > >> > >> After Madison's presentation on Net::DBus tonight, we retreated to > >> Burgundy's where a number of interesting technical discussions popped > >> up. Among them were discussions as to whether > >> > >> my $self = shift; > >> my $value = shift; > >> > >> would mean changes to $self would be reflected the same way than if > >> $self and $value were collected in one fell swoop using > >> > >> my ( $self, $value ) = @_; > >> > >> My experiments consisted of three files, Obj1.pm: > >> > >> package Obj1; > >> > >> sub new > >> { > >> my $class = shift; > >> my $self = {}; > >> > >> bless ( $self, $class ); > >> return ( $self ); > >> } > >> > >> sub add > >> { > >> my $self = shift; > >> my $value = shift; > >> > >> $self->{value} = $value; > >> } > >> > >> sub value > >> { > >> my $self = shift; > >> return ( $self->{value} ); > >> } > >> > >> 1; > >> > >> And the almost identical Obj2.pm: > >> > >> package Obj2; > >> > >> sub new > >> { > >> my $class = shift; > >> my $self = {}; > >> > >> bless ( $self, $class ); > >> return ( $self ); > >> } > >> > >> sub add > >> { > >> my ( $self, $value ) = @_; > >> > >> $self->{value} = $value; > >> } > >> > >> sub value > >> { > >> my $self = shift; > >> return ( $self->{value} ); > >> } > >> > >> 1; > >> > >> And finally the test script: > >> > >> #!/usr/bin/perl -w > >> # > >> # Test creating Obj1 and Obj2 to see if methods that access arguments > >> # differently affect whether changes propogate back to the caller. > >> # Specifically, does > >> # > >> # my $self = shift; > >> # my ( $vars ) = @_; > >> # > >> # produce a different result than > >> # > >> # my ( $self, $vars ) = @_; > >> > >> use Obj1; > >> use Obj2; > >> > >> { > >> my $obj1 = Obj1->new(); > >> $obj1->add("This is object one"); > >> print "Obj1 value is " . $obj1->value() . "\n"; > >> > >> my $obj2 = Obj2->new(); > >> $obj2->add("This is object two"); > >> print "Obj2 value is " . $obj2->value() . "\n"; > >> } > >> > >> The resulting output of running test12.pl is > >> > >> [alex at foo tpm-August2008]$ perl -w test12.pl > >> Obj1 value is This is object one > >> Obj2 value is This is object two > >> > >> This suggests that both methods (two shifts, or a single pull from @_) > >> produce the same results. > >> > >> Have I misunderstood, or coded something incorrectly? I believe that > >> both approaches mean pass by reference, meaning that changes are > >> reflected. > >> > > > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > toronto-pm mailing list > > toronto-pm at pm.org > > http://mail.pm.org/mailman/listinfo/toronto-pm > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm From talexb at gmail.com Fri Aug 29 06:36:52 2008 From: talexb at gmail.com (Alex Beamish) Date: Fri, 29 Aug 2008 09:36:52 -0400 Subject: [tpm] Pub discussion (1) In-Reply-To: <422455.93423.qm@web88002.mail.re2.yahoo.com> References: <422455.93423.qm@web88002.mail.re2.yahoo.com> Message-ID: Right -- but I have not yet encountered a situation where I want to get things off the calling stack without actually moving the stack pointer (that is, changing @_). I'm sure it's possible to cook something up like that, but at that point it becomes more of an intellectual exercise and not really something I'd find myself using regularly. Damian Conway's _Perl Best Practices_ (p. 180) says that you can use a single list assignment (as I was espousing) my ( $foo, $bar, $baz ) = @_; or a paragraph assignment my $foo = shift; my $bar = shift; my $baz = shift; but that the list assignment is more 'concise' and enhances readability. However (shudder) the paragraph version is fine when you want to check input parameters as you get them off the stack, and make suitable adjustments (using defaults, and so forth) as you go. I'm a strong proponent of making things as readable and as compact as possible (objectives that sometimes work against each other), hence my preference for the list assignment. And, as has already been pointed out, if you're making your choice based on performance, you're either worrying needlessly ;) or using the wrong language. Alex On Fri, Aug 29, 2008 at 12:08 AM, Jim Harris wrote: > The variables get set the same either way. The difference is that shift > changes the value of @_, and the other way does not. > > > --- On Fri, 8/29/08, Alex Beamish wrote: > > From: Alex Beamish > Subject: [tpm] Pub discussion (1) > To: "tpm" > Received: Friday, August 29, 2008, 3:46 AM > > Greetings, > > After Madison's presentation on Net::DBus tonight, we retreated to > Burgundy's where a number of interesting technical discussions popped > up. Among them were discussions as to whether > > my $self = shift; > my $value = shift; > > would mean changes to $self would be reflected the same way than if > $self and > $value were collected in > one fell swoop using > > my ( $self, $value ) = @_; > > My experiments consisted of three files, Obj1.pm: > > package Obj1; > > sub new > { > my $class = shift; > my $self = {}; > > bless ( $self, $class ); > return ( $self ); > } > > sub add > { > my $self = shift; > my $value = shift; > > $self->{value} = $value; > } > > sub value > { > my $self = shift; > return ( $self->{value} ); > } > > 1; > > And the almost identical Obj2.pm: > > package Obj2; > > sub new > { > my $class = shift; > my $self = {}; > > bless ( $self, $class ); > return ( $self ); > } > > sub add > { > my ( $self, $value ) = @_; > > $self->{value} = $value; > } > > sub value > { > my $self = shift; > return ( $self->{value} ); > } > > 1; > > And finally the test script: > > #!/usr/bin/perl > -w > # > # Test creating > Obj1 and Obj2 to see if methods that access arguments > # differently affect whether changes propogate back to the caller. > # Specifically, does > # > # my $self = shift; > # my ( $vars ) = @_; > # > # produce a different result than > # > # my ( $self, $vars ) = @_; > > use Obj1; > use Obj2; > > { > my $obj1 = Obj1->new(); > $obj1->add("This is object one"); > print "Obj1 value is " . $obj1->value() . "\n"; > > my $obj2 = Obj2->new(); > $obj2->add("This is object two"); > print "Obj2 value is " . $obj2->value() . "\n"; > } > > The resulting output of running test12.pl is > > [alex at foo tpm-August2008]$ perl -w test12.pl > Obj1 value is This is object one > Obj2 value is This is object two > > This suggests that both methods (two shifts, or a single pull from @_) > produce the same results. > > Have I misunderstood, or coded > something incorrectly? I believe > that > both approaches mean pass by reference, meaning that changes are > reflected. > > -- > Alex Beamish > Toronto, Ontario > aka talexb > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm > -- Alex Beamish Toronto, Ontario aka talexb From rbarc77 at yahoo.com Sat Aug 30 16:46:07 2008 From: rbarc77 at yahoo.com (Rodrigo Barcellos) Date: Sat, 30 Aug 2008 16:46:07 -0700 (PDT) Subject: [tpm] changing password for multiple accounts In-Reply-To: Message-ID: <315022.82552.qm@web55207.mail.re4.yahoo.com> Hello Ibrahim, Not sure if someone got back to you. Sounds like you want something exactly like LDAP. If you implement LDAP for your Unix servers, the password for all accounts will be synchronized - you change it on any box, it propagates it to all (because it sync's it at the LDAP server, the other servers are like a LDAP client). And that ID will expire on the same day, for all boxes. Depending on the LDAP implementation you use, there's one caveat, which doesn't tell you upfront that the password will expire. But that's easy to fix, you can have a perl script that runs on the global profile, which can launch a LDAP query command to check if you're about to expire and display a message accordingly. If you still want to have your passwords managed locally, it's doable, but way more painful and not secure. Basically, after a user enters a password and it gets crypted by HP-UX at /tcb/files/auth/r/root, you can capture that string with Perl and replicate it accross all the servers through scp, but you need the scp command to be run by another ID, exclusive to sync it to all servers (if you do the sync as root directly, you are openning root access to all servers without authentication, once you gain root access on one server). This other ID would leave the crypt password string on some directory, on all servers, and you can have a local cronjob (owned by root) that picks it up on every server and sets the password for that account accordingly. And then deletes that file left by the ID used to sync it everywhere. Cheers, Rodrigo --- On Wed, 8/27/08, Ibrahim Amin wrote: > From: Ibrahim Amin > Subject: [tpm] changing password for multiple accounts > To: toronto-pm at pm.org > Date: Wednesday, August 27, 2008, 5:19 PM > Hello, > I am looking for a secure and easy way for enabling users > to change the > password of his account before it expires. > > We use HP UX and some user have multiple logins in the form > of xxlogin, > where xx id two characters prefix and login is user login. > > 1 - I am looking for a way in which I can synchronize all > the account > expiration date. > 2 - If a user change the password for one of his account > that change also > effect those accounts belongs to the same user. > > I hope this can be done by perl. > > Thank you > -- > Yours truly, > Ibrahim Amin > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm From samogon at gmail.com Sun Aug 31 18:47:54 2008 From: samogon at gmail.com (Ilia Lobsanov) Date: Sun, 31 Aug 2008 21:47:54 -0400 Subject: [tpm] SVG to GIF converters? In-Reply-To: <1219851957.11129.180.camel@localhost> References: <48B56C11.9050204@alteeve.com> <1219851957.11129.180.camel@localhost> Message-ID: <711ACDF6-6941-4C58-A876-7D5052DE0004@gmail.com> This looks interesting as well, if you're into Prototype.js ... http://prototype-graphic.xilinus.com/ ilia. On 27-Aug-08, at 11:45 AM, Liam R E Quin wrote: > On Wed, 2008-08-27 at 11:00 -0400, Madison Kelly wrote: >> Hi all, >> >> I've got some SVG graphs I've created. I'd like to create GIF >> copies >> of these images though for browsers that don't support SVG. > > Note that there is also a jquery plugin to support SVG in most > modern browsers, including IE -- see http://plugins.jquery.com/ > > If you are not using transparency, you'll get better-looking results > with PNG, by the way, or with JPEG with a suitably high compression > quality (i.e. don't compress too much, if it's a graph -- try 98% > and smoothing of 12%, but it depends on the tool as to what the > "percentage" means). PNG is lossless, compress at the highest level > (usually called 9) to get the smallest file, but the JPEG file will > still be smaller. PNG can do transparency but not properly in > most IE versions, which is probably where you need it. > > Liam > > > -- > Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/ > Pictures from old books: http://fromoldbooks.org/ > Ankh: irc.sorcery.net irc.gnome.org www.advogato.org > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm