From jwalcik at notwithstanding.org Mon Jan 5 15:01:27 2004 From: jwalcik at notwithstanding.org (jacob walcik) Date: Mon Aug 2 21:23:22 2004 Subject: APM: question about unicode encoding Message-ID: <5437F478-3FC2-11D8-98AA-000393914A3A@notwithstanding.org> i apologize for my first post to the list being such a lengthy request for assistance, however i'm spinning my wheels here and could really use some guidance. i've got a pair of files, coming from different sources, which have special characters in them. in one file, they're represented by their html equivalents ( "&#" and then a three digit string) and in the other, they're written as a three digit code, escaped by a backslash. i need to take both of these files, and convert the text in them to unicode, with the special characters properly represented, and then insert the resulting strings into tables in a postgres database. initially, i wrote a pair of scripts, one to deal with each type of file, that just read the file in and through a series of regular expressions converted the characters, like so: #!/usr/bin/perl use Unicode::String qw(utf8); #open the incoming and outgoing sql files open(INFILE,"<:utf8","german_1.sql"); open(OUTFILE,">:utf8","german_unicode_2.sql"); while () { $line = utf8($_); $line =~ s#\374#?#g; ... $line = utf8($line); print OUTFILE $line; } close(INFILE); close(OUTFILE); in the output, instead all of the encoded characters are missing, and haven't been replaced with anything. i've tried adding a "use utf8;" at the beginning, but that doesn't appear to have had any affect. is there another module i need to add unicode support to regular expressions? i've found Unicode::Regex::Set, but that just appears to deal with addition and subtraction of characters, not with substitutions. any advice or suggestions would be much appreciated. thanks. -- jacob walcik jwalcik@notwithstanding.org From wwalker at bybent.com Mon Jan 5 23:00:31 2004 From: wwalker at bybent.com (Wayne Walker) Date: Mon Aug 2 21:23:22 2004 Subject: APM: OT: VMware Rocks! Message-ID: <20040106050030.GA3720@bybent.com> I know this is off topic, but since I use VMware for testing perl based code all the time, I thought I'd share this cool experience I just had with VMware! Wow! I've always been a proponent of VMware, but it just moved up two notches! ("but VMware goes to eleven!") All of the sudden, data transfer from my build machines to the virtual machines on my testbed (a single 3G P4 running 5 to 12 VM's, 5 right now) slowed to a crawl. I assumed something flaky with the testbed server. So, I had open ssh sessions to 3 of the VM's from my notebook. I went into the VMware instances (running in Xvnc :) and suspended the servers. I then shutdown the VMware GUIs. Finally a ran "init 0" on the testbed server. When the machine powered off, I pulled the plug (to power cycle the ethernet card since most motherboards keep the eth's live at all times (wake on lan). Then I booted back up, started 3 Xvnc sessions, started up a VMware window in each. Unsuspended the 5 VMs, went back to my desk. The ssh sessions to the VM's were still live and usable!!! even the 2 that had been running top! Just had to share that folks. Wayne P.S. - Of course the machines running in the VMware sessions were Linux (RedHat 8 and 9 to be specific :) -- Wayne Walker wwalker@bybent.com Do you use Linux?! http://www.bybent.com Get Counted! http://counter.li.org/ Perl - http://www.perl.org/ Perl User Groups - http://www.pm.org/ Jabber IM: wwalker@jabber.phototropia.org AIM: lwwalkerbybent From dbii at mudpuddle.com Wed Jan 14 00:03:49 2004 From: dbii at mudpuddle.com (David Bluestein II) Date: Mon Aug 2 21:23:22 2004 Subject: APM: Next Weeks Meeting Topic? Message-ID: Hey everyone, I missed December's meeting, what is the January topic? The web site still has the November announcement. David ---------- David H. Bluestein II President & Lead Developer dbii@interaction.net ii, inc. http://www.interaction.net - Specializing in Designing Interactive Websites - - and Searchable Internet Databases - From sam at sam-i-am.com Wed Jan 14 10:47:22 2004 From: sam at sam-i-am.com (Sam-I-Am) Date: Mon Aug 2 21:23:22 2004 Subject: APM: new guy In-Reply-To: References: Message-ID: <4005729A.7030409@sam-i-am.com> hi there, I just joined up and plan on coming along next week. Is there anything I need to bring, know, do? I've been learning and using perl sporadically over the last 4-5 years and finally hit a point where its really doing Useful Work for me on a regular basis. I'm looking forward to meeting you all. Sam Foster http://www.sam-i-am.com (woefully out of date, and mid-rebuild) From tom.bakken at tx.usda.gov Thu Jan 15 11:56:06 2004 From: tom.bakken at tx.usda.gov (Tom Bakken) Date: Mon Aug 2 21:23:22 2004 Subject: APM: Copying files Message-ID: <000401c3db90$da47d4a0$920e9dc7@agwest.one.usda.gov> I'm using an active perl script to move zip files between Windows 2000 servers. I've used the File::Copy module on smaller files without a problem but with these larger zip files I get an "Out of memory" error. I'm adding the optional buffer size argument but it appears to me this module might not be up to the heavy lifting. Does anybody have any better recommendations? Tom Bakken From dbii at mudpuddle.com Tue Jan 20 09:56:49 2004 From: dbii at mudpuddle.com (David Bluestein II) Date: Mon Aug 2 21:23:22 2004 Subject: APM: Pok-e Jo's Before Meeting Dinner Message-ID: For those who are interested, we meet at Pok-e Jo's on 5th Street around 6:00 pm for dinner. You can get directions from www.pokejos.com, it is about 2 blocks from Servergraph. David ---------- David H. Bluestein II President & Lead Developer dbii@interaction.net ii, inc. http://www.interaction.net - Specializing in Designing Interactive Websites - - and Searchable Internet Databases - From austin.pm at sam-i-am.com Tue Jan 20 15:51:38 2004 From: austin.pm at sam-i-am.com (Sam Foster) Date: Mon Aug 2 21:23:22 2004 Subject: APM: new guy In-Reply-To: <20040114223956.5C02.CHRIS@chrisbaker.net> References: <4005729A.7030409@sam-i-am.com> <20040114223956.5C02.CHRIS@chrisbaker.net> Message-ID: <400DA2EA.5030803@sam-i-am.com> Christopher Baker wrote: > Are you bring green eggs and ham to the meeting? > > What do you do? Where do you work? > > Chris No green eggs and ham, sorry. I'm a vegetarian so the ham is out. Green eggs could be done though. If you're nice to me, I'll consider it for next month :) I'm employed by frogdesign (www.frogdesign.com) as a "design technologist (Snr)" (read: front-end / client-side web developer.) I support the design teams by evaluating, prototyping and implementing designs, and integrate with either our or the client's development team to make it happen true to the design vision. I'm also usually the one charged with creating the end deliverable - which is frequently some kind of web-based styleguide or asset library. I push a lot of files around, and that's where perl comes in. I mostly use it to speed up "all the other stuff" that needs to happen, so I maximize my time doing the stuff where I can add real value (fancy html/css/javascript - where "value" is of course very subjective :). I've written scripts to (e.g.) build downloadable zip archives of a given page and all its immediate dependancies (images, css etc); convert from local to absolute paths; clean out cruft from directory trees, and so on. I also maintain locahost.com, where all the logging, redirection, emailing etc is handled by a perl/cgi I re-vamped recently. Some perl-ish ambitions: a configurable (real-time) proxy server for mirroring, analyzing and otherwise munging web content; a code-only search engine: search for the tags, not the content; a home-grown blogging tool that does what I need, and nothing more. so, that's something about me. I'll see some of you tommorow? Sam From jakulas at swbell.net Tue Jan 20 15:58:06 2004 From: jakulas at swbell.net (John Kulas) Date: Mon Aug 2 21:23:22 2004 Subject: APM: next meeting is tomorrow Wednesday Jan21 Message-ID: <20040120215806.72611.qmail@web80601.mail.yahoo.com> Pok-e Jo's on 5th Street about 6pm tomorrow it is then.....the meeting itself is about 6:30 tomorrow Wednesday Jan21 at ServerGraph (see http://austin.pm.org/meetings.htm) for details. - John Kulas From wwalker at bybent.com Tue Jan 20 19:02:30 2004 From: wwalker at bybent.com (Wayne Walker) Date: Mon Aug 2 21:23:22 2004 Subject: APM: next meeting is tomorrow Wednesday Jan21 In-Reply-To: <20040120215806.72611.qmail@web80601.mail.yahoo.com> References: <20040120215806.72611.qmail@web80601.mail.yahoo.com> Message-ID: <20040121010230.GB12980@bybent.com> John, David, thanks for stepping up to the plate and getting the ball rolling! IF YOU PLAN TO ATTEND, write down my cell - 791-2046. You might need it to get into the building, but probably not. You can also use it if you can't find the place. Slight correction - Meeting starts at 7:00. As I am the person at Servergraph with the key and I plan to attend the pre meeting dinner (which is just across the street). I won't make it back to the office till say 6:55. As to what we will talk about... Unless there is a topic and a speaker (one person talked about giving a talk on Perl 6 but I don't remember if that was actually scheduled).... Wednesday night will be a question and answer session. Bring your questions. We are not very strict or picky, but Perl questions get priority, then Linux, then whatever is left. If there are few enough questions, I will be asking Mark to teach us how to use the perl debugger in emacs, specifically regarding processes that fork while being debugged. On Tue, Jan 20, 2004 at 01:58:06PM -0800, John Kulas wrote: > Pok-e Jo's on 5th Street about 6pm tomorrow it is > then.....the meeting itself is about 6:30 tomorrow > Wednesday Jan21 at ServerGraph (see > http://austin.pm.org/meetings.htm) for details. > - John Kulas > _______________________________________________ > Austin mailing list > Austin@mail.pm.org > http://mail.pm.org/mailman/listinfo/austin -- Wayne Walker wwalker@bybent.com Do you use Linux?! http://www.bybent.com Get Counted! http://counter.li.org/ Perl - http://www.perl.org/ Perl User Groups - http://www.pm.org/ Jabber IM: wwalker@jabber.phototropia.org AIM: lwwalkerbybent From dbii at mudpuddle.com Tue Jan 20 21:21:28 2004 From: dbii at mudpuddle.com (David Bluestein II) Date: Mon Aug 2 21:23:22 2004 Subject: APM: next meeting is tomorrow Wednesday Jan21 In-Reply-To: <20040120215806.72611.qmail@web80601.mail.yahoo.com> References: <20040120215806.72611.qmail@web80601.mail.yahoo.com> Message-ID: <20040121032128.GM20627@mudpuddle.com> 6:30? I thought it was at 7:00 pm. That is the time on the website for the old meeting. I want to allow 1 hour for dinner (30 minutes is a little rushed). David On Tue, Jan 20, 2004 at 01:58:06PM -0800, John Kulas wrote: > Pok-e Jo's on 5th Street about 6pm tomorrow it is > then.....the meeting itself is about 6:30 tomorrow > Wednesday Jan21 at ServerGraph (see > http://austin.pm.org/meetings.htm) for details. > - John Kulas > _______________________________________________ > Austin mailing list > Austin@mail.pm.org > http://mail.pm.org/mailman/listinfo/austin From wwalker at bybent.com Tue Jan 20 19:02:30 2004 From: wwalker at bybent.com (Wayne Walker) Date: Mon Aug 2 21:23:22 2004 Subject: APM: next meeting is tomorrow Wednesday Jan21 In-Reply-To: <20040120215806.72611.qmail@web80601.mail.yahoo.com> References: <20040120215806.72611.qmail@web80601.mail.yahoo.com> Message-ID: <20040121010230.GB12980@bybent.com> John, David, thanks for stepping up to the plate and getting the ball rolling! IF YOU PLAN TO ATTEND, write down my cell - 791-2046. You might need it to get into the building, but probably not. You can also use it if you can't find the place. Slight correction - Meeting starts at 7:00. As I am the person at Servergraph with the key and I plan to attend the pre meeting dinner (which is just across the street). I won't make it back to the office till say 6:55. As to what we will talk about... Unless there is a topic and a speaker (one person talked about giving a talk on Perl 6 but I don't remember if that was actually scheduled).... Wednesday night will be a question and answer session. Bring your questions. We are not very strict or picky, but Perl questions get priority, then Linux, then whatever is left. If there are few enough questions, I will be asking Mark to teach us how to use the perl debugger in emacs, specifically regarding processes that fork while being debugged. On Tue, Jan 20, 2004 at 01:58:06PM -0800, John Kulas wrote: > Pok-e Jo's on 5th Street about 6pm tomorrow it is > then.....the meeting itself is about 6:30 tomorrow > Wednesday Jan21 at ServerGraph (see > http://austin.pm.org/meetings.htm) for details. > - John Kulas > _______________________________________________ > Austin mailing list > Austin@mail.pm.org > http://mail.pm.org/mailman/listinfo/austin -- Wayne Walker wwalker@bybent.com Do you use Linux?! http://www.bybent.com Get Counted! http://counter.li.org/ Perl - http://www.perl.org/ Perl User Groups - http://www.pm.org/ Jabber IM: wwalker@jabber.phototropia.org AIM: lwwalkerbybent From mlehmann at marklehmann.com Wed Jan 21 21:20:06 2004 From: mlehmann at marklehmann.com (Mark Lehmann) Date: Mon Aug 2 21:23:22 2004 Subject: APM: One liner to get hash from an environment list Message-ID: <32805.66.136.209.194.1074741606.squirrel@www.marklehmann.com> We used this in the meeting Wednesday evening. I learned this from Bill Raty. %config = map { /(.*?)=(.*)/ } qx(env); -- Mark Lehmannn mlehmann@marklehmann.com - mobile 512 689-7705 From mick at lowdrag.org Wed Jan 21 22:02:42 2004 From: mick at lowdrag.org (Mick) Date: Mon Aug 2 21:23:22 2004 Subject: APM: One liner to get hash from an environment list In-Reply-To: <32805.66.136.209.194.1074741606.squirrel@www.marklehmann.com> References: <32805.66.136.209.194.1074741606.squirrel@www.marklehmann.com> Message-ID: <20040122040242.GA12752@lowdrag.org> * Mark Lehmann [040121 21:35]: > We used this in the meeting Wednesday evening. I learned this from Bill > Raty. > > %config = map { /(.*?)=(.*)/ } qx(env); > %config = %ENV; # Shorter line -- -Mick mick@lowdrag.org OpenPGP info is in the X-mail headers '$A=A;for(0..14689){$A++}print"\U$A"' From wwalker at bybent.com Wed Jan 21 23:36:46 2004 From: wwalker at bybent.com (Wayne Walker) Date: Mon Aug 2 21:23:22 2004 Subject: APM: One liner to get hash from an environment list In-Reply-To: <32805.66.136.209.194.1074741606.squirrel@www.marklehmann.com> References: <32805.66.136.209.194.1074741606.squirrel@www.marklehmann.com> Message-ID: <20040122053646.GB31881@bybent.com> Someone pointed out the %config = %ENV; solution. The point was a small clean config file parser. we used env to generate shell type config data as an example, not for actual application of the concept. This is more clearly useful to those who weren't at the meeting. Boom, no foreach loop, nothing complex. %config = map { /(.*?)=['"]?(.*)['"]?/ } qx(cat /etc/defaults/some_prog_env.sh); This should parse any valid bourne shell syntax key=value config file into a hash. On Wed, Jan 21, 2004 at 09:20:06PM -0600, Mark Lehmann wrote: > We used this in the meeting Wednesday evening. I learned this from Bill > Raty. > > %config = map { /(.*?)=(.*)/ } qx(env); > > > -- > Mark Lehmannn > mlehmann@marklehmann.com - mobile 512 689-7705 > > > > > _______________________________________________ > Austin mailing list > Austin@mail.pm.org > http://mail.pm.org/mailman/listinfo/austin -- Wayne Walker wwalker@bybent.com Do you use Linux?! http://www.bybent.com Get Counted! http://counter.li.org/ Perl - http://www.perl.org/ Perl User Groups - http://www.pm.org/ Jabber IM: wwalker@jabber.phototropia.org AIM: lwwalkerbybent From wwalker at bybent.com Wed Jan 21 23:49:02 2004 From: wwalker at bybent.com (Wayne Walker) Date: Mon Aug 2 21:23:22 2004 Subject: APM: someone left a notebook Message-ID: <20040122054902.GE31881@bybent.com> Someone left a notebook at Servergraph. Black Spiral bound, Builder.com on the front. Call me if it's yours (791-2046). -- Wayne Walker wwalker@bybent.com Do you use Linux?! http://www.bybent.com Get Counted! http://counter.li.org/ Perl - http://www.perl.org/ Perl User Groups - http://www.pm.org/ Jabber IM: wwalker@jabber.phototropia.org AIM: lwwalkerbybent From dbii at mudpuddle.com Thu Jan 22 02:02:42 2004 From: dbii at mudpuddle.com (David Bluestein II) Date: Mon Aug 2 21:23:22 2004 Subject: APM: Site Mapping Graphing Program from November Message-ID: Okay, back at the November bring your question meeting, someone (actually a couple of people I think) mentioned a graphing program in Perl that output images. I remember I looked at it, and it would take a list of HTML pages, and what they pointed to, and make an image of the relationships. I can't remember the name of the graphing/diagramming program though (not GD, it may have used GD, but it was a wrapper at the very least). I remember I could provide the list of what linked to what and it would draw the diagram, but have lost hte URL. Thanks- David ---------- David H. Bluestein II President & Lead Developer dbii@interaction.net ii, inc. http://www.interaction.net - Specializing in Designing Interactive Websites - - and Searchable Internet Databases - From dbii at mudpuddle.com Thu Jan 22 02:21:02 2004 From: dbii at mudpuddle.com (David Bluestein II) Date: Mon Aug 2 21:23:22 2004 Subject: APM: Site Mapping Graphing Program from November In-Reply-To: References: Message-ID: <20040122082102.GI20627@mudpuddle.com> Okay, had searched for the answer for an hour. Emailed list, found answer 5 minutes later. GraphViz (www.graphviz.org) :) David On Thu, Jan 22, 2004 at 02:02:42AM -0600, David Bluestein II wrote: > Okay, back at the November bring your question meeting, someone (actually a > couple of people I think) mentioned a graphing program in Perl that output > images. I remember I looked at it, and it would take a list of HTML pages, > and what they pointed to, and make an image of the relationships. I can't > remember the name of the graphing/diagramming program though (not GD, it > may have used GD, but it was a wrapper at the very least). > > I remember I could provide the list of what linked to what and it would > draw the diagram, but have lost hte URL. > > Thanks- > > David > > ---------- > David H. Bluestein II President & Lead Developer > dbii@interaction.net ii, inc. > > http://www.interaction.net > - Specializing in Designing Interactive Websites - > - and Searchable Internet Databases - > > > > > > _______________________________________________ > Austin mailing list > Austin@mail.pm.org > http://mail.pm.org/mailman/listinfo/austin From austin.pm at sam-i-am.com Thu Jan 22 10:45:41 2004 From: austin.pm at sam-i-am.com (Sam Foster) Date: Mon Aug 2 21:23:22 2004 Subject: APM: One liner to get hash from an environment list In-Reply-To: <20040122053646.GB31881@bybent.com> References: <32805.66.136.209.194.1074741606.squirrel@www.marklehmann.com> <20040122053646.GB31881@bybent.com> Message-ID: <400FFE35.8090708@sam-i-am.com> > %config = map { /(.*?)=['"]?(.*)['"]?/ } qx(cat /etc/defaults/some_prog_env.sh); > > This should parse any valid bourne shell syntax key=value config file > into a hash. but if you want to allow #comments, blank lines etc, you might end up with something like this? my %config; foreach ( qx(cat /your/input/file) ) { next if /^\s*#/; # skip commented lines # match for name=value pairs, allowing for indentation and # options whitespace around the '='. # We should really use a backreference to pair up the quotes? next unless ( /\s*(.*?)\s*=\s*['"]?(.*)['"]?/ ); $config{$1} = $2; } Can you combine the regexps to get this back on one line? (for those who take joy from this sort of thing?) Sam From erik at debill.org Thu Jan 22 11:56:11 2004 From: erik at debill.org (erik@debill.org) Date: Mon Aug 2 21:23:22 2004 Subject: APM: One liner to get hash from an environment list In-Reply-To: <400FFE35.8090708@sam-i-am.com> References: <32805.66.136.209.194.1074741606.squirrel@www.marklehmann.com> <20040122053646.GB31881@bybent.com> <400FFE35.8090708@sam-i-am.com> Message-ID: <20040122175611.GA23650@debill.org> You guys are now illustrating why Config::General is a good thing. from the perldoc... use Config::General; $conf = new Config::General("rcfile"); my %config = $conf->getall; Erik From rock808 at davidslimp.com Thu Jan 22 11:23:06 2004 From: rock808 at davidslimp.com (David Slimp) Date: Mon Aug 2 21:23:22 2004 Subject: APM: One liner to get hash from an environment list In-Reply-To: <400FFE35.8090708@sam-i-am.com> References: <32805.66.136.209.194.1074741606.squirrel@www.marklehmann.com> <20040122053646.GB31881@bybent.com> <400FFE35.8090708@sam-i-am.com> Message-ID: <20040122172305.GW5769@DavidSlimp.com> try a regex like this (works for me): /^\s*([^#].*?)\s*=\s*['"]?(.*)['"]?/ david On Thu, Jan 22, 2004 at 10:45:41AM -0600, Sam Foster wrote: > >%config = map { /(.*?)=['"]?(.*)['"]?/ } qx(cat > >/etc/defaults/some_prog_env.sh); > > > >This should parse any valid bourne shell syntax key=value config file > >into a hash. > > but if you want to allow #comments, blank lines etc, you might end up > with something like this? > > my %config; > foreach ( qx(cat /your/input/file) ) { > next if /^\s*#/; # skip commented lines > > # match for name=value pairs, allowing for indentation and > # options whitespace around the '='. > # We should really use a backreference to pair up the quotes? > next unless ( /\s*(.*?)\s*=\s*['"]?(.*)['"]?/ ); > $config{$1} = $2; > } > > Can you combine the regexps to get this back on one line? (for those > who take joy from this sort of thing?) > > Sam > > _______________________________________________ > Austin mailing list > Austin@mail.pm.org > http://mail.pm.org/mailman/listinfo/austin -- David Slimp rock808@DavidSlimp.com Do you use Linux?! http://www.DavidSlimp.com Get Counted! http://counter.li.org/ Jabber IM: rock808@jabber.org fax: 801-858-4102 "He who desires the fruit, waters the tree." -- Nguyen Trai From rock808 at davidslimp.com Thu Jan 22 11:39:03 2004 From: rock808 at davidslimp.com (David Slimp) Date: Mon Aug 2 21:23:22 2004 Subject: APM: One liner to get hash from an environment list In-Reply-To: <400FFE35.8090708@sam-i-am.com> References: <32805.66.136.209.194.1074741606.squirrel@www.marklehmann.com> <20040122053646.GB31881@bybent.com> <400FFE35.8090708@sam-i-am.com> Message-ID: <20040122173903.GX5769@DavidSlimp.com> As I tested this out some more, I found a serious problem in the original RegEx when using quotes... I also have a fix.... might wanna use this test program: The 2nd RegEx in the while loop is the problem one. =============================== CUT ======================== #!/usr/bin/perl -w while () { /^\s*([^#].*?)\s*=\s*(['"]?)(.*)\2/ and $config{$1}=$3; #/^\s*([^#].*?)\s*=\s*['"]?(.*)['"]?/ and $config{$1}=$2; } foreach $k (keys %config) { print ":$k:$config{$k}:\n"; } __DATA__ a=b this = that hi = bye #commeent = not allows text=he said, "hi!" to me. quote=don't do that! key="some value" =============================== CUT ======================== On Thu, Jan 22, 2004 at 10:45:41AM -0600, Sam Foster wrote: > >%config = map { /(.*?)=['"]?(.*)['"]?/ } qx(cat > >/etc/defaults/some_prog_env.sh); > > > >This should parse any valid bourne shell syntax key=value config file > >into a hash. > > but if you want to allow #comments, blank lines etc, you might end up > with something like this? > > my %config; > foreach ( qx(cat /your/input/file) ) { > next if /^\s*#/; # skip commented lines > > # match for name=value pairs, allowing for indentation and > # options whitespace around the '='. > # We should really use a backreference to pair up the quotes? > next unless ( /\s*(.*?)\s*=\s*['"]?(.*)['"]?/ ); > $config{$1} = $2; > } > > Can you combine the regexps to get this back on one line? (for those > who take joy from this sort of thing?) > > Sam > > _______________________________________________ > Austin mailing list > Austin@mail.pm.org > http://mail.pm.org/mailman/listinfo/austin -- David Slimp rock808@DavidSlimp.com Do you use Linux?! http://www.DavidSlimp.com Get Counted! http://counter.li.org/ Jabber IM: rock808@jabber.org fax: 801-858-4102 "He who desires the fruit, waters the tree." -- Nguyen Trai From mlehmann at marklehmann.com Thu Jan 22 13:46:05 2004 From: mlehmann at marklehmann.com (Mark Lehmann) Date: Mon Aug 2 21:23:22 2004 Subject: APM: One liner to get hash from an environment list In-Reply-To: <20040122175611.GA23650@debill.org> References: <32805.66.136.209.194.1074741606.squirrel@www.marklehmann.com> <20040122053646.GB31881@bybent.com> <400FFE35.8090708@sam-i-am.com> <20040122175611.GA23650@debill.org> Message-ID: <1389.66.45.70.241.1074800765.squirrel@www.marklehmann.com> Aha, you revealed my secret agenda. Demonstration need and teach through iteration. I learn better when I see iterations of a concept, then I have buy in to some of the CPAN modules which do the concept for me as well as takes care of the situations I didn't forsee. -- Mark Lehmannn mlehmann@marklehmann.com - mobile 512 689-7705 > You guys are now illustrating why Config::General is a good thing. > > from the perldoc... > use Config::General; > $conf = new Config::General("rcfile"); > my %config = $conf->getall; > > > Erik > _______________________________________________ > Austin mailing list > Austin@mail.pm.org > http://mail.pm.org/mailman/listinfo/austin From bill_raty at yahoo.com Thu Jan 22 21:16:28 2004 From: bill_raty at yahoo.com (Bill Raty) Date: Mon Aug 2 21:23:22 2004 Subject: The situation to use the one liner (Re: APM: One liner to get hash from an environment list) In-Reply-To: <400FFE35.8090708@sam-i-am.com> Message-ID: <20040123031628.67490.qmail@web20420.mail.yahoo.com> Fellow Mongers (and Sam), This note isn't written to say the one-liner is superior to the other fine means from CPAN, but rather to describe the one situation which best exhibits its strength. Read on if you're interested. Yes you can combine the regexes (or transform them, or use grep) to filter out comments if such is your which. How is left as an excercise of the class. Hint: Schwarzian transform. However this brings us full circle to why the one liner was written in the first place. The original code that the one liner replaced was written to parse a shell script provided by a third party that set-up a database environment that had to be available from processes executed from Perl. When the DB engine was updated by the third party, the updated shell script broke the rather simple parsing rules of the perl code used, although the shell script remained perfectly legal. The one liner replaced about of score of lines of logic and relied upon the fact that a shell best knows how to interpret shell commands, and made the Perl script immune from changes to the third-party maintained script. The original one liner: %ENV = map /(^.*?)=(.*)/, qx( /some/script; env ); Will work for any version of /some/script that is valid for its shell interpreter, without reduplication of shell logic in Perl. This holds with standard Unix philosophy: stand on the shoulders of giants. The same holds for the CPAN modules (of which there are dozens of configuration schemes from Winduhs style .ini files to XML). If you're trying to leverage a shell script provided by a third party (DB vendor) that is written for a particular shell, its probably best to have the referenced shell interpret said script. My $0.02, -Bill --- Sam Foster wrote: > > %config = map { /(.*?)=['"]?(.*)['"]?/ } qx(cat > /etc/defaults/some_prog_env.sh); > > > > This should parse any valid bourne shell syntax key=value > config file > > into a hash. > > but if you want to allow #comments, blank lines etc, you > might end up > with something like this? > > my %config; > foreach ( qx(cat /your/input/file) ) { > next if /^\s*#/; # skip commented lines > > # match for name=value pairs, allowing for indentation and > # options whitespace around the '='. > # We should really use a backreference to pair up the > quotes? > next unless ( /\s*(.*?)\s*=\s*['"]?(.*)['"]?/ ); > $config{$1} = $2; > } > > Can you combine the regexps to get this back on one line? > (for those > who take joy from this sort of thing?) > > Sam > > _______________________________________________ > Austin mailing list > Austin@mail.pm.org > http://mail.pm.org/mailman/listinfo/austin From wwalker at bybent.com Thu Jan 22 23:32:46 2004 From: wwalker at bybent.com (Wayne Walker) Date: Mon Aug 2 21:23:22 2004 Subject: The situation to use the one liner (Re: APM: One liner to get hash from an environment list) In-Reply-To: <20040123031628.67490.qmail@web20420.mail.yahoo.com> References: <400FFE35.8090708@sam-i-am.com> <20040123031628.67490.qmail@web20420.mail.yahoo.com> Message-ID: <20040123053246.GD6649@bybent.com> Thanks Bill, I hadn't thought of the "execute the interpreter and parse the output of env" That's sweet. My solution looks ugly now... On Thu, Jan 22, 2004 at 07:16:28PM -0800, Bill Raty wrote: > Fellow Mongers (and Sam), > > This note isn't written to say the one-liner is superior to the > other fine means from CPAN, but rather to describe the one > situation which best exhibits its strength. Read on if you're > interested. > > Yes you can combine the regexes (or transform them, or use > grep) to filter out comments if such is your which. How is > left as an excercise of the class. Hint: Schwarzian transform. > > However this brings us full circle to why the one liner was > written in the first place. The original code that the one > liner replaced was written to parse a shell script provided by > a third party that set-up a database environment that had to be > available from processes executed from Perl. When the DB > engine was updated by the third party, the updated shell script > broke the rather simple parsing rules of the perl code used, > although the shell script remained perfectly legal. > > The one liner replaced about of score of lines of logic and > relied upon the fact that a shell best knows how to interpret > shell commands, and made the Perl script immune from changes to > the third-party maintained script. > > The original one liner: > > %ENV = map /(^.*?)=(.*)/, qx( /some/script; env ); > > Will work for any version of /some/script that is valid for its > shell interpreter, without reduplication of shell logic in > Perl. This holds with standard Unix philosophy: stand on the > shoulders of giants. > > The same holds for the CPAN modules (of which there are dozens > of configuration schemes from Winduhs style .ini files to XML). > If you're trying to leverage a shell script provided by a > third party (DB vendor) that is written for a particular shell, > its probably best to have the referenced shell interpret said > script. > > My $0.02, > > -Bill > > --- Sam Foster wrote: > > > %config = map { /(.*?)=['"]?(.*)['"]?/ } qx(cat > > /etc/defaults/some_prog_env.sh); > > > > > > This should parse any valid bourne shell syntax key=value > > config file > > > into a hash. > > > > but if you want to allow #comments, blank lines etc, you > > might end up > > with something like this? > > > > my %config; > > foreach ( qx(cat /your/input/file) ) { > > next if /^\s*#/; # skip commented lines > > > > # match for name=value pairs, allowing for indentation and > > # options whitespace around the '='. > > # We should really use a backreference to pair up the > > quotes? > > next unless ( /\s*(.*?)\s*=\s*['"]?(.*)['"]?/ ); > > $config{$1} = $2; > > } > > > > Can you combine the regexps to get this back on one line? > > (for those > > who take joy from this sort of thing?) > > > > Sam > > > > _______________________________________________ > > Austin mailing list > > Austin@mail.pm.org > > http://mail.pm.org/mailman/listinfo/austin > > _______________________________________________ > Austin mailing list > Austin@mail.pm.org > http://mail.pm.org/mailman/listinfo/austin -- Wayne Walker wwalker@bybent.com Do you use Linux?! http://www.bybent.com Get Counted! http://counter.li.org/ Perl - http://www.perl.org/ Perl User Groups - http://www.pm.org/ Jabber IM: wwalker@jabber.phototropia.org AIM: lwwalkerbybent From goldilox at teachnet.edb.utexas.edu Tue Jan 27 12:10:43 2004 From: goldilox at teachnet.edb.utexas.edu (Goldilox) Date: Mon Aug 2 21:23:23 2004 Subject: APM: some simple questions Message-ID: is it better form to do this: while($exlen > 0){$indent=$indent."  ";$exlen=$exlen-1;} or this while($exlen){$indent=$indent."  ";$exlen=$exlen-1;} (or is the second one even going to work?) 2nd question: why do sometimes I have to call a subroutine with an ampersand &subroutine(); and other times can just say the name of the subroutine subroutine; ?? Thanks for help, advice, etc! Rhett From wwalker at bybent.com Tue Jan 27 12:40:35 2004 From: wwalker at bybent.com (Wayne Walker) Date: Mon Aug 2 21:23:23 2004 Subject: APM: some simple questions In-Reply-To: References: Message-ID: <20040127184035.GC396@bybent.com> On Tue, Jan 27, 2004 at 12:10:43PM -0600, Goldilox wrote: > is it better form to do this: > > while($exlen > 0){$indent=$indent."  ";$exlen=$exlen-1;} > > or this > > while($exlen){$indent=$indent."  ";$exlen=$exlen-1;} > > (or is the second one even going to work?) Both should work (didn't test it, nor did I test this...) This should also work $indent .= ("  " x $exlen); see "perldoc perlop" search for " x " minus the quotes > 2nd question: > why do sometimes I have to call a subroutine with an ampersand > > &subroutine(); > > and other times can just say the name of the subroutine > > subroutine; Perl understands any subroutine that is builtin, or has already been defined (above where it's being called) is a subroutine. If you define it later in the program file, perl doesn't know yet that it's a sub. > > ?? > > Thanks for help, advice, etc! > > Rhett > > _______________________________________________ > Austin mailing list > Austin@mail.pm.org > http://mail.pm.org/mailman/listinfo/austin -- Wayne Walker wwalker@bybent.com Do you use Linux?! http://www.bybent.com Get Counted! http://counter.li.org/ Perl - http://www.perl.org/ Perl User Groups - http://www.pm.org/ Jabber IM: wwalker@jabber.phototropia.org AIM: lwwalkerbybent From mike at stok.co.uk Tue Jan 27 12:51:22 2004 From: mike at stok.co.uk (Mike Stok) Date: Mon Aug 2 21:23:23 2004 Subject: APM: some simple questions In-Reply-To: <20040127184035.GC396@bybent.com> References: <20040127184035.GC396@bybent.com> Message-ID: On Tue, 27 Jan 2004, Wayne Walker wrote: > On Tue, Jan 27, 2004 at 12:10:43PM -0600, Goldilox wrote: > > is it better form to do this: > > > > while($exlen > 0){$indent=$indent."  ";$exlen=$exlen-1;} > > > > or this > > > > while($exlen){$indent=$indent."  ";$exlen=$exlen-1;} > > > > (or is the second one even going to work?) > > Both should work (didn't test it, nor did I test this...) > This should also work > > $indent .= ("  " x $exlen); > > see "perldoc perlop" search for " x " minus the quotes Hmmm, if $exlen happens to start out with a value < 0 then the second while loop may take a while to complete. Wayne's solution is safer (and you could even say something like this use constant INDENT_SPACES => 2; #   per space $indent .= ' ' x (INDENT_SPACES * $exlen); if the mood took you...) Mike -- mike@stok.co.uk | The "`Stok' disclaimers" apply. http://www.stok.co.uk/~mike/ | GPG PGP Key 1024D/059913DA mike@exegenix.com | Fingerprint 0570 71CD 6790 7C28 3D60 http://www.exegenix.com/ | 75D2 9EC4 C1C0 0599 13DA From msouth at shodor.org Tue Jan 27 18:22:14 2004 From: msouth at shodor.org (Mike South) Date: Mon Aug 2 21:23:23 2004 Subject: APM: some simple questions In-Reply-To: References: <20040127184035.GC396@bybent.com> Message-ID: <401700B6.mail102110UWX@scan.shodor.org> On Tue, Jan 27, 2004 at 12:10:43PM -0600, Goldilox wrote: > is it better form to do this: > > while($exlen > 0){$indent=$indent."  ";$exlen=$exlen-1;} > > or this > > while($exlen){$indent=$indent."  ";$exlen=$exlen-1;} > > (or is the second one even going to work?) The first one is safer, because if $exlen had a value of 1.5 to start with, the second one is an endless loop. I agree with others who suggested the ' X ' operator for this situation. However, you might want another "one line loop" in the future, so you might look at the statement-modifer "for", like this: $spaces = ' ' x 2; # this way you get to use # BOTH ' x ' operator AND # a one-line loop! No # extra charge! :) $indent .= $spaces for 1..$exlen; mike From michalk at awpi.com Wed Jan 28 13:55:54 2004 From: michalk at awpi.com (Brian Michalk) Date: Mon Aug 2 21:23:23 2004 Subject: APM: Site Mapping Graphing Program from November In-Reply-To: <20040122082102.GI20627@mudpuddle.com> Message-ID: I checked this out. It looks pretty cool. As I've mentioned in a past presentation, I have a *huge* parse::recdescent parser definition. I use it to document the various protocols used at work. The problem is that it's difficult for non-programmers to read; most notably the Visual Basic guy. It would be very, very cool to feed GraphVis my parser, and have it generate web based clickable documentation. Is anyone familiar with anything like this already in development? I post some of my parser so that you can see what Parse::RecDescent uses: header : head3data | head4data head3data : 'HEAD3,' dateymd ',' # date hdistrict ','# district hcounty ','# county highway ','# highway hbrefmark ','# beg. Ref. marker hdirection # lane and roadbed | head4data : 'HEAD4,' comment ',' dmi1 ',' timestamp ','# date hdistrict ','# district hcounty ','# county highway ','# highway hbrefmark ','# beg. Ref. marker hdirection # lane and roadbed | GraphVis wants things like the following: digraph test123 { a -> b -> c; a -> {x y}; b [shape=box]; c [label="hello\nworld",color=blue,fontsize=24, fontname="Palatino-Italic",fontcolor=red,style=filled]; a -> z [label="hi", weight=100]; x -> z [label="multi-line\nlabel"]; edge [style=dashed,color=red]; b -> x; {rank=same; b x} } > -----Original Message----- > From: austin-bounces@mail.pm.org [mailto:austin-bounces@mail.pm.org]On > Behalf Of David Bluestein II > Sent: Thursday, January 22, 2004 2:21 AM > To: Austin@mail.pm.org > Subject: Re: APM: Site Mapping Graphing Program from November > > > Okay, had searched for the answer for an hour. Emailed list, > found answer 5 minutes later. > > GraphViz > > (www.graphviz.org) > > :) > > David > > On Thu, Jan 22, 2004 at 02:02:42AM -0600, David Bluestein II wrote: > > Okay, back at the November bring your question meeting, someone > (actually a > > couple of people I think) mentioned a graphing program in Perl > that output > > images. I remember I looked at it, and it would take a list of > HTML pages, > > and what they pointed to, and make an image of the > relationships. I can't > > remember the name of the graphing/diagramming program though (not GD, it > > may have used GD, but it was a wrapper at the very least). > > > > I remember I could provide the list of what linked to what and it would > > draw the diagram, but have lost hte URL. > > > > Thanks- > > > > David > > > > ---------- > > David H. Bluestein II President & Lead Developer > > dbii@interaction.net ii, inc. > > > > http://www.interaction.net > > - Specializing in Designing Interactive Websites - > > - and Searchable Internet Databases - > > > > > > > > > > > > _______________________________________________ > > Austin mailing list > > Austin@mail.pm.org > > http://mail.pm.org/mailman/listinfo/austin > _______________________________________________ > Austin mailing list > Austin@mail.pm.org > http://mail.pm.org/mailman/listinfo/austin > From eharris at puremagic.com Wed Jan 28 19:28:57 2004 From: eharris at puremagic.com (Evan Harris) Date: Mon Aug 2 21:23:23 2004 Subject: APM: Problem with DB_File and tie'd hash Message-ID: I have software that reads sendmail's access db using DB_File and perls tie. I just upgraded to a new version of sendmail (8.12.11), and now the tie is failing with this message: Unable to open access.db file '/etc/mail/access.db': Inappropriate ioctl for device at ./relaydelay.test.pl line 1437. Anybody know what I need to update to fix this? Are the db formats different? Does perl need to be recompiled using another db lib? Evan From tim at toolman.org Thu Jan 29 08:05:46 2004 From: tim at toolman.org (Tim Peoples) Date: Mon Aug 2 21:23:23 2004 Subject: APM: Problem with DB_File and tie'd hash In-Reply-To: References: Message-ID: <1075385146.29843.84.camel@tpeoples.dmotorworks.com> You probably just need to recompile DB_File. Tim. On Wed, 2004-01-28 at 19:28, Evan Harris wrote: > I have software that reads sendmail's access db using DB_File and perls tie. > > I just upgraded to a new version of sendmail (8.12.11), and now the tie is > failing with this message: > > Unable to open access.db file '/etc/mail/access.db': Inappropriate ioctl for device at ./relaydelay.test.pl line 1437. > > Anybody know what I need to update to fix this? Are the db formats > different? Does perl need to be recompiled using another db lib? > > Evan > > _______________________________________________ > Austin mailing list > Austin@mail.pm.org > http://mail.pm.org/mailman/listinfo/austin -- Tim Peoples From eharris at puremagic.com Thu Jan 29 10:36:50 2004 From: eharris at puremagic.com (Evan Harris) Date: Mon Aug 2 21:23:23 2004 Subject: APM: Problem with DB_File and tie'd hash In-Reply-To: <1075385146.29843.84.camel@tpeoples.dmotorworks.com> Message-ID: Actually, for those of you who may be interested, the solution turned out that DB_File only works with BDB 1.x format files, while 2.x/3.x/4.x seems to require the BerkeleyDB module, and of course the newer Sendmail used a later format. And part of the confusion problem is I was using $! to get the error message for the failed tie, and apparently a tie failure doesn't set $!, so I was getting a cause for an error from a previous and completely unrelated function. Evan On Thu, 29 Jan 2004, Tim Peoples wrote: > > You probably just need to recompile DB_File. > > Tim. > > On Wed, 2004-01-28 at 19:28, Evan Harris wrote: > > I have software that reads sendmail's access db using DB_File and perls tie. > > > > I just upgraded to a new version of sendmail (8.12.11), and now the tie is > > failing with this message: > > > > Unable to open access.db file '/etc/mail/access.db': Inappropriate ioctl for device at ./relaydelay.test.pl line 1437. > > > > Anybody know what I need to update to fix this? Are the db formats > > different? Does perl need to be recompiled using another db lib? > > > > Evan > > > > _______________________________________________ > > Austin mailing list > > Austin@mail.pm.org > > http://mail.pm.org/mailman/listinfo/austin > -- > Tim Peoples > > _______________________________________________ > Austin mailing list > Austin@mail.pm.org > http://mail.pm.org/mailman/listinfo/austin >