From otter101 at hotmail.com Mon Jan 3 19:51:17 2000 From: otter101 at hotmail.com (Steve Laybourn) Date: Wed Aug 4 00:07:01 2004 Subject: SPUG: Dates, anyone? Message-ID: <20000104015117.5125.qmail@hotmail.com> G'day, all! Well, my little code snippet to deal with date formatting seems to have stirred up a little excitement...but I don't think you would have wanted to see the whole of that package (Date::Calendrica, soon to be featured on a CPAN near you!) just to get at that little snippet! I like this group! OK, let's do another one... Currency functions! Everyone doing e-commerce programming needs or hand-rolls one of these type of functions, my own of which follows here: sub Cur { $ix=@_[0]; $ix=~ s/[^0123456789\.]//g; ($ix1,$ix2)=split(/\./,$ix); if (length($ix2)==0) { $ix2="00"; } if (length($ix2)==1) { $ix2="0"."$ix2"; } if (length($ix2)>3) { $ix2=substr($ix2,0,3); $ix2+=5; $ix2=substr($ix2,0,2); } $ix3=int(length($ix1)/3); $ix4=length($ix1)%3; $ix5=substr($ix1,0,$ix4); for($ix6=0;$ix6<$ix3;$ix6++) { $ix5.=",".substr($ix1,((3*$ix6)+$ix4+1),((3*$ix6)+$ix4+3)); } $final="\$"."$ix5".".$ix2"; return ($final); } This is somewhat shortened from the original I'd written, but it seems to deal with numbers in a xxxx(...)xxx.xxx(xxx)... format well enough. I'll just bet you aces can make this work better... Be seeing you, Steve Laybourn ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From mcglk at serv.net Mon Jan 3 21:52:57 2000 From: mcglk at serv.net (Ken McGlothlen) Date: Wed Aug 4 00:07:01 2004 Subject: SPUG: Dates, anyone? In-Reply-To: "Steve Laybourn"'s message of "Mon, 03 Jan 2000 17:51:17 PST" References: <20000104015117.5125.qmail@hotmail.com> Message-ID: <87vh5aqyqu.fsf@ralf.serv.net> "Steve Laybourn" writes: | Currency functions! Everyone doing e-commerce programming needs or | hand-rolls one of these type of functions, my own of which follows here: | | sub Cur { | $ix=@_[0]; | $ix=~ s/[^0123456789\.]//g; | ($ix1,$ix2)=split(/\./,$ix); | if (length($ix2)==0) { $ix2="00"; } | if (length($ix2)==1) { $ix2="0"."$ix2"; } | if (length($ix2)>3) { $ix2=substr($ix2,0,3); $ix2+=5; $ix2=substr($ix2,0,2); | } | $ix3=int(length($ix1)/3); | $ix4=length($ix1)%3; | $ix5=substr($ix1,0,$ix4); | for($ix6=0;$ix6<$ix3;$ix6++) { | $ix5.=",".substr($ix1,((3*$ix6)+$ix4+1),((3*$ix6)+$ix4+3)); } | $final="\$"."$ix5".".$ix2"; | return ($final); } | | This is somewhat shortened from the original I'd written, but it seems to | deal with numbers in a xxxx(...)xxx.xxx(xxx)... format well enough. I'm afraid to ask what the original was. Lessee if I have this algorithm right: grab the parameter; remove all nonnumeric characters (leaving "." as well); split on "."; if the last part is zero-length, make it "00", but if it's length 1, prepend a zero; if it's greater, round it to the nearest cent; insert commas in the part before the ".", add a dollar sign and return it. In a word, YUCK, Steve. That's horrible code. First of all, learn sprintf. It's such a handy tool. Handling the cents bit, for example (with automatic rounding) is as simple as $final = sprintf( "%.2f", $ix ); If you have "3", this turns into "3.00"; if you have "3.149", you get "3.15". The second part is the commas, and regular expressions are your friend here. The tricky part is that you have to do it repeatedly for each group of three. Easily done. So here's my rewrite of your function: sub Cur { my( $ix ) = shift; $ix = sprintf( "%.2f", $ix ); 1 while $ix =~ s/(.*\d)(\d\d\d)/$1,$2/g; return( "\$$ix" ); } Does that help? ---Ken - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From otter101 at hotmail.com Tue Jan 4 13:09:20 2000 From: otter101 at hotmail.com (Steve Laybourn) Date: Wed Aug 4 00:07:01 2004 Subject: SPUG: Rebuked... Message-ID: <20000104190920.12320.qmail@hotmail.com> Hello again! All right. I consider myself severely rebuked for posting such a crummy bit of code. But how am I gonna learn if I don't ask about it? Ken McGlothlen was nice enough (I think) to give me the sort of grab-that-guy-by-the-collar-and-shake-some-sense-into-him wake-up call and tell me why my code was inefficient. I more or less paraphrase him now: >So here's my rewrite of your function: (My turn to see if I have the interpretation of this correct): > > sub Cur { > my( $ix ) = shift; ---Let local variable $ix equal the first element of the default array @_, which in this case also equals $_. Hmmm, clever, that. How would you handle more than one element going in to the array? @_[0],@_[1], etc.? > $ix = sprintf( "%.2f", $ix ); ---This bit puzzles me a little. I understand the rounding function represented by the "%.2f" (you described it earlier, I'm looking into that further), but wouldn't assigning the result to $ix write over the current value of $ix, thusly eliminating the whole dollar part of $ix? > 1 while $ix =~ s/(.*\d)(\d\d\d)/$1,$2/g; ---OK, I really had to think this one out, but here goes: ---If the regular expression evaluates to true, then do the operation. Hmmm, I had wanted to work with up to nine digits and two decimal places, so would: ---1 while $ix=~ s/(.*\d)(\d\d\d)(\d\d\d)/$1,$2,$3/g; ---be more or less correct? The "1 while ..." statement is completely new to me. A long time ago I would have thought it to be a label or a line number. > return( "\$$ix" ); ---Prefix the result with a dollar sign and return the string. > } > >Does that help? ---Indeed it does. Sounds like I could save lots of time and variable space doing it this way. Again, I apologize for not being terribly good at Perl, but if I had known that people were going to actually answer back in this group, I would have joined long ago and learned to code a lot more responsibly than this! Thanks again. I'll be sure to irritate you again very soon. Be seeing you... Steve Laybourn ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From sab at rresearch.com Tue Jan 4 13:42:55 2000 From: sab at rresearch.com (Scott Blachowicz) Date: Wed Aug 4 00:07:02 2004 Subject: SPUG: Rebuked... In-Reply-To: <20000104190920.12320.qmail@hotmail.com>; from Steve Laybourn on Tue, Jan 04, 2000 at 11:09:20AM -0800 References: <20000104190920.12320.qmail@hotmail.com> Message-ID: <20000104114255.A41210@sabami.seaslug.org> On Tue, Jan 04, 2000 at 11:09:20AM -0800, Steve Laybourn wrote: > >So here's my rewrite of your function: > (My turn to see if I have the interpretation of this correct): > > > > sub Cur { > > my( $ix ) = shift; > > ---Let local variable $ix equal the first element of the default array @_, > which in this case also equals $_. Hmmm, clever, that. How would you handle It does? I'm not sure that's true (that '$_' is set to the first element of the '@_' arg list to the function). > more than one element going in to the array? @_[0],@_[1], etc.? my ($ix1, $ix2, $ix3) = @_; or my $ix1 = shift; my $ix2 = shift; my $ix3 = shift; Each of those 'shift's returns & removes the first element from the array (@_ is the default array for shift). > > $ix = sprintf( "%.2f", $ix ); > > ---This bit puzzles me a little. I understand the rounding function > represented by the "%.2f" (you described it earlier, I'm looking into that > further), but wouldn't assigning the result to $ix write over the current > value of $ix, thusly eliminating the whole dollar part of $ix? It's using a standard C printf() style format string. Check it's documentation. Basically that specification would use as much space as neeeded for the whole dollar part and only 2 digits for the fractional part. > > 1 while $ix =~ s/(.*\d)(\d\d\d)/$1,$2/g; > > ---OK, I really had to think this one out, but here goes: > ---If the regular expression evaluates to true, then do the operation. Hmmm, > I had wanted to work with up to nine digits and two decimal places, so > would: > ---1 while $ix=~ s/(.*\d)(\d\d\d)(\d\d\d)/$1,$2,$3/g; > ---be more or less correct? The "1 while ..." statement is completely new to > me. A long time ago I would have thought it to be a label or a line number. The '1' is just a statement to be able to use with the 'while' loop. It doesn't do a whole lot because the beef is in the conditional: STATEMENT while CONDITION; The CONDITION is a 'substitute' command. If the substitute command did something it'll return a "true" value for the CONDITION, which will cause it to be executed again. So, it repeatedly looks for occurrences of 4 digits in a row, inserting a comma before the last 3 digits in that run. So, it'll work for any length number. Your suggested revision will only work for to insert commas in runs of 7 or more digits. That while loop could've been formulated like this [untested snippet] as well: $ix = "$1,$2$3" while ($ix =~ m/^(.*\d)(\d\d\d)($|\D.*)$/); if you want the statement to actually do something. But the original suggestion is a bit more concise :-). -- Scott.Blachowicz@seaslug.org - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From andy at n2h2.com Tue Jan 4 14:08:49 2000 From: andy at n2h2.com (Andrew Sweger) Date: Wed Aug 4 00:07:02 2004 Subject: SPUG: Rebuked... In-Reply-To: <20000104190920.12320.qmail@hotmail.com> Message-ID: On Jan 4, 2000 @ 11:09am, Steve Laybourn wrote: > > sub Cur { > > my( $ix ) = shift; > > ---Let local variable $ix equal the first element of the default array @_, > which in this case also equals $_. Hmmm, clever, that. How would you handle > more than one element going in to the array? @_[0],@_[1], etc.? Time for a little more grabbing and shaking. $_ has nothing to do with @_ (other than sharing an entry in the symbol table). $_[0] is the scalar contained in the first (or zeroth if you prefer) element of the @_ array. @_[0] refers to an array slice, albeit containing a single element (a list of one scalar). -- Andrew Sweger N2H2, Incorporated 900 Fourth Avenue, Suite 3400 No thanks, I'll just have the Seattle WA 98164-1059 Linux with a side of Perl http://www.n2h2.com/ (206) 336-2947 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From otter101 at hotmail.com Tue Jan 4 14:38:37 2000 From: otter101 at hotmail.com (Steve Laybourn) Date: Wed Aug 4 00:07:02 2004 Subject: SPUG: Not again... Message-ID: <20000104203837.46574.qmail@hotmail.com> Wow! OK, I can see that I am screwing up Perl in a major way. I suppose I should not have said that in the case of: my ($ix)=shift; that @_[0] was equivalent to $_ (even though it did in an extremely limited sense for that statement only). I have been informed of my error. I have one more question that will doubtless irritate people even more... Search engines... Now, there are a couple of ways I have done this, none of them particularly good... One way was to use: $hit=index($wossname[$x],0,$searchstring); for each element in the array. If a -1 was returned, no match. OK. It seemed like a rather inefficient way to do a search engine, but it works pretty darn good for locating what line in an HTML/Perl/C++ script (or scripts) something occurs. Another way was to use a regex: if ($wossname[$x]=~ m/$searchstring/i) { &GizzaHit; } else { &NoHitz; } which seems to work quicker, but multiple words yielded too many multiple matching result strings, requiring another routine to filter out duplicates from the found list... The other way I recently learned was: @hitz=grep(/$searchstring/,@array); which seems to almost work the quickest, except the duplicate matches really pile up quickly in this one... I know I sound like a total dweeb for asking this, but what is really the best and most efficient way to search an array (record-by-record, \n is the record separator) for a particular substring? And if there is no way to avoid temporary duplicate matches, what is the best way to clean them up other than a sort-and-pack loop? I'll just bet someone will be waiting for me outside the next SPUG meeting with a tar melter and a couple of dozen goose-down pillows... Oh well. Thanks again, everyone, Steve Laybourn ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From andy at n2h2.com Tue Jan 4 15:45:47 2000 From: andy at n2h2.com (Andrew Sweger) Date: Wed Aug 4 00:07:02 2004 Subject: SPUG: Not again... In-Reply-To: <20000104203837.46574.qmail@hotmail.com> Message-ID: On Jan 4, 2000 @ 12:38pm, Steve Laybourn wrote: > The other way I recently learned was: > > @hitz=grep(/$searchstring/,@array); > > which seems to almost work the quickest, except the duplicate matches > really pile up quickly in this one... Pretty good analysis of the problem. Most folks are reduced to sort-and-uniquify to remove duplicates in a set (as a result of some other operation, like a search). An alternate method, that Perl affords, takes advantage of a hash. %hitz = map {$_, 1} grep {m/$searchstring/o} @array; I'm not sure that 'o' after the search pattern would help or not since the looping is already an internal function. The list, keys %hitz, will be the matching elements minus duplicates. You lose ordering information that was in the original @array. But there are ways to deal with that too (of course). Since it sounds like your dealing with a text file, here are some old fashioned ways to accomplish similar results (assuming you have Unix-like utilities at hand): grep file # finds lines matching pattern grep file | sort | uniq # "removes" duplicates grep file | sort -u # same as last one if your sort has -u grep file | sort | uniq -c | sort -n # lists an ordered frequency dist. of # matches > I'll just bet someone will be waiting for me outside the next SPUG > meeting with a tar melter and a couple of dozen goose-down pillows... I don't have any tar or feathers, but I'll be glad to bring the camel and penquin (I don't have to carry them as far this time). -- Andrew Sweger N2H2, Incorporated 900 Fourth Avenue, Suite 3400 No thanks, I'll just have the Seattle WA 98164-1059 Linux with a side of Perl http://www.n2h2.com/ (206) 336-2947 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From mcglk at serv.net Tue Jan 4 16:30:44 2000 From: mcglk at serv.net (Ken McGlothlen) Date: Wed Aug 4 00:07:02 2004 Subject: SPUG: Rebuked... In-Reply-To: "Steve Laybourn"'s message of "Tue, 04 Jan 2000 11:09:20 PST" References: <20000104190920.12320.qmail@hotmail.com> Message-ID: <877lhpjwq3.fsf@ralf.serv.net> "Steve Laybourn" writes: | > sub Cur { | > my( $ix ) = shift; | | ---Let local variable $ix equal the first element of the default array @_, | which in this case also equals $_. Hmmm, clever, that. How would you handle | more than one element going in to the array? @_[0],@_[1], etc.? Well, if you wanted to process each of these in a list, and return a list of values, you'd write something like: sub Cur { my( @ix ) = (); foreach( @_ ) { $_ = sprintf( "%.2f", $_ ); 1 while s/(.*\d)(\d\d\d)/$1,$2/g; push( @ix, "\$$_" ); } return( @ix ); } Make sense? | ---This bit puzzles me a little. I understand the rounding function | represented by the "%.2f" (you described it earlier, I'm looking into that | further), but wouldn't assigning the result to $ix write over the current | value of $ix, thusly eliminating the whole dollar part of $ix? Er, no. The "%.2f" translates something like "29330.5051" to "29330.51"; the "whole-dollar" part is preserved. For more information on "printf", check out "man printf" on any Unix system. If you don't have a Unix system handy, let me know and I'll mail you the page. | > 1 while $ix =~ s/(.*\d)(\d\d\d)/$1,$2/g; | | ---OK, I really had to think this one out, but here goes: | ---If the regular expression evaluates to true, then do the operation. Hmmm, | I had wanted to work with up to nine digits and two decimal places, so | would: | ---1 while $ix=~ s/(.*\d)(\d\d\d)(\d\d\d)/$1,$2,$3/g; | ---be more or less correct? The "1 while ..." statement is completely new to | me. A long time ago I would have thought it to be a label or a line number. Well, it's a trick. This could also be written while( $ix =~ s/(.*\d)(\d\d\d)/$1,$2/g ) { 1; } The "1" simply returns the value "1" (or true), but doesn't assign it to anything; it's just a syntactic placeholder that doesn't put too much of a load on the system. The real work is done by the while statement, which goes until the match fails. Let's assume that $ix is currently 9872349873.23. This is what happens. * The first match becomes: $1 = 9872349 $2 = 873 Why? Well, the .* is as greedy as possible, and $1 must end with a digit, so it's going to grab as much as it can. $2 prevents it from grabbing the remaining three digits. This means that "9872349873.23" becomes "9872349,873.23". * The second match becomes: $1 = 9872 $2 = 349 Why? Well, same thing as before, except that we have to remember that the comma is not a digit. So this also inserts a comma in the right place. One more iteration picks up the comma after the 9, and then on the next iteration, the match fails and the loop ends. | Again, I apologize for not being terribly good at Perl Hey, it's not all *that* easy. But there's a lot of power in Perl, and it's often worth looking around for a more convenient way of doing things rather than taking the approach you might use in, say, C or FORTRAN. Perl has a very natural way of working with text and numbers, and there's no better way to learn than by posting ineffecient code in front of a bunch of amazingly picky people. :) | Thanks again. I'll be sure to irritate you again very soon. No irritation registered. :) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From marlingreene at mindspring.com Tue Jan 4 17:02:15 2000 From: marlingreene at mindspring.com (marlin) Date: Wed Aug 4 00:07:02 2004 Subject: SPUG: GD file save Message-ID: <38727BF7.B0AA2338@mindspring.com> Dear Perl Gurus... I used the GD graphic module with success on a couple of projects last year to create charts from live data and then both display it directly and save the GD generated image to a file. That was accomplished on an NT system. I changed over my server to Linux last September and have had excellent results with the exception of this strange GD problem...I cannot get the GD module to save the created image to a file on the hard drive. Following lines are based on instructions with the GD module... ###print to screen -- this works binmode (STDOUT); print $im->gif; ####write to file -- from my NT module docs, works on NT $imgfile = 'testsave.gif'; $im->gif($imgfile); ####write to file -- from Linux module docs, does not work $gif_data = $im->gif; open (MYFILE,">testsave.gif") || die; binmode MYFILE; print MYFILE $gif_data; close DISPLAY; Neither of these "write" routines will create/save the image. I have chmod and owner/group names set correctly to allow file creation. Anyone know what I'm missing with Linux/GD? Thanks in advance... Marlin Greene -- 3 Hats Design INTERNET PRINT ILLUSTRATION 5201 15 Ave NW Suite 220 Seattle, WA 98107 206.784.1641 phone 206.784.2231 fax marlin@3hats.com www.3hats.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From charles.e.derykus at boeing.com Tue Jan 4 17:18:06 2000 From: charles.e.derykus at boeing.com (Charles DeRykus) Date: Wed Aug 4 00:07:02 2004 Subject: SPUG: GD file save Message-ID: <200001042318.PAA02767@carios2.ca.boeing.com> > ... > ####write to file -- from Linux module docs, does not work > $gif_data = $im->gif; > open (MYFILE,">testsave.gif") || die; > binmode MYFILE; > print MYFILE $gif_data; > close DISPLAY; > Neither of these "write" routines will create/save the image. I have > chmod and owner/group names set correctly to allow file creation. > Anyone know what I'm missing with Linux/GD? What errors do you see with: open (MYFILE,">testsave.gif") or die "open: $!\n"; ... close MYFILE or die "close: $!\n"; -- Charles DeRykus - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From otter101 at hotmail.com Tue Jan 4 17:48:44 2000 From: otter101 at hotmail.com (Steve Laybourn) Date: Wed Aug 4 00:07:02 2004 Subject: SPUG: GD file save Message-ID: <20000104234844.93074.qmail@hotmail.com> Hello! I, too, am interested in this very problem... >Dear Perl Gurus... > >I used the GD graphic module with success on a couple of projects last >year to create charts from live data and then both display it directly >and save the GD generated image to a file. That was accomplished on an >NT system. > >I changed over my server to Linux last September and have had excellent >results with the exception of this strange GD problem...I cannot get >the GD module to save the created image to a file on the hard drive. > >Following lines are based on instructions with the GD module... > > ###print to screen -- this works > binmode (STDOUT); > print $im->gif; > > ####write to file -- from my NT module docs, works on NT > $imgfile = 'testsave.gif'; > $im->gif($imgfile); > > ####write to file -- from Linux module docs, does not work > $gif_data = $im->gif; > open (MYFILE,">testsave.gif") || die; ---I'm not exactly sure, but I'm wondering if the +> option needs to be set for this file opening statement so's to clear the previous contents before writing... And perhaps: flock(MYFILE,2); #lock the file while in use could be used too. I'd always learned that it was a good idea to practice file locking whenever possible. But that could be more for databases in which a real risk of data collision could occur... > binmode MYFILE; > print MYFILE $gif_data; > close DISPLAY; --- close DISPLAY? (oops, wrong filehandle) Perhaps: flock(MYFILE,8); #We're done writing data, unlock the file close MYFILE; Hmmm, I'd be interested in how you can get CPAN modules installed on NT in the first place...this is easily the most stubborn system I've ever worked on... Good luck, sir! Be seeing you, Steve Laybourn ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From stuart_poulin at yahoo.com Tue Jan 4 18:02:26 2000 From: stuart_poulin at yahoo.com (Stuart Poulin) Date: Wed Aug 4 00:07:02 2004 Subject: SPUG: Rebuked... Message-ID: <20000105000226.9030.qmail@web107.yahoomail.com> --- Ken McGlothlen wrote: > > > Well, if you wanted to process each of these in a list, and return a list of > values, you'd write something like: > > sub Cur { > my( @ix ) = (); > foreach( @_ ) { > $_ = sprintf( "%.2f", $_ ); > 1 while s/(.*\d)(\d\d\d)/$1,$2/g; > push( @ix, "\$$_" ); > } > return( @ix ); > } > > But watch out for those references in for loops and @_. Try: @foo = (123.321, 212312.34221, 34234234.342); Cur(@foo); print "@foo\n"; (But maybe you wanted this behavior) Signed: One who's been bit by this many times. __________________________________________________ Do You Yahoo!? Talk to your friends online with Yahoo! Messenger. http://messenger.yahoo.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From wardk at halcyon.com Tue Jan 4 18:07:15 2000 From: wardk at halcyon.com (Ward Kaatz) Date: Wed Aug 4 00:07:02 2004 Subject: SPUG: GD file save In-Reply-To: <20000104234844.93074.qmail@hotmail.com>; from otter101@hotmail.com on Tue, Jan 04, 2000 at 03:48:44PM -0800 References: <20000104234844.93074.qmail@hotmail.com> Message-ID: <20000104160715.A6602@halcyon.com> Perhaps someone mentioned this already, but could it be an issue with the directory/file permissions? in moving from NT to Linux, this could be easily overlooked. Ward Kaatz - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From puckett at speakeasy.org Tue Jan 4 18:39:27 2000 From: puckett at speakeasy.org (Richard A Puckett II) Date: Wed Aug 4 00:07:02 2004 Subject: SPUG: GD file save References: <38727BF7.B0AA2338@mindspring.com> Message-ID: <387292BF.E581F72@speakeasy.org> marlin wrote: > ####write to file -- from Linux module docs, does not work > $gif_data = $im->gif; > open (MYFILE,">testsave.gif") || die; > binmode MYFILE; > print MYFILE $gif_data; > close DISPLAY; Do you really mean "close DISPLAY"? Do you really mean "close MYFILE"? You're using strict and perl -w, right? :) - Richard. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From smorton at pobox.com Tue Jan 4 19:27:26 2000 From: smorton at pobox.com (Sanford Morton) Date: Wed Aug 4 00:07:02 2004 Subject: SPUG: GD file save In-Reply-To: <38727BF7.B0AA2338@mindspring.com> References: <38727BF7.B0AA2338@mindspring.com> Message-ID: <200001050127.RAA27142@swan.prod.itd.earthlink.net> Your code looks ok to me, suggesting a perms problem, though you say you've checked that. Is there any error message or does it just create an empty file? It might help to look at my Chart::Plot module which does this. It's a front end to GD for drawing 2-d line graphs. Look on CPAN, or probably better www.pobox.com/~cgires/modules/ where you can view and play with a cgi demonstration script which writes files. Sandy - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tim at consultix-inc.com Wed Jan 5 00:20:24 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:02 2004 Subject: SPUG: Perl job in Renton Message-ID: <20000104222024.A4882@timji.consultix.wa.com> We are looking for a PERL programmer to help complete and maintain a web based document imaging program that we are almost done with. The program runs on Linux or other Unix systems. Part time or full time is ok. We are located in Renton Washington. Stock options are available. The contract duration could be 4 months long. And continuing upgrades and fixes. Payment can be 1099 or W-2 Telecommuting could work depending how fast the tasks take place. E-mail at: archive@archiveindex.com or archive@wolfenet.com. Our web site is www.archiveindex.com. We have been in business since 1993. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tim at consultix-inc.com Wed Jan 5 12:49:32 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:02 2004 Subject: SPUG: SPUG Web Page, Text Version Message-ID: <20000105104932.A6821@timji.consultix.wa.com> Welcome to SPUG-2000! I've just finished updating the SPUG/E-SPUG web page, and figured it might be a good idea to send a text version of its contents out to the list-membership at least once a millennium, so here it is! Any comments are welcome, as usual. -Tim * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * The following are excerpts from the web pages for SPUG, (http://www.halcyon.com/spug/), the Seattle Perl Users Group, and E-SPUG (http://www.halcyon.com/spug/eastside), the Eastside Seattle Perl Users Group. What is PERL? Perl is a powerful, portable, and mature programming language created by Larry Wall, with contributions from lots of other people. It is culturally derived from the UNIX C language, various UNIX shells, and the grep, sed, and AWK utilities of UNIX, among other influences. Although it was first embraced by UNIX programmers and Systems Administrators, in recent years, Perl has become the most popular choice of Web developers doing CGI applications. It runs under most modern computer operating systems, and is freely available and unencumbered by royalty or licensing restrictions. What is SPUG? The Seattle PERL Users Group is dedicated to the development of a mutually supportive community of Perl programmers in the Seattle, WA area, and to the professional development of the individual members. Our primary focus is on helping each other learn more about the Perl programming language. We keep in touch through an Email List Server, which provides meeting reminders, job postings, and questions/answers about Perl programming. We hold monthly meetings (on 3rd Tuesdays) in the building housing N2H2, Inc., in Downtown Seattle, WA, USA. In pursuit of these goals, we strive to encourage the following types of activities: * helping local Perl programmers get to know each other, * helping each other learn more about Perl, * helping each other find Perl programming contracts and jobs, * discussing the ways in which the SPUG meetings can better serve the membership, * encouraging SPUG members to take active roles in SPUG for our collective benefit. We operate as a kind of Educational Cooperative, by taking turns telling each other what we've learned about Perl. Our meetings are open to the general public, and Perl programmers of all levels are welcome. What is E-SPUG? Eastside-SPUG is a new project being led by Ryan Erwin (ryan@erwin.org) to explore the creation of a SPUG chapter that meets on the East-side of Lake Washington. That body of water presents a formidable obstacle to vehicular traffic, and its congested bridges have discouraged many Perl enthusiasts from attending the regular SPUG meetings. (SPUG meets in downtown Seattle, on the West side of Lake Washington). Anyone interested in helping establish E-SPUG, in speaking at an E-SPUG meeting, or in attending an E-SPUG meeting, please get in touch with Ryan. RECRUITERS PLEASE NOTE: Although we are happy to help recruiters and contract programmers find each other, we recommend that recruiters provide information about job openings via Email, rather than by coming to meetings. (Although we find the technical discussions fascinating, some recruiters have found them to be unendurably dreary.) Location and Time The official meeting is on 3rd Tuesdays from 7-9pm, followed by an optional meeting over adult beverages at a nearby facility. Our new regular meeting place for the Y2K is in the building housing N2H2, Inc., the Union Bank of California building, between 4th and 5th and Marion and Madison in downtown Seattle. We'll be meeting in the first-floor conference room - more details coming soon (as of 1/5/00, this is all we know). SPUG Mailing List! Would you like to be notified about upcoming meetings and participate in discussions with other local programmers, like the 200+ other Perl enthusiasts on our mailing list? If so, join the SPUG Mailing List by sending a message body containing: subscribe spug-list your_address TO majordomo@pm.org Job Offers for SPUG Members Some of our members do contract Perl programming work, while others are looking for full-time jobs. Accordingly, we are always interested to hear about openings for Perl Programmers in the Seattle area! If you want your job opening communicated to the hundreds of Perl programmers on our mailing list, Email a description of the job opening, including the following details, to spug@halcyon.com: required skill-set contract or permanent position contract duration? W-2 vs. 1099 status any restrictions on 1099 status: Corporation, etc.? physical location telecommuting possible? pay range stock options available? company's product or service e-commerce, grocery shopping, nuclear weapons, pornography, etc. SPUG officials will post announcements of such openings to our mailing list after ensuring that all details are complete. If you are reluctant to disclose any of these details, then you are encouraged to post your job announcement elsewhere. Job announcements should not be posted directly to our mailing list. SPUG Contact Info Leader: Tim Maher SPUG Email: spug@halcyon.com SPUG Web: http://www.halcyon.com/spug/ U.S. Mail: SPUG, POB 70563, Seattle WA, 98107-0563 USA Phone: (206) 781-UNIX (8649) Many thanks to our ISP sponsor, Winstar NorthWest Nexus, and our meeting space sponsor, N2H2, Inc. ========================================================== | Tim Maher, Ph.D. Tel/Fax: (206) 781-UNIX | | SPUG Founder & Leader Email: spug@halcyon.com | | Seattle Perl Users Group HTTP: www.halcyon.com/spug | ========================================================== - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tim at consultix-inc.com Wed Jan 5 13:05:23 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:02 2004 Subject: SPUG: January Meeting Message-ID: <20000105110523.A6830@timji.consultix.wa.com> January SPUG Meeting (1/18/2000) ADVANCED PATTERN MATCHING WITH PERL Tim Maher (tim@consultix-inc.com) of Consultix, a Seattle-based provider of UNIX & Perl Training, will present excerpts from a one-day training course entitled: "Advanced Pattern Matching with Perl". Although he does lots of stuff for the sheer joy of helping the SPUG membership, he has two ulterior motives for giving this presentation: 1) He's looking for an opportunity to practice presenting the new course material before the next offering of the course, and 2) he's looking for constructive feedback on his course materials, especially ideas for realistic yet simple examples of the different programming concepts. Topics for discussion will be taken from the following list, time permitting: * pattern ranges (e.g., /re1/,/re2/ and print; ) * positive and negative lookahead Regular Expressions (REs) * tricks with split() * Balanced Matches * using the Text::Balanced module * Fuzzy matching with the String::Approx module * maximizing efficiency of REs using study() to accelerate matching using eval() to accelerate matching using qr/RE/ to accelerate matching Attendees might want to review the following before the meeting: "man perlre", Mastering Regular Expressions (Friedl), and the Perl Cookbook, Chapter 6. LOCATION and TIME The official meeting is on 3rd Tuesdays from 7-9pm, followed by an optional meeting over adult beverages at a nearby facility. Our new regular meeting place for the Y2K is in the building housing N2H2, Inc., the Union Bank of California building, between 4th and 5th and Marion and Madison in downtown Seattle. We'll be meeting in the first-floor conference room - more details coming soon (as of 1/5/00, this is all we know). *========================================================================* | Tim Maher, PhD Consultix & (206) 781-UNIX/8649 | | Pacific Software Gurus, Inc Email: tim@consultix-inc.com | | UNIX/Linux & Perl Training http://www.consultix-inc.com | | 2/22: UNIX 2/28: Perl Modules 2/29: Int. Perl 3/3: Pattern Matching | *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From ryan at erwin.org Wed Jan 5 13:09:10 2000 From: ryan at erwin.org (Ryan Erwin) Date: Wed Aug 4 00:07:02 2004 Subject: SPUG: e-spug is here... Message-ID: <004a01bf57b0$59494d60$470b91d8@host> Greetings spugers- Now is the moment some of you have been waiting for. E-spug will meet every 4th Wednesday, at Lucent in Redmond. That puts our first meeting on January 26th. Lucent Technologies * 6464 185th Ave NE Redmond, WA 98052-6736 We can all thank David Patterson for arranging for our meeting place at lucent. Thanks to all of those who mailed me last time to show your interest. I would appreciate it if those who are planning to attend would mail me Ryan Erwin so I have an idea of how many people to expect. Also, topic suggestions are welcome, and anyone volunteering to talk about something is especially welcome! Need Directions? http://www.mapquest.com/ Thanks- Ryan [ryan@erwin.org] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From charles.e.derykus at boeing.com Wed Jan 5 14:28:44 2000 From: charles.e.derykus at boeing.com (Charles DeRykus) Date: Wed Aug 4 00:07:02 2004 Subject: SPUG: GD file save Message-ID: <200001052028.MAA03258@carios2.ca.boeing.com> > It might help to look at my Chart::Plot module which does this. It's > a front end to GD for drawing 2-d line graphs. Look on CPAN, or > probably better > www.pobox.com/~cgires/modules/ > where you can view and play with a cgi demonstration script which > writes files. Good thoughts. I'm still confused by the original poster's code: open(...) or die; which likely won't reveal any info about the exact nature of the problem, e.g., perl -e 'open F,"nosuch" or die' Died at -e line 1. perl -e 'open F, "nosuch" or die $!' No such file or directory at -e line 1. Hope this helps, -- Charles DeRykus - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tim at consultix-inc.com Wed Jan 5 17:54:15 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:02 2004 Subject: SPUG: Larry Wall article on-line Message-ID: <20000105155415.A760@timji.consultix.wa.com> There's an amusing article about how Larry Wall managed the evolution of Perl at the Linux Magazine web site: http://www.linux-mag.com/1999-10/uncultured_01.html Enjoy! *========================================================================* | Tim Maher, PhD Consultix & (206) 781-UNIX/8649 | | Pacific Software Gurus, Inc Email: tim@consultix-inc.com | | UNIX/Linux & Perl Training http://www.consultix-inc.com | | 2/22: UNIX 2/28: Perl Modules 2/29: Int. Perl 3/3: Pattern Matching | *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From peter at hivnet.fhcrc.org Wed Jan 5 18:08:44 2000 From: peter at hivnet.fhcrc.org (Peter Dueber) Date: Wed Aug 4 00:07:02 2004 Subject: SPUG: modems Message-ID: <200001060009.QAA29277@scharp.fhcrc.org> This isn't about perl but I thought some of you might be able to help. I have a PlugNPlay modem (on an Intel 586 at 133MHz) for MS Windows 95 (shudder) that doesn't work with Linux. If anyone has figured out how to make a PNP modem work on Linux or knows any external modems that are compatible with Linux (the lazy way), I'm in need of information. Peter Dueber, Esq. HIVNET Statistical Center Fred Hutchinson Cancer Research Center Phone: 206.667.6568 Fax : 206.667.4812 Email: peter@hivnet.fhcrc.org - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From otter101 at hotmail.com Wed Jan 5 18:31:20 2000 From: otter101 at hotmail.com (Steve Laybourn) Date: Wed Aug 4 00:07:02 2004 Subject: SPUG: modems Message-ID: <20000106003121.54149.qmail@hotmail.com> Hello! Nope, you are out of luck. A Winmodem will NEVER work on a Linux system. Seems that the hard-wired (or jumpered) IRQ and COM ports are a necessity for Linux to work with your modem. Don't feel bad, it took me a month (and two versions of Linux) before I got this one sorted out. Good luck, man! Steve Laybourn ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From kmeyer at aa.net Wed Jan 5 19:11:24 2000 From: kmeyer at aa.net (Kenneth W. Meyer) Date: Wed Aug 4 00:07:02 2004 Subject: SPUG: modems Message-ID: <01BF579F.E5B31A80@host211.207-55-127.aadsl.com> I don't have the last word on this subject but there are a couple of things: to consider 1) A "Winmodem" per se off-loads the signal processing to software controlled by the operating system. Therefore, it is pretty clear that, lacking very specific accommodations by Linux, only Windows will be compatible with "Winmodems". However, not all modems that will function with Windows are Winmodems. I would guess that no external modems are Winmodems, but many internal ones also are not. In fact, I would not buy a Winmodem inasmuch as it merely tangles the O/S with another task, and most importantly, a time-critical one. The original question did not specify whether the modem in question was specifically a Winmodem or not. 2) I have the feeling that the PnP aspects of IRQ assignment etc. are really primarily settled between the motherboard and the modem card. I would examine the BIOS setup screens carefully to ascertain whether you can take a PCI slot (I presume that this is a PCI type of modem) out of the PnP sequence and give it a specific, legacy, interrupt. Then Linux may be happier with it. This is the part that I am most uncertain of. 3) Another aspect of the solution is whether your communications software is compatible with the command set used by the modem. If the modem is not specifically named in the program's set-up list, it used to be that one could pretty safely designate a generic "Hayes-compatible" modem to obtain most if not all of the functionality. However, these days, since Hayes lost its leadership position, and since there is such a proliferation of registers needed to service the newly available feature-sets, this may not be a feasible approach. Nevertheless, a compatible fit may be available under some other name. I wouldn't give up without a fight, and some conversation with tech support from both the modem and the O/S vendors. Good luck, again. Ken Meyer kmeyer@aa.net ---------- From: Steve Laybourn[SMTP:otter101@hotmail.com] Sent: Wednesday, January 05, 2000 4:31 PM To: spug-list@pm.org Subject: Re: SPUG: modems Hello! Nope, you are out of luck. A Winmodem will NEVER work on a Linux system. Seems that the hard-wired (or jumpered) IRQ and COM ports are a necessity for Linux to work with your modem. Don't feel bad, it took me a month (and two versions of Linux) before I got this one sorted out. Good luck, man! Steve Laybourn ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From billg at vitessa.net Wed Jan 5 19:49:25 2000 From: billg at vitessa.net (William Graham) Date: Wed Aug 4 00:07:02 2004 Subject: SPUG: modems Message-ID: <012201bf57e8$42acbff0$a800a8c0@billg-new> Hi, Peter -- Lucent, for one, has released a binary for one of their WinModems for Linux. If yours is a Lucent, usually known as an "LTWinmodem", this may work -- it works on the one built into my Compaq Presario 1930 notebook running Redhat 6.1, Kernel 2.2.12. A friend has a newish Toshiba model running Slackware 4.0, though, and the Lucent driver doesn't work. here's the url: http://linmodems.org Look for the "Vendor linmodems" section, and get Lucent's file "linx565a.zip" (yes, it's a zip file for some reason -- use unzip instead of gunzip to extract the files under Linux). Also note that there is significant effort going towards getting these things working under Linux, so keep checking the site for more breakthroughs ... ;-) Best Regards, Bill Graham p.s. first post, but I've been lurking for a while. I do Java / Oracle ecommerce stuff by day, Perl / Linux / MySQL by night :). I hope to meet you folks at a meeting soon ... thanks for this forum -- I'm learning tons just from lurking! -----Original Message----- From: Peter Dueber To: spug-list@pm.org Date: Wednesday, January 05, 2000 5:12 PM Subject: SPUG: modems >This isn't about perl but I thought some of you might be able to help. > >I have a PlugNPlay modem (on an Intel 586 at 133MHz) for MS Windows 95 (shudder) >that doesn't work with Linux. If anyone has figured out how to make a PNP modem >work on Linux or knows any external modems that are compatible with Linux (the lazy >way), I'm in need of information. > > >Peter Dueber, Esq. >HIVNET Statistical Center >Fred Hutchinson Cancer Research Center >Phone: 206.667.6568 >Fax : 206.667.4812 >Email: peter@hivnet.fhcrc.org > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe > Email to majordomo@pm.org: ACTION spug-list your_address > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From moonbeam at catmanor.com Wed Jan 5 22:01:20 2000 From: moonbeam at catmanor.com (William Julien) Date: Wed Aug 4 00:07:02 2004 Subject: SPUG: modems In-Reply-To: Mail from '"William Graham" ' dated: Wed, 5 Jan 2000 17:49:25 -0800 Message-ID: <200001060401.UAA03553@catmanor.com> >Hi, Peter -- > >Lucent, for one, has released a binary for one of their WinModems for Linux. >If yours is a Lucent, usually known as an "LTWinmodem", this may work -- it >works on the one built into my Compaq Presario 1930 notebook running Redhat >6.1, Kernel 2.2.12. A friend has a newish Toshiba model running Slackware >4.0, though, and the Lucent driver doesn't work. Note - Binary only kernel modules are not, and probably never will be supported by the linux kernel. Quote from Linus: "I'm not all that interested in trying to help binary-only drivers, when people like 3dfx are opening up their specs and their libraries to the open source community. Why would I go to the extra work to help people who aren't even willing to help me?" See... http://kt.linuxcare.com/kt19991227_48.html#1 If you manage to get one of these beasts to work with linux, you are now locked into that particular kernel. I can understand your desire to not have to cut your losses and have to go out an buy a "real" modem. But it boggles the mind why one would spend so many man-months of "significant effort" to save the $50 extra it would take to get a real modem. The real answer is... Just say no. Buy a real modem. _,'| _.-''``-...___..--'; /, \'. _..-' , ,--...--''' < \ .`--''' ` /| William Julien moonbeam@catmanor.com `-,;' ; ; ; http://www.catmanor.com/moonbeam/ __...--'' __...--_..' .;.' vi is my shepherd; i shall not font. (,__....----''' (,..--'' perl -e 'print $i=pack(c5,(41*2),sqrt(7056),(unpack(c,H)-2),oct(115),10);' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From otter101 at hotmail.com Thu Jan 6 15:39:21 2000 From: otter101 at hotmail.com (Steve Laybourn) Date: Wed Aug 4 00:07:02 2004 Subject: SPUG: Search me... Message-ID: <20000106213921.46661.qmail@hotmail.com> Hello again! Well, this is getting interesting... OK, a while ago I asked what was an alternative way of preventing duplicates from piling up as a result of using grep() on an array for several words. I was told that using a hash was such a way, and it works, but: It’s in an ASCII flat-file database, and only certain fields of the record are to be searched. I would be using the record ID as the hash key, since it’s an absolutely unique identifier for any record. The record ID is at the end of the record, so I could actually use a substr() method for getting the name for the hash key. Is there a way (if you know the symbol for the field separator) to be able to skip areas of the record without breaking it apart via split(), or would I have to break the record apart, join only the fields to be searched, and then run the grep()? I need to know at any time how many matches have in fact been processed so I can stop the results list from becoming too large. If I use a hash, can I use something like $#keys to find out how many keys have been registered for this search pass so I know whether or not to continue the search? I do so like talking in a group where the average IQ is well over a thousand... Be seeing you... Steve Laybourn ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From charles.e.derykus at boeing.com Thu Jan 6 17:01:11 2000 From: charles.e.derykus at boeing.com (Charles DeRykus) Date: Wed Aug 4 00:07:02 2004 Subject: SPUG: MM_Unix mod needed? Message-ID: <200001062301.PAA01981@carios2.ca.boeing.com> > I want to change MakeMaker so that subdirectories do not inherit the > INSTALLSITELIB installation path from the parent Makefile.PL. From > my review of the code, it appears I'd need to change MM_Unix.pm to > change the 'sub tools_other' method to remove the following line: > > return join "", @m if $self->{PARENT}; > > Additionally, I'd need to modify MakeMaker.pm as follows to avoid the subdir p >ass: > > if ($self->{PARENT}) { > for (qw/install dist dist_basics dist_core dist_dir dist_test dist_ci >/) { > $self->{SKIPHASH}{$_} = 1; > } > } > > _to_ > > if ($self->{PARENT}) { > for (qw/dist dist_basics dist_core dist_dir dist_test dist_ci/) { > $self->{SKIPHASH}{$_} = 1; > } > } > > Has anyone dealt with this before? Is there a better solution? I saw your original post and was suprised that passing a PREFIX attribute didn't work within the subdirectory. I did notice that there's a a mechanism for overriding MakeMaker method output though: If you cannot achieve the desired Makefile behaviour by specifying attributes you may define private subroutines in the Makefile.PL. Each subroutines returns the text it wishes to have written to the Makefile. To override a section of the Makefile you can either say: sub MY::c_o { "new literal text" } or you can edit the default by saying something like: sub MY::c_o { package MY; # so that "SUPER" works right my $inherited = shift->SUPER::c_o(@_); $inherited =~ s/old text/new text/; $inherited; } Sounds like this would be easier and more flexible - if you can just figure out the appropriate method to override. Hopefully, I'm not barking up the wrong tree here. -- Charles DeRykus - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From toddw at wrq.com Fri Jan 7 15:37:58 2000 From: toddw at wrq.com (Todd Wells) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: parsing a config file Message-ID: <1654BC972546D31189DA00508B318AC8A57F58@charmander.wrq.com> Hello, I have a regular expression question for you gurus. I haven't done any Perl programming in a couple months and my skills are showing it. I would like to parse variables from a data file, and the data file is created by another app, so I can't change the file format. Accurately parsing this file is of utmost importance. At the bottom of this mail, you can see the format. I'd love to have a routine that could parse these settings more easily. Right now I'm sure I'm doing this the hard way, and I'd like to be more flexible. I'm currently reading all the lines of the file into the array @lines. Then I parse as such (partially complete example): for ($i = 0; $i < @lines; $i++) { if ($lines[$i] =~ /Domain =/) { $domain_servers = $lines[++$i] =~ s/servers = (.*);/$1/; $domain_status = $lines[++$i] =~ s/status = (.*);/$1/; } } Note I've avoided using a foreach because within the routine I want to look ahead at the next line(s). I'm sure there's a magic Perl variable that will tell me which array position I'm at during a foreach, but I couldn't figure out what the correct variable is. Forgive that the formatting in this email didn't come through as cleanly as I would've liked. I know Perl will let me parse easier than this, but my regular expression skills are pretty rusty. It'd be great if it could auto-name the variables based on what's on the left side of the equals sign, but I could hard-code variable names if necessary. The other thing I'm not sure how to deal with are the nested brackets -- for instance, see that the Restart section is enclosed by {} but it also has a nested {} inside of it. And I don't need variables called "Domain" or "Restart" (which are actually section names), but it'd be great if it could set the variables enclosed in that section. I'd like this to be more flexible than the way I've started to do it here, because it may be that unanticipated variables could pop up and my simple line incrementing may get out-of-synch with the way the config file is actually formatted. - Todd Here's the general config file format: { Domain = { servers = (); status = Enabled; }; Log = { easLogLevel = Standard; log = On; }; Restart = { Condition = 0; Enabled = NO; RestartTime = { CalenderFormat = "%d/%m/%Y %I:%M %p"; FromTime = "18/07/1997 03:00 AM"; ToTime = "18/07/1997 06:00 AM"; }; Schedule = 0; }; Security = { administrator = Administrators; domain = MINE; manager = Users; security = Off; user = Users; }; } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tim at consultix-inc.com Fri Jan 7 17:08:09 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: Parsing a config file Message-ID: <20000107150809.A7790@timji.consultix.wa.com> Those of you who want to post source code, please understand that the majordomo server will get upset when it sees "sub" in your code, thinking it's a subscription request being sent to the list! In such cases, the message is forwarded to the list-owner (me) for manual processing. I'm going to change sub to ssub, in the hope that will get it through. -Tim ========================================================== | Tim Maher, Ph.D. Tel/Fax: (206) 781-UNIX | | SPUG Founder & Leader Email: spug@halcyon.com | | Seattle Perl Users Group HTTP: www.halcyon.com/spug | ========================================================== ----- Forwarded message from owner-spug-list@pm.org ----- From: owner-spug-list@pm.org Date: Fri, 7 Jan 2000 17:48:41 -0500 (EST) X-Authentication-Warning: happyfunball.pm.org: mjordomo set sender to owner-spug-list@pm.org using -f To: owner-spug-list@pm.org Subject: BOUNCE spug-list@pm.org: Admin request of type /^sub\b/i at line 5 >From tim@consultix-inc.com Fri Jan 7 17:48:39 2000 Received: from smaug.wrq.com (smaug.wrq.com [150.215.17.2]) by happyfunball.pm.org (8.9.3/8.9.1) with ESMTP id RAA23975 for ; Fri, 7 Jan 2000 17:48:38 -0500 (EST) Received: from abra.wrq.com (abra.wrq.com [150.215.8.10]) by smaug.wrq.com (8.8.6 (PHNE_17135)/8.8.6) with ESMTP id OAA08338 for ; Fri, 7 Jan 2000 14:54:10 -0800 (PST) Received: by abra.wrq.com with Internet Mail Service (5.5.2448.0) id ; Fri, 7 Jan 2000 14:54:10 -0800 Message-ID: <1654BC972546D31189DA00508B318AC8A57F59@charmander.wrq.com> From: Todd Wells To: "'spug-list@pm.org'" Subject: RE: SPUG: parsing a config file Date: Fri, 7 Jan 2000 14:54:09 -0800 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2448.0) Content-Type: text/plain; charset="iso-8859-1" Okay, I think I'm a lot closer now, I haven't tested it quite yet, but I'm doing this based on p299 of the cookbook. I wanted to send this possible solution out before any of you spent more time on it: ssub new_parse { open (CONFIG, "< $config_file") or die "Couldn't open $config_file for reading: $!\n"; while () { chomp; #remove newline character s/^\s*{\s*(?!\S)//; # remove a lone "{" on a line s/^\s*};//; # remove a line with only "};" s/^\s*}\s*(?!\S)//; # remove a lone "}" on a line s/^\s*\w+ = {\s*(?!\S)//; # remove if only "NAME = {" next unless length; # is there anything left? s/(.+);$/$1/; # remove ";" at the end of line # now split remaining string into variable and value my ($var, $value) = split(/\s*=\s*/, $_, 2); $config{$var} = $value; #create a hash of variable/value pairs } } -----Original Message----- From: Todd Wells [mailto:toddw@wrq.com] Sent: Friday, January 07, 2000 1:38 PM To: spug-list@pm.org Subject: SPUG: parsing a config file Hello, I have a regular expression question for you gurus. I haven't done any Perl programming in a couple months and my skills are showing it. I would like to parse variables from a data file, and the data file is created by another app, so I can't change the file format. Accurately parsing this file is of utmost importance. At the bottom of this mail, you can see the format. I'd love to have a routine that could parse these settings more easily. Right now I'm sure I'm doing this the hard way, and I'd like to be more flexible. I'm currently reading all the lines of the file into the array @lines. Then I parse as such (partially complete example): for ($i = 0; $i < @lines; $i++) { if ($lines[$i] =~ /Domain =/) { $domain_servers = $lines[++$i] =~ s/servers = (.*);/$1/; $domain_status = $lines[++$i] =~ s/status = (.*);/$1/; } } Note I've avoided using a foreach because within the routine I want to look ahead at the next line(s). I'm sure there's a magic Perl variable that will tell me which array position I'm at during a foreach, but I couldn't figure out what the correct variable is. Forgive that the formatting in this email didn't come through as cleanly as I would've liked. I know Perl will let me parse easier than this, but my regular expression skills are pretty rusty. It'd be great if it could auto-name the variables based on what's on the left side of the equals sign, but I could hard-code variable names if necessary. The other thing I'm not sure how to deal with are the nested brackets -- for instance, see that the Restart section is enclosed by {} but it also has a nested {} inside of it. And I don't need variables called "Domain" or "Restart" (which are actually section names), but it'd be great if it could set the variables enclosed in that section. I'd like this to be more flexible than the way I've started to do it here, because it may be that unanticipated variables could pop up and my simple line incrementing may get out-of-synch with the way the config file is actually formatted. - Todd Here's the general config file format: { Domain = { servers = (); status = Enabled; }; Log = { easLogLevel = Standard; log = On; }; Restart = { Condition = 0; Enabled = NO; RestartTime = { CalenderFormat = "%d/%m/%Y %I:%M %p"; FromTime = "18/07/1997 03:00 AM"; ToTime = "18/07/1997 06:00 AM"; }; Schedule = 0; }; Security = { administrator = Administrators; domain = MINE; manager = Users; security = Off; user = Users; }; } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address ----- End forwarded message ----- -- *========================================================================* | Tim Maher, PhD Consultix & (206) 781-UNIX/8649 | | Pacific Software Gurus, Inc Email: tim@consultix-inc.com | | UNIX/Linux & Perl Training http://www.consultix-inc.com | | 2/22: UNIX 2/28: Perl Modules 2/29: Int. Perl 3/3: Pattern Matching | *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From jimfl at colltech.com Fri Jan 7 17:19:37 2000 From: jimfl at colltech.com (jimfl) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: parsing a config file In-Reply-To: <1654BC972546D31189DA00508B318AC8A57F58@charmander.wrq.com> Message-ID: <1479696.3156247177@erdos.nwest.attws.com> --On Friday, January 7, 2000 1:37 PM -0800 Todd Wells wrote: > { > Domain = { > servers = (); > status = Enabled; > }; > Log = { > easLogLevel = Standard; > log = On; > }; > Restart = { > Condition = 0; > Enabled = NO; > RestartTime = { > CalenderFormat = "%d/%m/%Y %I:%M %p"; > FromTime = "18/07/1997 03:00 AM"; > ToTime = "18/07/1997 06:00 AM"; > }; > Schedule = 0; > }; > Security = { > administrator = Administrators; > domain = MINE; > manager = Users; > security = Off; > user = Users; > }; > } This is almost perl. All you have to do is change all occurrances of '=' to '=>', all ';' to ',' and assign it to a variable, with code like: $cdata = q($Config = ); while ($line = ) { $line =~ s/=/=>/g; $line =~ s/\;/\,/g; $cdata .= $line; } $cdata .= ";"; eval $cdata; Then you will have a hashref called $Config which you can reference with code like: print $Config->{Log}->{easLogLevel}; -- Jim Flanagan Collective Technologies jimfl@colltech.com http://www.colltech.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From andy at n2h2.com Fri Jan 7 21:31:09 2000 From: andy at n2h2.com (Andrew Sweger) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: parsing a config file In-Reply-To: <1479696.3156247177@erdos.nwest.attws.com> Message-ID: On Jan 7, 2000 @ 3:19pm, jimfl wrote: > $cdata = q($Config = ); > while ($line = ) { > $line =~ s/=/=>/g; > $line =~ s/\;/\,/g; > $cdata .= $line; > } > $cdata .= ";"; > eval $cdata; Oh, that's very nice. That's a beaut. But it's slightly flawed. Odd number of elements in hash assignment at (eval 5) line 1, chunk 28. eval '$Config = { Domain => { servers => (), status => Enabled, }, Log => { easLogLevel => Standard, log => On, }, Restart => { Condition => 0, Enabled => NO, RestartTime => { CalenderFormat => "%d/%m/%Y %I:%M %p", FromTime => "18/07/1997 03:00 AM", ToTime => "18/07/1997 06:00 AM", }, Schedule => 0, }, Security => { administrator => Administrators, domain => MINE, manager => Users, security => Off, user => Users, }, } ;' ^---- here It's that last comma. This works... #!/usr/local/bin/perl -w # use strict; # Damn, can't use strict with barewords (in DATA)! undef $/; # what's that sucking sound? my $line = ; $line =~ s/=/=>/g; $line =~ s/\;/\,/g; $line =~ s/}\s*,\s*}/}}/; # changes '}, }' to '}}' $line .= ";"; my $Config = eval $line; __DATA__ blah __END__ ...but I'm not sure that chopping a comma out from between two closing braces will be enough (or it could go horribly wrong depending on what's in the data). -- Andrew Sweger | N2H2, Incorporated v=206.336.2947 f=206.336.1541 | 900 Fourth Avenue, Suite 3400 Advanced Technologies | Seattle WA 98164-1059 Development | http://www.n2h2.com/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From toddw at wrq.com Sat Jan 8 12:11:26 2000 From: toddw at wrq.com (Todd Wells) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: parsing a config file Message-ID: <1654BC972546D31189DA00508B318AC8A57F61@charmander.wrq.com> Here's what I actually ended up doing -- I sent the code to the list earlier, but it was the offending code with the magic word in it, so it only made the list tagged onto Dr. Tim's msg (you had to scroll down quite a ways to figure that out). This is not quite as elegant, but it seems to work. I tried using Jim's method, but hit the same snag you did. I may tackle it again using your revised method, we'll see... TMTOWTDI. But your method is nice how it sets up the nested hashes... open (CONFIG, "< $config_file") or die "Couldn't open $config_file for reading: $!\n"; while () { chomp; #remove newline character s/^\s*{\s*(?!\S)//; # remove a lone "{" on a line s/^\s*};//; # remove a line with only "};" s/^\s*}\s*(?!\S)//; # remove a lone "}" on a line s/^\s*\w+ = {\s*(?!\S)//; # remove if only "NAME = {" next unless length; # is there anything left? s/(.+);$/$1/; # remove ";" at the end of line s/^\s+(.*)/$1/; # remove leading whitespace # now split remaining string into variable and value my ($var, $value) = split(/\s*=\s*/, $_, 2); $config{$var} = $value; #create a hash of variable/value pairs } -----Original Message----- From: Andrew Sweger [mailto:andy@n2h2.com] Sent: Friday, January 07, 2000 7:31 PM To: jimfl Cc: Todd Wells; spug-list@pm.org Subject: Re: SPUG: parsing a config file On Jan 7, 2000 @ 3:19pm, jimfl wrote: > $cdata = q($Config = ); > while ($line = ) { > $line =~ s/=/=>/g; > $line =~ s/\;/\,/g; > $cdata .= $line; > } > $cdata .= ";"; > eval $cdata; Oh, that's very nice. That's a beaut. But it's slightly flawed. Odd number of elements in hash assignment at (eval 5) line 1, chunk 28. eval '$Config = { Domain => { servers => (), status => Enabled, }, Log => { easLogLevel => Standard, log => On, }, Restart => { Condition => 0, Enabled => NO, RestartTime => { CalenderFormat => "%d/%m/%Y %I:%M %p", FromTime => "18/07/1997 03:00 AM", ToTime => "18/07/1997 06:00 AM", }, Schedule => 0, }, Security => { administrator => Administrators, domain => MINE, manager => Users, security => Off, user => Users, }, } ;' ^---- here It's that last comma. This works... #!/usr/local/bin/perl -w # use strict; # Damn, can't use strict with barewords (in DATA)! undef $/; # what's that sucking sound? my $line = ; $line =~ s/=/=>/g; $line =~ s/\;/\,/g; $line =~ s/}\s*,\s*}/}}/; # changes '}, }' to '}}' $line .= ";"; my $Config = eval $line; __DATA__ blah __END__ ...but I'm not sure that chopping a comma out from between two closing braces will be enough (or it could go horribly wrong depending on what's in the data). -- Andrew Sweger | N2H2, Incorporated v=206.336.2947 f=206.336.1541 | 900 Fourth Avenue, Suite 3400 Advanced Technologies | Seattle WA 98164-1059 Development | http://www.n2h2.com/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From toddw at wrq.com Sat Jan 8 14:14:52 2000 From: toddw at wrq.com (Todd Wells) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: derefencing hash reference / parsing config file (con't) Message-ID: <1654BC972546D31189DA00508B318AC8A57F62@charmander.wrq.com> Okay, now I have another question related to this nice routine you guys suggested. Basically, I ended up using a variation of this to process the variables which can be nested, in this example I'm using "models". I have a feeling my problem is related to Camel p. 256 and Cookbook p.148, but I haven't figured it out. In the following code, assume that $config{models} = "{CCS = { name = CCS; pool = 1; max = 1; }; };" (without the quotes) Excerpted Code: my $line = $config{models}; $line =~ s/=/=>/g; # replace "=" with "=>" $line =~ s#\;#\,#g; # change ";" to "," $line .= ";"; # add a ; to the end so it's Perl $models = eval $line; # create a models hash print "\nmodels\n=======\n"; foreach $var (keys %models) { my $value = $models{$var}; print "$var is $value\n"; } print "models is $models\n"; My output was only: models ======= models is HASH(0x15ba60) So, like I said above, I think this is related to Camel p. 256 and Cookbook p.148, hard references don't work as hash keys. The cookbook says to solve this problem using Tie::RefHash, so at the begining of my code I put: use Tie::RefHash; tie %models, "Tie::RefHash"; but my output did not change! What am I doing wrong here? I'm assuming Tie::RefHash is part of a standard Perl distribution? I'm not getting any warnings about it, so I'm assuming that it's there and "working". I'm running this script under Solaris. Thanks for any help you can give, -Todd -----Original Message----- From: Andrew Sweger [mailto:andy@n2h2.com] Sent: Friday, January 07, 2000 7:31 PM To: jimfl Cc: Todd Wells; spug-list@pm.org Subject: Re: SPUG: parsing a config file On Jan 7, 2000 @ 3:19pm, jimfl wrote: > $cdata = q($Config = ); > while ($line = ) { > $line =~ s/=/=>/g; > $line =~ s/\;/\,/g; > $cdata .= $line; > } > $cdata .= ";"; > eval $cdata; Oh, that's very nice. That's a beaut. But it's slightly flawed. Odd number of elements in hash assignment at (eval 5) line 1, chunk 28. eval '$Config = { Domain => { servers => (), status => Enabled, }, Log => { easLogLevel => Standard, log => On, }, Restart => { Condition => 0, Enabled => NO, RestartTime => { CalenderFormat => "%d/%m/%Y %I:%M %p", FromTime => "18/07/1997 03:00 AM", ToTime => "18/07/1997 06:00 AM", }, Schedule => 0, }, Security => { administrator => Administrators, domain => MINE, manager => Users, security => Off, user => Users, }, } ;' ^---- here It's that last comma. This works... #!/usr/local/bin/perl -w # use strict; # Damn, can't use strict with barewords (in DATA)! undef $/; # what's that sucking sound? my $line = ; $line =~ s/=/=>/g; $line =~ s/\;/\,/g; $line =~ s/}\s*,\s*}/}}/; # changes '}, }' to '}}' $line .= ";"; my $Config = eval $line; __DATA__ blah __END__ ...but I'm not sure that chopping a comma out from between two closing braces will be enough (or it could go horribly wrong depending on what's in the data). -- Andrew Sweger | N2H2, Incorporated v=206.336.2947 f=206.336.1541 | 900 Fourth Avenue, Suite 3400 Advanced Technologies | Seattle WA 98164-1059 Development | http://www.n2h2.com/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From jope-spug at n2h2.com Sat Jan 8 14:42:50 2000 From: jope-spug at n2h2.com (El JoPe Magnifico) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: parsing a config file In-Reply-To: Message-ID: Not quite right, Mr. Sluggo! The trailing comma between the two closing curly brackets does no harm. Look closer below, specifically the value for $Config->{'Domain'}{'servers'} ...parentheses, rather than square brackets! Because => is syntactically the same as a comma, that empty list collapses in on itself, leaving you with three items in the list being assigned to the %{$Config->{'Domain'}} hash, efffectively making the assigment... Domain => { servers => status, Enabled => } Hence the error below. My connection keeps dogging out on me, so I'll leave it to someone else to add the line(s) to convert the parenthese to square brackets. -jp On Fri, 7 Jan 2000, Andrew Sweger wrote: > On Jan 7, 2000 @ 3:19pm, jimfl wrote: > >> $cdata = q($Config = ); >> while ($line = ) { >> $line =~ s/=/=>/g; >> $line =~ s/\;/\,/g; >> $cdata .= $line; >> } >> $cdata .= ";"; >> eval $cdata; > > Oh, that's very nice. That's a beaut. But it's slightly flawed. > > Odd number of elements in hash assignment at (eval 5) line 1, chunk > 28. > eval '$Config = > { > Domain => { > servers => (), ^^^ *** here's the problem! ** > status => Enabled, > }, > Log => { > easLogLevel => Standard, > log => On, > }, > Restart => { > Condition => 0, > Enabled => NO, > RestartTime => { > CalenderFormat => "%d/%m/%Y %I:%M %p", > FromTime => "18/07/1997 03:00 AM", > ToTime => "18/07/1997 06:00 AM", > }, > Schedule => 0, > }, > Security => { > administrator => Administrators, > domain => MINE, > manager => Users, > security => Off, > user => Users, > }, > } > ;' > ^---- here > > It's that last comma. This works... [...] > ...but I'm not sure that chopping a comma out from between two closing > braces will be enough (or it could go horribly wrong depending on what's > in the data). - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From andy at n2h2.com Sat Jan 8 14:46:01 2000 From: andy at n2h2.com (Andrew Sweger) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: derefencing hash reference / parsing config file (con't) In-Reply-To: <1654BC972546D31189DA00508B318AC8A57F62@charmander.wrq.com> Message-ID: On Jan 8, 2000 @ 12:14pm, Todd Wells wrote: > $config{models} = "{CCS = { name = CCS; pool = 1; max = 1; }; };" > > my $line = $config{models}; > $line =~ s/=/=>/g; # replace "=" with "=>" > $line =~ s#\;#\,#g; # change ";" to "," > $line .= ";"; # add a ; to the end so it's Perl > $models = eval $line; # create a models hash > > print "\nmodels\n=======\n"; > foreach $var (keys %models) > { > my $value = $models{$var}; > print "$var is $value\n"; > } > > print "models is $models\n"; > > My output was only: > > models > ======= > models is HASH(0x15ba60) You may be reading too much into it. When you, my $value = $models{$var}; you have just copied the value found in the hash %models in the $var key slot to the scalar $value. That value was a reference to a hash. > So, like I said above, I think this is related to Camel p. 256 and > Cookbook p.148, hard references don't work as hash keys. That's not entirely true (more later). In your example above, it is not the case that you used a reference as a key. There's also some confusion above on the difference between %models and $models. You've assign the result of the eval to the scalar $models which is the reference to a hash. Later you loop over the keys of the hash %models. The two are not quite related. In the foreach loop, use %$models to get the hash referenced by the scalar $models. You can use a reference as the key in a hash, but it will lose (up through Pelr 5.005_6x at least I think) it's magical referenceishness. But the value (the scalar created from the reference and used as the key) will still be unique and can be used in interesting ways. -- Andrew Sweger | N2H2, Incorporated v=206.336.2947 f=206.336.1541 | 900 Fourth Avenue, Suite 3400 Advanced Technologies | Seattle WA 98164-1059 Development | http://www.n2h2.com/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From andy at n2h2.com Sat Jan 8 14:57:05 2000 From: andy at n2h2.com (Andrew Sweger) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: parsing a config file In-Reply-To: Message-ID: Oh, Lord of the Little People, I now see the error of my ways. undef $/; my $line = ; $line =~ s/=/=>/g; $line =~ s/\;/\,/g; $line =~ s/\(\)/""/g; $line .= ";"; my $Config = eval $line; I used an empty string in place of the empty list instead of a ref to list. Get a real network connection, Monkey Boy. %) On Jan 8, 2000 @ 12:42pm, El JoPe Magnifico wrote: > Not quite right, Mr. Sluggo! The trailing comma between the two closing > curly brackets does no harm. Look closer below, specifically the value for > $Config->{'Domain'}{'servers'} ...parentheses, rather than square brackets! > Because => is syntactically the same as a comma, that empty list collapses > in on itself, leaving you with three items in the list being assigned to > the %{$Config->{'Domain'}} hash, efffectively making the assigment... > > Domain => { > servers => status, > Enabled => > } > > Hence the error below. My connection keeps dogging out on me, so I'll > leave it to someone else to add the line(s) to convert the parenthese to > square brackets. -- Andrew Sweger | N2H2, Incorporated v=206.336.2947 f=206.336.1541 | 900 Fourth Avenue, Suite 3400 Advanced Technologies | Seattle WA 98164-1059 Development | http://www.n2h2.com/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From andy at n2h2.com Sat Jan 8 15:00:28 2000 From: andy at n2h2.com (Andrew Sweger) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: derefencing hash reference / parsing config file (con't) In-Reply-To: Message-ID: On Jan 8, 2000 @ 12:46pm, Andrew Sweger wrote: > > So, like I said above, I think this is related to Camel p. 256 and > > Cookbook p.148, hard references don't work as hash keys. > > That's not entirely true (more later). In your example above, it is not > the case that you used a reference as a key. There's also some confusion > above on the difference between %models and $models. You've assign the > result of the eval to the scalar $models which is the reference to a hash. > Later you loop over the keys of the hash %models. The two are not quite > related. In the foreach loop, use %$models to get the hash referenced by > the scalar $models. I forgot to mention, you may want to use Data::Dumper when playing with nested ref structures in Perl. Very handy. And if I had used it properly and was paying attention, I would have seen my original mistake and not be publicly embarrassed by El JoPe Magnifico. use Data::Dumper; print Dumper $someref; I need to get out of the house... -- Andrew Sweger | N2H2, Incorporated v=206.336.2947 f=206.336.1541 | 900 Fourth Avenue, Suite 3400 Advanced Technologies | Seattle WA 98164-1059 Development | http://www.n2h2.com/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From sean at chittenden.org Sat Jan 8 15:25:09 2000 From: sean at chittenden.org (Sean Chittenden) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: derefencing hash reference / parsing config file (con't) In-Reply-To: <1654BC972546D31189DA00508B318AC8A57F62@charmander.wrq.com> Message-ID: Below: On Sat, 8 Jan 2000, Todd Wells wrote: > In the following code, assume that > $config{models} = "{CCS = { name = CCS; pool = 1; max = 1; }; };" (without > the quotes) > > Excerpted Code: > > my $line = $config{models}; > $line =~ s/=/=>/g; # replace "=" with "=>" > $line =~ s#\;#\,#g; # change ";" to "," Toss in an 'o' modifier to the end of your regexps for a speed boost, but I don't know if that's an issue here > $line .= ";"; # add a ; to the end so it's Perl > $models = eval $line; # create a models hash > > print "\nmodels\n=======\n"; I think your problem is in the following line: > foreach $var (keys %models) Depends on how your eval is setup, but if my guess is right, you're getting a hash ref from the eval, so you need to dereference the models scalar, which is a hash ref. foreach $var (keys %$models) { > { > my $value = $models{$var}; Then you'd change the previous line to: my $value = $models->{$var}; > print "$var is $value\n"; > } > > print "models is $models\n"; I'm not sure what you'd achieve by printing out the hash ref, but oh well... if you' enjoy looking at that kinda stuff.... ;~) > My output was only: > > models > ======= > models is HASH(0x15ba60) Which is correct and tells you, the programmer, that the value of $model is a hash ref. That being the case, just stick a % in front of your hashrefs and you're golden... well... that and you have to dereference your hash ref data members using the -> operator (why don't they make a key that displays '->'? I know both C and perl programmers would live the guy/gal who came out with such a keyboard...) > Thanks for any help you can give, No problem.... a distraction while working OT is a good thing... ::grin:: > -Todd -- Sean Chittenden fingerprint = 6988 8952 0030 D640 3138 C82F 0E9A DEF1 8F45 0466 There once was an old man from Esser, Who's knowledge grew lesser and lesser. It at last grew so small, He knew nothing at all, And now he's a College Professor. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tim at consultix-inc.com Sun Jan 9 02:12:26 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: parsing a config file Message-ID: <20000109001226.A11800@timji.consultix.wa.com> Majordomo didn't like "config" in this one - Tim ========================================================== | Tim Maher, Ph.D. Tel/Fax: (206) 781-UNIX | | SPUG Founder & Leader Email: spug@halcyon.com | | Seattle Perl Users Group HTTP: www.halcyon.com/spug | ========================================================== From: owner-spug-list@pm.org Date: Sat, 8 Jan 2000 14:26:05 -0500 (EST) X-Authentication-Warning: happyfunball.pm.org: mjordomo set sender to owner-spug-list@pm.org using -f To: owner-spug-list@pm.org Subject: BOUNCE spug-list@pm.org: Admin request of type /^\s*config\b/i at line 2 >From tim@consultix-inc.com Sat Jan 8 14:26:03 2000 Received: from rand.csyn.net (dsl016180.midsl.net [216.190.16.180]) by happyfunball.pm.org (8.9.3/8.9.1) with ESMTP id OAA26300 for ; Sat, 8 Jan 2000 14:26:02 -0500 (EST) Received: from localhost (sean@localhost) by rand.csyn.net (8.9.3/8.9.3) with ESMTP id LAA99115 for ; Sat, 8 Jan 2000 11:26:39 -0800 (PST) Date: Sat, 8 Jan 2000 11:26:34 -0800 (PST) From: Sean Chittenden X-Sender: sean@rand.csyn.net To: spug-list@pm.org Subject: RE: SPUG: parsing a config file In-Reply-To: <1654BC972546D31189DA00508B318AC8A57F61@charmander.wrq.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Here's a question for you: who's going to be maintaining the *config file? If it's only going to be you (or some other perl programmer), why not use Data::Dumper to save the state of the config hash and read it in when the program is started? Or, if other people are going to be maintaining this, add a layer of abstraction to the code that is evaled by the parent program. Here's some skeleton code trying to explain this if you didn't follow. # To save data: reverse whatever load process you choose # To load data: my $configs = ; # If you put evals in the $configs, the variables should # be loaded into the current name space eval $configs; if ($@) { die $@; } #### # The config file looks like a dumped perl code (this is the layer of # abstraction that I was talking about. The layer allows you to pull info # from all over the system/network). # # I'm using a file per variable just for an example. Instead of files, it # could be a regexp reading from an open file, it's up to you. I use # subroutines that use multiple regexps on the same file and IO::Socket # to load config files. # # And, incase someone asks, the last variable is returned from the block. # If I wanted to, I could use ($temp1, $temp2); as my last line and return # an array; # # Last note, I use $temp instead of $_: it increases maintainability of # code incase someone injects something before a line down the road. <:) my $config_hash = { # Get the domain domain = { open FILE, "; close ; $temp; }, admin = { open FILE, "; close ; $temp; }, [...] }; The code is pseudo code, but I think it gets the concept across. Layers and separation in a large projects are typically welcome by all those involved except for those that are going into a project ground zero and having to map out the problem. -- Sean Chittenden fingerprint = 6988 8952 0030 D640 3138 C82F 0E9A DEF1 8F45 0466 Sir, it's very possible this asteroid is not stable. -- CP30 ----- End forwarded message ----- -- *========================================================================* | Tim Maher, PhD Consultix & (206) 781-UNIX/8649 | | Pacific Software Gurus, Inc Email: tim@consultix-inc.com | | UNIX/Linux & Perl Training http://www.consultix-inc.com | | 2/22: UNIX 2/28: Perl Modules 2/29: Int. Perl 3/3: Pattern Matching | *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From sean at chittenden.org Sun Jan 9 06:28:37 2000 From: sean at chittenden.org (Sean Chittenden) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: parsing a config file In-Reply-To: <20000109001226.A11800@timji.consultix.wa.com> Message-ID: ARG!!!! #$*& (pick your four letter explicative) Majordomo!!!! Sure it's written in perl, yes I swear by it and will use it to the death (or until I write my own), and yes its a pretty slick piece of software, but couldn't the escape things that aren't sent to majordomo@mydomain.com? Ugh!!! I'm going to quote all of my words from now on. Think it'd have a problem with \Qsomething\E \Qlike\E \Qthis?\E I apologize to the list... this is the 3rd time this week on PM, 2 more times on SFPUG... had to vent... PS Thanks Tim, your list admin'ing is appreciated. ::sigh:: --Disgruntal Majorodomo lover (it's a love/hate thing) > Here's a question for you: who's going to be maintaining the > *config file? If it's only going to be you (or some other perl > programmer), why not use Data::Dumper to save the state of the config > hash and read it in when the program is started? > Or, if other people are going to be maintaining this, add a layer > of abstraction to the code that is evaled by the parent program. Here's > some skeleton code trying to explain this if you didn't follow. > > # To save data: reverse whatever load process you choose > # To load data: > my $configs = ; > > # If you put evals in the $configs, the variables should > # be loaded into the current name space > eval $configs; if ($@) { die $@; } > > > #### > # The config file looks like a dumped perl code (this is the layer of > # abstraction that I was talking about. The layer allows you to pull info > # from all over the system/network). > # > # I'm using a file per variable just for an example. Instead of files, it > # could be a regexp reading from an open file, it's up to you. I use > # subroutines that use multiple regexps on the same file and IO::Socket > # to load config files. > # > # And, incase someone asks, the last variable is returned from the block. > # If I wanted to, I could use ($temp1, $temp2); as my last line and return > # an array; > # > # Last note, I use $temp instead of $_: it increases maintainability of > # code incase someone injects something before a line down the road. <:) > my $config_hash = { > # Get the domain > domain = { open FILE, " $temp = ; > close ; $temp; }, > admin = { open FILE, " $temp = ; > close ; $temp; }, > [...] > }; > > > > The code is pseudo code, but I think it gets the concept > across. Layers and separation in a large projects are typically welcome > by all those involved except for those that are going into a project > ground zero and having to map out the problem. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From sab at rresearch.com Sun Jan 9 10:58:00 2000 From: sab at rresearch.com (Scott Blachowicz) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: parsing a config file In-Reply-To: ; from Sean Chittenden on Sun, Jan 09, 2000 at 04:28:37AM -0800 References: <20000109001226.A11800@timji.consultix.wa.com> Message-ID: <20000109085759.A18934@sabami.seaslug.org> On Sun, Jan 09, 2000 at 04:28:37AM -0800, Sean Chittenden wrote: > ARG!!!! #$*& (pick your four letter explicative) Majordomo!!!! So, what ARE the patterns that it gaks on? If they have the be anchored at the beginning of the line with a bunch of whitespace (or whatever), maybe we could come up with a way to prefix the lines that allows them through AND is still legitimate perl code. Maybe putting a semi-colon or two before the s-u-b (for example) would be enough to get it by majordomo? But tricks like that only work if we know what words are touchy for majordomo... Scott.Blachowicz@seaslug.org - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From toddw at wrq.com Sun Jan 9 13:37:46 2000 From: toddw at wrq.com (Todd Wells) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: parsing a config file Message-ID: <1654BC972546D31189DA00508B318AC8A57F68@charmander.wrq.com> The *config file is generated by other software, and it is quite possible it could be changed outside of my little perl program. -----Original Message----- From: Sean Chittenden Here's a question for you: who's going to be maintaining the *config file? If it's only going to be you (or some other perl programmer), why not use Data::Dumper to save the state of the config hash and read it in when the program is started? Or, if other people are going to be maintaining this, add a layer of abstraction to the code that is evaled by the parent program. Here's some skeleton code trying to explain this if you didn't follow. # To save data: reverse whatever load process you choose # To load data: my $configs = ; # If you put evals in the $configs, the variables should # be loaded into the current name space eval $configs; if ($@) { die $@; } #### # The config file looks like a dumped perl code (this is the layer of # abstraction that I was talking about. The layer allows you to pull info # from all over the system/network). # # I'm using a file per variable just for an example. Instead of files, it # could be a regexp reading from an open file, it's up to you. I use # subroutines that use multiple regexps on the same file and IO::Socket # to load config files. # # And, incase someone asks, the last variable is returned from the block. # If I wanted to, I could use ($temp1, $temp2); as my last line and return # an array; # # Last note, I use $temp instead of $_: it increases maintainability of # code incase someone injects something before a line down the road. <:) my $config_hash = { # Get the domain domain = { open FILE, "; close ; $temp; }, admin = { open FILE, "; close ; $temp; }, [...] }; The code is pseudo code, but I think it gets the concept across. Layers and separation in a large projects are typically welcome by all those involved except for those that are going into a project ground zero and having to map out the problem. -- Sean Chittenden fingerprint = 6988 8952 0030 D640 3138 C82F 0E9A DEF1 8F45 0466 Sir, it's very possible this asteroid is not stable. -- CP30 ----- End forwarded message ----- -- *========================================================================* | Tim Maher, PhD Consultix & (206) 781-UNIX/8649 | | Pacific Software Gurus, Inc Email: tim@consultix-inc.com | | UNIX/Linux & Perl Training http://www.consultix-inc.com | | 2/22: UNIX 2/28: Perl Modules 2/29: Int. Perl 3/3: Pattern Matching | *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From gheil at uswest.net Sun Jan 9 23:19:13 2000 From: gheil at uswest.net (greg heil) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: PERL a LLL Message-ID: <38796BD1.D0CA564E@uswest.net> PERL considered a low level language: Are VHLLs Really High-Level? http://www.oreilly.com/news/vhll_1299.html -- greg heil mailto:gheil@scn.org http://www.scn.org/tl/anvil - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tim at consultix-inc.com Mon Jan 10 16:25:25 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: PERL a LLL In-Reply-To: <38796BD1.D0CA564E@uswest.net>; from gheil@uswest.net on Sun, Jan 09, 2000 at 09:19:13PM -0800 References: <38796BD1.D0CA564E@uswest.net> Message-ID: <20000110142525.A16836@timji.consultix.wa.com> On Sun, Jan 09, 2000 at 09:19:13PM -0800, greg heil wrote: > > PERL considered a low level language: A reading of the article actually shows that the author, who sounds like a University professor familiar with lots of experimental languages, considers Perl a HLL, rather than a VHLL (very high level language). He doesn't call it a LLL at all, which if he had, would surely have raised the ire of Perl mongers everywhere. -Tim > > Are VHLLs Really High-Level? > http://www.oreilly.com/news/vhll_1299.html > > > -- > greg heil > mailto:gheil@scn.org > http://www.scn.org/tl/anvil > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe > Email to majordomo@pm.org: ACTION spug-list your_address > > -- *========================================================================* | Tim Maher, PhD Consultix & (206) 781-UNIX/8649 | | Pacific Software Gurus, Inc Email: tim@consultix-inc.com | | UNIX/Linux & Perl Training http://www.consultix-inc.com | | 2/22: UNIX 2/28: Perl Modules 2/29: Int. Perl 3/3: Pattern Matching | *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From toddw at wrq.com Mon Jan 10 20:13:56 2000 From: toddw at wrq.com (Todd Wells) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: parsing a config file Message-ID: <1654BC972546D31189DA00508B318AC8A57F7B@charmander.wrq.com> Well, this method has worked out great, but I'm having a problem as a result of this parentheses/square brackets issue. Here's the deal, if I feed this data to the routine: Domain = { servers = (beluga,toddw2,150.215.141.11); status = Enabled; }; Then I get this data structure: $config = HASH(0x2ff098) 'Domain' => HASH(0x282a0c) 'servers' => 'beluga' 'status' => 'Enabled' 'toddw2' => '150.215141.11' This becomes a problem when after winding all of this config data into nested hashes I have to unwind it back into a config file. Would it better if I turn those parens into brackets? Or do you have some other trick up your sleeve? - Todd undef $/; my $line = ; $line =~ s/=/=>/g; $line =~ s/\;/\,/g; $line =~ s/\(\)/""/g; $line .= ";"; my $Config = eval $line; -----Original Message----- From: El JoPe Magnifico [mailto:jope-spug@n2h2.com] Sent: Saturday, January 08, 2000 12:43 PM To: Andrew Sweger Cc: Todd Wells; Seattle Perl Users Group Subject: Re: SPUG: parsing a config file Not quite right, Mr. Sluggo! The trailing comma between the two closing curly brackets does no harm. Look closer below, specifically the value for $Config->{'Domain'}{'servers'} ...parentheses, rather than square brackets! Because => is syntactically the same as a comma, that empty list collapses in on itself, leaving you with three items in the list being assigned to the %{$Config->{'Domain'}} hash, efffectively making the assigment... Domain => { servers => status, Enabled => } Hence the error below. My connection keeps dogging out on me, so I'll leave it to someone else to add the line(s) to convert the parenthese to square brackets. -jp On Fri, 7 Jan 2000, Andrew Sweger wrote: > On Jan 7, 2000 @ 3:19pm, jimfl wrote: > >> $cdata = q($Config = ); >> while ($line = ) { >> $line =~ s/=/=>/g; >> $line =~ s/\;/\,/g; >> $cdata .= $line; >> } >> $cdata .= ";"; >> eval $cdata; > > Oh, that's very nice. That's a beaut. But it's slightly flawed. > > Odd number of elements in hash assignment at (eval 5) line 1, chunk > 28. > eval '$Config = > { > Domain => { > servers => (), ^^^ *** here's the problem! ** > status => Enabled, > }, > Log => { > easLogLevel => Standard, > log => On, > }, > Restart => { > Condition => 0, > Enabled => NO, > RestartTime => { > CalenderFormat => "%d/%m/%Y %I:%M %p", > FromTime => "18/07/1997 03:00 AM", > ToTime => "18/07/1997 06:00 AM", > }, > Schedule => 0, > }, > Security => { > administrator => Administrators, > domain => MINE, > manager => Users, > security => Off, > user => Users, > }, > } > ;' > ^---- here > > It's that last comma. This works... [...] > ...but I'm not sure that chopping a comma out from between two closing > braces will be enough (or it could go horribly wrong depending on what's > in the data). - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From andy at n2h2.com Mon Jan 10 20:40:45 2000 From: andy at n2h2.com (Andrew Sweger) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: parsing a config file In-Reply-To: <1654BC972546D31189DA00508B318AC8A57F7B@charmander.wrq.com> Message-ID: On Jan 10, 2000 @ 6:13pm, Todd Wells wrote: > Well, this method has worked out great, but I'm having a problem as a result > of this parentheses/square brackets issue. > > Here's the deal, if I feed this data to the routine: > Domain = { > servers = (beluga,toddw2,150.215.141.11); > status = Enabled; > }; > > This becomes a problem when after winding all of this config data into > nested hashes I have to unwind it back into a config file. > > Would it better if I turn those parens into brackets? Or do you have some > other trick up your sleeve? Use Jope's original suggestion. Turn parethesized lists into annonymous arrays (square brackets). -- Andrew Sweger | N2H2, Incorporated v=206.336.2947 f=206.336.1541 | 900 Fourth Avenue, Suite 3400 Advanced Technologies | Seattle WA 98164-1059 Development | http://www.n2h2.com/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From toddw at wrq.com Mon Jan 10 21:18:32 2000 From: toddw at wrq.com (Todd Wells) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: parsing a config file Message-ID: <1654BC972546D31189DA00508B318AC8A57F7F@charmander.wrq.com> Oh boy, will the thread ever die? Well, El Jope Magnifico has brought up an important issue I haven't dealt with and I'm hoping you SPUGgers can give me a hand once again. >> One last item: You should consider escaping special characters and >> adding surrounding quotes to your keys and values. You could get >> bitten hard if at some point one of perl's reserved words gets used >> for either. Can some experienced soul give me an easy approach to this? After I read in this data and manipulate it, it has to be written back to a file, so any quotes or special characters that actually end up in the value will need to be removed when written back to the file (if that's even an issue, which I suspect it's not). If you haven't been following the thread, here's the parsing code and some example data: while ($line = ) { $line =~ s/=/=>/g; $line =~ s#\;#\,#g; $line =~ s#\(\)#""#g; $line =~ s#\((.+)\)#\[$1\]#; $config_data .= $line; } $line .= ";"; eval $config_data; #**** data below { Domain = { servers = (beluga,toddw2,150.215.141.11); status = Enabled; }; Log = { easLogLevel = Standard; log = On; }; Model = { modelPath = "~/My/Models"; models = {CCSDemo = { name = CCSDemo; pool = 1; max = 1; }; }; }; Restart = { Condition = 1; Enabled = YES; RestartTime = { CalendarFormat = "%d/%m/%Y %I:%M %p"; FromTime = "18/07/1997 03:41 AM"; ToTime = "18/07/1997 05:16 AM"; }; Schedule = 1; }; Security = { administrator = Administrators; domain = DOMAIN; manager = Users; security = Off; user = Users; }; Session = { idleTime = 100000; inactivityTimeout = 100000; maxSessions = 200; }; SessionPool = {CCSDemo = {Entity = SignonPanel; Model = CCSDemo; ModelVars = ({}); }; }; } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From sab at rresearch.com Mon Jan 10 21:36:58 2000 From: sab at rresearch.com (Scott Blachowicz) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: parsing a config file In-Reply-To: <1654BC972546D31189DA00508B318AC8A57F7B@charmander.wrq.com>; from Todd Wells on Mon, Jan 10, 2000 at 06:13:56PM -0800 References: <1654BC972546D31189DA00508B318AC8A57F7B@charmander.wrq.com> Message-ID: <20000110193658.A72566@sabami.seaslug.org> On Mon, Jan 10, 2000 at 06:13:56PM -0800, Todd Wells wrote: > Well, this method has worked out great, but I'm having a problem as a result > of this parentheses/square brackets issue. > > Here's the deal, if I feed this data to the routine: > Domain = { > servers = (beluga,toddw2,150.215.141.11); > status = Enabled; > }; > > Then I get this data structure: > > $config = HASH(0x2ff098) > 'Domain' => HASH(0x282a0c) > 'servers' => 'beluga' > 'status' => 'Enabled' > 'toddw2' => '150.215141.11' I bet it's interpreting that 150.215.141.11 as two floating point numbers separated by a concatenation operator. > Would it better if I turn those parens into brackets? Or do you have some > other trick up your sleeve? Turning them into brackets would turn the contents into an anonymous reference to a hash (curly braces) or an array (square brackets)...and that's not what you want. Maybe a substitution to specifically turn IP addresses (or things that might look like them) into quoted strings? # Put double quotes around a sequence of 4 blocks of digits # separated from each other by dots. (followed by some optional # white space and a comma or end-of-line char). $line =~ s/(\d+\.\d+\.\d+\.\d+)(\s*[,\)\r\n])/"$1"$2/g; Or, more generally, a sequence of characters starting with an alphanumeric and ending with an alphanumeric consisting of non-whitespace, non-commas, non-paren chars? Scott.Blachowicz@seaslug.org - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From Richard.Anderson at seaslug.org Mon Jan 10 23:25:07 2000 From: Richard.Anderson at seaslug.org (Richard Anderson) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: Perl One-Liners Message-ID: <00a601bf5bf4$3dd54c80$1788ddd1@adcom133> Tom Christianson's canonical list of one-line perl programs: # run debugger "stand-alone" perl -d -e 42 # just check syntax, with warnings perl -wc my_file # useful at end of "find foo -print" perl -nle unlink # simplest one-liner program perl -e 'print "hello world!\n"' # add first and penultimate columns perl -lane 'print $F[0] + $F[-2]' # just lines 15 to 17 perl -ne 'print if 15 .. 17' *.pod # in-place edit of *.c files changing all foo to bar perl -p -i.bak -e 's/\bfoo\b/bar/g' *.c # command-line that prints the first 50 lines (cheaply) perl -pe 'exit if $. > 50' f1 f2 f3 ... # delete first 10 lines perl -i.old -ne 'print unless 1 .. 10' foo.txt # change all the isolated oldvar occurrences to newvar perl -i.old -pe 's{\boldvar\b}{newvar}g' *.[chy] # command-line that reverses the whole file by lines perl -e 'print reverse <>' file1 file2 file3 .... # find palindromes perl -lne 'print if $_ eq reverse' /usr/dict/words # command-line that reverse all the bytes in a file perl -0777e 'print scalar reverse <>' f1 f2 f3 ... # command-line that reverses the whole file by paragraphs perl -00 -e 'print reverse <>' file1 file2 file3 .... # increment all numbers found in these files perl i.tiny -pe 's/(\d+)/ 1 + $1 /ge' file1 file2 .... # command-line that shows each line with its characters backwards perl -nle 'print scalar reverse $_' file1 file2 file3 .... # delete all but lines beween START and END perl -i.old -ne 'print unless /^START$/ .. /^END$/' foo.txt # binary edit (careful!) perl -i.bak -pe 's/Mozilla/Slopoke/g' /usr/local/bin/netscape # look for dup words perl -0777 -ne 'print "$.: doubled $_\n" while /\b(\w+)\b\s+\b\1\b/gi' # command-line that prints the last 50 lines (expensively) perl -e '@lines = <>; print @lines[ $#lines .. $#lines-50' f1 f2 f3 ... Richard.Anderson@seaslug.org www.zipcon.net/~starfire/home (personal) www.raycosoft.com (corporate) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From sab at rresearch.com Mon Jan 10 23:25:52 2000 From: sab at rresearch.com (Scott Blachowicz) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: parsing a config file In-Reply-To: <20000110193658.A72566@sabami.seaslug.org>; from Scott Blachowicz on Mon, Jan 10, 2000 at 07:36:58PM -0800 References: <1654BC972546D31189DA00508B318AC8A57F7B@charmander.wrq.com> <20000110193658.A72566@sabami.seaslug.org> Message-ID: <20000110212552.A75042@sabami.seaslug.org> On Mon, Jan 10, 2000 at 07:36:58PM -0800, Scott Blachowicz wrote: > > Would it better if I turn those parens into brackets? Or do you have some > > other trick up your sleeve? > > Turning them into brackets would turn the contents into an anonymous > reference to a hash (curly braces) or an array (square brackets)...and > that's not what you want. Nevermind...I misread things... Scott - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From gheil at uswest.net Mon Jan 10 20:54:23 2000 From: gheil at uswest.net (greg heil) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: PERL a LLL References: <38796BD1.D0CA564E@uswest.net> <20000110142525.A16836@timji.consultix.wa.com> Message-ID: <387A9B5F.7E5847B2@uswest.net> Tim Maher/CONSULTIX wrote: > He doesn't call it a LLL at all, which if he had, would surely have raised the ire of Perl mongers everywhere. Well, that would be a step towards consciousness raising;) But he was right to try and shed more light than heat on the subject. 'spose we might see the authors wish list (available in languages such as "Icon, Linda, Erlang, Haskell, Eiffel, and data-parallel languages like J and Fortran-90"): "True multi-dimensional data structures Tuple spaces Type inference Lazy evaluation Programming by contract" ... sometime before PERL 9? Or maybe just throw out some of the crust? Personally i think the author was too hard on programmers. i think it really is the managers who load the govenors on bright inquisitive minds. If someone paid me, heavens i might even program in COBOL or RPG! The way to riches, surely, would be to be paid by the line and use a K to RPG sifter;-) -- greg heil mailto:gheil@scn.org http://www.scn.org/tl/anvil - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From debert at dusya.osd.com Tue Jan 11 12:55:36 2000 From: debert at dusya.osd.com (Daniel V. Ebert) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: Array comparison and "breaking" out of a foreach loop Message-ID: <200001111855.AA27236@dusya.osd.com> Does this code do what I think it does? The object of the code is to remove from @array1 those elements which are in @array2 > @targetArrray. In "real life" the lengths of @array1 and @array2 are variable, but @array1 will always be larger than @array2. If there is a more efficent way of comparing two arrays of strings I'm all ears. Thanks! #!/usr/bin/perl -w @array1 = ("a","b","c","d","e","f","g"); #create @array1 @array2 = ("a","b","e","g"); #create @array2 # Here's what I want to create: @targetArray should be ("c","d","f") OUTER: foreach $entry1 (@array1) { #cycle thru elements of @array1 $check = 0; #(re)set flag to 0 INNER: foreach $entry2 (@array2) { #cycle thru elements of @array2 if ($entry1 eq $entry2) {$check = 1; last INNER} #if condition met set flag then stop testing $entry1 } if ($check != 1) {push @targetArray, $entry1;} #add elem to new array } foreach $elem (@targetArray) {print $elem, "\n";} #print new array --- Dan Ebert Seanet Internet Services (206)343-7828 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From largest at largest.org Tue Jan 11 13:44:19 2000 From: largest at largest.org (Joel) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: Array comparison and "breaking" out of a foreach loop In-Reply-To: Message-ID: Daniel Ebert wrote: > The object of the code is to remove from @array1 those elements which > are in @array2 > @targetArrray. Hi Dan, See the Perl Cookbook, recipe 4.7 for something very similar to this: #--------------------------------------------------------------- my %seen; my @targetArray; # build lookup table @seen{@array2} = (); foreach $item ( @array1 ) { push ( @targetArray, $item ) unless exists $seen{$item}; } #--------------------------------------------------------------- Joel > In "real life" the lengths of @array1 and @array2 are variable, but @array1 > will always be larger than @array2. > > If there is a more efficent way of comparing two arrays of strings I'm all > ears. Thanks! > > #!/usr/bin/perl -w > > @array1 = ("a","b","c","d","e","f","g"); #create @array1 > @array2 = ("a","b","e","g"); #create @array2 > > # Here's what I want to create: @targetArray should be ("c","d","f") > > > OUTER: foreach $entry1 (@array1) { #cycle thru elements of @array1 > $check = 0; #(re)set flag to 0 > INNER: foreach $entry2 (@array2) { #cycle thru elements of @array2 > if ($entry1 eq $entry2) {$check = 1; last INNER} #if > condition met set flag then stop testing $entry1 > } > if ($check != 1) {push @targetArray, $entry1;} #add elem to new array > } > > foreach $elem (@targetArray) {print $elem, "\n";} #print new array > > > > --- > Dan Ebert > Seanet Internet Services > (206)343-7828 > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe > Email to majordomo@pm.org: ACTION spug-list your_address > > > > --------------------------------------------------- Procedure Computers_Move(var CPU_Turn :boolean); var a:integer; begin writeln('Computer decides to skip this round. '); CPU_Turn := False; end; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From jope-spug at n2h2.com Tue Jan 11 14:22:32 2000 From: jope-spug at n2h2.com (El JoPe Magnifico) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: parsing a config file In-Reply-To: <20000110193658.A72566@sabami.seaslug.org> Message-ID: On Mon, 10 Jan 2000, Scott Blachowicz wrote: > On Mon, Jan 10, 2000 at 06:13:56PM -0800, Todd Wells wrote: >> Well, this method has worked out great, but I'm having a problem >> as a result of this parentheses/square brackets issue. >> Here's the deal, if I feed this data to the routine: >> Domain = { >> servers = (beluga,toddw2,150.215.141.11); >> status = Enabled; >> }; >> >> Then I get this data structure: >> >> $config = HASH(0x2ff098) >> 'Domain' => HASH(0x282a0c) >> 'servers' => 'beluga' >> 'status' => 'Enabled' >> 'toddw2' => '150.215141.11' [...] >> Would it better if I turn those parens into brackets? >> Or do you have some other trick up your sleeve? > > Turning them into brackets would turn the contents into an anonymous > reference to a hash (curly braces) or an array (square brackets)... > and that's not what you want. I'm assuming this is in reference to the 'servers' field above. An anonymous array reference (a la square brackets) _is_ what you want. That's how you nest an array/list inside another data structure in perl. Apologies if I'm misunderstanding your response, Scott. -jp - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From sab at rresearch.com Tue Jan 11 15:25:26 2000 From: sab at rresearch.com (Scott Blachowicz) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: parsing a config file In-Reply-To: ; from El JoPe Magnifico on Tue, Jan 11, 2000 at 12:22:32PM -0800 References: <20000110193658.A72566@sabami.seaslug.org> Message-ID: <20000111132526.A1231@sabami.seaslug.org> On Tue, Jan 11, 2000 at 12:22:32PM -0800, El JoPe Magnifico wrote: > >> $config = HASH(0x2ff098) > >> 'Domain' => HASH(0x282a0c) > >> 'servers' => 'beluga' > >> 'status' => 'Enabled' > >> 'toddw2' => '150.215141.11' > [...] > >> Would it better if I turn those parens into brackets? > >> Or do you have some other trick up your sleeve? > > > > Turning them into brackets would turn the contents into an anonymous > > reference to a hash (curly braces) or an array (square brackets)... > > and that's not what you want. > > I'm assuming this is in reference to the 'servers' field above. > An anonymous array reference (a la square brackets) _is_ what you want. > That's how you nest an array/list inside another data structure in perl. > Apologies if I'm misunderstanding your response, Scott. No...you're right...I was just fixating on that "150.215141.11" number and how that happened without noticing the general data structure problem...so I misspoke...sorry for the confusion. Scott.Blachowicz@seaslug.org - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From rcroot at atl.com Tue Jan 11 16:46:01 2000 From: rcroot at atl.com (Rick Croote) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: Array comparison and "breaking" out of a foreach loop References: <200001111855.AA27236@dusya.osd.com> Message-ID: <003301bf5c85$a2b65f90$27fa3b95@atl.com> (BTW, sorry if you get this twice, I suffered through a crash and cannot find any evidence that the first instance was actually sent.) Assuming that there are no duplicates in any given array, as your example eludes to, then I would use the hash array to count the occurances, and then look for those that only occured once. # # Count all occurances, incrementing by one for each # one found. # my %found; foreach (@array1, @array2) { $found{$_}++; } # # Now retrieve those elements in array1 that did not # exist in array2. # my @targetArray = grep $found{$_} == 1, @array1; --- Rick Croote ATL Ultrasound ----- Original Message ----- From: Daniel V. Ebert To: Sent: Tuesday, January 11, 2000 10:55 AM Subject: SPUG: Array comparison and "breaking" out of a foreach loop > > Does this code do what I think it does? > > The object of the code is to remove from @array1 those elements which are in > @array2 > @targetArrray. > > In "real life" the lengths of @array1 and @array2 are variable, but @array1 > will always be larger than @array2. > > If there is a more efficent way of comparing two arrays of strings I'm all > ears. Thanks! > > #!/usr/bin/perl -w > > @array1 = ("a","b","c","d","e","f","g"); #create @array1 > @array2 = ("a","b","e","g"); #create @array2 > > # Here's what I want to create: @targetArray should be ("c","d","f") > > > OUTER: foreach $entry1 (@array1) { #cycle thru elements of @array1 > $check = 0; #(re)set flag to 0 > INNER: foreach $entry2 (@array2) { #cycle thru elements of @array2 > if ($entry1 eq $entry2) {$check = 1; last INNER} #if > condition met set flag then stop testing $entry1 > } > if ($check != 1) {push @targetArray, $entry1;} #add elem to new array > } > > foreach $elem (@targetArray) {print $elem, "\n";} #print new array > > > > --- > Dan Ebert > Seanet Internet Services > (206)343-7828 > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe > Email to majordomo@pm.org: ACTION spug-list your_address > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From sab at rresearch.com Tue Jan 11 17:17:06 2000 From: sab at rresearch.com (Scott Blachowicz) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: Array comparison and "breaking" out of a foreach loop In-Reply-To: ; from Joel on Tue, Jan 11, 2000 at 02:44:19PM -0500 References: Message-ID: <20000111151706.A4292@sabami.seaslug.org> On Tue, Jan 11, 2000 at 02:44:19PM -0500, Joel wrote: > my %seen; > my @targetArray; > > # build lookup table > @seen{@array2} = (); > > foreach $item ( @array1 ) { > push ( @targetArray, $item ) unless exists $seen{$item}; > } I wonder if replacing that explicit loop with something like this: @targetArray = grep {! exists $seen{$_}} @array1; would be any faster? I don't have the time to play with Benchmark.pm at the moment... Scott.Blachowicz@seaslug.org - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tim at consultix-inc.com Wed Jan 12 01:56:43 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: Data Conversion Projects Message-ID: <20000111235643.B1193@timji.consultix.wa.com> SPUGers, I have a 2 programming projects that should be easily handled with Perl. One is very small and another is fairly large and continuous. The first involves converting medical records with clearly delimited data fields into a different format. I have the specs and it shouldn't be that big of a job for an experienced programmer. The second project is more complicated. It involves reading "pages" of printed data from a file (that would normally be printed on a form) and "scraping" the data off and putting it into a specified format to be transmitted to another system for processing. The specs on the format consist of a book of several hundred pages and nobody seems to have this in electronic format. In other words I can't email it to anyone to check out. I would however like to meet with someone and give them the run down on the whole project. After some initial face-to-face meetings, in North Seattle, most of the programming work could be done remotely. The first project might only take a day or two, but the second might require more than a week of initial effort, and then some ongoing maintenance for many months after that. Applicants must know the data-conversion aspects of Perl, including beginning to intermediate pattern matching techniques, and for the second project applicants will also need to be good at deciphering lengthy format-specification manuals. The programmer will be paid on a 1099 basis, at a competitive rate. Thanks Shawn Clark Reliant Business Services shawn@rbs.net - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tim at consultix-inc.com Wed Jan 12 16:34:56 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: Jobs with Cobalt Group Message-ID: <20000112143456.A3770@timji.consultix.wa.com> Perl Programmers, The Cobalt Group, Inc is the largest provider of Internet marketing systems for car dealers. Our positions involve scripting and systems programming for our Web sites and online Unix databases. PERL or C programming experience and familiarity with the Web, HTML, UNIX, CGI scripting required. Familiarity with Java programming for Web applications, Linux and Apache a plus. Experience with Unix databases such as Oracle, a plus. Backgrounds in Object Oriented programming & User Interface design are big pluses. These are permanent positions located in downtown Seattle. Telecommuting is not an option. All positions include the following comprehensive benefits: Stock Options, Employee Stock Purchase Plan (15% discount), Medical, Dental, Vision, 401(k), LTD, Vacation, Sick, Holidays, Transportation/Parking Subsidy, Sports Court/Exercise Room including basketball, stairmasters, weights. Position #1: Team Lead Our Team Lead position will lead and participate on a team of programmers. Requires a degree(CS pref), extensive Web, Unix & PERL experience & 2 yrs experience in project management. At least 1 year experience leading a team of developers. Salary: Competitive, DOE Send resume to: nnelson@cobaltgroup.com. Position #2: Webmaster/Programmer Required skills include: proven portal management (prior webmaster experience for major portal site), strong programming skills (UNIX, Perl or C), project management skills and strong interdepartmental skills. Salary: Competitive, DOE Send resume to: nnelson@cobaltgroup.com. Nicole R. Nelson Technical Recruiter The Cobalt Group nnelson@cobaltgroup.com http://www.cobaltgroup.com http://www.dealernet.com http://www.yachtworld.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tim at consultix-inc.com Thu Jan 13 13:18:37 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: Testing SPUG Service - Ignore! Message-ID: <20000113111837.A6383@timji.consultix.wa.com> This is a test, no I'm sayin? *========================================================================* | Tim Maher, PhD Consultix & (206) 781-UNIX/8649 | | Pacific Software Gurus, Inc Email: tim@consultix-inc.com | | UNIX/Linux & Perl Training http://www.consultix-inc.com | | 2/22: UNIX 2/28: Perl Modules 2/29: Int. Perl 3/3: Pattern Matching | *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tim at consultix-inc.com Thu Jan 13 17:11:42 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: Web Jobs at US West Message-ID: <20000113151142.A7061@timji.consultix.wa.com> Perl/CGI Programmer Position ---------------------------- Job Description: Web/CGI/Perl software developer needed for developing Web database applications. Candidates should have experience with the full project development life cycle including: scoping out a project, developing estimates, developing application requirements, design, development and deployment. Other important candidate criteria are: the ability to work independently as well as part of a development team, resourcefulness, good client and communication skills and an excellent sense of humor. Job Skill Requirements: - 2+ years of Perl/CGI development experience - 2+ years of Web development experience - 1+ years of SQL database development experience, Oracle preferred Desired Skills: - Experience with Apache Web server and mod_perl - Experience with Linux and UNIX (SGI/IRIX and Sun/Solaris) - Object Oriented design/programming experience Pay: $62,000 - $79,000 annual salary depending on experience, plus time and a half for overtime. Benefits and 401k included. Start: immediate Type: full-time Length: permanent If you are interested in working with a young, fun group of Web developers, please send your resume with contact information to: Brian Vallene U S WEST Creative Services New Media Group phone: 206.345.2065 fax: 206.346.9007 email: bvallen@uswest.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From andy at n2h2.com Fri Jan 14 15:09:20 2000 From: andy at n2h2.com (Andrew Sweger) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: Re: Local watering holes Message-ID: Here is some information on the local watering holes near N2H2 from our local expert. -- Andrew Sweger | N2H2, Incorporated v=206.336.2947 f=206.336.1541 | 900 Fourth Avenue, Suite 3400 Advanced Technologies | Seattle WA 98164-1059 Development | http://www.n2h2.com/ ---------- Forwarded message ---------- Date: Fri, 14 Jan 2000 13:04:55 -0800 (PST) From: Name removed to protect the guilty... To: Andrew Sweger Subject: Re: Local watering holes Well, you've come to the right person (you already knew that though) :) My choices (in order): 1. Vito's is close - 9th & Madison. It's GREAT for after-work beer/cocktails! Dark, swank, but you can wear whatever you want. I like going there on a Friday nite. Lotsa red interior! Head up the hill, East on Madison and it's on the corner of 9th. Excellent martini place. 2. There's also the Elephant and Castle. Just head North on 5th and it's about 4 blocks up. That's nice for a large number of people (so is Vito's though). Great for corporate and geeks alike. They are nice to everyone there, and they know that geeky lookin' dudes probably have some cash to throw down on good food and beer, so they'll hook ya up. :) They have a pool table area too. It can be reserved for large groups. 3. Rock Bottom is good if you want to go "standard corporate", but not that creative of a choice. My favorite part- They have a lot of cute, "perky" waitresses to objectify. hee hee. 4. Skuz-Mexican is just across the way at Mexico Lindo. I think you've seen that place. Not sure who you want to impress, but that's probably not the place to do it. I like it because it's very non-intrusive (almost to the point of bad service). Bring the Spanish dictionary. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From jay at Scherrer.com Sat Jan 15 11:20:27 2000 From: jay at Scherrer.com (Jay Scherrer) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: PDF to HTML? Message-ID: <3880AC5A.95E45B91@scherrer.com> Hello fellow SPUGER'S, I have a new project that I will be starting and I was wondering if someone could point me in the right direction? I would like to convert several PDF docs into html with perl. Is this possible? I figured I will need to start with pdftotext and then use text2html.pm. But as I have a 100+ documents there must be a way of templating the process. Any suggestions? Jay - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From taliesin at speakeasy.org Sat Jan 15 12:22:25 2000 From: taliesin at speakeasy.org (taliesin@speakeasy.org) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: PDF to HTML? In-Reply-To: <3880AC5A.95E45B91@scherrer.com> Message-ID: On Sat, 15 Jan 2000, Jay Scherrer wrote: >I have a new project that I will be starting and I was wondering if >someone could point me in the right direction? I would like to convert >several PDF docs into html with perl. Is this possible? >I figured I will need to start with pdftotext and then use >text2html.pm. But as I have a 100+ documents there must be a way of >templating the process. Any reason this has to be done in Perl? Adobe already has tools to convert PDF to HTML, and they appear to be freebies... now, they all run on Winders, but if that's not an issue, I think you're set. No reason to re-invent the wheel.... Check out http://access.adobe.com for details... -- Glenn - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From kmeyer at aa.net Sat Jan 15 14:29:10 2000 From: kmeyer at aa.net (Kenneth W. Meyer) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: PDF to HTML? Message-ID: <01BF5F54.20876920@host211.207-55-127.aadsl.com> I don't understand why one would want to convert the usually excellent PDF renderings to poor approximations in HTML, when downloading and installing the Acrobat Viewer is free and takes 5 - 10 minutes (ex download time) and requires zip computer expertise. Moreover, it seems likely to me that a significant amount or reformatting of the conversions will be necessary, and with 100 docs to convert, that could be a real chore, unless the documents are very regular in their layout. However....... I will assume that Jay has a directive from management -- oh, well. To determine the best approach, it seems necessary to first understand the degree of fidelity expected. Is it just extracting text, or is the formatting complex? How big are the files? Are there graphics involved that must be preserved? How much manual re-formatting is anticipated.? What is the budget (seems to me that any reasonable tool cost will leverage labor costs extremely, unless maximizing contract billable hours is an objective). Etc. etc. I followed the great link to Adobe provided by Glenn. At that site, there is a plug-in for Acrobat 4.0.5 that apparently creates plain text from PDF's; i.e. it appears that all formatting and graphics are trashed. Also, there are free on-line services available to do the conversion, but they are targeted to vision-impaired persons, so loading them with 100 documents for commercial ends might be a bit much. Acrobat 4.0 goes for about $250 at list (the .0.5 upgrade is free), I believe, but the academic price is $100 at the UW Bookstore Computer Annex (could Tim's courses qualify you?). Finally, if one really surfs the Adobe site, the web leads one to the ubiquitous Third-party Tool sites, and here is an outfit that appears to specialize in products for converting PDF's to other formats. They have a product called Magellan ($200 and multiple product promotion potential) that does the job with graphics et al preserved, it says there. Also, there appears to be a free mail-in conversion service available from this site -- good for a check-out anyway: http://www.bcl-computers.com/ I would be interested in any feedback on what you find out and decide to do, Jay. Ken Meyer kmeyer@aa.net ---------- From: taliesin@speakeasy.org[SMTP:taliesin@speakeasy.org] Sent: Saturday, January 15, 2000 2:22 AM To: Jay Scherrer Cc: Tim Maher Subject: Re: SPUG: PDF to HTML? On Sat, 15 Jan 2000, Jay Scherrer wrote: >I have a new project that I will be starting and I was wondering if >someone could point me in the right direction? I would like to convert >several PDF docs into html with perl. Is this possible? >I figured I will need to start with pdftotext and then use >text2html.pm. But as I have a 100+ documents there must be a way of >templating the process. Any reason this has to be done in Perl? Adobe already has tools to convert PDF to HTML, and they appear to be freebies... now, they all run on Winders, but if that's not an issue, I think you're set. No reason to re-invent the wheel.... Check out http://access.adobe.com for details... -- Glenn - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From jdevlin at stadiumdistrict.com Mon Jan 17 23:38:33 2000 From: jdevlin at stadiumdistrict.com (Joe Devlin) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: SSI exec command in HTML w/arguments Message-ID: <01BF6133.3623B780@tac-lx100-ip32.nwnexus.net> Where do I look to find the syntax for the HTML that is accepted by my server. The server will not always be the same depending on who I am writing code for. I especially want to be able to pass arguments to my CGI script. Joe - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tim at consultix-inc.com Tue Jan 18 00:23:22 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: Jan Meeting: Adv. Pattern Matching Message-ID: <20000117222322.A12840@timji.consultix.wa.com> JANUARY SPUG MEETING Sure to be the best of the millennium (so far)! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * SPUG, the Seattle Perl Users Group, will meet on January 18th (3rd Tuesday) from 7-9pm, in the 5th floor meeting room of the Union Bank of California Bldg. in downtown Seattle. Tim Maher of Consultix will present excerpts from a one-day training course entitled "Advanced Pattern Matching with Perl." Topics for discussion will include Lookahead Regular Expressions, extracting delimited text (HTML tags, etc.), and the optimization of pattern matching. Admission is free and open to the general public. Attendees are encouraged to arrive at the building's 5th & Madison door by 6:45pm, to meet their escorts. Parking Parking is available in an underground garage beneath the building, at the price of $4 for the entire 4pm - 11pm period. Additional parking is available at other ground-level lots and on the street. Pre-Meeting Gathering Place For the First Quarter of the Millennium, we will be auditioning the Rock Bottom brewpub, at 1333 5th Ave., (206) 623-3070. To locate the other SPUGsters whiling away the time until the meeting commences, you could try looking for the SPUG leader (expected to arrive around 5:45), who currently looks more like this cartoon Perl Instructor http://www.consultix-inc.com/contact.html than this actual photo of himself: http://www.consultix-inc.com/tim_pro.html For more information, including driving directions and street addresses, see http://www.halcyon.com/spug/. Let's get the SPUG-ing millennium off to a good start with a great meeting! ========================================================== | Tim Maher, Ph.D. Tel/Fax: (206) 781-UNIX | | SPUG Founder & Leader Email: spug@halcyon.com | | Seattle Perl Users Group HTTP: www.halcyon.com/spug | ========================================================== - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From andy at n2h2.com Tue Jan 18 00:23:15 2000 From: andy at n2h2.com (Andrew Sweger) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: SSI exec command in HTML w/arguments In-Reply-To: <01BF6133.3623B780@tac-lx100-ip32.nwnexus.net> Message-ID: On Jan 17, 2000 @ 9:38pm, Joe Devlin wrote: > Where do I look to find the syntax for the HTML > > that is accepted by my server. The server will not > always be the same depending on who I am > writing code for. Well, that would depend a lot on the specific server and its particular SSI module. The HTML is actually an HTML comment that has special meaning to the server or server module responsible for the SSI feature. If you were using Apache and its SSI (mod_include), I'd suggest starting with the module documentation at apache.org: http://apache.org/docs/mod/mod_include.html Otherwise, consult the documentation for the server in question. > I especially want to be able to pass arguments > to my CGI script. CGI scripts usually do not take arguments in the traditional sense of command line arguments (right?). CGI's take input from the CGI interface (an URL query or POST method input, i.e. stdin). Also, a mod_include (SSI) #exec method can be used to run any arbitrary executable on the server host (e.g., /bin/date). It's not meant to set up the CGI environment expected by a CGI script (a la CGI.pm or whathaveyou). RTFM for specifics. Don't mix application logic and presentation. You'll just get into a world of hurt. Yeah, sure. Sometimes you're forced to by powers beyond your control, but it really isn't worth mixing them. Code inside HTML or HTML inside code: they both suck except for the most simple applications (and what application doesn't become more complicated with time). -- Andrew Sweger | N2H2, Incorporated v=206.336.2947 f=206.336.1541 | 900 Fourth Avenue, Suite 3400 Advanced Technologies | Seattle WA 98164-1059 Development | http://www.n2h2.com/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From ryan at erwin.org Tue Jan 18 14:55:11 2000 From: ryan at erwin.org (Ryan Erwin) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: Change perl's libpth on the fly? Message-ID: My OpenBSD distro came with perl's libpth set to '/usr/lib' instead of '/usr/lib /usr/local/lib' or something else that would be useful ;) How can I change perl's libpth *without* rebuilding perl? Is there some variable that I can set that will take care of this? Maybe some cool switch that I haven't seen. You can check the lib path on your system with 'perl -V' I can't run GD or and of those cool Term:: modules until I get this libpth fixed so if anyone knows, please tell. Thanks- Ryan Erwin [ryan@erwin.org] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From asherr at cs.unm.edu Tue Jan 18 16:07:25 2000 From: asherr at cs.unm.edu (Aryeh "Cody" Sherr) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: Change perl's libpth on the fly? In-Reply-To: Message-ID: Well, I think you need to rebuild perl, but a workaround is the 'use lib' pragma: use lib '/usr/lib/perl5/site_perl'; This also works for any situation that you want to use modules in nonstandard places. It's still probably better to keep your libs in someplace consolidated, or at least planned. hope this helps. A. "Cody" Sherr - asherr@cs.unm.edu http://www.cs.unm.edu/~asherr ---------- WARNING! THIS EMAIL IS A MUNITION ------------ #!/bin/perl -sp0777iMy OpenBSD distro came with perl's libpth set to '/usr/lib' >instead of '/usr/lib /usr/local/lib' or something else that >would be useful ;) > >How can I change perl's libpth *without* rebuilding perl? >Is there some variable that I can set that will take care of >this? Maybe some cool switch that I haven't seen. > >You can check the lib path on your system with 'perl -V' > >I can't run GD or and of those cool Term:: modules until >I get this libpth fixed so if anyone knows, please tell. > >Thanks- > >Ryan Erwin [ryan@erwin.org] > > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe > Email to majordomo@pm.org: ACTION spug-list your_address > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From otter101 at hotmail.com Tue Jan 18 16:13:21 2000 From: otter101 at hotmail.com (Steve Laybourn) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: Change perl's libpth on the fly? Message-ID: <20000118221322.99925.qmail@hotmail.com> G'day! I had a problem like this once when I installed ActiveState on my machine. Seems you can do something like: push(@INC,"/usr/bin/perl/wossname"); at the beginning of the script to add paths to @INC, which has all the Perl subdirectory markers for scripts to be evaluated by do, use, or require constructs. Hopefully this will solve your problem, or I anticipate there will be a tar machine and several dozen goose-down pillows waiting for me at the meeting tonight. Be seeing you... Steve Laybourn Camel Herdsman, imandi.com >From: Ryan Erwin >To: spug-list@pm.org >Subject: SPUG: Change perl's libpth on the fly? >Date: Tue, 18 Jan 2000 12:55:11 -0800 (PST) > >My OpenBSD distro came with perl's libpth set to '/usr/lib' >instead of '/usr/lib /usr/local/lib' or something else that >would be useful ;) > >How can I change perl's libpth *without* rebuilding perl? >Is there some variable that I can set that will take care of >this? Maybe some cool switch that I haven't seen. > >You can check the lib path on your system with 'perl -V' > >I can't run GD or and of those cool Term:: modules until >I get this libpth fixed so if anyone knows, please tell. > >Thanks- > >Ryan Erwin [ryan@erwin.org] > > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe > Email to majordomo@pm.org: ACTION spug-list your_address > > ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From jimfl at colltech.com Tue Jan 18 16:53:52 2000 From: jimfl at colltech.com (jimfl) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: Change perl's libpth on the fly? In-Reply-To: Message-ID: <1039672.3157196032@erdos.nwest.attws.com> --On Tuesday, January 18, 2000 12:55 PM -0800 Ryan Erwin wrote: > My OpenBSD distro came with perl's libpth set to '/usr/lib' > instead of '/usr/lib /usr/local/lib' or something else that > would be useful ;) > > How can I change perl's libpth *without* rebuilding perl? > Is there some variable that I can set that will take care of > this? Maybe some cool switch that I haven't seen. > > You can check the lib path on your system with 'perl -V' > > I can't run GD or and of those cool Term:: modules until > I get this libpth fixed so if anyone knows, please tell. Permanently and inviariantly, no. Within a script, you can say use lib "/usr/local/lib"; And perl pays attention to the environment variable PERL5LIB, which you can set for all users in /etc/profile or the apropriate file for the shell(s) in use on your system. Set it to a colon-separated list of places to look in before looking at the compiled-in path. -- Jim Flanagan Collective Technologies jimfl@colltech.com http://www.colltech.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From jshaffer at chronology.com Tue Jan 18 17:22:21 2000 From: jshaffer at chronology.com (Jamie Shaffer) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: Change perl's libpth on the fly? References: Message-ID: <3884F5AD.E35BCC20@chronology.com> Does setting the environment variable PERL5LIB get the results you want? PERL5LIB, PERL5OPT and possibly a few other environment variables are available to you to tweak such things. Ryan Erwin wrote: > My OpenBSD distro came with perl's libpth set to '/usr/lib' > instead of '/usr/lib /usr/local/lib' or something else that > would be useful ;) > > How can I change perl's libpth *without* rebuilding perl? > Is there some variable that I can set that will take care of > this? Maybe some cool switch that I haven't seen. > > You can check the lib path on your system with 'perl -V' > > I can't run GD or and of those cool Term:: modules until > I get this libpth fixed so if anyone knows, please tell. > > Thanks- > > Ryan Erwin [ryan@erwin.org] > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe > Email to majordomo@pm.org: ACTION spug-list your_address - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From jshaffer at chronology.com Tue Jan 18 17:59:40 2000 From: jshaffer at chronology.com (Jamie Shaffer) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: Change perl's libpth on the fly? References: <1039672.3157196032@erdos.nwest.attws.com> Message-ID: <3884FE6C.6D114660@chronology.com> jimfl wrote: > > How can I change perl's libpth *without* rebuilding perl? > > Is there some variable that I can set that will take care of > > this? Maybe some cool switch that I haven't seen. > > > > You can check the lib path on your system with 'perl -V' > > > > I can't run GD or and of those cool Term:: modules until > > I get this libpth fixed so if anyone knows, please tell. > > Permanently and inviariantly, no. Then again, maybe you can. You can tweak some of the variables in the ASCII files Config.pm and config.h after Perl has been compiled. We change the variables archlibexp, installarchlib, installprivlib, prefix, and privlibexp when we provide Perl for customers to install on their own systems. (An installation script fills these in based on where the customer decided to put the Perl directory.) The variable "libpth" is also in this file; we don't change it but you may find that you can make use of it. You will find these files in your Perl installation under lib...in ours it is in perl/lib/5.00503/ (your path may be different). > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe > Email to majordomo@pm.org: ACTION spug-list your_address - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From sab at rresearch.com Tue Jan 18 18:12:00 2000 From: sab at rresearch.com (Scott Blachowicz) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: Change perl's libpth on the fly? In-Reply-To: ; from Ryan Erwin on Tue, Jan 18, 2000 at 12:55:11PM -0800 References: Message-ID: <20000118161159.A61285@sabami.seaslug.org> On Tue, Jan 18, 2000 at 12:55:11PM -0800, Ryan Erwin wrote: > How can I change perl's libpth *without* rebuilding perl? > Is there some variable that I can set that will take care of > this? Maybe some cool switch that I haven't seen. There's a PERL5INC envar you can set: % PERL5LIB=.:/usr/lib perl -V ...etc... Characteristics of this binary (from libperl): Built under freebsd Compiled at May 18 1999 02:56:17 %ENV: PERL5LIB=".:/usr/lib" @INC: . /usr/lib /usr/libdata/perl/5.00503/mach /usr/libdata/perl/5.00503 /usr/local/lib/perl5/site_perl/5.005/i386-freebsd /usr/local/lib/perl5/site_perl/5.005 . Or if you want to things dynamically in your scripts, you can do things like this: use lib ($0 =~ m,(.*)/[^/]+,); to (for instance) add the directory containing your script to the lib path. Or, in other words, look into using the 'use lib' statement in your script. -- Scott.Blachowicz@seaslug.org - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From ryan at erwin.org Wed Jan 19 01:21:42 2000 From: ryan at erwin.org (Ryan Erwin) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: -E guest speaker? Message-ID: Greetings from your friendly, neighborhood E-SPUG emperor- We are in the home stretch before our very first E-SPUG meeting now. The only thing left is to decide on our meeting topic. The first half of the meeting will be spent covering new business such as who will bring the meeting snacks ;) So who wants to step forward and educate your fellow Perl Coders on some thing that is perl? Please reply directly to me [ryan@erwin.org] to discuss a possible meeting topic. The topic should be something that is relatively brief since we will most likely spend 40-min to 1 hr. on this topic after we finish meeting business. Also note that the first ever SPUG speaker was Larry himself. Now, over on the Eastside, we don't have to start at the top and work our way down! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tim at consultix-inc.com Wed Jan 19 21:59:21 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: Perl Banned -- Too Good! Message-ID: <20000119195921.A22110@timji.consultix.wa.com> An old article from www.perl.org, recently recycled on the perl-trainers@pm.org mailing list - Enjoy! -Tim Perl "Too Good" This is a true story. Names have not been changed. UCLA's Computer Science Undergraduate Association regularly hosts its programming competition. Contestants are given six complex problems and have three hours to write programs to solve as many of the problems as possible. In 1997, the rules stated that any programming language could be used so long as you solved the problem, so then-undergraduate Keith Chiem entered and used Perl. Keith did not merely win, he conquered. He solved five of the six problems in the three hours allotted. The second-place two-person team solved only three problems. They, needless to say, were not using Perl. But if you're a UCLA undergraduate contemplating entering the contest and using Perl, don't bother. After Keith's conquest, Perl was banned from the contest. You've got to admire a language that is banned because it makes problems too easy to solve. These days, Keith is reportedly a sysadmin at Yahoo! Inc., and is wondering what to do with the copy of Visual C++ that was his prize. -- Peter Scott Pacific Systems Design Technologies - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From toddw at wrq.com Thu Jan 20 13:53:39 2000 From: toddw at wrq.com (Todd Wells) Date: Wed Aug 4 00:07:03 2004 Subject: SPUG: getting a list of directories Message-ID: <1654BC972546D31189DA00508B318AC8A5801F@charmander.wrq.com> I'd like to get a list of directory names (and only directory names) in /usr/myapp. What's the best way to go about this? I wish the cookbook had a recipe for this. I see that readdir specifically excludes directory names. -Todd - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From mmertel at ix.netcom.com Thu Jan 20 14:32:19 2000 From: mmertel at ix.netcom.com (Mark Mertel) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: getting a list of directories References: <1654BC972546D31189DA00508B318AC8A5801F@charmander.wrq.com> Message-ID: <00012012332201.01130@mmertel3> On Thu, 20 Jan 2000, Todd Wells wrote: > I'd like to get a list of directory names (and only directory names) in > /usr/myapp. What's the best way to go about this? I wish the cookbook had > a recipe for this. I see that readdir specifically excludes directory > names. > > -Todd @files=<*>; for $file (@files) { print $file."\n" if -d $file; } mmertel@ix.netcom.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From sab at rresearch.com Thu Jan 20 14:24:24 2000 From: sab at rresearch.com (Scott Blachowicz) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: getting a list of directories In-Reply-To: <1654BC972546D31189DA00508B318AC8A5801F@charmander.wrq.com>; from Todd Wells on Thu, Jan 20, 2000 at 11:53:39AM -0800 References: <1654BC972546D31189DA00508B318AC8A5801F@charmander.wrq.com> Message-ID: <20000120122424.A26024@sabami.seaslug.org> On Thu, Jan 20, 2000 at 11:53:39AM -0800, Todd Wells wrote: > I'd like to get a list of directory names (and only directory names) in > /usr/myapp. What's the best way to go about this? I wish the cookbook had > a recipe for this. I see that readdir specifically excludes directory > names. How about something like this [untested] bit o code: use File::Find; my @dirs; find(\&wanted, '/usr/myapp'); sub wanted { -d && push (@dirs, $File::Find::name); } Scott.Blachowicz@seaslug.org - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From Keith.Litwin at pss.boeing.com Thu Jan 20 15:06:36 2000 From: Keith.Litwin at pss.boeing.com (EXT-Litwin, Keith) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: getting a list of directories Message-ID: <350B10493F95D21199270008C7A4075402711388@xch-rtn-01.ca.boeing.com> How about the sloppy unix way @dirs=`file *|grep directory|cut -d":" -f1`; Not sure if this is portable across unicies and it will give you all directories from your current downward. Keith. > ---------- > From: Todd Wells[SMTP:toddw@wrq.com] > Sent: Thursday, January 20, 2000 11:53 > To: 'spug-list@pm.org' > Subject: SPUG: getting a list of directories > > I'd like to get a list of directory names (and only directory names) in > /usr/myapp. What's the best way to go about this? I wish the cookbook had > a recipe for this. I see that readdir specifically excludes directory > names. > > -Todd > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe > Email to majordomo@pm.org: ACTION spug-list your_address > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From ryannn at u.washington.edu Thu Jan 20 15:11:27 2000 From: ryannn at u.washington.edu (Ryan Christianson) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: getting a list of directories References: <1654BC972546D31189DA00508B318AC8A5801F@charmander.wrq.com> Message-ID: <002c01bf638a$ea7d2550$0601a8c0@echospace.com> How about this: my @dir; map { push @dir,$_ if -d "/usr/myapp/" . $_ } split /\n/, `ls /usr/myapp`; ----- Original Message ----- From: Todd Wells To: Sent: Thursday, January 20, 2000 11:53 AM Subject: SPUG: getting a list of directories > I'd like to get a list of directory names (and only directory names) in > /usr/myapp. What's the best way to go about this? I wish the cookbook had > a recipe for this. I see that readdir specifically excludes directory > names. > > -Todd > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe > Email to majordomo@pm.org: ACTION spug-list your_address > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From Keith.Litwin at pss.boeing.com Thu Jan 20 15:12:39 2000 From: Keith.Litwin at pss.boeing.com (EXT-Litwin, Keith) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: getting a list of directories Message-ID: <350B10493F95D21199270008C7A4075402711389@xch-rtn-01.ca.boeing.com> Whoops wrong. It will only give you directories in your current directory. > ---------- > From: EXT-Litwin, Keith > Sent: Thursday, January 20, 2000 13:06 > To: 'spug-list@pm.org'; 'Todd Wells' > Subject: RE: SPUG: getting a list of directories > > How about the sloppy unix way > > @dirs=`file *|grep directory|cut -d":" -f1`; > > Not sure if this is portable across unicies and it will give you all directories from your current downward. > > Keith. > > ---------- > From: Todd Wells[SMTP:toddw@wrq.com] > Sent: Thursday, January 20, 2000 11:53 > To: 'spug-list@pm.org' > Subject: SPUG: getting a list of directories > > I'd like to get a list of directory names (and only directory names) in > /usr/myapp. What's the best way to go about this? I wish the cookbook had > a recipe for this. I see that readdir specifically excludes directory > names. > > -Todd > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe > Email to majordomo@pm.org: ACTION spug-list your_address > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From byoung at speakeasy.org Thu Jan 20 15:18:50 2000 From: byoung at speakeasy.org (Bradley E. Young) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: getting a list of directories In-Reply-To: <1654BC972546D31189DA00508B318AC8A5801F@charmander.wrq.com> Message-ID: <000a01bf638b$f26d3330$9a26e7d8@byoung.fiven.com> opendir(DIR, "/usr/myapp"); @dirs = grep { -d "/usr/myapp/$_" } readdir(DIR); readdir() does not exclude directories. Brad > -----Original Message----- > From: owner-spug-list@pm.org [mailto:owner-spug-list@pm.org]On Behalf Of > Todd Wells > Sent: Thursday, January 20, 2000 11:54 AM > To: 'spug-list@pm.org' > Subject: SPUG: getting a list of directories > > > I'd like to get a list of directory names (and only directory names) in > /usr/myapp. What's the best way to go about this? I wish the > cookbook had > a recipe for this. I see that readdir specifically excludes directory > names. > > -Todd > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe > Email to majordomo@pm.org: ACTION spug-list your_address > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tim at consultix-inc.com Thu Jan 20 15:31:15 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: getting a list of directories In-Reply-To: <1654BC972546D31189DA00508B318AC8A5801F@charmander.wrq.com>; from toddw@wrq.com on Thu, Jan 20, 2000 at 11:53:39AM -0800 References: <1654BC972546D31189DA00508B318AC8A5801F@charmander.wrq.com> Message-ID: <20000120133115.B26487@timji.consultix.wa.com> On Thu, Jan 20, 2000 at 11:53:39AM -0800, Todd Wells wrote: > I'd like to get a list of directory names (and only directory names) in > /usr/myapp. What's the best way to go about this? I wish the cookbook had > a recipe for this. I see that readdir specifically excludes directory > names. Sheesh! Such complicated solutions in previous replies! If you don't need to descend into subdirectories, all you need is this: @dirs=grep { -d } <*> ; # filter list, passing only directories If you want hidden directories too, excluding . and .., @dirs=grep { -d } <*>, <.[^.]>, <.[^.]?*> ; You can then print them, if that's the ultimate goal, with print "@dirs\n"; > > -Todd > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe > Email to majordomo@pm.org: ACTION spug-list your_address > > -- *========================================================================* | Tim Maher, PhD Consultix & (206) 781-UNIX/8649 | | Pacific Software Gurus, Inc Email: tim@consultix-inc.com | | UNIX/Linux & Perl Training http://www.consultix-inc.com | | 2/22: UNIX 2/28: Perl Modules 2/29: Int. Perl 3/3: Pattern Matching | *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From mcglk at serv.net Thu Jan 20 15:36:03 2000 From: mcglk at serv.net (Ken McGlothlen) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: getting a list of directories In-Reply-To: Mark Mertel's message of "Thu, 20 Jan 2000 12:32:19 -0800" References: <1654BC972546D31189DA00508B318AC8A5801F@charmander.wrq.com> <00012012332201.01130@mmertel3> Message-ID: <874sc8juik.fsf@ralf.serv.net> Mark Mertel writes: | On Thu, 20 Jan 2000, Todd Wells wrote: | > I'd like to get a list of directory names (and only directory names) in | > /usr/myapp. What's the best way to go about this? I wish the cookbook had | > a recipe for this. I see that readdir specifically excludes directory | > names. | | @files=<*>; | for $file (@files) { | print $file."\n" if -d $file; | } Globbing is rarely a great idea, though. A more robust way to do this would be something like (and I'll write it as a function): sub directories_in { my( $directory ) = shift; my( @result ) = (); opendir( D, $directory ); while( $_ = readdir( D ) ) { push( @result, $_ ) if( -d $_ ); } closedir( D ); return( @result ); } Just call that with something like @list = &directories_in( "/usr/myapp" ); I haven't tested it, but it's pretty straightforward. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tim at consultix-inc.com Thu Jan 20 17:03:31 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: Benchmark.pm broken? Message-ID: <20000120150331.A257@timji.consultix.wa.com> SPUG-sters, I'm comparing the code samples below for execution time, and Benchmark.pm is giving funny results, including fields it doesn't show me for other code samples (cusr, csys) and a total CPU time of 0.00. Anybody know what's wrong here? -Tim P.S. Once this gets working, I'll compare these two with a Schwartzian Transformation version. #! /usr/local/bin/perl -w use Benchmark; $count=200; # first argument is the desired number of runs of each code sample # second is an "anonymous hash", containing keys pointing # to quoted code samples timethese($count, { first => ' # must backslash any SQs in code samples! @stuff=sort { ($mtime{$a} ||= -M $a) <=> ($mtime{$b} ||= -M $b) } <*> ; # print "Results: $_\n"; ' # end of quoted code sample , # this comma separates the two code samples being compared second => ' # no-cacheing version @stuff=sort { -M $a <=> -M $b } <*> ; ' # end of quoted code sample } ); print "\nPerl Version: $]\n"; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Here's output from a sample run: Benchmark: timing 50 iterations of first, second... first: 4 wallclock secs ( 0.09 usr 0.11 sys + 0.84 cusr 2.33 csys = 0.00 CPU) second: 3 wallclock secs ( 0.05 usr 0.20 sys + 0.83 cusr 2.38 csys = 0.00 CPU) Perl Version: 5.00502 (results same with 5.00503, and different numbers of iterations) Anybody understand what's wrong here? *========================================================================* | Tim Maher, PhD Consultix & (206) 781-UNIX/8649 | | Pacific Software Gurus, Inc Email: tim@consultix-inc.com | | UNIX/Linux & Perl Training http://www.consultix-inc.com | | 2/22: UNIX 2/28: Perl Modules 2/29: Int. Perl 3/3: Pattern Matching | *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From toddw at wrq.com Thu Jan 20 18:04:41 2000 From: toddw at wrq.com (Todd Wells) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: getting a list of directories Message-ID: <1654BC972546D31189DA00508B318AC8A5802D@charmander.wrq.com> Thanks for all your suggestions -- I opted for Tim's one-liner :-) -Todd -----Original Message----- From: Tim Maher/CONSULTIX [mailto:tim@consultix-inc.com] Sent: Thursday, January 20, 2000 1:31 PM To: Todd Wells Cc: spug-list@pm.org Subject: Re: SPUG: getting a list of directories On Thu, Jan 20, 2000 at 11:53:39AM -0800, Todd Wells wrote: > I'd like to get a list of directory names (and only directory names) in > /usr/myapp. What's the best way to go about this? I wish the cookbook had > a recipe for this. I see that readdir specifically excludes directory > names. Sheesh! Such complicated solutions in previous replies! If you don't need to descend into subdirectories, all you need is this: @dirs=grep { -d } <*> ; # filter list, passing only directories If you want hidden directories too, excluding . and .., @dirs=grep { -d } <*>, <.[^.]>, <.[^.]?*> ; You can then print them, if that's the ultimate goal, with print "@dirs\n"; > > -Todd > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe > Email to majordomo@pm.org: ACTION spug-list your_address > > -- *========================================================================* | Tim Maher, PhD Consultix & (206) 781-UNIX/8649 | | Pacific Software Gurus, Inc Email: tim@consultix-inc.com | | UNIX/Linux & Perl Training http://www.consultix-inc.com | | 2/22: UNIX 2/28: Perl Modules 2/29: Int. Perl 3/3: Pattern Matching | *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From sab at rresearch.com Thu Jan 20 18:52:14 2000 From: sab at rresearch.com (Scott Blachowicz) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: getting a list of directories In-Reply-To: <1654BC972546D31189DA00508B318AC8A5802D@charmander.wrq.com>; from Todd Wells on Thu, Jan 20, 2000 at 04:04:41PM -0800 References: <1654BC972546D31189DA00508B318AC8A5802D@charmander.wrq.com> Message-ID: <20000120165214.A32637@sabami.seaslug.org> On Thu, Jan 20, 2000 at 04:04:41PM -0800, Todd Wells wrote: > Thanks for all your suggestions -- I opted for Tim's one-liner :-) And...if you need to traverse down the directory tree and find all subdirs, the File::Find module is the way to go... Scott.Blachowicz@seaslug.org - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From jimfl at colltech.com Thu Jan 20 19:18:45 2000 From: jimfl at colltech.com (jimfl) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: Benchmark.pm broken? In-Reply-To: <20000120150331.A257@timji.consultix.wa.com> Message-ID: <840266.3157377525@erdos.nwest.attws.com> --On Thursday, January 20, 2000 3:03 PM -0800 "Tim Maher/CONSULTIX" wrote: > Here's output from a sample run: > > Benchmark: timing 50 iterations of first, second... > first: 4 wallclock secs ( 0.09 usr 0.11 sys + 0.84 cusr > 2.33 csys = 0.00 CPU) second: 3 wallclock secs ( 0.05 usr > 0.20 sys + 0.83 cusr 2.38 csys = 0.00 CPU) > > Perl Version: 5.00502 > > (results same with 5.00503, and different numbers of iterations) > > Anybody understand what's wrong here? A Benchmark object is a blessed list that is presumed to have only 5 elements in it by the code in Benchmark::timestr() that prints out the line. That line looks something like: $s = sprintf("%2d wallclock.....CPU", @t, $t) if $style eq 'all'; The only problem is that somehow, the Benchmark object (@t in this case) is getting an extra zero appended to it (I haven't figured out where.) Changing the above line to $s = sprintf("%2d wallclock.....CPU", @t[0..4], $t) if $style eq 'all'; Solves the problem. -- Jim Flanagan Collective Technologies jimfl@colltech.com http://www.colltech.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From trosmus at nwnexus.net Thu Jan 20 19:57:35 2000 From: trosmus at nwnexus.net (Tim Rosmus) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: getting a list of directories In-Reply-To: <20000120165214.A32637@sabami.seaslug.org> Message-ID: On Thu, 20 Jan 2000, Scott Blachowicz wrote: |# On Thu, Jan 20, 2000 at 04:04:41PM -0800, Todd Wells wrote: |# > Thanks for all your suggestions -- I opted for Tim's one-liner :-) |# |# And...if you need to traverse down the directory tree and find all |# subdirs, the File::Find module is the way to go... |# And if your understand find options but are not well versed in the use of File::Find, just use "find2perl" with normal 'find' options and it will generate the perl code for you. -- Tim Rosmus Postmaster / USENET / DNS WinStar Northwest Nexus - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From chris at smalldognet.com Fri Jan 21 01:12:26 2000 From: chris at smalldognet.com (Chris Sutton) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: Optimizing replace code Message-ID: <388806DA.E0C34436@smalldognet.com> Hello, I have a general purpose function that takes a string like this This {is} a {test} and a hash like this is => "IS", test => "TEST" and spits out This IS a TEST Here is my original code my $hash = shift; #pointer to hash my $string = shift; #pointer to string my $key; foreach $key (keys %$hash) { $$string =~ s/\{$key\}/$$hash{$key}/g; } After going to the December SPUG meeting and learning a bit more about the different efficiencies of regular expressions, it dawned on me that this is pretty slow and doing it the eval way would be much better. (Some testing and benchmarking proved eval to be about 4 times faster). So, here is my new code my $hash = shift; #pointer to hash my $string = shift; #pointer to string my $key; my $evalcode; foreach $key (keys %$hash) { $evalcode .= "\$\$string =~ s/\\{$key\\}/$$hash{$key}/g;"; } eval { $evalcode }; But for some reason it's not working the way it should and I think it has something to do with the $string pointer but I don't know how it's acting inside the eval. Any pointers? I'm off by a backslash somewhere right? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From wormwood at speakeasy.org Fri Jan 21 08:09:19 2000 From: wormwood at speakeasy.org (Riley) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: Optimizing replace code In-Reply-To: <388806DA.E0C34436@smalldognet.com> Message-ID: I think the problem may be that you're using the eval {} form rather than eval "" so that $evalcode is not run-time interpolated before evaluation -- it's just returned as a scalar value. You're getting great efficiency but not compiling any regexes at all! --Riley ---------------------- CARTHAGO DELENDA EST. On Thu, 20 Jan 2000, Chris Sutton wrote: > Hello, > > I have a general purpose function that takes a string like this > > This {is} a {test} > > and a hash like this > > is => "IS", > test => "TEST" > > and spits out > > This IS a TEST > > Here is my original code > > my $hash = shift; #pointer to hash > my $string = shift; #pointer to string > my $key; > > foreach $key (keys %$hash) { > $$string =~ s/\{$key\}/$$hash{$key}/g; > } > > After going to the December SPUG meeting and learning a bit more about > the different efficiencies of regular expressions, it dawned on me that > this is pretty slow and doing it the eval way would be much better. > (Some testing and benchmarking proved eval to be about 4 times faster). > > So, here is my new code > > my $hash = shift; #pointer to hash > my $string = shift; #pointer to string > my $key; > > my $evalcode; > > foreach $key (keys %$hash) { > $evalcode .= "\$\$string =~ s/\\{$key\\}/$$hash{$key}/g;"; > } > > eval { $evalcode }; > > But for some reason it's not working the way it should and I think it > has something to do with the $string pointer but I don't know how it's > acting inside the eval. > > Any pointers? I'm off by a backslash somewhere right? > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe > Email to majordomo@pm.org: ACTION spug-list your_address > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From wormwood at speakeasy.org Fri Jan 21 11:44:25 2000 From: wormwood at speakeasy.org (Riley) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: Optimizing replace code In-Reply-To: Message-ID: On second thought, if you really want to light a fire under your script, skip out on the regexes altogether and try something like this: sub hash_interpol { # hide yer stash! my $hash = shift; my $string = shift; my ($endpos, $index); while (($index = index($$string,'{',$index)) > 0) { $endpos = index($$string,'}',$index); substr($$string,$index,($endpos-$index)+1) = $hash->{substr($$string,$index+1,($endpos-$index)-1)}; } } This runs about twice as fast as the original code, and 4-5 times as fast as the eval'd version on my machine. --Riley ---------------------- CARTHAGO DELENDA EST. On Fri, 21 Jan 2000, Riley wrote: > > I think the problem may be that you're using the eval {} form rather than > eval "" so that $evalcode is not run-time interpolated before evaluation > -- it's just returned as a scalar value. > > You're getting great efficiency but not compiling any regexes at all! > > > --Riley > ---------------------- > CARTHAGO DELENDA EST. > > On Thu, 20 Jan 2000, Chris Sutton wrote: > > > Hello, > > > > I have a general purpose function that takes a string like this > > > > This {is} a {test} > > > > and a hash like this > > > > is => "IS", > > test => "TEST" > > > > and spits out > > > > This IS a TEST > > > > Here is my original code > > > > my $hash = shift; #pointer to hash > > my $string = shift; #pointer to string > > my $key; > > > > foreach $key (keys %$hash) { > > $$string =~ s/\{$key\}/$$hash{$key}/g; > > } > > > > After going to the December SPUG meeting and learning a bit more about > > the different efficiencies of regular expressions, it dawned on me that > > this is pretty slow and doing it the eval way would be much better. > > (Some testing and benchmarking proved eval to be about 4 times faster). > > > > So, here is my new code > > > > my $hash = shift; #pointer to hash > > my $string = shift; #pointer to string > > my $key; > > > > my $evalcode; > > > > foreach $key (keys %$hash) { > > $evalcode .= "\$\$string =~ s/\\{$key\\}/$$hash{$key}/g;"; > > } > > > > eval { $evalcode }; > > > > But for some reason it's not working the way it should and I think it > > has something to do with the $string pointer but I don't know how it's > > acting inside the eval. > > > > Any pointers? I'm off by a backslash somewhere right? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From chris at smalldognet.com Fri Jan 21 13:58:57 2000 From: chris at smalldognet.com (Chris Sutton) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: Optimizing replace code References: Message-ID: <3888BA81.47F03CC3@smalldognet.com> Oh, I like that. Actually, after I got the eval working it seemed to run slower than my original regex. I didn't think to try a whole different approach. Thanks. Chris Riley wrote: > > On second thought, if you really want to light a fire under your script, > skip out on the regexes altogether and try something like this: > > sub hash_interpol { # hide yer stash! > my $hash = shift; > my $string = shift; > my ($endpos, $index); > while (($index = index($$string,'{',$index)) > 0) { > $endpos = index($$string,'}',$index); > substr($$string,$index,($endpos-$index)+1) = > $hash->{substr($$string,$index+1,($endpos-$index)-1)}; > } > } > > This runs about twice as fast as the original code, and 4-5 times as > fast as the eval'd version on my machine. > > --Riley > ---------------------- > CARTHAGO DELENDA EST. > > On Fri, 21 Jan 2000, Riley wrote: > > > > > I think the problem may be that you're using the eval {} form rather than > > eval "" so that $evalcode is not run-time interpolated before evaluation > > -- it's just returned as a scalar value. > > > > You're getting great efficiency but not compiling any regexes at all! > > > > > > --Riley > > ---------------------- > > CARTHAGO DELENDA EST. > > > > On Thu, 20 Jan 2000, Chris Sutton wrote: > > > > > Hello, > > > > > > I have a general purpose function that takes a string like this > > > > > > This {is} a {test} > > > > > > and a hash like this > > > > > > is => "IS", > > > test => "TEST" > > > > > > and spits out > > > > > > This IS a TEST > > > > > > Here is my original code > > > > > > my $hash = shift; #pointer to hash > > > my $string = shift; #pointer to string > > > my $key; > > > > > > foreach $key (keys %$hash) { > > > $$string =~ s/\{$key\}/$$hash{$key}/g; > > > } > > > > > > After going to the December SPUG meeting and learning a bit more about > > > the different efficiencies of regular expressions, it dawned on me that > > > this is pretty slow and doing it the eval way would be much better. > > > (Some testing and benchmarking proved eval to be about 4 times faster). > > > > > > So, here is my new code > > > > > > my $hash = shift; #pointer to hash > > > my $string = shift; #pointer to string > > > my $key; > > > > > > my $evalcode; > > > > > > foreach $key (keys %$hash) { > > > $evalcode .= "\$\$string =~ s/\\{$key\\}/$$hash{$key}/g;"; > > > } > > > > > > eval { $evalcode }; > > > > > > But for some reason it's not working the way it should and I think it > > > has something to do with the $string pointer but I don't know how it's > > > acting inside the eval. > > > > > > Any pointers? I'm off by a backslash somewhere right? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From jope-spug at n2h2.com Fri Jan 21 15:32:06 2000 From: jope-spug at n2h2.com (El JoPe Magnifico) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: Optimizing replace code In-Reply-To: <3888BA81.47F03CC3@smalldognet.com> Message-ID: On Fri, 21 Jan 2000, Chris Sutton wrote: > Actually, after I got the eval working it seemed to run slower than my > original regex. I didn't think to try a whole different approach. (Use of "zub" below is an attempt to avoid the mailing list's filter, not the result of some odd typographic speech impediment... =) You're missing the power of perl's _fast_ regex engine, by building up a long list of per-key zubstitutions, each of which is going to start back at the beginning of your template text every time. The slowdown is worsened by the unnecessary use of eval(). A regex equivalent to Chris's un-perl-ish zubstr() approach is in this example's replace() zubroutine. The important part is the /g modifier on the regex, to do a global replace. If perl's regex engine doesn't beat the pants off the while-zubstring approach, I'll be mightily surprised. At very least, this one-line regex is easier on the ol' carpal tunnel. Benchmarking (and converting "zub") left as an exercise to the reader... #!/usr/bin/perl $template =< 'John Doe', 'function' => 'perlaholic', 'hobby1' => 'hacking', 'hobby2' => 'scuba diving', 'numpets' => 'zero', } ); printinfo ( "string1", $string1 ); ## Second run; note that the template wasn't munged by previous run's ## replace() call, because it worked on a _copy_ of the template... printinfo ( "string2", replace( $template, { 'name' => 'Eva Gabore', 'function' => 'mistress of Green Acres', 'hobby1' => 'shopping', 'hobby2' => 'getting manicures', 'numpets' => 'many, many', } ) ); ## Add a title line, follow with a blank line... zub printinfo { my ($descrip, $text) = @_; print "Text of $descrip:\n$text\n"; } ## Here's the magic! zub replace { my ($string, $data) = @_; $string =~ s/{([^}]+)}/$data->{$1}/g; return $string; } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tim at consultix-inc.com Fri Jan 21 17:32:45 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: each() on hashref giving INFINITE LOOP! Message-ID: <20000121153245.A4161@timji.consultix.wa.com> The following program, a simple demo for passing and using a hash-ref, is getting an infinite loop when using while(each) in the sub, but not when using foreach there! Can anybody shed some light on this? -Tim $ animal2title Here is the hash: Camel Programming Perl Llama Learning Perl These are the keys: Camel Llama Camel -> Programming Perl Llama -> Learning Perl (while loop starts now) Camel -> Programming Perl Camel -> Programming Perl Camel -> Programming Perl Camel -> Programming Perl Infinite Loop Terminated! #! /usr/bin/perl -w # animal2title use strict; #sub print_hash; # not complaining this time, for some reason! $main::DEBUG=1; my $h_ref = { } ; # create reference to empty hash # Load animals and their corresponding O'Reilly Perl-book titles $h_ref->{Camel} = 'Programming Perl'; $h_ref->{Llama} = 'Learning Perl'; if ($main::DEBUG) {local $,=' '; print "Here is the hash: ", %$h_ref, "\n"; } print_hash ( $h_ref ); # call sub that takes hash ref sub print_hash { my ($i, $key, $value, $hashref); if (ref ($hashref=shift) ne 'HASH') { warn ((caller 0)[3], # provides sub's name "(): argument \"$hashref\" not hash ref\n"); return 0; } if ($main::DEBUG) { local $,=' '; print "These are the keys: ", keys %$hashref, "\n"; } foreach ( keys %$hashref ) { print "$_ -> $$hashref{$_}\n"; } print "\n"; $i=0; # sense and break out of infinite loop! while ( ($key,$value) = %$hashref ) { print "$key -> $value\n"; $i++; # break out of infinite loop $i > 3 and die "\tInfinite Loop Terminated!\n"; } return 1; } TIA, as usual, *========================================================================* | Tim Maher, PhD Consultix & (206) 781-UNIX/8649 | | Pacific Software Gurus, Inc Email: tim@consultix-inc.com | | UNIX/Linux & Perl Training http://www.consultix-inc.com | | 2/22: UNIX 2/28: Perl Modules 2/29: Int. Perl 3/3: Pattern Matching | *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From chris at smalldognet.com Fri Jan 21 18:02:54 2000 From: chris at smalldognet.com (Chris Sutton) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: Optimizing replace code References: Message-ID: <3888F3AE.5C011554@smalldognet.com> JoPe wins. Original 4.80 Riley (index) 1.77 JoPe (regex) 1.23 Just so I (and probably others) can fully understand what is going on here can someone explain: ([^}]+) Also, one thing that might make this a little more complicated is that if there is not a hash value for a specific {text} string, leave the {text} string alone. Right now, it whipes it out. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From dougb at scalar.org Fri Jan 21 18:29:44 2000 From: dougb at scalar.org (Doug Beaver) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: each() on hashref giving INFINITE LOOP! In-Reply-To: <20000121153245.A4161@timji.consultix.wa.com>; from tim@consultix-inc.com on Fri, Jan 21, 2000 at 03:32:45PM -0800 References: <20000121153245.A4161@timji.consultix.wa.com> Message-ID: <20000121162944.A28674@scalar.org> On Fri, Jan 21, 2000 at 03:32:45PM -0800, Tim Maher/CONSULTIX wrote: > The following program, a simple demo for passing and using a hash-ref, is > getting an infinite loop when using while(each) in the sub, but not > when using foreach there! Can anybody shed some light on this? You're not doing the while loop correctly: > $i=0; # sense and break out of infinite loop! > while ( ($key,$value) = %$hashref ) { > print "$key -> $value\n"; > $i++; # break out of infinite loop > $i > 3 and die "\tInfinite Loop Terminated!\n"; > } That should be: while (($key, $value) = each %$hashref) { Doug -- Smithers: I'm afraid we have a bad image, Sir. Market research shows people see you as somewhat of an ogre. Burns: I ought to club them and eat their bones! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From sab at rresearch.com Fri Jan 21 18:38:38 2000 From: sab at rresearch.com (Scott Blachowicz) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: Optimizing replace code In-Reply-To: ; from El JoPe Magnifico on Fri, Jan 21, 2000 at 01:32:06PM -0800 References: <3888BA81.47F03CC3@smalldognet.com> Message-ID: <20000121163838.A65734@sabami.seaslug.org> On Fri, Jan 21, 2000 at 01:32:06PM -0800, El JoPe Magnifico wrote: > $template =< Hello my name is {name} and I am a {function}. > My hobbies are {hobby1} and {hobby2}, and I have {numpets} pets. > END > printinfo( "template", $template ); > > ## First run; dumping results into a variable... > $string1 = replace( $template, { > 'name' => 'John Doe', > 'function' => 'perlaholic', > 'hobby1' => 'hacking', > 'hobby2' => 'scuba diving', > 'numpets' => 'zero', > } ); > printinfo ( "string1", $string1 ); > > ## Second run; note that the template wasn't munged by previous run's > ## replace() call, because it worked on a _copy_ of the template... > printinfo ( "string2", replace( $template, { > 'name' => 'Eva Gabore', > 'function' => 'mistress of Green Acres', > 'hobby1' => 'shopping', > 'hobby2' => 'getting manicures', > 'numpets' => 'many, many', > } ) ); > > ## Add a title line, follow with a blank line... > zub printinfo > { > my ($descrip, $text) = @_; > print "Text of $descrip:\n$text\n"; > } > > ## Here's the magic! > zub replace > { > my ($string, $data) = @_; > $string =~ s/{([^}]+)}/$data->{$1}/g; > return $string; > } OK...that "([^}]+)" means: ( - start a tagged section of the input (first open paren gets referred to as $1 in the substitution string). [^}] - a negated character class - any non-"}" character matches + - one or more of the previous thing (the char class above) ) - end a tagged section of the input As for keeping non-matched text...maybe something in this vein: zub replace { my ($string, $data) = @_; $string =~ s/{([^}]+)}/subst($1,$data)/eg; return $string; } zub subst { my $substring = shift; my $data = shift; defined $data->{$substring} ? "$data->{$substring}" : "{$substring}"; } Don't know about performance issues as I've never really used the 'e' flag on the s/// command before. Scott - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tim at consultix-inc.com Fri Jan 21 18:41:34 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: each() on hashref giving INFINITE LOOP! In-Reply-To: <20000121162944.A28674@scalar.org>; from dougb@scalar.org on Fri, Jan 21, 2000 at 04:29:44PM -0800 References: <20000121153245.A4161@timji.consultix.wa.com> <20000121162944.A28674@scalar.org> Message-ID: <20000121164134.A4635@timji.consultix.wa.com> On Fri, Jan 21, 2000 at 04:29:44PM -0800, Doug Beaver wrote: > On Fri, Jan 21, 2000 at 03:32:45PM -0800, Tim Maher/CONSULTIX wrote: > > The following program, a simple demo for passing and using a hash-ref, is > > getting an infinite loop when using while(each) in the sub, but not > > when using foreach there! Can anybody shed some light on this? > > You're not doing the while loop correctly: > > > $i=0; # sense and break out of infinite loop! > > while ( ($key,$value) = %$hashref ) { > > print "$key -> $value\n"; > > $i++; # break out of infinite loop > > $i > 3 and die "\tInfinite Loop Terminated!\n"; > > } > > That should be: > > while (($key, $value) = each %$hashref) { The each() was there at one time, I swear it! But it did get lost along the way, and I couldn't spot my mistake. Thanks! -Tim > > Doug > > -- > Smithers: I'm afraid we have a bad image, Sir. Market research shows > people see you as somewhat of an ogre. > Burns: I ought to club them and eat their bones! -- *========================================================================* | Tim Maher, PhD Consultix & (206) 781-UNIX/8649 | | Pacific Software Gurus, Inc Email: tim@consultix-inc.com | | UNIX/Linux & Perl Training http://www.consultix-inc.com | | 2/22: UNIX 2/28: Perl Modules 2/29: Int. Perl 3/3: Pattern Matching | *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From jope-spug at n2h2.com Fri Jan 21 18:44:05 2000 From: jope-spug at n2h2.com (El JoPe Magnifico) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: Optimizing replace code In-Reply-To: <3888F3AE.5C011554@smalldognet.com> Message-ID: On Fri, 21 Jan 2000, Chris Sutton wrote: > JoPe wins. And the crowd goes wild! No wait... those are just the voices in my head. =) > Just so I (and probably others) can fully understand what is going on > here can someone explain: ([^}]+) Character range ([]) consisting of everything except (^) closing curly bracket (}), with the one-or-more (+) modifier. The parentheses are so we hold onto it for use later as $1, in this case in our replacement string. Fairly run-of-the-mill. > Also, one thing that might make this a little more complicated is that > if there is not a hash value for a specific {text} string, leave the > {text} string alone. Right now, it whipes it out. Rather than.... s/{([^}]+)}/$data->{$1}/g; this instead... s/{([^}]+)}/$data->{$1} || "{$1}"/eg; The /e modifier makes the replacement string be interpreted as an eval expression, rather than a double-quoted (interpolated) string. Using || to failover to the original string if $data->{$1} is false. Which means this wouldn't work as expected, if $data->{$1} is 0 (zero). D'oh! To only have it failover on empty string or undef (the other two values interpreted as false) use this... s/{([^}]+)}/$data->{$1} ne '' ? $data->{$1} : "{$1}"/eg; In this fashion, you can get wicked fancy with your defaulting. Not sure how adversely the eval from the /e will affect performance. (if you run benchmarking again, make sure to add the failover behavior to all applicable sets of code) -jp - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From byoung at speakeasy.org Fri Jan 21 19:36:05 2000 From: byoung at speakeasy.org (Bradley E. Young) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: each() on hashref giving INFINITE LOOP! In-Reply-To: <20000121153245.A4161@timji.consultix.wa.com> Message-ID: <001401bf6479$0cccc4f0$9a26e7d8@byoung.fiven.com> Tim, Looks like the last chunk is giving you fits because it doesn't iterate over the hash. You are setting $key and $value to the first two elements of %$hash every loop through. I think that you might have meant to do this: $i=0; # sense and break out of infinite loop! while ( ($key,$value) = each %$hashref ) { print "$key -> $value\n"; $i++; # break out of infinite loop $i > 3 and die "\tInfinite Loop Terminated!\n"; } return 1; Notice the addition of each(). Brad > -----Original Message----- > From: owner-spug-list@pm.org [mailto:owner-spug-list@pm.org]On Behalf Of > Tim Maher/CONSULTIX > Sent: Friday, January 21, 2000 3:33 PM > To: spug-list@pm.org > Subject: SPUG: each() on hashref giving INFINITE LOOP! > > > The following program, a simple demo for passing and using a hash-ref, is > getting an infinite loop when using while(each) in the sub, but not > when using foreach there! Can anybody shed some light on this? > > -Tim > > $ animal2title > Here is the hash: Camel Programming Perl Llama Learning Perl > These are the keys: Camel Llama > Camel -> Programming Perl > Llama -> Learning Perl > > (while loop starts now) > Camel -> Programming Perl > Camel -> Programming Perl > Camel -> Programming Perl > Camel -> Programming Perl > Infinite Loop Terminated! > > #! /usr/bin/perl -w > # animal2title > > use strict; > #sub print_hash; # not complaining this time, for some reason! > > $main::DEBUG=1; > my $h_ref = { } ; # create reference to empty hash > > # Load animals and their corresponding O'Reilly Perl-book titles > $h_ref->{Camel} = 'Programming Perl'; > $h_ref->{Llama} = 'Learning Perl'; > > if ($main::DEBUG) {local $,=' '; print "Here is the hash: ", > %$h_ref, "\n"; } > > print_hash ( $h_ref ); # call sub that takes hash ref > > sub print_hash { > my ($i, $key, $value, $hashref); > > if (ref ($hashref=shift) ne 'HASH') { > warn ((caller 0)[3], # provides sub's name > "(): argument \"$hashref\" not hash ref\n"); > return 0; > } > if ($main::DEBUG) { > local $,=' '; > print "These are the keys: ", keys %$hashref, "\n"; > } > > foreach ( keys %$hashref ) { > print "$_ -> $$hashref{$_}\n"; > } > print "\n"; > > $i=0; # sense and break out of infinite loop! > while ( ($key,$value) = %$hashref ) { > print "$key -> $value\n"; > $i++; # break out of infinite loop > $i > 3 and die "\tInfinite Loop Terminated!\n"; > } > return 1; > } > > TIA, as usual, > > *========================================================================* > | Tim Maher, PhD Consultix & (206) 781-UNIX/8649 | > | Pacific Software Gurus, Inc Email: tim@consultix-inc.com | > | UNIX/Linux & Perl Training http://www.consultix-inc.com | > | 2/22: UNIX 2/28: Perl Modules 2/29: Int. Perl 3/3: Pattern Matching | > *========================================================================* > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe > Email to majordomo@pm.org: ACTION spug-list your_address > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From andy at n2h2.com Sat Jan 22 03:03:38 2000 From: andy at n2h2.com (Andrew Sweger) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: Optimizing replace code In-Reply-To: <3888F3AE.5C011554@smalldognet.com> Message-ID: On Jan 21, 2000 @ 4:02pm, Chris Sutton wrote: > Just so I (and probably others) can fully understand what is going on > here can someone explain: > > ([^}]+) It's a guy with a spug [sic] look on his face wearing fancy Terminator-style shades with a goatee and a crucifix on a choke chain. Now, come on, gimme a hard one. -- Andrew Sweger | N2H2, Incorporated v=206.336.2947 f=206.336.1541 | 900 Fourth Avenue, Suite 3400 Advanced Technologies | Seattle WA 98164-1059 Development | http://www.n2h2.com/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tim at consultix-inc.com Sat Jan 22 12:18:06 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: List Subscriber Data Message-ID: <20000122101806.A8270@timji.consultix.wa.com> Well, after almost two years of SPUGery, we've just reached a milestone- the list has grown past 300 users! To commemorate this auspicious event, here are some summary data about our members, along with the program that generated the report. -Tim ========================================================== | Tim Maher, Ph.D. Tel/Fax: (206) 781-UNIX | | SPUG Founder & Leader Email: spug@halcyon.com | | Seattle Perl Users Group HTTP: www.halcyon.com/spug | ========================================================== $ cat spug_domains #! /usr/bin/perl -lnaF'@' # spug_domains: report domains of SPUG-list subscribers # Tim Maher, tim@consultix-inc.com, 1/22/00 BEGIN { @ARGV or @ARGV='spug-list'; } # convert each domain-name to lower-case, and count occurrences # by using domain-name as hash index $domain_counts{"\L$F[1]"}++; END { # sort hash by values, and store result in array @domain_counts_sorted= map { sprintf "%26s = %s\n", $_, $domain_counts{$_} } reverse sort { $domain_counts{$a} <=> $domain_counts{$b} } keys %domain_counts; # NOTE: -l on in shebang line, so don't need trailing \n's print "\nNumber of SPUG subscribers: $."; print "\nNumber of unique domains: ", scalar keys %domain_counts; $"="\t"; # set list-item separator print "\nTop 10 domains:\n\t@domain_counts_sorted[0..9]"; print "Entire list of domains:\n\t@domain_counts_sorted"; } $ spug_domains Number of SPUG subscribers: 301 Number of unique domains: 174 Top 10 domains: boeing.com = 14 halcyon.com = 10 hotmail.com = 10 attws.com = 9 n2h2.com = 9 microsoft.com = 8 pss.boeing.com = 7 pobox.com = 6 yahoo.com = 6 nwlink.com = 5 Entire list of domains: boeing.com = 14 halcyon.com = 10 hotmail.com = 10 attws.com = 9 n2h2.com = 9 microsoft.com = 8 pss.boeing.com = 7 pobox.com = 6 yahoo.com = 6 nwlink.com = 5 u.washington.edu = 5 amazon.com = 5 eskimo.com = 4 cobaltgroup.com = 4 seanet.com = 4 speakeasy.org = 4 scn.org = 4 tc.fluke.com = 4 uswnvg.com = 4 seaslug.org = 3 atl.com = 3 geospiza.com = 3 uswest.com = 3 rei.com = 2 sdc.cs.boeing.com = 2 earthlink.net = 2 nv.airtouch.com = 2 eddiebauer.com = 2 courtlink.com = 2 bcstec.ca.boeing.com = 2 usa.net = 2 bigfoot.com = 2 filmworks.com = 2 drizzle.com = 2 aa.net = 2 premier1.net = 2 wolfenet.com = 2 acm.org = 2 uswest.net = 2 pop.nwnexus.com = 1 destinations.com = 1 altavista.net = 1 blarg.net = 1 medius.net = 1 kalesis.com = 1 memoria.com = 1 home.com = 1 sleepy.ns.cs.boeing.com = 1 jetcity.com = 1 e-valuations.com = 1 meer.net = 1 fhcrc.org = 1 sihb.org = 1 cyberrealm.net = 1 webrocket.net = 1 microen.com = 1 adam.kellersupply.com = 1 weezel.com = 1 ucla.edu = 1 serviceintelligence.com = 1 seattle.gii.net = 1 wrq.com = 1 thinker.celestial.com = 1 metaip.checkpoint.com = 1 common-sense.com = 1 accountingnet.com = 1 tscnet.com = 1 consultix-inc.com = 1 hivnet.fhcrc.org = 1 driveway.com = 1 cncglobal.com = 1 sequent.com = 1 digidot.com = 1 dreamhaven.org = 1 vcommunities.com = 1 dynamicweb.com = 1 metrokc.gov = 1 mathin.com = 1 elwha.evergreen.edu = 1 sounddomain.com = 1 admin.gla.ac.uk = 1 igc.org = 1 smalldognet.com = 1 npl.washington.edu = 1 paul.spu.edu = 1 cco.caltech.edu = 1 bestnet.com = 1 metapath.com = 1 dblv017.ca.boeing.com = 1 teleport.com = 1 webforia.com = 1 gibbs.npl.washington.edu = 1 erwin.org = 1 coltrane.ns.cs.boeing.com = 1 esu2.esu2.k12.ne.us = 1 lucent.com = 1 fugue.ca.boeing.com = 1 nwsr.com = 1 gateway.uswnvg.com = 1 pugettech.com = 1 ust.hk = 1 stornet.com = 1 panix.com = 1 chittenden.org = 1 eud.com = 1 pnl.gov = 1 mushroom.ca.boeing.com = 1 cs.unm.edu = 1 webtv.net = 1 2dgs.com = 1 kirkham.net = 1 rbs.net = 1 photodisc.com = 1 cruciblelabs.com = 1 unigard.com = 1 emeraldsolutions.com = 1 gte.net = 1 sasha.ca.boeing.com = 1 chronology.com = 1 vcd.hp.com = 1 pacifier.com = 1 tanzatech.com = 1 teamdesign.com = 1 nwnexus.net = 1 airtouch.com = 1 libronix.com = 1 stadiumdistrict.com = 1 zipcon.net = 1 carios2.ca.boeing.com = 1 easyliving.com = 1 chocobo.org = 1 forge.ds.boeing.com = 1 ricochet.net = 1 lagwagon.net = 1 ix.netcom.com = 1 catmanor.com = 1 edmark.com = 1 mccaw-stg.com = 1 ministry.eu.org = 1 partes.com = 1 msn.com = 1 hsvaic.hv.boeing.com = 1 maximgroup.com = 1 emeraldnet.net = 1 serv.net = 1 windowware.com = 1 alum.mit.edu = 1 corixa.com = 1 3hats.com = 1 daft.com = 1 vertexdev.com = 1 swog.fhcrc.org = 1 cac.washington.edu = 1 jps.net = 1 olywa.net = 1 dis.wa.gov = 1 marin.net = 1 oz.net = 1 scherrer.com = 1 colltech.com = 1 grieg.seaslug.org = 1 cnw.com = 1 uffda.com = 1 ero.com = 1 chriskate.net = 1 scalar.org = 1 haakenson.com = 1 astro.washington.edu = 1 integrityol.com = 1 contract-jobs.com = 1 visca.com = 1 fluke.com = 1 interlinq.com = 1 aventail.com = 1 *========================================================================* | Tim Maher, PhD Consultix & (206) 781-UNIX/8649 | | Pacific Software Gurus, Inc Email: tim@consultix-inc.com | | UNIX/Linux & Perl Training http://www.consultix-inc.com | | 2/22: UNIX 2/28: Perl Modules 2/29: Int. Perl 3/3: Pattern Matching | *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From taliesin at speakeasy.org Sat Jan 22 16:24:41 2000 From: taliesin at speakeasy.org (taliesin@speakeasy.org) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: List Subscriber Data In-Reply-To: <20000122101806.A8270@timji.consultix.wa.com> Message-ID: On Sat, 22 Jan 2000, Tim Maher/CONSULTIX wrote: >To commemorate this auspicious event, here are some summary data about >our members, along with the program that generated the report. > boeing.com = 14 ... > pss.boeing.com = 7 Ummm.... in most cases an SLD commonality indicates being from the same location... I do know that boeing.com and pss.boeing.com are the same, as one forwards to the other... .washington.edu would be likewise... not that it would change the results too much, as my current contractee is alreddie Numero Uno, but I think it would be interesting to collapse the domains.... What I think is even more interesting is the number of singleton domains out there.... shows a definite tendency for SPUGgers to either (a) work for small businesses or (b) have their own domain.... either is a Good Thing, IMHO, it shows we're a bunch of rugged individualists :) 300, and only 20some from Boeing, less than ten percent, and the rest on down. Hmmm. Definitely a grassroots effort. (I will note, however, that in my little corner of Boeing, that Perl is the language of choice for all platforms.... and we're growing. :) -- Glenn Stone Linux kinda guy knit one, Perl two... - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From byoung at speakeasy.org Sun Jan 23 19:39:06 2000 From: byoung at speakeasy.org (Bradley E. Young) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: List Subscriber Data In-Reply-To: <20000122101806.A8270@timji.consultix.wa.com> Message-ID: <000301bf660b$cd8804a0$9a26e7d8@byoung.fiven.com> A conspicuous absence: aol.com Brad > -----Original Message----- > From: owner-spug-list@pm.org [mailto:owner-spug-list@pm.org]On Behalf Of > Tim Maher/CONSULTIX > Sent: Saturday, January 22, 2000 10:18 AM > To: spug-list@pm.org > Subject: SPUG: List Subscriber Data > > > Well, after almost two years of SPUGery, we've just reached a milestone- > the list has grown past 300 users! > > To commemorate this auspicious event, here are some summary data about > our members, along with the program that generated the report. > > -Tim > ========================================================== > | Tim Maher, Ph.D. Tel/Fax: (206) 781-UNIX | > | SPUG Founder & Leader Email: spug@halcyon.com | > | Seattle Perl Users Group HTTP: www.halcyon.com/spug | > ========================================================== - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From twitch at webrocket.net Mon Jan 24 17:58:32 2000 From: twitch at webrocket.net (Ryan Forsythe) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: one of those 'other' programming languages Message-ID: <001d01bf66c6$ebb30900$d29227d8@net> --spugers i'm a comp. sci student who has to write in c++. good for some stuff...but it sucks big time on text. this weekend i wrote a mountain of c (which ended up not working) to do something i could have done in around five or six lines of perl. i'm not only complaining about c -- i do have a question: i was wondering if anybody has used perl embedded in c, thought it was useful enough / fast enough / generally worth it. i remember something like that being alluded to in the camel book, how perl was a friendly language which can embed / be embedded in other languages. comments? suggestions? (other than tell my prof that i'll be writing the rest of my assignments in perl...i doubt that would go over too well :) --ryan - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From asherr at cs.unm.edu Mon Jan 24 19:13:18 2000 From: asherr at cs.unm.edu (Aryeh "Cody" Sherr) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: one of those 'other' programming languages In-Reply-To: <001d01bf66c6$ebb30900$d29227d8@net> Message-ID: The perlembed man page should have most of what you need. Chapter 19 of the Advanced perl book also covers this topic. Aryeh "Cody" Sherr - asherr@cs.unm.edu http://www.cs.unm.edu/~asherr ---------- THIS EMAIL IS A MUNITION ------------ #!/bin/perl -sp0777i Message-ID: <005101bf66f3$7fb1d470$6d510ed1@test> ryan, The answer is 'yes'. You can embed Perl in other languanges. And have done it a couple of times myself. And 'yes' I think it's useful enough and produces a cleaner code (depending on what you want to achieve with your code). Maybe it'll help if you floated that piece of code you're working on, so we can have a few 'extra pairs of eyes' look at it and give some suggestions on how to write an effective code. ../seppy ----- Original Message ----- From: Ryan Forsythe To: Sent: Monday, January 24, 2000 6:58 PM Subject: SPUG: one of those 'other' programming languages > --spugers > > i'm a comp. sci student who has to write in c++. good for some stuff...but > it sucks big time on text. this weekend i wrote a mountain of c (which > ended up not working) to do something i could have done in around five or > six lines of perl. > > i'm not only complaining about c -- i do have a question: i was wondering if > anybody has used perl embedded in c, thought it was useful enough / fast > enough / generally worth it. i remember something like that being alluded > to in the camel book, how perl was a friendly language which can embed / be > embedded in other languages. > > comments? suggestions? (other than tell my prof that i'll be writing the > rest of my assignments in perl...i doubt that would go over too well :) > > --ryan > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe > Email to majordomo@pm.org: ACTION spug-list your_address > > > __________________________________________ NetZero - Defenders of the Free World Get your FREE Internet Access and Email at http://www.netzero.net/download/index.html - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From ryan at webrocket.net Mon Jan 24 23:49:51 2000 From: ryan at webrocket.net (Ryan Forsythe) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: one of those 'other' programming languages References: <001d01bf66c6$ebb30900$d29227d8@net> <005101bf66f3$7fb1d470$6d510ed1@test> Message-ID: <001401bf66f7$ffadd1c0$d29227d8@net> > Maybe it'll help if you floated that piece of code you're working on, so we > can have a few 'extra pairs of eyes' look at it and give some suggestions on > how to write an effective code. i would, but it's a bit of a mess...and it's c. pretty much what i wanted to do was make a translation method for this object we had to make. i wanted it to take in something like '3x^5 + 2x^2 + 4' and spit the coefficient and the power out into an array. it would be incredibly simple if c had regexes. but it doesn't, so i had to write this load of 'walk through the char array until you find 'x', then walk backward until you hit a space, sticking each char into a buffer array, reverse that array, tack on a /0, convert it to an int, stick it in the polynomial array then go back to the x and blah blah blah.' it ballooned, and it wasn't very well written. if anyone's still interested in looking at it, i've got the code here: www.flamingweasel.com/c.html and sorry about the formatting...tabs always turn a little screwy across different programs --ryan ----- Original Message ----- From: "Jafaar Nyang'oro" To: "Ryan Forsythe" ; Sent: Monday, January 24, 2000 9:17 PM Subject: Re: SPUG: one of those 'other' programming languages > ryan, > > The answer is 'yes'. You can embed Perl in other languanges. And have done > it a couple of times myself. And 'yes' I think it's useful enough and > produces a cleaner code (depending on what you want to achieve with your > code). > > Maybe it'll help if you floated that piece of code you're working on, so we > can have a few 'extra pairs of eyes' look at it and give some suggestions on > how to write an effective code. > > ../seppy - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From andy at n2h2.com Tue Jan 25 00:26:33 2000 From: andy at n2h2.com (Andrew Sweger) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: one of those 'other' programming languages In-Reply-To: <001401bf66f7$ffadd1c0$d29227d8@net> Message-ID: You may also want to look at PCRE. PCRE is a library of functions to support regular expressions whose syntax and semantics are as close as possible to those of the Perl 5 language by Philip Hazel . I've seen it in the postfix distribution (in the official directory): http://www.postfix.org/ Don't know what the original source is, but it plays a pivotal role in postfix's regex maps. On Jan 24, 2000 @ 9:49pm, Ryan Forsythe wrote: > > Maybe it'll help if you floated that piece of code you're working on, so > we > > can have a few 'extra pairs of eyes' look at it and give some suggestions > on > > how to write an effective code. > > i would, but it's a bit of a mess...and it's c. pretty much what i wanted to > do was make a translation method for this object we had to make. i wanted > it to take in something like '3x^5 + 2x^2 + 4' and spit the coefficient and > the power out into an array. it would be incredibly simple if c had > regexes. but it doesn't, so i had to write this load of 'walk through the > char array until you find 'x', then walk backward until you hit a space, > sticking each char into a buffer array, reverse that array, tack on a /0, > convert it to an int, stick it in the polynomial array then go back to the x > and blah blah blah.' -- Andrew Sweger | N2H2, Incorporated v=206.336.2947 f=206.336.1541 | 900 Fourth Avenue, Suite 3400 Advanced Technologies | Seattle WA 98164-1059 Development | http://www.n2h2.com/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From ryan at erwin.org Mon Jan 24 17:07:54 2000 From: ryan at erwin.org (Ryan Erwin) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: -E ESPUG launch in 43.5 hours! Message-ID: Greetings and apologies from your neighborhood ESPUG Emperor- Over the last week or so my webserver got hosed, as a result, my mail has been getting bounced and I spent most waking minutes getting everything back together. More Importantly, the temporary home of the espug on the web is: -> http://dbedge.com/espug At the espug website, you can find detailed directions and a map! Our fist espug meeting will be @ 7:00pm at Lucent in Redmond. Our meeting topic is GD, the defacto standard for on the fly graphics in perl presented by none other than your espug emperor. Lucent Technologies 6464 185th Ave NE Redmond, WA 98052 The route to Lucent is: * Take 520 East to Redmond-Fall City Road (last exit before the end of the 520 freeway) * Go Right on Redmond-Fall City Road (east) * Straight through 2 lights, then left on 185th Ave (halfway up hill) * Go one short block to the top of the hill and the Lucent Technologies logo will be plainly visible on the main entrance of the Building (to the right) * If you get to the fire station, you have gone too far * Just walk to the front door and someone will be there to let you in from 6:45 to 7:15. If you will be arriving late, please mail me rerwin@ricochet.net so I can make arrangements to let you in. * We will meet in the Columbia Room Thanks, and we hope to see you there! -Ryan Erwin [rerwin@ricochet.net] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tim at consultix-inc.com Tue Jan 25 02:34:20 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: -E ESPUG launch in 43.5 hours! In-Reply-To: ; from ryan@erwin.org on Mon, Jan 24, 2000 at 03:07:54PM -0800 References: Message-ID: <20000125003420.A19520@timji.consultix.wa.com> SPUG-sters, I've created links from the main SPUG page to the interim E-SPUG page, for the convenience of our list readers. Also, please note that the inaugural meeting of E-SPUG, which Ryan identifies below by an "hourly offset", will take place this Wednesday, 1/26, at 7pm. Those of you who have been lurking on this list waiting for an easier drive to a SPUG meeting, this is your call to action! Be there to help get this new group off to a good start! Also, those who have presented topics at SPUG meetings in the past, who find the E-SPUG location convenient, please consider presenting one of your previous topics again at a future E-SPUG meeting ! This means less preparation time for you, with a "re-broadcast" to a fresh audience, and the benefits of your previous speaking experience to help get E-SPUG off the ground. Ryan is E-SPUG Emperor, and he's reachable at ryan@erwin.org. Go E-SPUG ! ! Way to go, Ryan! Shorter way to drive, all (E-)?SPUG-sters! Thanks, David P. ! -Tim P.S. There's no law saying that one cannot attend both SPUG and E-SPUG meetings, or alternate between them, or choose by topic or fluctuating proximity to location, etc. Not yet, anyway! 8-} (but Congress is still in session. . .) ========================================================== | Tim Maher, Ph.D. Tel/Fax: (206) 781-UNIX | | SPUG Founder & Leader Email: spug@halcyon.com | | Seattle Perl Users Group HTTP: www.halcyon.com/spug | ========================================================== On Mon, Jan 24, 2000 at 03:07:54PM -0800, Ryan Erwin wrote: > Greetings and apologies from your neighborhood ESPUG Emperor- > > Over the last week or so my webserver got hosed, as a result, > my mail has been getting bounced and I spent most waking minutes > getting everything back together. > > More Importantly, the temporary home of the espug on the web is: > -> http://dbedge.com/espug > At the espug website, you can find detailed directions and a map! > > Our fist espug meeting will be @ 7:00pm at Lucent in Redmond. > Our meeting topic is GD, the defacto standard for on the fly > graphics in perl presented by none other than your espug emperor. > > Lucent Technologies > 6464 185th Ave NE > Redmond, WA 98052 > > The route to Lucent is: > * Take 520 East to Redmond-Fall City Road (last exit before the end of > the 520 freeway) > * Go Right on Redmond-Fall City Road (east) > * Straight through 2 lights, then left on 185th Ave (halfway up hill) > * Go one short block to the top of the hill and the Lucent Technologies > logo will be plainly visible on the main entrance of the Building (to > the right) > * If you get to the fire station, you have gone too far > * Just walk to the front door and someone will be there to let you in > from 6:45 to 7:15. If you will be arriving late, please mail me > rerwin@ricochet.net so I can make arrangements to let you in. > * We will meet in the Columbia Room > > Thanks, and we hope to see you there! > > -Ryan Erwin [rerwin@ricochet.net] > > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe > Email to majordomo@pm.org: ACTION spug-list your_address > > *========================================================================* | Tim Maher, PhD Consultix & (206) 781-UNIX/8649 | | Pacific Software Gurus, Inc Email: tim@consultix-inc.com | | UNIX/Linux & Perl Training http://www.consultix-inc.com | | 2/22: UNIX 2/28: Perl Modules 2/29: Int. Perl 3/3: Pattern Matching | *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From nik at tiuk.ti.com Wed Jan 26 08:50:05 2000 From: nik at tiuk.ti.com (Nick Ing-Simmons) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: Re: [MM] MM_Unix mod needed? In-Reply-To: <200001062214.OAA10520@beryllium.cobaltgroup.com> from Brian Schieber on Thu, 6 Jan 100 14:14:18 -0800 (PST) References: <200001062214.OAA10520@beryllium.cobaltgroup.com> Message-ID: <200001261450.OAA19581@tiuk.ti.com> Brian Schieber writes: >Hi, > I want to change MakeMaker so that subdirectories do not inherit the > INSTALLSITELIB installation path from the parent Makefile.PL. From > my review of the code, it appears I'd need to change MM_Unix.pm to > change the 'sub tools_other' method to remove the following line: This is object oriented perl. You don't _need_ to change anything, you can use a derived class to do it: package MY; sub tools_other { my $self = shift; local $_ = $self->SUPER::tools_other(@_); ... mess with $_ as you see fit return $_; } -- Nick Ing-Simmons - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From pdarley at serviceintelligence.com Wed Jan 26 09:59:17 2000 From: pdarley at serviceintelligence.com (Peter Darley) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: Mod Perl and persistent objects Message-ID: <000201bf6816$4cfd4860$61ee6fd8@rc-701> Friends, I'm putting together an application, and intend to use Mod Perl. My application will need to load a large data table into memory (~10,000 records) and I would like to load it into an object once and use it for all the perl processes created by Mod Perl. I have some ideas how to get around it if I can't have a single object, but I was hoping that someone out there could tell me how to have the single persistent object. Couldn't find it in any documentation. Thanks for your help! Peter Darley pdarley@serviceintelligence.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tim at consultix-inc.com Wed Jan 26 11:21:50 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: do vs. eval with Data::Dumper Message-ID: <20000126092150.A25500@timji.consultix.wa.com> SPUGsters (and E-SPUGsters), I'm working on a complicated Data::Dumper example for my "Intermediate Perl" course, which worked just fine until I enabled "use strict" and rendered some previously global variables private. (I know, been there, done that, got the T-shirt . . .) I found a solution, but it shouldn't work, from what I read! 8-} Specifically, although the Camel says that "do file" is the same as "eval `cat file`" (p. 158), except for a few minor details, I'm finding evidence that there's a fundamental difference. It looks like "do" is executing the code in its own scope, but eval is using the surrounding scope. Or is there another explanation for the output of this test program? #! /usr/bin/perl -w use strict; my $size=0; open FILE, '> /tmp/dofile' or die; print FILE ' $size=42; '; close FILE or die; print "File contains: ", `cat /tmp/dofile`, "\n"; do '/tmp/dofile'; print "\nDo yields:\t$size\n"; # prints 0 eval `cat /tmp/dofile`; print "\nEval yields:\t$size\n"; # prints 42 OUTPUT: File contains: $size=42; Do yields: 0 Eval yields: 42 Also, I'm trying to make an alias for Data::Dumper::Dump (unexported!), using variations including: *::Dump = \&Data::Dumper::Dump; and *Dump = *Data::Dumper::Dump; but when I hit the line below, I get; Can't coerce array into hash at /usr/lib/Perl5/5.00502/i586-linux/Data/Dumper.pm line 161. print Dump([$size, \%pals, $hosts, \@::words], ["size", "*${prefix}pals", "${prefix}hosts", "*${prefix}words"]); (I set $prefix to :: to reload variables as globals, with "strict" in effect) What's wrong here? And why doesn't Data::Dumper export Dump() in the first place? 8-} TIA, *========================================================================* | Tim Maher, PhD Consultix & (206) 781-UNIX/8649 | | Pacific Software Gurus, Inc Email: tim@consultix-inc.com | | UNIX/Linux & Perl Training http://www.consultix-inc.com | | 2/22: UNIX 2/28: Perl Modules 2/29: Int. Perl 3/3: Pattern Matching | *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From johnl at meer.net Wed Jan 26 11:43:59 2000 From: johnl at meer.net (John Labovitz) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: do vs. eval with Data::Dumper In-Reply-To: Your message of "Wed, 26 Jan 2000 09:21:50 PST." <20000126092150.A25500@timji.consultix.wa.com> Message-ID: > It looks like "do" is executing the code in its own scope, but eval is > using the surrounding scope. that almost makes sense. back in the old days (before i used perl, i must admit), you called subroutines using `do sub'. later, you could use `&sub'; now you can use `sub()'. looking at that, it would make sense that `do $code', where $code is Data::Dumper output, is like calling a subroutine that is implemented with the code in $code. whereas `eval' is simply evaluating that code, inline with your current location (scope). btw, i've had better luck with this: my $code = Data::Dumper([$data]); my $result = do $code; it only helps your problems with globals in that you don't *have* any globals. ;) > And why doesn't Data::Dumper export Dump() in the first place? 8-} because it exports Dumper() instead. ;) john - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From stuart_poulin at yahoo.com Wed Jan 26 11:50:17 2000 From: stuart_poulin at yahoo.com (Stuart Poulin) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: do vs. eval with Data::Dumper Message-ID: <20000126175017.1498.qmail@web114.yahoomail.com> --- Tim Maher/CONSULTIX wrote: > SPUGsters (and E-SPUGsters), > ... > I found a solution, but it shouldn't work, from what I read! 8-} > Specifically, although the Camel says that "do file" is the same as > "eval `cat file`" (p. 158), except for a few minor details, I'm finding > evidence that there's a fundamental difference. > > It looks like "do" is executing the code in its own scope, but eval is > using the surrounding scope. > ... I think I ran into the same thing a while back. Charles DeRykus pointed out that the documentation has been changed. -Stu __________________________________________________ Do You Yahoo!? Talk to your friends online with Yahoo! Messenger. http://im.yahoo.com -------------- next part -------------- > I was looking for a cheap rc type file behavior. I thought I could just use a > "do" file with variables in it - but I wanted "use strict" to be enforced. The > perlfunc man page says: > do 'stat.pl'; > is just like > scalar eval `cat stat.pl`; > This doesn't appear to be true. This is on win98 so s/cat/type/ but "type" is > expensive as far as run time. Is there a way to force a "use strict" on do > files? Stu, I noticed now that Tom Christiansen has amended the docs slightly to say: do $file is like eval `cat $file`, except the former: 1.1 searchs @INC and updates @INC 1.2 bequeaths an unrelated "lexical" scope on the eval'ed code (See: http://x32.deja.com/[ST_rn=ps]/getdoc.xp?AN=503977526&CONTEXT=933300222.1535180873&hitnum=1) That's rather confusing though and doesn't account for instance why 'use constant' is visible whereas 'use strict' pragma isn't in the case below: package main; ... package doit: use strict; # doesn't propagate to 'do file' use constant CONS => 3 # does " " " package main; package doit; do "doit.pl"; #-------------------------- # doit.pl $whoops = "toss_an_error"; print "CONS = ", CONS, "\n"; # prints CONS = 3 So, you'll probably have to insert a 'use strict' in doit.pl unless I'm missing something. Regards, -- Charles DeRykus From johnl at meer.net Wed Jan 26 12:10:33 2000 From: johnl at meer.net (John Labovitz) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: do vs. eval with Data::Dumper In-Reply-To: Your message of "Wed, 26 Jan 2000 09:43:59 PST." Message-ID: i myself wrote: > my $code = Data::Dumper([$data]); > my $result = do $code; of course, i meant `do 'file'' in my examples, not `do $code'. i was only typing, not programming. ;) john - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tim at consultix-inc.com Wed Jan 26 12:19:38 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: Aliasing Data::Dumper::Dump; how ? In-Reply-To: <20000126092150.A25500@timji.consultix.wa.com>; from tim@consultix-inc.com on Wed, Jan 26, 2000 at 09:21:50AM -0800 References: <20000126092150.A25500@timji.consultix.wa.com> Message-ID: <20000126101938.A25840@timji.consultix.wa.com> Thanks for the quick responses to my first question in my previous post; but I had another buried at the end, which is: > > Also, I'm trying to make an alias for Data::Dumper::Dump (unexported!), > using variations including: > *::Dump = \&Data::Dumper::Dump; > and > *Dump = *Data::Dumper::Dump; > > but when I hit the line below > (which works fine with the Data::Dumper:: prefix on it), I get; > Can't coerce array into hash at > /usr/lib/Perl5/5.00502/i586-linux/Data/Dumper.pm line 161. What hash? > > print Dump([$size, \%pals, $hosts, \@::words], > ["size", "*${prefix}pals", "${prefix}hosts", "*${prefix}words"]); > > (I set $prefix to :: to reload variables as globals, with "strict" > in effect) > > What's wrong here? And why doesn't Data::Dumper export Dump() > in the first place? 8-} This is my first attempt at aliasing through typeglobs, and seems like a good place to do it, so I'd appreciate some help with this. Thanks! *========================================================================* | Tim Maher, PhD Consultix & (206) 781-UNIX/8649 | | Pacific Software Gurus, Inc Email: tim@consultix-inc.com | | UNIX/Linux & Perl Training http://www.consultix-inc.com | | 2/22: UNIX 2/28: Perl Modules 2/29: Int. Perl 3/3: Pattern Matching | *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From jeremy at weezel.com Wed Jan 26 12:47:17 2000 From: jeremy at weezel.com (Jeremy Devenport) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: do vs. eval with Data::Dumper References: <20000126092150.A25500@timji.consultix.wa.com> Message-ID: <388F4135.B451DCE9@weezel.com> Maybe this little tidbit from `perldoc -f do` will help. It also differs in that code evaluated with 'do FILENAME' cannot see lexicals in the enclosing scope; 'eval STRING' does. This is listed as one of the minor details in the second paragraph. Jeremy Tim Maher/CONSULTIX wrote: > > SPUGsters (and E-SPUGsters), > > I'm working on a complicated Data::Dumper example for my "Intermediate > Perl" course, which worked just fine until I enabled "use strict" and > rendered some previously global variables private. > (I know, been there, done that, got the T-shirt . . .) > > I found a solution, but it shouldn't work, from what I read! 8-} > Specifically, although the Camel says that "do file" is the same as > "eval `cat file`" (p. 158), except for a few minor details, I'm finding > evidence that there's a fundamental difference. > > It looks like "do" is executing the code in its own scope, but eval is > using the surrounding scope. > > Or is there another explanation for the output of this test program? > > #! /usr/bin/perl -w > use strict; > > my $size=0; > > open FILE, '> /tmp/dofile' or die; > print FILE ' $size=42; '; > close FILE or die; > > print "File contains: ", `cat /tmp/dofile`, "\n"; > > do '/tmp/dofile'; > print "\nDo yields:\t$size\n"; # prints 0 > > eval `cat /tmp/dofile`; > print "\nEval yields:\t$size\n"; # prints 42 > > OUTPUT: > > File contains: $size=42; > > Do yields: 0 > > Eval yields: 42 > > Also, I'm trying to make an alias for Data::Dumper::Dump (unexported!), > using variations including: > *::Dump = \&Data::Dumper::Dump; > and > *Dump = *Data::Dumper::Dump; > > but when I hit the line below, I get; > Can't coerce array into hash at > /usr/lib/Perl5/5.00502/i586-linux/Data/Dumper.pm line 161. > > print Dump([$size, \%pals, $hosts, \@::words], > ["size", "*${prefix}pals", "${prefix}hosts", "*${prefix}words"]); > > (I set $prefix to :: to reload variables as globals, with "strict" > in effect) > > What's wrong here? And why doesn't Data::Dumper export Dump() > in the first place? 8-} > > TIA, > *========================================================================* > | Tim Maher, PhD Consultix & (206) 781-UNIX/8649 | > | Pacific Software Gurus, Inc Email: tim@consultix-inc.com | > | UNIX/Linux & Perl Training http://www.consultix-inc.com | > | 2/22: UNIX 2/28: Perl Modules 2/29: Int. Perl 3/3: Pattern Matching | > *========================================================================* > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe > Email to majordomo@pm.org: ACTION spug-list your_address - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tim at consultix-inc.com Wed Jan 26 12:57:13 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: do vs. eval with Data::Dumper In-Reply-To: <388F4135.B451DCE9@weezel.com>; from jeremy@weezel.com on Wed, Jan 26, 2000 at 10:47:17AM -0800 References: <20000126092150.A25500@timji.consultix.wa.com> <388F4135.B451DCE9@weezel.com> Message-ID: <20000126105713.A26095@timji.consultix.wa.com> On Wed, Jan 26, 2000 at 10:47:17AM -0800, Jeremy Devenport wrote: > Maybe this little tidbit from `perldoc -f do` will help. > > It also differs in that code evaluated with 'do FILENAME' > cannot see lexicals in the enclosing scope; 'eval STRING' does. > > This is listed as one of the minor details in the second paragraph. Not if you're looking at the Camel, p. 158! It omits that "minor detail"! Guess I need to have less faith in Camels from now on ... > > Jeremy *========================================================================* | Tim Maher, PhD Consultix & (206) 781-UNIX/8649 | | Pacific Software Gurus, Inc Email: tim@consultix-inc.com | | UNIX/Linux & Perl Training http://www.consultix-inc.com | | 2/22: UNIX 2/28: Perl Modules 2/29: Int. Perl 3/3: Pattern Matching | *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From smorton at pobox.com Wed Jan 26 13:49:41 2000 From: smorton at pobox.com (Sanford Morton) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: Does a class module support a method? Message-ID: <20000126194941.4D771325BA@scribe.pobox.com> I have a module which creates an internal or private object from a class module. In my module, I can use can() to determine if the object supports certain methods. What can I do in the script which uses my module, but which does not routinely have access to the internal object, to determine if that private object supports certain methods? Presumably, I cannot use can() in the script without creating a useless instance from the class module. I hope to make the E-spug meeting tonight. Sandy - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tim at consultix-inc.com Wed Jan 26 15:28:30 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: Has TPJ hit Seattle yet? Message-ID: <20000126132830.A26923@timji.consultix.wa.com> SPUG-o-maniacs, When I placed my new, improved, full-color advertisement for the January, 2000 issue of The Perl Journal, I was told distribution would start 1/10. Yet I still haven't received my copy. This worries me, because they keep sending me subscription renewal notices, despite the fact that I keep proving to them that I already paid for renewal. So, have any Seattle subscribers received the new issue yet? Maybe it's just that I was left out? *========================================================================* | Tim Maher, PhD Consultix & (206) 781-UNIX/8649 | | Pacific Software Gurus, Inc Email: tim@consultix-inc.com | | UNIX/Linux & Perl Training http://www.consultix-inc.com | | 2/22: UNIX 2/28: Perl Modules 2/29: Int. Perl 3/3: Pattern Matching | *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From matw at halcyon.com Wed Jan 26 15:20:20 2000 From: matw at halcyon.com (Mathew D. Watson) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: one of those 'other' programming languages In-Reply-To: <001401bf66f7$ffadd1c0$d29227d8@net> References: <001d01bf66c6$ebb30900$d29227d8@net> <005101bf66f3$7fb1d470$6d510ed1@test> Message-ID: <3.0.5.32.20000126132020.009211c0@mail.halcyon.com> I looked into calling Perl from C and remember that it gets pretty hairy. You in essence link the perl interpreter and libraries into your c program. I got pretty scared. On the other hand ... can you write a simple perl script that reads '3x^5 + 2x^2 + 4' from the standard input and then writes something like '3,0,0,2,4' (these are the coefficients) to the standard output? And then run the script from within c? My programmming skills have dipped to near nothing, but here's a crude way to do what I have in mind: system(" myscript.pl < equation.txt > coefficients.txt "); Parsing the coefficient string could probably be done with ... strtok()? Mat At 09:49 PM 1/24/00 -0800, Ryan wrote: >> Maybe it'll help if you floated that piece of code you're working on, so >we >> can have a few 'extra pairs of eyes' look at it and give some suggestions >on >> how to write an effective code. > >i would, but it's a bit of a mess...and it's c. pretty much what i wanted to >do was make a translation method for this object we had to make. i wanted >it to take in something like '3x^5 + 2x^2 + 4' and spit the coefficient and >the power out into an array. it would be incredibly simple if c had >regexes. but it doesn't, so i had to write this load of 'walk through the >char array until you find 'x', then walk backward until you hit a space, >sticking each char into a buffer array, reverse that array, tack on a /0, >convert it to an int, stick it in the polynomial array then go back to the x >and blah blah blah.' > >it ballooned, and it wasn't very well written. if anyone's still interested >in looking at it, i've got the code here: >www.flamingweasel.com/c.html > >and sorry about the formatting...tabs always turn a little screwy across >different programs > > ---------------------------------------------------------------- Mathew D. Watson matw@halcyon.com ---------------------------------------------------------------- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tim at consultix-inc.com Wed Jan 26 16:00:42 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: die from BEGIN; how suppress ugly message? Message-ID: <20000126140042.A27039@timji.consultix.wa.com> SPUGicans, Does anybody know an elegant, simple (might be asking too much there) way to trap/suppress/avoid this kind of ugly message when I call exit or die from within BEGIN? $ turbo_fax Usage: turbo_fax file1 [file2 . . .] BEGIN failed--compilation aborted at ./in_place line 19. $ In some cases, I can set a flag in BEGIN and have "$fatal and die" as the first line of the program body, but if I'm using -n/-p, I need to get a line of input before dying, which ruins that approach. There should be a way . . . What it is? 8-} -Tim P.S. Going for a personal daily-posting record today! If I don't shutup, as the list-owner I'll have to rebuke myself! *========================================================================* | Tim Maher, PhD Consultix & (206) 781-UNIX/8649 | | Pacific Software Gurus, Inc Email: tim@consultix-inc.com | | UNIX/Linux & Perl Training http://www.consultix-inc.com | | 2/22: UNIX 2/28: Perl Modules 2/29: Int. Perl 3/3: Pattern Matching | *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tim at consultix-inc.com Wed Jan 26 16:05:07 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: Re: die from BEGIN; how suppress ugly message? In-Reply-To: <20000126140042.A27039@timji.consultix.wa.com>; from tim@consultix-inc.com on Wed, Jan 26, 2000 at 02:00:42PM -0800 References: <20000126140042.A27039@timji.consultix.wa.com> Message-ID: <20000126140507.A27105@timji.consultix.wa.com> On Wed, Jan 26, 2000 at 02:00:42PM -0800, Tim Maher/CONSULTIX wrote: > SPUGicans, > > Does anybody know an elegant, simple (might be asking too much there) > way to trap/suppress/avoid this kind of ugly message when I call > exit or die from within BEGIN? > > $ turbo_fax > Usage: turbo_fax file1 [file2 . . .] > BEGIN failed--compilation aborted at ./in_place line 19. > $ Had a brainstorm just after posting the question to the list: open STDERR, "> /dev/null" does the trick. Anybody know other solutions? *========================================================================* | Tim Maher, PhD Consultix & (206) 781-UNIX/8649 | | Pacific Software Gurus, Inc Email: tim@consultix-inc.com | | UNIX/Linux & Perl Training http://www.consultix-inc.com | | 2/22: UNIX 2/28: Perl Modules 2/29: Int. Perl 3/3: Pattern Matching | *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From andy at n2h2.com Wed Jan 26 16:11:15 2000 From: andy at n2h2.com (Andrew Sweger) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: Has TPJ hit Seattle yet? In-Reply-To: <20000126132830.A26923@timji.consultix.wa.com> Message-ID: Okay, now you got me worried. I've been wondering why it's been so darn long since I've received one (and I just got a free two year extension recently too). Hmmm. On Jan 26, 2000 @ 1:28pm, Tim Maher/CONSULTIX wrote: > When I placed my new, improved, full-color advertisement for the > January, 2000 issue of The Perl Journal, I was told distribution > would start 1/10. Yet I still haven't received my copy. > This worries me, because they keep sending me subscription renewal > notices, despite the fact that I keep proving to them that I already > paid for renewal. > > So, have any Seattle subscribers received the new issue yet? > Maybe it's just that I was left out? -- Andrew Sweger | N2H2, Incorporated v=206.336.2947 f=206.336.1541 | 900 Fourth Avenue, Suite 3400 Advanced Technologies | Seattle WA 98164-1059 Development | http://www.n2h2.com/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From andy at n2h2.com Wed Jan 26 16:17:58 2000 From: andy at n2h2.com (Andrew Sweger) Date: Wed Aug 4 00:07:04 2004 Subject: SPUG: Does a class module support a method? In-Reply-To: <20000126194941.4D771325BA@scribe.pobox.com> Message-ID: On Jan 26, 2000 @ 2:49pm, Sanford Morton wrote: > I have a module which creates an internal or private object from a > class module. In my module, I can use can() to determine if the object > supports certain methods. > > What can I do in the script which uses my module, but which does not > routinely have access to the internal object, to determine if that > private object supports certain methods? Presumably, I cannot use > can() in the script without creating a useless instance from the class > module. How about an instance method defined in your class that calls the can() method on the private object hidden within your class. Your class's can() would override UNIVERSAL::can() then. I know Damian would probably frown at me and express serious doubts about my upbringing. Come on everybody, let's do the can(can())! > I hope to make the E-spug meeting tonight. See you there. -- Andrew Sweger | N2H2, Incorporated v=206.336.2947 f=206.336.1541 | 900 Fourth Avenue, Suite 3400 Advanced Technologies | Seattle WA 98164-1059 Development | http://www.n2h2.com/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From slagel at geospiza.com Wed Jan 26 16:41:20 2000 From: slagel at geospiza.com (Joe Slagel) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: Has TPJ hit Seattle yet? References: <20000126132830.A26923@timji.consultix.wa.com> Message-ID: <388F7810.1A1D692F@geospiza.com> Tim Maher/CONSULTIX wrote: > SPUG-o-maniacs, > > When I placed my new, improved, full-color advertisement for the > January, 2000 issue of The Perl Journal, I was told distribution > would start 1/10. Yet I still haven't received my copy. > This worries me, because they keep sending me subscription renewal > notices, despite the fact that I keep proving to them that I already > paid for renewal. > > So, have any Seattle subscribers received the new issue yet? > Maybe it's just that I was left out? > > *========================================================================* > | Tim Maher, PhD Consultix & (206) 781-UNIX/8649 | > | Pacific Software Gurus, Inc Email: tim@consultix-inc.com | > | UNIX/Linux & Perl Training http://www.consultix-inc.com | > | 2/22: UNIX 2/28: Perl Modules 2/29: Int. Perl 3/3: Pattern Matching | > *========================================================================* > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe > Email to majordomo@pm.org: ACTION spug-list your_address Come to think of it...we haven't gotten our copy in a * long * time either. - joe - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From andy at n2h2.com Wed Jan 26 16:53:07 2000 From: andy at n2h2.com (Andrew Sweger) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: Has TPJ hit Seattle yet? In-Reply-To: Message-ID: Okay! Okay! Sheesh. Everybody stop asking already. I "won" it in the quiz show at TPC 3.0 last year. I have witnesses! Either that or Jon just thinks I deserve it. :) On Jan 26, 2000 @ 2:11pm, Andrew Sweger wrote: > Okay, now you got me worried. I've been wondering why it's been so darn > long since I've received one (and I just got a free two year extension > recently too). Hmmm. -- Andrew Sweger | N2H2, Incorporated v=206.336.2947 f=206.336.1541 | 900 Fourth Avenue, Suite 3400 Advanced Technologies | Seattle WA 98164-1059 Development | http://www.n2h2.com/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From rcroot at atl.com Wed Jan 26 17:01:01 2000 From: rcroot at atl.com (Rick Croote) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: die from BEGIN; how suppress ugly message? References: <20000126140042.A27039@timji.consultix.wa.com> Message-ID: <004c01bf6851$3753c620$27fa3b95@atl.com> I do not get any ugly messages while using "exit" from within a BEGIN block. I do get them from "die", no matter what. I didn't try your method in your follow up. --- Rick Croote ATL Ultrasound ----- Original Message ----- From: Tim Maher/CONSULTIX To: Sent: Wednesday, January 26, 2000 2:00 PM Subject: SPUG: die from BEGIN; how suppress ugly message? > SPUGicans, > > Does anybody know an elegant, simple (might be asking too much there) > way to trap/suppress/avoid this kind of ugly message when I call > exit or die from within BEGIN? > > $ turbo_fax > Usage: turbo_fax file1 [file2 . . .] > BEGIN failed--compilation aborted at ./in_place line 19. > $ > > In some cases, I can set a flag in BEGIN and have "$fatal and die" > as the first line of the program body, but if I'm using -n/-p, I > need to get a line of input before dying, which ruins that approach. > > There should be a way . . . What it is? 8-} > > -Tim > P.S. Going for a personal daily-posting record today! If I don't shutup, > as the list-owner I'll have to rebuke myself! > > *========================================================================* > | Tim Maher, PhD Consultix & (206) 781-UNIX/8649 | > | Pacific Software Gurus, Inc Email: tim@consultix-inc.com | > | UNIX/Linux & Perl Training http://www.consultix-inc.com | > | 2/22: UNIX 2/28: Perl Modules 2/29: Int. Perl 3/3: Pattern Matching | > *========================================================================* > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe > Email to majordomo@pm.org: ACTION spug-list your_address > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From jimfl at colltech.com Wed Jan 26 17:03:15 2000 From: jimfl at colltech.com (jimfl) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: Re: die from BEGIN; how suppress ugly message? In-Reply-To: <20000126140507.A27105@timji.consultix.wa.com> Message-ID: <1362929.3157887795@erdos.nwest.attws.com> --On Wednesday, January 26, 2000 2:05 PM -0800 "Tim Maher/CONSULTIX" wrote: > > Does anybody know an elegant, simple (might be asking too much > there) > way to trap/suppress/avoid this kind of ugly message when I > call > exit or die from within BEGIN? > > > > $ turbo_fax > > Usage: turbo_fax file1 [file2 . . .] > > BEGIN failed--compilation aborted at ./in_place line 19. > > $ > > Had a brainstorm just after posting the question to the list: > open STDERR, "> /dev/null" > does the trick. Anybody know other solutions? You should only get the ickyness on a die, not on an exit. You can trap the die, and exit gracefull with some variation on the theme: BEGIN { $SIG{__DIE__} = sub{exit}; ... die(); ... } -- Jim Flanagan Collective Technologies jimfl@colltech.com http://www.colltech.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From ced at carios2.ca.boeing.com Wed Jan 26 16:59:39 2000 From: ced at carios2.ca.boeing.com (Charles DeRykus) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: die from BEGIN; how suppress ugly message? Message-ID: <200001262259.OAA11906@carios2.ca.boeing.com> > open STDERR, ">/dev/null" If I catch your meaning, could you simply wrap the BEGIN innards in an eval... ? BEGIN { eval { print "foo\n"; die "bar" }; } Any fatals will be trapped and available in $@ when the BEGIN block terminates. Hope this helps, -- Charles DeRykus - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From slagel at geospiza.com Wed Jan 26 17:33:34 2000 From: slagel at geospiza.com (Joe Slagel) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: ISP Recommendations Message-ID: <388F844E.7A4F42F9@geospiza.com> Does anyone have a ISP recommendations? We're considering switching. Any recommendations would be great! - Joe - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From jope-spug at n2h2.com Wed Jan 26 17:26:46 2000 From: jope-spug at n2h2.com (El JoPe Magnifico) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: Aliasing Data::Dumper::Dump; how ? In-Reply-To: <20000126101938.A25840@timji.consultix.wa.com> Message-ID: Answer to both questions: Dump() is meant to be used as an OO-style method. If you want a procedural interface, use Dumper() instead, or make a wrapper around Dump(). Look at the first part of Dump()... zub Dump { my($s) = shift; my(@out, $val, $name); my($i) = 0; local(@post); $s = $s->new(@_) unless ref $s; for $val (@{$s->{todump}}) { ... Because you're not calling it as a method, neither an object nor a package is name is passed as the first argument, contrary to what it expects. It then gets confused because all it does is check whether $s is a ref, period. In your usage, it is a ref... to an array though, not an object. And the first thing it tries to do with that ref is dereference it as a hash. Maybe it should check whether the ref is a ref to ARRAY, and if so, call the new() method, but instead using __PACKAGE__ for the package name, rather than the first argument (as in Data::Dumper->Dump())? Mmmm... nah! Proper sanity-checking is for weenies! =) -jp On Wed, 26 Jan 2000, Tim Maher/CONSULTIX wrote: >> Also, I'm trying to make an alias for Data::Dumper::Dump (unexported!), >> using variations including: >> *::Dump = \&Data::Dumper::Dump; >> and >> *Dump = *Data::Dumper::Dump; >> >> but when I hit the line below >> (which works fine with the Data::Dumper:: prefix on it), I get; >> Can't coerce array into hash at >> /usr/lib/Perl5/5.00502/i586-linux/Data/Dumper.pm line 161. > > What hash? > >> print Dump([$size, \%pals, $hosts, \@::words], >> ["size", "*${prefix}pals", "${prefix}hosts", "*${prefix}words"]); >> >> (I set $prefix to :: to reload variables as globals, with "strict" >> in effect) >> >> What's wrong here? And why doesn't Data::Dumper export Dump() >> in the first place? 8-} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From greg.mushen at gettyimages.com Wed Jan 26 17:24:43 2000 From: greg.mushen at gettyimages.com (Greg Mushen) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: Has TPJ hit Seattle yet? Message-ID: <990EFA5D5CA7D311B44300A0C9D5E1492210CF@SEAEXCHG02> I haven't received mine either. Hmmmmm. -----Original Message----- From: Joe Slagel [mailto:slagel@geospiza.com] Sent: Wednesday, January 26, 2000 2:41 PM To: spug-list@pm.org Subject: Re: SPUG: Has TPJ hit Seattle yet? Tim Maher/CONSULTIX wrote: > SPUG-o-maniacs, > > When I placed my new, improved, full-color advertisement for the > January, 2000 issue of The Perl Journal, I was told distribution > would start 1/10. Yet I still haven't received my copy. > This worries me, because they keep sending me subscription renewal > notices, despite the fact that I keep proving to them that I already > paid for renewal. > > So, have any Seattle subscribers received the new issue yet? > Maybe it's just that I was left out? > > *========================================================================* > | Tim Maher, PhD Consultix & (206) 781-UNIX/8649 | > | Pacific Software Gurus, Inc Email: tim@consultix-inc.com | > | UNIX/Linux & Perl Training http://www.consultix-inc.com | > | 2/22: UNIX 2/28: Perl Modules 2/29: Int. Perl 3/3: Pattern Matching | > *========================================================================* > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe > Email to majordomo@pm.org: ACTION spug-list your_address Come to think of it...we haven't gotten our copy in a * long * time either. - joe - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From Scott.Blachowicz at seaslug.org Wed Jan 26 17:40:40 2000 From: Scott.Blachowicz at seaslug.org (Scott Blachowicz) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: Has TPJ hit Seattle yet? In-Reply-To: <20000126132830.A26923@timji.consultix.wa.com>; from Tim Maher/CONSULTIX on Wed, Jan 26, 2000 at 01:28:30PM -0800 References: <20000126132830.A26923@timji.consultix.wa.com> Message-ID: <20000126154040.A34954@sabami.seaslug.org> On Wed, Jan 26, 2000 at 01:28:30PM -0800, Tim Maher/CONSULTIX wrote: > So, have any Seattle subscribers received the new issue yet? > Maybe it's just that I was left out? Haven't gotten mine yet...didn't they just change publishers with the last issue? Wonder if that could be related? Oh...there's an idea...I just went to www.tpj.com (which redirects to www.itknowledge.com/tpj/) and it has issue #15 (Fall 99) as the current issue and mentions "Issue #16 will ship mid-January", so I guess we're jumping the gun here a bit :-). -- Scott.Blachowicz@seaslug.org - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tim at consultix-inc.com Wed Jan 26 18:16:33 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: die from BEGIN; how suppress ugly message? In-Reply-To: <200001262259.OAA11906@carios2.ca.boeing.com>; from ced@carios2.ca.boeing.com on Wed, Jan 26, 2000 at 02:59:39PM -0800 References: <200001262259.OAA11906@carios2.ca.boeing.com> Message-ID: <20000126161633.A27590@timji.consultix.wa.com> On Wed, Jan 26, 2000 at 02:59:39PM -0800, Charles DeRykus wrote: > > open STDERR, ">/dev/null" > > If I catch your meaning, could you simply wrap > the BEGIN innards in an eval... ? > > BEGIN { eval { print "foo\n"; die "bar" }; } > > Any fatals will be trapped and available in $@ > when the BEGIN block terminates. - Been there, tried that (before posting) As I said, if you have -n/-p turned on, you can't test $@ to decide what to do about the trapped exception until after you get a line of input! And you *really need* BEGIN when using -n/-p, otherwise everything is in the implicit input-reading loop! Hence my desire for another solution to suppressing errors within BEGIN, and I'm happy with the redirection to /dev/null idea. Thanks, -Tim > > Hope this helps, > -- > Charles DeRykus -- *========================================================================* | Tim Maher, PhD Consultix & (206) 781-UNIX/8649 | | Pacific Software Gurus, Inc Email: tim@consultix-inc.com | | UNIX/Linux & Perl Training http://www.consultix-inc.com | | 2/22: UNIX 2/28: Perl Modules 2/29: Int. Perl 3/3: Pattern Matching | *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From sab at rresearch.com Wed Jan 26 18:41:29 2000 From: sab at rresearch.com (Scott Blachowicz) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: die from BEGIN; how suppress ugly message? In-Reply-To: <20000126161633.A27590@timji.consultix.wa.com>; from Tim Maher/CONSULTIX on Wed, Jan 26, 2000 at 04:16:33PM -0800 References: <200001262259.OAA11906@carios2.ca.boeing.com> <20000126161633.A27590@timji.consultix.wa.com> Message-ID: <20000126164129.A36019@sabami.seaslug.org> On Wed, Jan 26, 2000 at 04:16:33PM -0800, Tim Maher/CONSULTIX wrote: > And you *really need* BEGIN when using -n/-p, otherwise > everything is in the implicit input-reading loop! Well...there's an easy workaround - don't use -n/-p. Just code the implicit input-reading loop explicitly. :-). Scott.Blachowicz@seaslug.org - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tim at consultix-inc.com Wed Jan 26 18:48:53 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: Aliasing Data::Dumper::Dump; how ? In-Reply-To: ; from jope-spug@n2h2.com on Wed, Jan 26, 2000 at 03:26:46PM -0800 References: <20000126101938.A25840@timji.consultix.wa.com> Message-ID: <20000126164853.A27769@timji.consultix.wa.com> On Wed, Jan 26, 2000 at 03:26:46PM -0800, El JoPe Magnifico wrote: > Answer to both questions: Dump() is meant to be used as an OO-style > method. If you want a procedural interface, use Dumper() instead, > or make a wrapper around Dump(). Look at the first part of Dump()... Thanks for the *z*ub! But you're missing my point; Dump() works perfectly well in a non-OO program (although I'll admit perhaps it shouldn't), and in fact examples of using Data::Dumper::Dump in this way appear in many of the Perl books I've got on my shelf (e.g., Effective Perl, p. 148). I'm very new to typeglobs, and figured I was just typing the wrong stuff, but my original question was simply how do I make an alias so I can type Dump rather than Data::Dumper::Dump, and still have my program work. What you're telling me is that it shouldn't have worked in the first place, but it definitely did. Now I'm really confused (but I'm used to that state! 8-}) Maybe the better question is why does it work at all in the form shown in Effective Perl p. 148 (Item 37). -Tim > > zub Dump { > my($s) = shift; > my(@out, $val, $name); > my($i) = 0; > local(@post); > > $s = $s->new(@_) unless ref $s; > > for $val (@{$s->{todump}}) { > ... > > Because you're not calling it as a method, neither an object nor a > package is name is passed as the first argument, contrary to what it > expects. It then gets confused because all it does is check whether > $s is a ref, period. In your usage, it is a ref... to an array though, > not an object. And the first thing it tries to do with that ref is > dereference it as a hash. Good explanation, but it doesn't fit the evidence that it actually works perfectly well when invoked with an annonymous array ref as the first argument (without aliasing being used). > > Maybe it should check whether the ref is a ref to ARRAY, and if so, > call the new() method, but instead using __PACKAGE__ for the package > name, rather than the first argument (as in Data::Dumper->Dump())? > Mmmm... nah! Proper sanity-checking is for weenies! =) > -jp > > On Wed, 26 Jan 2000, Tim Maher/CONSULTIX wrote: > >> Also, I'm trying to make an alias for Data::Dumper::Dump (unexported!), > >> using variations including: > >> *::Dump = \&Data::Dumper::Dump; > >> and > >> *Dump = *Data::Dumper::Dump; > >> > >> but when I hit the line below > >> (which works fine with the Data::Dumper:: prefix on it), I get; > >> Can't coerce array into hash at > >> /usr/lib/Perl5/5.00502/i586-linux/Data/Dumper.pm line 161. > > > > What hash? > > > >> print Dump([$size, \%pals, $hosts, \@::words], > >> ["size", "*${prefix}pals", "${prefix}hosts", "*${prefix}words"]); > >> > >> (I set $prefix to :: to reload variables as globals, with "strict" > >> in effect) > >> > >> What's wrong here? And why doesn't Data::Dumper export Dump() > >> in the first place? 8-} > -- *========================================================================* | Tim Maher, PhD Consultix & (206) 781-UNIX/8649 | | Pacific Software Gurus, Inc Email: tim@consultix-inc.com | | UNIX/Linux & Perl Training http://www.consultix-inc.com | | 2/22: UNIX 2/28: Perl Modules 2/29: Int. Perl 3/3: Pattern Matching | *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From taliesin at speakeasy.org Wed Jan 26 18:54:11 2000 From: taliesin at speakeasy.org (taliesin@speakeasy.org) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: ISP Recommendations In-Reply-To: <388F844E.7A4F42F9@geospiza.com> Message-ID: On Wed, 26 Jan 2000, Joe Slagel wrote: >Does anyone have a ISP recommendations? We're considering >switching. Any recommendations would be great! I can unreservedly recommend Speakeasy for a personal ISP.... (they also do business customers, but I don't know anything about that... if they're as good on that end of the biz as they are on mine, though...) Speakeasy started life as an Internet Cafe not too far from Pike Place. They're still there, but they now offer dialup 56k in the Seattle area, and Covad DSL in select cities nationwide (basically wherever Covad is). They give you a free 56k account when you sign up for DSL, which then converts to a 5hrs/month backup thingy for if you're on the road or the link is down.... Customer service is excellent, they're Linux-friendly, they have all sorts of FAQ's on how to set things up, including basic DNS config if you have your own domain (they'll secondary for free if you configure your own primary)..... I'm very happy. Covad hardware is an Efficient Networks SpeedStream 5620 hooked to my Linux box... I have only had one downtime in almost a month of the service, and it was scheduled and alerted to me by email almost 24 hours in advance (i.e. as soon as they knew), and it was only 15 minutes. They're hooked directly to the PNAP here in Seattle, and access Sprintlink, AlterNet, Qwest, and everyone else directly from there. They also have some gaming servers inside their local net, for those interested in blowing things up, as well as a fairly extensive WinDoze shareware archive. (Actually, they do have some Linux stuff as well, but it looks like it's mostly gameservers... but hey, get a few folks around with DSL, set up a tourney on your own box, and go at it.... no need to dedicate a box to the server, we have enough horsepower to do both!) http://www.speakeasy.net they rock. YYMV, #include -- Glenn Stone RHCE taliesin@speakeasy.org (the .org is for personal accounts, you get .net for biz ones) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From kmeyer at aa.net Wed Jan 26 19:42:20 2000 From: kmeyer at aa.net (Kenneth W. Meyer) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: ISP Recommendations Message-ID: <01BF6824.B2B9DDE0@host211.207-55-127.aadsl.com> Joe - I have been with Alternate Access for several years, and DSL with them for about a year. You can get their DSL connection for $17.95, and through US West, the wire is $29.95 for a direct connection and $19.95 for a pooled access (at the DSLAM, not at the ISP). With the latter, you're still always connected to the phone-line, but you need to be assigned a port when you light-up the keyboard, much like dialing-in and getting a modem port. I have heard some complaints about service in the GTE domain, but what else is new?! AA also provides Unix shell accounts for $5, and a static address costs the same; they run on Solaris and Linux (not sure if they have an NT box). I don't know the details of their ability to host all manner of active web apps. They have a real Geek technical director (who started the company) and they are really fastidious about connection quality. They also will connect your DSL via Covad, but this service is substantially more expensive. I have had no real problems at all with US West reliability. Only one down-time that I am sure was their problem. However, there can be a real hassle getting support from these guys, and you may end up speaking with Denver and Phoenix and Seattle before it's over; I would imagine that Covad is much better about this. We had an outage on our phone line; and for about a week they kept bouncing me around and claiming that the problem was in our house. Of course, I swapped the wires for line 1 and line 2 at the outside box and the problem remained on the other line, so they finally fixed it. I think they drowned some cables during a spate of heavy rain, but it was Hell to get them to face up to it. In all, I find this to be a good service with a real local presence, and it seems to me to be a good price for something that doesn't involve accepting obnoxious advertisements. Anyone with contrary experience out there? Ken Meyer kmeyer@aa.net ---------- From: Joe Slagel[SMTP:slagel@geospiza.com] Sent: Wednesday, January 26, 2000 3:33 PM To: spug-list@pm.org Subject: SPUG: ISP Recommendations Does anyone have a ISP recommendations? We're considering switching. Any recommendations would be great! - Joe - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From slagel at geospiza.com Wed Jan 26 20:39:49 2000 From: slagel at geospiza.com (Joe Slagel) Date: Wed Aug 4 00:07:05 2004 Subject: [Fwd: Re: SPUG: ISP Recommendations US West and DSL] Message-ID: <388FAFF5.D46D4C8@geospiza.com> "Kenneth W. Meyer" wrote: > Joe - > > I have been with Alternate Access for several years, and DSL with them for about a year. You can get their DSL connection for $17.95, and through US West, the wire is $29.95 for a direct connection and $19.95 for a pooled access (at the DSLAM, not at the ISP). With the latter, you're still always connected to the phone-line, but you need to be assigned a port when you light-up the keyboard, much like dialing-in and getting a modem port. I have heard some complaints about service in the GTE domain, but what else is new?! Both home and work are currently with AA.net and I was thinking about alternatives because of a number of reasons. > I have had no real problems at all with US West reliability. Only one down-time that I am sure was their problem. However, there can be a real hassle getting support from these guys, and you may end up speaking with Denver and Phoenix and Seattle before it's over; I would imagine that Covad is much better about this. We had an outage on our phone line; and for about a week they kept bouncing me around and claiming that the problem was in our house. Of course, I swapped the wires for line 1 and line 2 at the outside box and the problem remained on the other line, so they finally fixed it. I think they drowned some cables during a spate of heavy rain, but it was Hell to get them to face up to it. > Funny, I was having exactly the same problem with my US West DSL. The service rep said the same thing, the problem was in the house (he said he left the cover of the box unscrewed). Interestingly enough when I checked the box he had looked at the WRONG box, and tested a disconnected second line to the house. Fiddling with the right box seemed to get everything to work. Funny, I thought it might have been the heavy rain too... > > In all, I find this to be a good service with a real local presence, and it seems to me to be a good price for something that doesn't involve accepting obnoxious advertisements. > > Anyone with contrary experience out there? > > Ken Meyer > kmeyer@aa.net Thanks for the info - Joe - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tim at consultix-inc.com Wed Jan 26 21:19:22 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: ISP -Stifle! Message-ID: <20000126191922.A28241@timji.consultix.wa.com> ISP Recommendations don't belong on the SPUG-list, which is experiencing enough traffic these days from real Perl-related questions. Please hold all further discussions on this topic off the list. (As the list-owner, I see the unZubscribe requests start pouring in when list-traffic gets heavy, as it did today, or when off-topic posts start to creep in.) Thanks, ========================================================== | Tim Maher, Ph.D. Tel/Fax: (206) 781-UNIX | | SPUG Founder & Leader Email: spug@halcyon.com | | Seattle Perl Users Group HTTP: www.halcyon.com/spug | ========================================================== - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From kmeyer at aa.net Wed Jan 26 21:42:22 2000 From: kmeyer at aa.net (Kenneth W. Meyer) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: ISP -Stifle! Message-ID: <01BF6835.776AB320@host211.207-55-127.aadsl.com> You're the boss, Tim; but it seems to me that your list isn't worth much to anyone without access to an ISP that provides good service. For instance, since I hooked up to DSL, I poll my e-mail almost constantly, whereas the dial-up process was a real pain, as was the download time, so I could avoid it for days. And where can one find a more knowledgeable group to inquire about these essential foundation functions than in such a sophisticated user community? Also, I say that someone who signs up to find out about PERL and then bails out when the info flow is substantial was probably just a curiousity-seeker anyway, and the high volume of PERL communications is certainly in no danger of being overwhelmed by these other occasional subjects. If it's still legal to pose such a question, but responses must be off-line, then I suppose other interested parties will have to contact the person asking the question and ask him to forward any answers he receives. Bummer. Ken Meyer kmeyer@aa.net ---------- From: Tim Maher/CONSULTIX[SMTP:tim@consultix-inc.com] Sent: Wednesday, January 26, 2000 7:19 PM To: spug-list@pm.org Subject: Re: SPUG: ISP -Stifle! ISP Recommendations don't belong on the SPUG-list, which is experiencing enough traffic these days from real Perl-related questions. Please hold all further discussions on this topic off the list. (As the list-owner, I see the unZubscribe requests start pouring in when list-traffic gets heavy, as it did today, or when off-topic posts start to creep in.) Thanks, ========================================================== | Tim Maher, Ph.D. Tel/Fax: (206) 781-UNIX | | SPUG Founder & Leader Email: spug@halcyon.com | | Seattle Perl Users Group HTTP: www.halcyon.com/spug | ========================================================== - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tim at consultix-inc.com Wed Jan 26 21:59:02 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: Sources of ISP Info Message-ID: <20000126195902.C28358@timji.consultix.wa.com> I probably should have stated this earlier, but I got preoccupied with reposting my ISP-Stifle! message after it bounced the first time due to "unZubscribe" being present! If you want to get info on good Seattle ISPs, your can sign up for the linux-list@ssc.com, where they periodically host discussions on this topic, or you could look for recent discussions on www.deja.com (probably from the seattle.general newsgroup). I understand the motiviation to post to the spug-list with these inquiries, but there really are better places to hold those discussions. -Tim ========================================================== | Tim Maher, Ph.D. Tel/Fax: (206) 781-UNIX | | SPUG Founder & Leader Email: spug@halcyon.com | | Seattle Perl Users Group HTTP: www.halcyon.com/spug | ========================================================== - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tim at consultix-inc.com Thu Jan 27 01:37:08 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: Data::Dumper mania - Stop the Madness! In-Reply-To: <388FEF62.10EAC250@weezel.com>; from jeremy@weezel.com on Wed, Jan 26, 2000 at 11:10:26PM -0800 References: <20000126101938.A25840@timji.consultix.wa.com> <20000126164853.A27769@timji.consultix.wa.com> <388FEF62.10EAC250@weezel.com> Message-ID: <20000126233708.A28920@timji.consultix.wa.com> Jeremy (and countless others), Thanks for your analysis - I'm just working through Conway's impressive OO Perl book today, and still a bit confused about the syntax elements and their associated behaviors, while experiencing significant crosstalk from ancient C++ memories. The reply-postings elicited by my deranged attempts to explain and understand my own program turned out to be very educational to me! But I'm not, as you intimate, "hell bent on breaking the API" ! 8-} I was just following the lead of "Effective Perl Programming" (p. 148) and "Advanced Perl Programming" (p. 158), which both show uses of Data::Dumper->Dump like mine. It struck me as odd that Dump wasn't automatically imported into my namespace, so I was exploring the idea of making an alias for it. (Still haven't found one that works, but surprisingly I find that I no longer care . . . 8-}) Sorry about adding to the confusion by claiming my invocation was Data::Dumper::Dump(), when in fact, by version 42 when the program actually worked, it had become Data::Dumper->Dump()! 8-} Thanks to all for their input, and Goodnight! 9-| -Tim *========================================================================* | Tim Maher, PhD Consultix & (206) 781-UNIX/8649 | | Pacific Software Gurus, Inc Email: tim@consultix-inc.com | | UNIX/Linux & Perl Training http://www.consultix-inc.com | | 2/22: UNIX 2/28: Perl Modules 2/29: Int. Perl 3/3: Pattern Matching | *========================================================================* On Wed, Jan 26, 2000 at 11:10:26PM -0800, Jeremy Devenport wrote: > Here's my quick analysis, you can repost any interesting bits to the > list if you like and it's not too redundant. > > Effective Perl Programming, page 148: > > use Data::Dumper; > $a = { H => 1, He => 2, Li => 3, Be => 4 }; > $b = { B => 5, C => 6, N => 7, O => 8 }; > print Data::Dumper->Dump([$a, $b], [qw(a b)]); > > Data/Dumper.pm > 153 zub Dump { > 154 my($s) = shift; > ...159 $s = $s->new(@_) unless ref $s; > > The EPP example isn't calling Dump as a zubroutine it is calling it as a > class method, so the name of the class is passed automagically as the > first argument. > > If Dump had been called like $my_dump_object->Dump then perl would have > automagically passed the blessed reference representing the object as > the first argument. Line 159 of the Dump method checks to see if it was > called on an existing object or as a class method generating a new > object. > > If you're really hell bent on breaking the API try passing undef or any > other non-ref thing as the first argument explicitly when you call it as > a zubroutine. > > Jeremy - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From gavinb at pobox.com Thu Jan 27 02:09:43 2000 From: gavinb at pobox.com (Gavin Bong) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: Must have perl books Message-ID: <00d201bf689d$e0b5d3b0$0d92bfce@neotropic> Hi, What would be the minimum number of books that would be considered a must have ? For example - do you consider the RegExp book from Oreilly a must have - in order to be a real Perl expert. I did some Perl 4 before but am not good enough to produce some sexy obsfucated code. My code is too readable at this moment - which means I'm doing something wrong! Gavin - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From andy at n2h2.com Thu Jan 27 02:23:48 2000 From: andy at n2h2.com (Andrew Sweger) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: Report on SPUG->E(0) Message-ID: Okay. You've all been wondering what happened at the first ever SPUG->E. Too bad you weren't there! Just kidding. Here it is. Sorry about the VOLUME on the list. Not. Ryan -- I mean, YOUR GRACE -- great job. Excellent facilities. They even had free refreshments (were they free? I didn't look closely). The data projector did only 640x480, BUT IT WORKED (unlike some other projectors I could just throw down a stairwell)! However, on the downside, Ryan was using some lame, super-secure OS. I'd say there were about 15 people that showed up. One notable absence was the esteemed leader from the West faction. There were other people (yes, I know who you are and so do _you_) I thought would show up but did not (about three SPUG->W regulars showed up). Ryan demonstrated a very clever use of GD in a web page (a page that lets you draw freehand, after a fashion). Ryan, please do host that thing somewhere and tell us all about it. It looks like fun. Besides, I want to try breaking it! Someone (I'll be kind) kept asking about practical applications that directly use GD (as opposed to a wrapper that abstracts things like charting packages). I don't think he received a satisfactory answer. At some point near the end, the discussion veered sharply into XML and we covered all the details. All of it, you name it. Sorry if you missed it. There was a woman (sorry I forget your name) at the meeting from a company called (something like) Chronology who said she works on a project with an embedded perl interpreter in a C program. If you get this message, please, if you would consider it, get in touch with Tim, Ryan, or myself (or the whole list if you want) about the possibility of giving a presentation on this topic. In fact, anyone with experience on embedded perl interested in presenting! It would be very popular. I'm hoping to do this one myself someday, but I don't have time to tinker with it yet. I might put one together on XSUBs. Next month, someone should stand outside to shine a flashlight on the Lucent logo because it is _not_ so clearly visible from the road at night. I'm glad I had a local as a copilot (thanks, Rob!). All in all, a success. You folks that thought it would be convenient to have an East side location but *bailed* out, do try to get there next month. -- Andrew Sweger | N2H2, Incorporated v=206.336.2947 f=206.336.1541 | 900 Fourth Avenue, Suite 3400 Advanced Technologies | Seattle WA 98164-1059 Development | http://www.n2h2.com/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From andy at n2h2.com Thu Jan 27 02:23:39 2000 From: andy at n2h2.com (Andrew Sweger) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: Must have perl books In-Reply-To: <00d201bf689d$e0b5d3b0$0d92bfce@neotropic> Message-ID: Zero. At a minimum, you need exactly zero (this from the guy with almost every O'Reilly technical title in his office). Some of the tutorials are nice if you like to read on the bus or have the book at your side while you read. But most Perl installations come with an amazing amount of documentation and what's available at web sites is unbounded and expanding all the time at all levels. On Jan 27, 2000 @ 12:09am, Gavin Bong wrote: > What would be the minimum number of books that would be considered > a must have ? For example - do you consider the RegExp book from Oreilly > a must have - in order to be a real Perl expert. I did some Perl 4 before > but am not good enough to produce some sexy obsfucated code. My > code is too readable at this moment - which means I'm doing something > wrong! -- Andrew Sweger | N2H2, Incorporated v=206.336.2947 f=206.336.1541 | 900 Fourth Avenue, Suite 3400 Advanced Technologies | Seattle WA 98164-1059 Development | http://www.n2h2.com/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From andy at n2h2.com Thu Jan 27 02:25:37 2000 From: andy at n2h2.com (Andrew Sweger) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: ISP -Stifle! Piffle! In-Reply-To: <20000126191922.A28241@timji.consultix.wa.com> Message-ID: On Jan 26, 2000 @ 7:19pm, Tim Maher/CONSULTIX wrote: > (As the list-owner, I see the unZubscribe requests > start pouring in when list-traffic gets heavy, as it did > today, or when off-topic posts start to creep in.) I agree with keeping the discussions more or less on topic, but volume... piffle. I want VOLUME! I want lots of dumb (and smart) questions with brilliant answers (and dumb answers too or else I wouldn't be able to post) from a (big) local community that I think I understand. I want all sorts of discussions about Perl going on from the simple, "What on Earth is @this?," to the esoteric, "Why does my strict scope not cross into the do call?" (huh, I actually hear a patriotic tune in the background right now). Sing it with me, I want VOLUME! (I really have no right to be in such a good mood, honest.) -- Andrew Sweger | N2H2, Incorporated v=206.336.2947 f=206.336.1541 | 900 Fourth Avenue, Suite 3400 Advanced Technologies | Seattle WA 98164-1059 Development | http://www.n2h2.com/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From andy at n2h2.com Thu Jan 27 02:35:17 2000 From: andy at n2h2.com (Andrew Sweger) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: class methods Message-ID: And to keep the VOLUME turned way up... Please note that, Some::Package->method(@args); and &Some::Package::method("Some::Package", @args); are the same thing (if not, I'm sure I'll hear about it). They're exactly the same thing. When you make the call using the first example, the class (or package name) is passed to the function in that package as the first argument in @_. Gah! Oh, that wasn't as clear on the second reading. Just pretend, if you write it as in the first example, that it is magically transformed into the second when it's executed. Perl's object orientedness is merely syntactic sugar to help you more easily think in terms of OO design. Of course, if you've been using "->" and telling everyone that you're really using "::", some people are going to talk about you behind your terminal. "If you fork a child and don't reap them when they die, you end up with zombies." -- Andrew Sweger | N2H2, Incorporated v=206.336.2947 f=206.336.1541 | 900 Fourth Avenue, Suite 3400 Advanced Technologies | Seattle WA 98164-1059 Development | http://www.n2h2.com/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From andy at n2h2.com Thu Jan 27 02:37:05 2000 From: andy at n2h2.com (Andrew Sweger) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: Must have perl books In-Reply-To: Message-ID: On Jan 27, 2000 @ 12:23am, Andrew Sweger wrote: > Zero. At a minimum, you need exactly zero (this from the guy with almost > every O'Reilly technical title in his office). Some of the tutorials are > nice if you like to read on the bus or have the book at your side while > you read. But most Perl installations come with an amazing amount of ^^^^ I meant while you bang away at the keyboard. I swear that's what I typed the first time. > documentation and what's available at web sites is unbounded and expanding > all the time at all levels. -- Andrew Sweger | N2H2, Incorporated v=206.336.2947 f=206.336.1541 | 900 Fourth Avenue, Suite 3400 Advanced Technologies | Seattle WA 98164-1059 Development | http://www.n2h2.com/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From jshaffer at chronology.com Thu Jan 27 13:21:37 2000 From: jshaffer at chronology.com (Jamie Shaffer) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: Report on SPUG->E(0) References: Message-ID: <38909ABE.E69C4221@chronology.com> > There was a woman (sorry I forget your name) at the meeting from a company > called (something like) Chronology who said she works on a project with an > embedded perl interpreter in a C program. If you get this message, please, > if you would consider it, get in touch with Tim, Ryan, or myself (or the > whole list if you want) about the possibility of giving a presentation ... 'Twas I. Unfortunately, I didn't actually do the embedding, I just became responsible for re-compiling Perl 5 for it, including removing all the 'hard coded' library paths, adding the DynaLoader, getting it to use the same environment variables that the rest of our tool uses, and putting all changes to the original Perl source under version control with happy make files for 4 platforms. (NT, HPUX, Solaris, Linux) I suspect there is someone much more knowledgeable about the actual embedding process out there in SPUG-land. However, if nobody else volunteers, I can try to trim that part out of our code base into a smaller working example for some far-future ESPUG meeting. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tgy at chocobo.org Thu Jan 27 13:41:34 2000 From: tgy at chocobo.org (Neko) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: class methods In-Reply-To: Message-ID: On Thu, 27 Jan 2000, Andrew Sweger wrote: > And to keep the VOLUME turned way up... > > Please note that, > > Some::Package->method(@args); Lacking its own method(), Some::Package will inherit method() from one of its parents. > and > > &Some::Package::method("Some::Package", @args); This one requires more typing. :) > are the same thing (if not, I'm sure I'll hear about it). They're exactly > the same thing. -- Neko - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From ced at carios2.ca.boeing.com Thu Jan 27 14:15:50 2000 From: ced at carios2.ca.boeing.com (Charles DeRykus) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: die from BEGIN; how suppress ugly message? Message-ID: <200001272015.MAA12373@carios2.ca.boeing.com> > > > BEGIN { eval { print "foo\n"; die "bar" }; } > >> Been there, tried that (before posting) >> As I said, if you have -n/-p turned on, you can't test >> $@ to decide what to do about the trapped exception >> until after you get a line of input! >> And you *really need* BEGIN when using -n/-p, otherwise >> everything is in the implicit input-reading loop! >> Hence my desire for another solution to suppressing >> errors within BEGIN, and I'm happy with the >> redirection to /dev/null idea. I believe I understand your problem now. This is probably more convoluted than anyone will want to suffer reading through but I believe there's another possibility: You can stack BEGIN blocks so you can conceivably get the eval error before you ever see a line of input. The only catch is that the global $@ doesn't remain set across BEGIN blocks so you have to use a package variable: perl -ne ' BEGIN { eval { ... ; die "bar"; ... }; $e= $@ } BEGIN { print $e } ... END Of course, you can just toss STDERR too but the above allows you to actually see $@ before -n/-p reads a line. -- Charles DeRykus - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From andy at n2h2.com Thu Jan 27 16:22:17 2000 From: andy at n2h2.com (Andrew Sweger) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: Report on SPUG->E(0) In-Reply-To: <38909ABE.E69C4221@chronology.com> Message-ID: On Jan 27, 2000 @ 11:21am, Jamie Shaffer wrote: > 'Twas I. Unfortunately, I didn't actually do the embedding, I just became > responsible for re-compiling Perl 5 for it, including removing all the 'hard > coded' library paths, adding the DynaLoader, getting it to use the same > environment variables that the rest of our tool uses, and putting all changes > to the original Perl source under version control with happy make files for > 4 platforms. (NT, HPUX, Solaris, Linux) Yeah. Sure. Everyone knows this stuff inside and out. Yikes! Are you sure you wouldn't want to share all this in more detail at a SPUG? I'd show up (of course, I always do). I'm sure there's at least a few others too. > I suspect there is someone much more knowledgeable about the actual > embedding process out there in SPUG-land. However, if nobody else > volunteers, I can try to trim that part out of our code base into a smaller > working example for some far-future ESPUG meeting. Sure, but they're not paying attention to this list 'cause they're too busy hacking. I say go for it. -- Andrew Sweger | N2H2, Incorporated v=206.336.2947 f=206.336.1541 | 900 Fourth Avenue, Suite 3400 Advanced Technologies | Seattle WA 98164-1059 Development | http://www.n2h2.com/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From jshaffer at chronology.com Thu Jan 27 17:12:52 2000 From: jshaffer at chronology.com (Jamie Shaffer) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: Report on SPUG->E(0) References: Message-ID: <3890D0F3.422F1AF9@chronology.com> > > 'Twas I. Unfortunately, I didn't actually do the embedding, I just became > > responsible for re-compiling Perl 5 for it, including removing all the 'hard > > coded' library paths, adding the DynaLoader, getting it to use the same > > environment variables that the rest of our tool uses, and putting all changes > > to the original Perl source under version control with happy make files for > > 4 platforms. (NT, HPUX, Solaris, Linux) > > Yeah. Sure. Everyone knows this stuff inside and out. Yikes! Are you sure > you wouldn't want to share all this in more detail at a SPUG? I'd show up > (of course, I always do). I'm sure there's at least a few others too. > I suspect there is someone much more knowledgeable about the actual > embedding process out there in SPUG-land. However, if nobody else > volunteers, I can try to trim that part out of our code base into a smaller > working example for some far-future ESPUG meeting. > Sure, but they're not paying attention to this list 'cause they're too > busy hacking. I say go for it. Okay, I'll start thinking about how I would put together something that would make sense. Don't sign me up yet, though, 'cuz with the stuff going on right now it wouldn't happen until summer. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From cmeyer at zipcon.net Thu Jan 27 17:24:39 2000 From: cmeyer at zipcon.net (Colin Meyer) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: Mod Perl and persistent objects In-Reply-To: <000201bf6816$4cfd4860$61ee6fd8@rc-701>; from Peter Darley on Wed, Jan 26, 2000 at 07:59:17AM -0800 References: <000201bf6816$4cfd4860$61ee6fd8@rc-701> Message-ID: <20000127152439.A17008@sim.zipcon.net> Peter, If you are only going to read your data structure, then can load up the structure once in the startup (parent) process, and all children will share the same copy. As soon as a child writes to the data structure, then copy-on-write memory handling will copy the shared pages to the child's memory space, producing two copies of the structure. For a more thorough description, see the excellent mod_perl guide: http://perl.apache.org/guide and specifically: http://perl.apache.org/guide/performance.html#Sharing_Memory -C. On Wed, Jan 26, 2000 at 07:59:17AM -0800, Peter Darley wrote: > Friends, > I'm putting together an application, and intend to use Mod Perl. My > application will need to load a large data table into memory (~10,000 > records) and I would like to load it into an object once and use it for all > the perl processes created by Mod Perl. I have some ideas how to get around > it if I can't have a single object, but I was hoping that someone out there > could tell me how to have the single persistent object. Couldn't find it in > any documentation. > Thanks for your help! > Peter Darley > pdarley@serviceintelligence.com > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe > Email to majordomo@pm.org: ACTION spug-list your_address > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From andy at n2h2.com Fri Jan 28 12:00:19 2000 From: andy at n2h2.com (Andrew Sweger) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: Perl Journal is HERE Message-ID: I got mine! Woo Hoo! -- Andrew Sweger | N2H2, Incorporated v=206.336.2947 f=206.336.1541 | 900 Fourth Avenue, Suite 3400 Advanced Technologies | Seattle WA 98164-1059 Development | http://www.n2h2.com/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tim at consultix-inc.com Fri Jan 28 13:39:28 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: Perl Journal is HERE In-Reply-To: ; from andy@n2h2.com on Fri, Jan 28, 2000 at 10:00:19AM -0800 References: Message-ID: <20000128113928.A16118@timji.consultix.wa.com> On Fri, Jan 28, 2000 at 10:00:19AM -0800, Andrew Sweger wrote: > I got mine! Woo Hoo! How does my new color ad look? Recognize me? -Tim > > -- > Andrew Sweger | N2H2, Incorporated > v=206.336.2947 f=206.336.1541 | 900 Fourth Avenue, Suite 3400 > Advanced Technologies | Seattle WA 98164-1059 > Development | http://www.n2h2.com/ > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe > Email to majordomo@pm.org: ACTION spug-list your_address > > -- *========================================================================* | Tim Maher, PhD Consultix & (206) 781-UNIX/8649 | | Pacific Software Gurus, Inc Email: tim@consultix-inc.com | | UNIX/Linux & Perl Training http://www.consultix-inc.com | | 2/22: UNIX 2/28: Perl Modules 2/29: Int. Perl 3/3: Pattern Matching | *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From toddw at wrq.com Fri Jan 28 13:46:01 2000 From: toddw at wrq.com (Todd Wells) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: No such file? Message-ID: <1654BC972546D31189DA00508B318AC80122EC27@charmander.wrq.com> What is going on here? When I run this program with "#!/usr/bin/perl -w" as the first line, I get this spew: bash-2.03$ app.pl Name "main::hash" used only once: possible typo at ./apptrieve.pl line 1137. Unquoted string "adm" may clash with future reserved word at (eval 1) line 26, chunk 36. Unquoted string "dev" may clash with future reserved word at (eval 1) line 27, chunk 36. Unquoted string "other" may clash with future reserved word at (eval 1) line 29, chunk 36. Okay, that's fine, I can deal with it. But if I remove the "-w", I get this! bash-2.03$ app.pl bash: ./app.pl: No such file or directory I'm in the same directory, what's up here? This must be something stupid on my part. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From andy at n2h2.com Fri Jan 28 15:18:57 2000 From: andy at n2h2.com (Andrew Sweger) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: Perl Journal is HERE In-Reply-To: <20000128113928.A16118@timji.consultix.wa.com> Message-ID: On Jan 28, 2000 @ 11:39am, Tim Maher/CONSULTIX wrote: > On Fri, Jan 28, 2000 at 10:00:19AM -0800, Andrew Sweger wrote: > > I got mine! Woo Hoo! > > How does my new color ad look? Recognize me? Uh, oh yeah. Amazing. p. 15 -- Andrew Sweger | N2H2, Incorporated v=206.336.2947 f=206.336.1541 | 900 Fourth Avenue, Suite 3400 Advanced Technologies | Seattle WA 98164-1059 Development | http://www.n2h2.com/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tim at consultix-inc.com Fri Jan 28 15:45:23 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: Perl Journal is HERE In-Reply-To: ; from andy@n2h2.com on Fri, Jan 28, 2000 at 01:18:57PM -0800 References: <20000128113928.A16118@timji.consultix.wa.com> Message-ID: <20000128134523.B16565@timji.consultix.wa.com> On Fri, Jan 28, 2000 at 01:18:57PM -0800, Andrew Sweger wrote: > On Jan 28, 2000 @ 11:39am, Tim Maher/CONSULTIX wrote: > > > On Fri, Jan 28, 2000 at 10:00:19AM -0800, Andrew Sweger wrote: > > > I got mine! Woo Hoo! Doh! Just got mine too. > > > > How does my new color ad look? Recognize me? > > Uh, oh yeah. Amazing. p. 15 Yuck! The background color came out wrong! I guess their TIFF->paper system is a bit color-skewed. But the blue eyes are about right 8-} And of course, all the courses listed there have already taken place. (I knew the December ones would be in the past, but they had promised a Jan. 10 distribution date, so I was hoping that the January courses would still be current.) -Tim > > -- > Andrew Sweger | N2H2, Incorporated > v=206.336.2947 f=206.336.1541 | 900 Fourth Avenue, Suite 3400 > Advanced Technologies | Seattle WA 98164-1059 > Development | http://www.n2h2.com/ > -- *========================================================================* | Tim Maher, PhD Consultix & (206) 781-UNIX/8649 | | Pacific Software Gurus, Inc Email: tim@consultix-inc.com | | UNIX/Linux & Perl Training http://www.consultix-inc.com | | 2/22: UNIX 2/28: Perl Modules 2/29: Int. Perl 3/3: Pattern Matching | *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tim at consultix-inc.com Fri Jan 28 15:48:24 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: TPJ availability in Seattle Message-ID: <20000128134824.C16565@timji.consultix.wa.com> This guy used a bad word, related to zubscribe, so I had to re-post. Beware! -Tim ========================================================== | Tim Maher, Ph.D. Tel/Fax: (206) 781-UNIX | | SPUG Founder & Leader Email: spug@halcyon.com | | Seattle Perl Users Group HTTP: www.halcyon.com/spug | ========================================================== Does anyone know of a location within Seattle that you can purchase TPJ from a newstand? I have noticed an uncanny tendency for journals and magazines to begin to suck after I zubscribe to them, so I usually don't. Cody - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From smorton at pobox.com Fri Jan 28 17:20:20 2000 From: smorton at pobox.com (Sanford Morton) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: Point and click GD/CGI Message-ID: <20000128232020.1ACF1325C4@scribe.pobox.com> Ryan hasn't posted his demo yet from the last E-Spug meeting, so I wrote a simple one over lunch. His was much cooler so I hope we get to see it. Save both files in the same cgi-enabled web directory. s/gif/png/g; in the second file if you have a more recent version of GD. Oh, this thing draws a point wherever you click on the image. --Sandy ############################################# #!/usr/bin/perl # filename: "click.cgi" use CGI::Carp qw(fatalsToBrowser carpout); use CGI; my $q = new CGI; my $web_form = <<"HERE";
Click the image to draw a point. HERE ; my $points = $q->param('points'); $points .= ';' if $points; $points .= $q->param('x') . ',' . $q->param('y') if $q->param('x'); $web_form =~ s/asddsa/$points/g; print "Cache-Control: no-cache\nContent-Type: text/html\n\n"; print "$web_form

$points"; ############################################# ############################################# #!/usr/bin/perl # filename: "image.cgi" use GD; $im = new GD::Image(200,200); $white = $im->colorAllocate(255,255,255); $black = $im->colorAllocate(0,0,0); for (split /;/, $ENV{'QUERY_STRING'}) { /(.*),(.*)/; $im->arc($1,$2,5,5,0,360,$black); } print "Cache-Control: no-cache\nContent-Type: image/gif\n\n"; print $im->gif; ############################################# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From debert at dusya.osd.com Fri Jan 28 18:48:08 2000 From: debert at dusya.osd.com (Daniel V. Ebert) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: Opening files Message-ID: <200001290048.AA29759@dusya.osd.com> I'm trying to write some code to pull out the title from some HTML files. Below is the code I am using to get the filenames ... when $filename is a file in a subdirectory it dies (because it can't open the file). I am guessing that this has something to do with the "/" character in the string $filename. Any ideas? #!/usr/bin/perl @ARGV = qw(.) unless @ARGV; use File::Find; find sub { if ($File::Find::name =~ /^\.\/admin/ || $File::Find::name =~ /^\.\/deleted/) {} #skip files in subdirs elsif ($File::Find::name =~ /\.html/) { #only process .html files $filename = $File::Find::name; $filename =~ s/\.\///; #remove the ./ from start of $filename open (HTMLFILE, $filename) or die; @htmlfile = ; close (HTMLFILE); } #DO OTHER STUFF } --- Dan Ebert Seanet Internet Services (206)343-7828 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From otter101 at hotmail.com Fri Jan 28 18:56:26 2000 From: otter101 at hotmail.com (Steve Laybourn) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: TPJ availability in Seattle Message-ID: <20000129005626.25772.qmail@hotmail.com> G'day! Hmmm, in the city of Seattle itself, I don't know about the availability of TPJ, but there's two Barnes & Noble stores I know that carry TPJ, one near Bellevue Square, the other in Tacoma (well, Lakewood, actually). I don't know if Borders carries TPJ. The University Bookstore on 4th and University says they will be carrying TPJ soon, I've asked them about that enough times seeing their store has a great Perl selection (even getting non-mainstream stuff, too!). Hope this helps! Be seeing you... Steve Laybourn ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From Scott.Blachowicz at seaslug.org Fri Jan 28 19:13:18 2000 From: Scott.Blachowicz at seaslug.org (Scott Blachowicz) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: Opening files In-Reply-To: <200001290048.AA29759@dusya.osd.com>; from Daniel V. Ebert on Fri, Jan 28, 2000 at 04:48:08PM -0800 References: <200001290048.AA29759@dusya.osd.com> Message-ID: <20000128171317.A5474@sabami.seaslug.org> On Fri, Jan 28, 2000 at 04:48:08PM -0800, Daniel V. Ebert wrote: > > I'm trying to write some code to pull out the title from some HTML files. > Below is the code I am using to get the filenames ... when $filename is a > file in a subdirectory it dies (because it can't open the file). I am > guessing that this has something to do with the "/" character in the string > $filename. > > Any ideas? Well...the docs for File::Find mention that it does a chdir to each directory it enters. That $File::Find::name var is the full path from the top and if these are relative paths, that probably isn't what you want. I think you just want to open "$_" which holds the current filename (and $File::Find::dir is the containing directory). > > #!/usr/bin/perl > @ARGV = qw(.) unless @ARGV; > use File::Find; > > find sub { > > if ($File::Find::name =~ /^\.\/admin/ || > $File::Find::name =~ /^\.\/deleted/) {} #skip files in subdirs > > elsif ($File::Find::name =~ /\.html/) { #only process .html files > $filename = $File::Find::name; > $filename =~ s/\.\///; #remove the ./ from start of $filename > > > open (HTMLFILE, $filename) or die; > @htmlfile = ; > close (HTMLFILE); > } > #DO OTHER STUFF > } Scott.Blachowicz@seaslug.org - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From moonbeam at catmanor.com Fri Jan 28 19:48:41 2000 From: moonbeam at catmanor.com (William Julien) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: No such file? In-Reply-To: Mail from 'Todd Wells ' dated: Fri, 28 Jan 2000 11:46:01 -0800 Message-ID: <200001290148.RAA23579@catmanor.com> > >What is going on here? > >When I run this program with "#!/usr/bin/perl -w" as the first line, I get >this spew: > >bash-2.03$ app.pl >Name "main::hash" used only once: possible typo at ./apptrieve.pl line 1137. >Unquoted string "adm" may clash with future reserved word at (eval 1) line >26, chunk 36. >Unquoted string "dev" may clash with future reserved word at (eval 1) line >27, chunk 36. >Unquoted string "other" may clash with future reserved word at (eval 1) line >29, chunk 36. > >Okay, that's fine, I can deal with it. But if I remove the "-w", I get >this! > >bash-2.03$ app.pl >bash: ./app.pl: No such file or directory > Let me guess. Was the program was written on a winbox and uploaded to a unix server in binary mode? So, the unix shell sees the dos line end character on the header. In a "real man's editor"... like uh, ... vi!; you would see: "/usr/bin/perl^M". Guess what... there is "No such file or directory" by that name! You may ask, but, why does this act differently when the "-w" parameter is inserted on the shell header? The syntax for the normal unix getopt processing allows for the grouping of parameters (-x -y == -xy). So, perl parses the paramters of "-w^M" as "-w -^M". This is why you saw the normal warnings with the perl diagnostic checking enabled. I'm a little surprised that perl didn't give an error on the invalid "-^M" parameter. Perl 5.005_03 will abort on an invalid parameter error. Moral: use ascii transfer for text files. This is not as easy as it sounds. Some win9x ftp clients decide "for you", because they run on the assumption that you are an idiot and you don't know what you are doing. They use the extension to determine the transfer method and they default to binary. There are a lot of windows programmers who have never heard of perl. Second Moral: Friends don't let friends use dos. --- _,'| _.-''``-...___..--'; /, \'. _..-' , ,--...--''' < \ .`--''' ` /| William Julien moonbeam@catmanor.com `-,;' ; ; ; http://www.catmanor.com/moonbeam/ __...--'' __...--_..' .;.' vi is my shepherd; i shall not font. (,__....----''' (,..--'' perl -e 'print $i=pack(c5,(41*2),sqrt(7056),(unpack(c,H)-2),oct(115),10);' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From andy at n2h2.com Fri Jan 28 21:43:11 2000 From: andy at n2h2.com (Andrew Sweger) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: No such file? In-Reply-To: <200001290148.RAA23579@catmanor.com> Message-ID: On Jan 28, 2000 @ 5:48pm, William Julien wrote: > >What is going on here? > > > >bash-2.03$ app.pl > >bash: ./app.pl: No such file or directory > > Let me guess. Was the program was written on a winbox and uploaded to a unix > server in binary mode? So, the unix shell sees the dos line end character > on the header. In a "real man's editor"... like uh, ... vi!; you would see: > "/usr/bin/perl^M". Guess what... there is "No such file or directory" > by that name! Wow! My mystery is solved. Every once in a while this would happen to me. About as often as I'm forced to edit a script on a system with MS-DOS in its family tree. I never made the connection and hadn't thought to examine the file contents itself. I usually just nuked it and started over. And all I needed was a quick, tr -d "\r" < f1 > f2 Or, if you prefer Perl, perl -pi -e 'y;\r;;d;' f1 Thanks for explaining it. -- Andrew Sweger | N2H2, Incorporated v=206.336.2947 f=206.336.1541 | 900 Fourth Avenue, Suite 3400 Advanced Technologies | Seattle WA 98164-1059 Development | http://www.n2h2.com/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tim at consultix-inc.com Fri Jan 28 22:54:12 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: No such file? In-Reply-To: ; from andy@n2h2.com on Fri, Jan 28, 2000 at 07:43:11PM -0800 References: <200001290148.RAA23579@catmanor.com> Message-ID: <20000128205412.A17985@timji.consultix.wa.com> On Fri, Jan 28, 2000 at 07:43:11PM -0800, Andrew Sweger wrote: > On Jan 28, 2000 @ 5:48pm, William Julien wrote: > > > >What is going on here? > > > > > >bash-2.03$ app.pl > > >bash: ./app.pl: No such file or directory Part of the problem here is that when the exec* system call cannot find the designated pathname, it gives a "stock" error message, instead of a useful one, like: bash: ./app.pl: "/usr/bin/perl ": No such file or directory > > > > Let me guess. Was the program was written on a winbox and uploaded to a unix > > server in binary mode? So, the unix shell sees the dos line end character > > on the header. In a "real man's editor"... like uh, ... vi!; you would see: > > "/usr/bin/perl^M". Guess what... there is "No such file or directory" > > by that name! Just to avoid this SNAFU at all costs in the future, I think I'll execute # ln /usr/bin/perl '/usr/bin/perl^M' next time I talk to a shell rootily! I almost had the right idea. I recognized the error message as the same one I see when my students type #! /usr/perl/bin , so I thought it might be a trailing space (left after "perl -w" was converted to "perl "), on some Lame UNIX-like OS that didn't ignore trailing white-space there. (Seems to me I encountered an OS like that somewhere, along with one that could handle #! path but not #!path.) So close, yet so far! And it really irks me that VI (or William Julien, same thing 8-,) ended up being the hero of the story! 8-} How are we ever going to get rid of this abomination, this egregiously pessimal example of ergonomic design (viz., VI), if people keep pointing out good things about it? 8-} > > Wow! My mystery is solved. Every once in a while this would happen to me. > About as often as I'm forced to edit a script on a system with MS-DOS in > its family tree. I never made the connection and hadn't thought to examine > the file contents itself. I usually just nuked it and started over. And > all I needed was a quick, > > tr -d "\r" < f1 > f2 To further delay the onset of carpal-tunnel syndrome, I prefer this: col < f1 > f2 (although it will remove any formfeeds in your file too) But my primary use for the widely ignored "col" command is removing "overstriking by backspacing", so I can grep within man-pages: $ man date | grep NAME (nothing) $ man date | col -b | grep NAME # convert a^Ha to a, etc. NAME $ > > Or, if you prefer Perl, > > perl -pi -e 'y;\r;;d;' f1 As a famous educator once opined: When on UNIX, only the clueless, masochists, Windows trained, or rabid Perl bigots would prefer ugly custom Perl programs with complex syntax to much simpler alternatives like "col". Other things being equal, of course. But once you factor in the coolosity of insanely wonderful features like "-i f1" vs "f2", Perl wins hands down. > > Thanks for explaining it. Ditto! > > -- > Andrew Sweger | N2H2, Incorporated > v=206.336.2947 f=206.336.1541 | 900 Fourth Avenue, Suite 3400 > Advanced Technologies | Seattle WA 98164-1059 > Development | http://www.n2h2.com/ > *========================================================================* | Tim Maher, PhD Consultix & (206) 781-UNIX/8649 | | Pacific Software Gurus, Inc Email: tim@consultix-inc.com | | UNIX/Linux & Perl Training http://www.consultix-inc.com | | 2/22: UNIX 2/28: Perl Modules 2/29: Int. Perl 3/3: Pattern Matching | *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From ryan at erwin.org Sat Jan 29 06:32:27 2000 From: ryan at erwin.org (Ryan Erwin) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: ESPUG GD Example... Message-ID: I've been wanting to do a little more with this but just haven't had the time. Here it is for now. Get GD and check it out. Have fun connecting the dots ;) --Ryan Erwin [ryan@erwin.org] -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- #!/usr/bin/perl -w # program: cgi-bin/thengone [the n gon ] # purpose: cgi part of GD / espug demo # creator: ryan s erwin [ryan@erwin.org] # date: 01.26.2000 use CGI; use strict; my $cgi = new CGI; my ($connect, $bgcolor, $fgcolor, $points, $text, $imageurl); if ($cgi->param()) { if ( $cgi->param('connect the dots') ) { $connect = 'true'; } else { $connect = 'false'; } $bgcolor = $cgi->param('bgcolor'); $fgcolor = $cgi->param('fgcolor'); if ( $cgi->param('theImage.x') && $cgi->param('theImage.y')) { $points = $cgi->param('points'); $points .= $cgi->param('theImage.x') . ":"; $points .= $cgi->param('theImage.y') . ":"; } else { $points = $cgi->param('points'); } $text = $cgi->param('text'); } else { $connect = 'false'; $bgcolor = 'white'; $fgcolor = 'red'; $points = ''; $text = ''; } $cgi->param('points',$points); $imageurl = "/cgi-bin/image?connect=$connect&bgcolor=$bgcolor&fgcolor=$fgcolor&points=$points&text=$text"; print $cgi->header(), $cgi->start_html('click here and there...'), $cgi->h3("click on the image for polygon fun!\n"); print "

"; print $cgi->start_form(), $cgi->hidden('points',$points), "Foregrond Color:", $cgi->popup_menu(-name=>'fgcolor', -values=>['red','green','blue','black','white', 'black50'],-default=>'red'), "
\n", "Background Color:", $cgi->popup_menu(-name=>'bgcolor', -values=>['red','green','blue','black','white', 'black50'],-default=>'white'), "
\n", "Text:", $cgi->textfield('text'), "
\n", $cgi->submit('submit'), "
\n", $cgi->submit('connect the dots'), "
\n", $cgi->defaults('reset'), "
\n","
", "
\n", $cgi->image_button("theImage",$imageurl), "
\n", $cgi->end_form(),"\n

\n", "

"; foreach ($cgi->param()) { print "Parameter: $_ => ", $cgi->param($_), "
\n"; } print "\$connect = $connect
\n"; print $cgi->end_html(); -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- #!/usr/bin/perl # program: cgi-bin/image # purpose: draw with gd! # creator: ryan s erwin [ryan@erwin.org] # date: 01.26.2000 #params $connect, $bgcolor, $fgcolor, $points, $text use GD; use CGI; my $cgi = new CGI; print $cgi->header('image/png'); my $connect = $cgi->param('connect'); my $bgcolor = $cgi->param('bgcolor'); my $fgcolor = $cgi->param('fgcolor'); my $points = $cgi->param('points'); my $text = $cgi->param('text'); my $image = new GD::Image(200,200) || die "Couldn't create GD Image $!"; $white = $image->colorAllocate(255,255,255); $black = $image->colorAllocate(0,0,0); $red = $image->colorAllocate(255,0,0); $blue = $image->colorAllocate(0,0,255); $green = $image->colorAllocate(0,255,0); $black50= $image->colorAllocate(127,127,127); $image->transparent($white); $image->interlaced('true'); $image->filledRectangle(0,0,199,199,${$bgcolor}); $image->string(gdLargeFont,0,0,$text,$green) if $text ne ""; my @points = split ( ":", $cgi->param('points')); if ( $connect ne 'true' ) { while (@points) { my ($x, $y); $x = shift(@points); $y = shift(@points); #print "set: $x, $y\n"; #$image->setPixel($x, $y, ${$fgcolor} ); #print "setPixel($x, $y, ${$fgcolor} )\n"; $image->arc($x,$y, 7,7, 0,360, ${$fgcolor}); } } else { my $ngon = new GD::Polygon; while (@points) { my ($x, $y); $x = shift(@points); $y = shift(@points); $ngon->addPt($x,$y); } $image->filledPolygon($ngon, ${$fgcolor}); } binmode STDOUT; print $image->png; -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tim at consultix-inc.com Sat Jan 29 16:57:32 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: -MO=Deparse; what it is? Message-ID: <20000129145732.A20594@timji.consultix.wa.com> (E-)?SPUG-ticians, In a Perl Beautification discussion I had with somebody, the following -MO=Deparse business came up. Does anybody know what this is? (My O'Reilly bookshelf seems mute on the subject, and the person who brought this up has long since "gone out of scope" (mine, not his)). It sure gives interesting output, but I wouldn't call it a beautifier; it's more like an overzealous copy-editor! $ perl -n -e '1 .. 10 and print;' /etc/motd Linux 2.0.36. (POSIX). $ perl -MO=Deparse -n -e '1 .. 10 and print;' /etc/motd -e syntax OK LINE: while (defined($_ = )) { print $_ if 1 .. 10; } $ *========================================================================* | Tim Maher, PhD Consultix & (206) 781-UNIX/8649 | | Pacific Software Gurus, Inc Email: tim@consultix-inc.com | | UNIX/Linux & Perl Training http://www.consultix-inc.com | | 2/22: UNIX 2/28: Perl Modules 2/29: Int. Perl 3/3: Pattern Matching | *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From dougb at scalar.org Sat Jan 29 18:10:43 2000 From: dougb at scalar.org (Doug Beaver) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: -MO=Deparse; what it is? In-Reply-To: <20000129145732.A20594@timji.consultix.wa.com>; from tim@consultix-inc.com on Sat, Jan 29, 2000 at 02:57:32PM -0800 References: <20000129145732.A20594@timji.consultix.wa.com> Message-ID: <20000129161043.A82808@scalar.org> On Sat, Jan 29, 2000 at 02:57:32PM -0800, Tim Maher/CONSULTIX wrote: > (E-)?SPUG-ticians, > > In a Perl Beautification discussion I had with somebody, > the following -MO=Deparse business came up. Does anybody > know what this is? (My O'Reilly bookshelf seems mute on > the subject, and the person who brought this up has long > since "gone out of scope" (mine, not his)). The classes under B:: let you get at the internals of the perl compiler (I think B is supposed to stand for Backend). If you have tchrist's pmtools package (http://language.perl.com/misc/pmtools-1.00.tar.gz), you can see what they all do: % pminst ^B:: | xargs pmdesc B::Deparse (0.56) - Perl compiler backend to produce perl code B::CC - Perl compiler's optimized C translation backend B::Debug - Walk Perl syntax tree, printing debug info about ops B::Showlex - Show lexical variables used in functions or files B::Bblock - Walk basic blocks B::Bytecode - Perl compiler's bytecode backend B::Stackobj - Helper module for CC backend B::Xref - Generates cross reference reports for Perl programs B::Lint - Perl lint B::Asmdata - Autogenerated data about Perl ops, used to generate bytecode B::Assembler - Assemble Perl bytecode B::Disassembler - Disassemble Perl bytecode B::Terse - Walk Perl syntax tree, printing terse info about ops B::C - Perl compiler's C backend (This list is from 5.00503, which is what I have installed at home.) Doug -- Smithers: I'm afraid we have a bad image, Sir. Market research shows people see you as somewhat of an ogre. Burns: I ought to club them and eat their bones! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From tnight at ironworx.com Sat Jan 29 19:46:10 2000 From: tnight at ironworx.com (Terry Nightingale) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: Has TPJ hit Seattle yet? In-Reply-To: <990EFA5D5CA7D311B44300A0C9D5E1492210CF@SEAEXCHG02> Message-ID: I just got mine yesterday, for what it's worth. On Wed, 26 Jan 2000, Greg Mushen wrote: > I haven't received mine either. Hmmmmm. > > -----Original Message----- > From: Joe Slagel [mailto:slagel@geospiza.com] > Sent: Wednesday, January 26, 2000 2:41 PM > To: spug-list@pm.org > Subject: Re: SPUG: Has TPJ hit Seattle yet? > > > Tim Maher/CONSULTIX wrote: > > > SPUG-o-maniacs, > > > > When I placed my new, improved, full-color advertisement for the > > January, 2000 issue of The Perl Journal, I was told distribution > > would start 1/10. Yet I still haven't received my copy. > > This worries me, because they keep sending me subscription renewal > > notices, despite the fact that I keep proving to them that I already > > paid for renewal. > > > > So, have any Seattle subscribers received the new issue yet? > > Maybe it's just that I was left out? > > > > *========================================================================* > > | Tim Maher, PhD Consultix & (206) 781-UNIX/8649 | > > | Pacific Software Gurus, Inc Email: tim@consultix-inc.com | > > | UNIX/Linux & Perl Training http://www.consultix-inc.com | > > | 2/22: UNIX 2/28: Perl Modules 2/29: Int. Perl 3/3: Pattern Matching | > > *========================================================================* > > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > > SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe > > Email to majordomo@pm.org: ACTION spug-list your_address > > Come to think of it...we haven't gotten our copy in a * long * time either. > > - joe > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe > Email to majordomo@pm.org: ACTION spug-list your_address > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe > Email to majordomo@pm.org: ACTION spug-list your_address > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From toddw at wrq.com Mon Jan 31 10:25:11 2000 From: toddw at wrq.com (Todd Wells) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: No such file? Message-ID: <1654BC972546D31189DA00508B318AC80122EC50@charmander.wrq.com> Well, you were very close to the actual scenario. Actually I started to write the program on a unix box, I've (almost) finished it on a unix box, but somewhere along the way it did pass through an NT box via binary FTP. I always wondered what purpose ASCII transfers served in FTP -- I just figured bits is bits so why not just do it all binary? I used Andrew's 'tr -d "\r" < f1 > f2' and that solved the problem beautifully. Special thanks to William, Tim Maher, Stuart Poulin, and Riley for their efforts in solving this. -Todd -----Original Message----- From: William Julien [mailto:moonbeam@catmanor.com] Sent: Friday, January 28, 2000 5:49 PM To: spug-list@pm.org Subject: Re: SPUG: No such file? > >What is going on here? > >When I run this program with "#!/usr/bin/perl -w" as the first line, I get >this spew: > >bash-2.03$ app.pl >Name "main::hash" used only once: possible typo at ./apptrieve.pl line 1137. >Unquoted string "adm" may clash with future reserved word at (eval 1) line >26, chunk 36. >Unquoted string "dev" may clash with future reserved word at (eval 1) line >27, chunk 36. >Unquoted string "other" may clash with future reserved word at (eval 1) line >29, chunk 36. > >Okay, that's fine, I can deal with it. But if I remove the "-w", I get >this! > >bash-2.03$ app.pl >bash: ./app.pl: No such file or directory > Let me guess. Was the program was written on a winbox and uploaded to a unix server in binary mode? So, the unix shell sees the dos line end character on the header. In a "real man's editor"... like uh, ... vi!; you would see: "/usr/bin/perl^M". Guess what... there is "No such file or directory" by that name! You may ask, but, why does this act differently when the "-w" parameter is inserted on the shell header? The syntax for the normal unix getopt processing allows for the grouping of parameters (-x -y == -xy). So, perl parses the paramters of "-w^M" as "-w -^M". This is why you saw the normal warnings with the perl diagnostic checking enabled. I'm a little surprised that perl didn't give an error on the invalid "-^M" parameter. Perl 5.005_03 will abort on an invalid parameter error. Moral: use ascii transfer for text files. This is not as easy as it sounds. Some win9x ftp clients decide "for you", because they run on the assumption that you are an idiot and you don't know what you are doing. They use the extension to determine the transfer method and they default to binary. There are a lot of windows programmers who have never heard of perl. Second Moral: Friends don't let friends use dos. --- _,'| _.-''``-...___..--'; /, \'. _..-' , ,--...--''' < \ .`--''' ` /| William Julien moonbeam@catmanor.com `-,;' ; ; ; http://www.catmanor.com/moonbeam/ __...--'' __...--_..' .;.' vi is my shepherd; i shall not font. (,__....----''' (,..--'' perl -e 'print $i=pack(c5,(41*2),sqrt(7056),(unpack(c,H)-2),oct(115),10);' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From pdarley at serviceintelligence.com Mon Jan 31 10:55:33 2000 From: pdarley at serviceintelligence.com (Peter Darley) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: Installing DBD::mysql Message-ID: <000201bf6c0b$fd258d80$61ee6fd8@rc-701> Friends, I'm trying to set up a machine that was lent to me, an Alpha upon which I've installed Linux. I'm new to Linux and to the Alpha, and I'm having some significant trouble installing DBD::mysql. I'm getting the some error message which are mostly Greek to me. I can't find any evidence that DBD::mysql is not thread safe or that it isn't 64 bit compliant, which seem like the most likely problems. Anyone been in a similar situation or have any suggestions? The errors I get are as follow: t/00base............install_driver(mysql) failed: Can't load '../blib/arch/auto/DBD/mysql /mysql.so' for module DBD::mysql: ../blib/arch/auto/DBD/mysql/mysql.so: undefined symbol: mysql_init at /usr/lib/perl5/5.00503/alpha-linux/DynaLoader.pm line 169. at (eval 1) line 3 at t/00base.t line 38 dubious Test returned status 255 (wstat 65280, 0xff00) Undefined subroutine &Test::Harness::WCOREDUMP called at /usr/lib/perl5/5.00503/Test/Harn ess.pm line 288. make[1]: *** [test_dynamic] Error 255 make[1]: Leaving directory `/root/.cpan/build/Msql-Mysql-modules-1.2210/mysql' make: *** [test] Error 2 /usr/bin/make test -- NOT OK Thanks! Peter Darley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From phillipneal at hotmail.com Mon Jan 31 13:19:51 2000 From: phillipneal at hotmail.com (Phillip Neal) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: Installing DBD::mysql Message-ID: <20000131191951.86544.qmail@hotmail.com> Peter, It looks like it can't find mysql.so. Here are some things you might check, not in any particular order. Some will have absolutely no relevance, but it's what I do when I run across an install problem like this. 1. Is there a ../blib/arch/auto/DBD/mysql/mysql.so reachable from where you started up the test script? 2. Did you untar everything as root and are you running as root? 3. Are you in the correct directory when you start up the test script ? 5. If mysql.so exists, does it have the correct permissions ? 6. Are you running compatible versions of Perl and DBD::mysql ? 7. Do you have the DBI modules installed ? 8. If you installed mysql from an RPM you might have to install other RPMS. That is, if my memory serves me correctly, there is a client rpm and a development rpm that have to be installed to actually do any good work. 9. If you installed from a mysql tar file then the best bet might be to uninstall the DBD stuff and then restart again all the way from the tar file. 10. Do Alpha libraries have the ".so" extension ? I grabbed all my mysql and mysql/dbd stuff off a Walnut Creek CDROM called "LINUX Web Tools" and I definitely had to install not only the server but also the "mysql-client.." and the "mysql-devel..." stuff. Phil >From: "Peter Darley" >Reply-To: >To: >Subject: SPUG: Installing DBD::mysql >Date: Mon, 31 Jan 2000 08:55:33 -0800 > >Friends, > I'm trying to set up a machine that was lent to me, an Alpha upon which >I've installed Linux. I'm new to Linux and to the Alpha, and I'm having >some significant trouble installing DBD::mysql. I'm getting the some error >message which are mostly Greek to me. I can't find any evidence that >DBD::mysql is not thread safe or that it isn't 64 bit compliant, which seem >like the most likely problems. Anyone been in a similar situation or have >any suggestions? The errors I get are as follow: > > > >t/00base............install_driver(mysql) failed: Can't load >'../blib/arch/auto/DBD/mysql >/mysql.so' for module DBD::mysql: ../blib/arch/auto/DBD/mysql/mysql.so: >undefined symbol: > mysql_init at /usr/lib/perl5/5.00503/alpha-linux/DynaLoader.pm line 169. > > at (eval 1) line 3 > > at t/00base.t line 38 >dubious > Test returned status 255 (wstat 65280, 0xff00) >Undefined subroutine &Test::Harness::WCOREDUMP called at >/usr/lib/perl5/5.00503/Test/Harn >ess.pm line 288. >make[1]: *** [test_dynamic] Error 255 >make[1]: Leaving directory >`/root/.cpan/build/Msql-Mysql-modules-1.2210/mysql' >make: *** [test] Error 2 > /usr/bin/make test -- NOT OK > > > >Thanks! >Peter Darley > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe > Email to majordomo@pm.org: ACTION spug-list your_address > > ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From mark.johnston at pnl.gov Mon Jan 31 15:07:42 2000 From: mark.johnston at pnl.gov (Johnston, Mark) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: -MO=Deparse; what it is? Message-ID: Tim, Looks like a literal translation of the parse tree to me. Since Perl uses so many implicit shortcuts, the -MO=Deparse option could be used to de-obfuscate someone else's dense code as well as to check to see if the Perl interpreter was understanding one's own line of code the way it was intended to be written. Otherwise, my guess is that many would consider it something like "verbose mode." --Mark -----Original Message----- From: Tim Maher/CONSULTIX [tim@consultix-inc.com] Sent: Saturday, January 29, 2000 2:58 PM To: spug-list@pm.org Subject: SPUG: -MO=Deparse; what it is? (E-)?SPUG-ticians, In a Perl Beautification discussion I had with somebody, the following -MO=Deparse business came up. Does anybody know what this is? (My O'Reilly bookshelf seems mute on the subject, and the person who brought this up has long since "gone out of scope" (mine, not his)). It sure gives interesting output, but I wouldn't call it a beautifier; it's more like an overzealous copy-editor! $ perl -n -e '1 .. 10 and print;' /etc/motd Linux 2.0.36. (POSIX). $ perl -MO=Deparse -n -e '1 .. 10 and print;' /etc/motd -e syntax OK LINE: while (defined($_ = )) { print $_ if 1 .. 10; } $ *========================================================================* | Tim Maher, PhD Consultix & (206) 781-UNIX/8649 | | Pacific Software Gurus, Inc Email: tim@consultix-inc.com | | UNIX/Linux & Perl Training http://www.consultix-inc.com | | 2/22: UNIX 2/28: Perl Modules 2/29: Int. Perl 3/3: Pattern Matching | *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address From otter101 at hotmail.com Mon Jan 31 15:52:07 2000 From: otter101 at hotmail.com (Steve Laybourn) Date: Wed Aug 4 00:07:05 2004 Subject: SPUG: File headers Message-ID: <20000131215207.20590.qmail@hotmail.com> Hello again! I'm wondering if there is a way to be able to open a remote file long enough to get the first 256 bytes and close the record again. Example: If I wanted to scan the first 1024 bytes of http://www.arglebargle.com/images/very_big_graphic.jpg to make sure it WAS a JPEG file without having to load the entire image, could it be done? If so, how? open / read don't seem to do it. Thanks, oh mighty ones! Be seeing you... Steve Laybourn ---Remember: King Kong died for your sins. ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe Email to majordomo@pm.org: ACTION spug-list your_address