From Tom.Bakken at tx.usda.gov Thu Sep 5 09:53:44 2002 From: Tom.Bakken at tx.usda.gov (Tom.Bakken) Date: Mon Aug 2 21:23:14 2004 Subject: APM: ActivePerl documentation Message-ID: <3D776FF8.A339D4C1@tx.usda.gov> Can anybody recommend a good ActivePerl (Windows 2000) documentation source, either textbook, web or otherwise? -- Tom Bakken Information Resource Manager USDA, Rural Development 101 South Main, Suite 102 Temple, TX 76501 Phone: 254-742-9726 Fax: 254-742-9709 Email: tom.bakken@tx.usda.gov From bmetcalf at nortelnetworks.com Thu Sep 5 10:42:09 2002 From: bmetcalf at nortelnetworks.com (Brandon Metcalf) Date: Mon Aug 2 21:23:14 2004 Subject: APM: ActivePerl documentation In-Reply-To: <3D776FF8.A339D4C1@tx.usda.gov> References: <3D776FF8.A339D4C1@tx.usda.gov> Message-ID: Tom.Bakken@tx.usda.gov writes: == Can anybody recommend a good ActivePerl (Windows 2000) documentation == source, either textbook, web or otherwise? Other than what comes with the distribution or is available on the ActiveState website? What else do you need? Brandon -- There are risks and costs to action. But they are far less than the long range risks of comfortable inaction. --John F. Kennedy From Tom.Bakken at tx.usda.gov Wed Sep 11 11:23:03 2002 From: Tom.Bakken at tx.usda.gov (Tom.Bakken) Date: Mon Aug 2 21:23:14 2004 Subject: APM: Perl on Windows 2000 Message-ID: <3D7F6DE7.B7684B2E@tx.usda.gov> I'm off to a creaky start running perl scripts on a windows 2000 server. I'm used to LINUX, so maybe somebody that's been down this road can share some of their hard earned experience with me. I've written a very simple perl script: #!perl -w use strict; use CGI; unless (open BACKUPFILE, "f:/serverbackup/2002.09.10.11.00p.txt") { die "Cannot read backup file: $!"; } while () { chomp; print; #print if /^ Backup Type:/ ; #print if /B a/ ; } Which works great as far as opening and reading the file. Unfortunately, there's some white space between each of the characters. The file looks normal in word pad and notepad and type the file from the command prompt, but when I use edit from the command prompt and print the file from the perl script, there is white space inserted between each of the characters. I've checked the perldoc FAQ on DOS but can't see where I err. Any help for a PERL/Win32 novice? -- Tom Bakken Information Resource Manager USDA, Rural Development 101 South Main, Suite 102 Temple, TX 76501 Phone: 254-742-9726 Fax: 254-742-9709 Email: tom.bakken@tx.usda.gov From wwalker at bybent.com Wed Sep 11 11:58:06 2002 From: wwalker at bybent.com (Wayne Walker) Date: Mon Aug 2 21:23:14 2004 Subject: APM: Perl on Windows 2000 In-Reply-To: <3D7F6DE7.B7684B2E@tx.usda.gov> References: <3D7F6DE7.B7684B2E@tx.usda.gov> Message-ID: <20020911165806.GA21166@bybent.com> The file is probably in unicode. So every character is made up of two bytes. zip the file, then get it on a linux box and run: od -cx filename | less That will let you see what the "blanks" are. Then you can do something like this on thw W2K side: Insert Redhat ...er..no , like this while () { chomp; s/\000//g; # Remove all ASCII nuls # (I think \000 represents a single character in perl in octal, I may # have this wrong don't use it very often and have to head to to # office, running a little behind on my 9:00 start time...) print; #print if /^ Backup Type:/ ; #print if /B a/ ; } On Wed, Sep 11, 2002 at 11:23:03AM -0500, Tom.Bakken wrote: > I'm off to a creaky start running perl scripts on a windows 2000 > server. I'm used to LINUX, so maybe somebody that's been down this road > can share some of their hard earned experience with me. > > I've written a very simple perl script: > #!perl -w > use strict; > use CGI; > unless (open BACKUPFILE, "f:/serverbackup/2002.09.10.11.00p.txt") { > die "Cannot read backup file: $!"; > } > while () { > chomp; > print; > #print if /^ Backup Type:/ ; > #print if /B a/ ; > } > > Which works great as far as opening and reading the file. > Unfortunately, there's some white space between each of the characters. > The file looks normal in word pad and notepad and type the file from the > command prompt, but when I use edit from the command prompt and print > the file from the perl script, there is white space inserted between > each of the characters. > > I've checked the perldoc FAQ on DOS but can't see where I err. > > Any help for a PERL/Win32 novice? > > -- > Tom Bakken > Information Resource Manager > USDA, Rural Development > 101 South Main, Suite 102 > Temple, TX 76501 > > Phone: 254-742-9726 Fax: 254-742-9709 > Email: tom.bakken@tx.usda.gov > _______________________________________________ > Austin mailing list > Austin@mail.pm.org > http://mail.pm.org/mailman/listinfo/austin -- Wayne Walker From wwalker at bybent.com Wed Sep 11 12:00:04 2002 From: wwalker at bybent.com (Wayne Walker) Date: Mon Aug 2 21:23:14 2004 Subject: APM: Perl on Windows 2000 In-Reply-To: <20020911165806.GA21166@bybent.com> References: <3D7F6DE7.B7684B2E@tx.usda.gov> <20020911165806.GA21166@bybent.com> Message-ID: <20020911170004.GC21166@bybent.com> On Wed, Sep 11, 2002 at 11:58:06AM -0500, Wayne Walker wrote: > The file is probably in unicode. So every character is made up of two > bytes. zip the file, then get it on a linux box and run: > unzip filename.zip > od -cx filename | less From Tom.Bakken at tx.usda.gov Wed Sep 11 15:57:24 2002 From: Tom.Bakken at tx.usda.gov (Tom.Bakken) Date: Mon Aug 2 21:23:14 2004 Subject: APM: Perl on Windows 2000 References: <3D7F6DE7.B7684B2E@tx.usda.gov> <20020911165806.GA21166@bybent.com> Message-ID: <3D7FAE34.C791263A@tx.usda.gov> > s/\000//g; # Remove all ASCII nuls > > # (I think \000 represents a single character in perl in octal, I may > # have this wrong don't use it very often and have to head to to > # office, running a little behind on my 9:00 start time...) > Wayne, you thought right. Good call. Thanks. -- Tom Bakken Information Resource Manager USDA, Rural Development 101 South Main, Suite 102 Temple, TX 76501 Phone: 254-742-9726 Fax: 254-742-9709 Email: tom.bakken@tx.usda.gov From dbii at mudpuddle.com Fri Sep 13 15:45:01 2002 From: dbii at mudpuddle.com (David Bluestein II) Date: Mon Aug 2 21:23:14 2004 Subject: APM: Meeting on 9/18 Message-ID: I forget the topic, but we are having a meeting next week on the 18th, right? Guess Larry can tell us the topic, and make sure we where and when it is (Maxim, or whatever they go by now?)? David Bluestein ---------- David H. Bluestein II President & Lead Developer dbii@mudpuddle.com ii, inc. http://www.interaction.net - Specializing in Designing Interactive Websites - - and Searchable Internet Databases - From lhunter at lhunter.com Mon Sep 16 21:31:50 2002 From: lhunter at lhunter.com (Larry Hunter) Date: Mon Aug 2 21:23:14 2004 Subject: APM: Next meeting Wednesday, Sept. 18 Message-ID: <4.2.2.20020916210941.00a33f00@lhunter.com> The Austin Perl Mongers September meeting is this Wednesday, September 18 at the Tek Systems office (formerly Maxim Group). Light munchies at 6:30 pm, meeting at 7:00, and the Tek Systems building doors lock at 7:00 so be on time. The scheduled topic is VMWare for Perl testing in multiple environments. (Andrew - what is your email address so I can check if this is still on?) Tek Systems is at 12331 Riata Trace Parkway. For a map go to http://www.teksystems.com and follow the links to "Locations" and Texas. ------------------------------------------------------------------------ Larry Hunter lhunter@lhunter.com http://lhunter.com/ From asanders at bybent.com Tue Sep 17 17:16:47 2002 From: asanders at bybent.com (Andrew Sanders) Date: Mon Aug 2 21:23:14 2004 Subject: APM: test message 2 Message-ID: <1032301007.4382.1715.camel@digitalfiend.internal.net.org> just testing here From Goldilox at teachnet.edb.utexas.edu Tue Sep 24 12:37:39 2002 From: Goldilox at teachnet.edb.utexas.edu (Goldilox) Date: Mon Aug 2 21:23:14 2004 Subject: APM: Unix time help Message-ID: I want to convert -M $file output to Unix time (or -M's equivalent seconds so I can create its corresponding Unix time). I also want to convert dates to their corresponding Unix time. Anyone know of a module or code snippet(s)? Thanks Rhett From mike at stok.co.uk Tue Sep 24 12:59:05 2002 From: mike at stok.co.uk (Mike Stok) Date: Mon Aug 2 21:23:14 2004 Subject: APM: Unix time help In-Reply-To: Message-ID: On Tue, 24 Sep 2002, Goldilox wrote: > I want to convert -M $file output to Unix time (or -M's equivalent seconds so I > can create its corresponding Unix time). > > I also want to convert dates to their corresponding Unix time. > > Anyone know of a module or code snippet(s)? Thanks [mike@won mike]$ ls -l /etc/passwd -rw-r--r-- 1 root root 1328 Sep 16 06:56 /etc/passwd [mike@won mike]$ perl -de 1 Loading DB routines from perl5db.pl version 1.19 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(-e:1): 1 DB<1> $t = -M '/etc/passwd' DB<2> print scalar localtime $^T - $t * 24 * 60 * 60 Mon Sep 16 06:56:11 2002 Hope this helps, 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 mike at stok.co.uk Tue Sep 24 13:00:57 2002 From: mike at stok.co.uk (Mike Stok) Date: Mon Aug 2 21:23:14 2004 Subject: APM: Unix time help In-Reply-To: Message-ID: On Tue, 24 Sep 2002, Goldilox wrote: > I also want to convert dates to their corresponding Unix time. Try a module like Time::Local or one of the date modules from CPAN. NAME Time::Local - efficiently compute time from local and GMT time SYNOPSIS $time = timelocal($sec,$min,$hour,$mday,$mon,$year); $time = timegm($sec,$min,$hour,$mday,$mon,$year); DESCRIPTION These routines are the inverse of built-in perl functions localtime() and gmtime(). They accept a date as a six- element array, and return the corresponding time(2) value in seconds since the Epoch (Midnight, January 1, 1970). This value can be positive or negative. Hope this helps, (and sorry for the second post...) 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 wwalker at bybent.com Tue Sep 24 13:16:37 2002 From: wwalker at bybent.com (Wayne Walker) Date: Mon Aug 2 21:23:14 2004 Subject: APM: Unix time help In-Reply-To: References: Message-ID: <20020924181637.GZ11835@bybent.com> This hsould do it but too swamped to test... $age_in_days = -M $file; $then = time() - (86400 * $age_in_days); On Tue, Sep 24, 2002 at 12:37:39PM -0500, Goldilox wrote: > I want to convert -M $file output to Unix time (or -M's equivalent seconds so I > can create its corresponding Unix time). > > I also want to convert dates to their corresponding Unix time. > > Anyone know of a module or code snippet(s)? Thanks > > Rhett > > _______________________________________________ > Austin mailing list > Austin@mail.pm.org > http://mail.pm.org/mailman/listinfo/austin -- Wayne Walker From dave at thedevilneversleeps.com Tue Sep 24 14:03:27 2002 From: dave at thedevilneversleeps.com (David Humphreys) Date: Mon Aug 2 21:23:14 2004 Subject: APM: Unix time help In-Reply-To: <20020924181637.GZ11835@bybent.com> References: <20020924181637.GZ11835@bybent.com> Message-ID: <29491134.1032876207@[10.0.1.2]> Date::Manip rocks, too. It'll handle date addition and subtraction, and produce whatever kind of format you want. It'll even convert from loose dates like "last Tuesday." --On Tuesday, September 24, 2002 1:16 PM -0500 Wayne Walker wrote: > This hsould do it but too swamped to test... > > $age_in_days = -M $file; > > $then = time() - (86400 * $age_in_days); > > On Tue, Sep 24, 2002 at 12:37:39PM -0500, Goldilox wrote: >> I want to convert -M $file output to Unix time (or -M's equivalent >> seconds so I can create its corresponding Unix time). >> >> I also want to convert dates to their corresponding Unix time. >> >> Anyone know of a module or code snippet(s)? Thanks >> >> Rhett >> >> _______________________________________________ >> Austin mailing list >> Austin@mail.pm.org >> http://mail.pm.org/mailman/listinfo/austin > > -- > > Wayne Walker > _______________________________________________ > Austin mailing list > Austin@mail.pm.org > http://mail.pm.org/mailman/listinfo/austin ============================================= dave humphreys * dave@thedevilneversleeps.com "Every extra buck has a meaning all its own." - Thelma Ritter in _Pickup on South Street_, 1953 From Goldilox at teachnet.edb.utexas.edu Tue Sep 24 17:28:48 2002 From: Goldilox at teachnet.edb.utexas.edu (Goldilox) Date: Mon Aug 2 21:23:14 2004 Subject: APM: Re: Unix time help Message-ID: Thanks for all the great help! Where can I get good hands-on Perl training? I would prefer to take an ongoing class, but I couldn't find anything past a beginner level when I looked a couple years ago (here in Austin). I would say I'm probably at an intermediate level; anyone have any recommendations for either short or long term training? From david at prc.utexas.edu Thu Sep 26 10:27:28 2002 From: david at prc.utexas.edu (David Parr) Date: Mon Aug 2 21:23:14 2004 Subject: APM: Austin.pm: next meeting? Message-ID: <3D932760.58DA7FB6@prc.utexas.edu> Hello, I was checking the web site, http://austin.pm.org, and it says that the next meeting is June 19th. When is the actual next meeting? October 16th? Topics? thanks! david -- David Parr, UNIX Administrator Population Research Center [ http://www.prc.utexas.edu ] The University of Texas at Austin [ http://www.utexas.edu ] Email: david@prc.utexas.edu Phone: [512] 471-8307 "Everything should be as simple as possible -- but no simpler." -- A. Einstein From wwalker at bybent.com Thu Sep 26 10:35:32 2002 From: wwalker at bybent.com (Wayne Walker) Date: Mon Aug 2 21:23:14 2004 Subject: APM: Austin.pm: next meeting? In-Reply-To: <3D932760.58DA7FB6@prc.utexas.edu> References: <3D932760.58DA7FB6@prc.utexas.edu> Message-ID: <20020926153532.GA5574@bybent.com> The 16th it is. I don't remember if anyone is slated to talk at the next meeting. I can always bore you to tears with 5 minutes notice. On Thu, Sep 26, 2002 at 10:27:28AM -0500, David Parr wrote: > > Hello, > > I was checking the web site, http://austin.pm.org, and it says > that the next meeting is June 19th. > > When is the actual next meeting? October 16th? Topics? > > thanks! > david > > -- > David Parr, UNIX Administrator > Population Research Center [ http://www.prc.utexas.edu ] > The University of Texas at Austin [ http://www.utexas.edu ] > Email: david@prc.utexas.edu Phone: [512] 471-8307 > > "Everything should be as simple as possible -- but no simpler." > -- A. Einstein > _______________________________________________ > Austin mailing list > Austin@mail.pm.org > http://mail.pm.org/mailman/listinfo/austin -- Wayne Walker From Goldilox at teachnet.edb.utexas.edu Thu Sep 26 13:00:27 2002 From: Goldilox at teachnet.edb.utexas.edu (Goldilox) Date: Mon Aug 2 21:23:14 2004 Subject: APM: Question: breaking up a numeric variable Message-ID: Is there a good way to take a numeric variable of undetermined length $var=3423723482309234098; $var2=3325656; etc. and print it out with a comma appropriately placed at every third character slot from the end, i.e. 3,423,723,482,309,234,098 3,325,656 etc. Rhett From ezra at jdba.org Thu Sep 26 13:53:48 2002 From: ezra at jdba.org (ezra) Date: Mon Aug 2 21:23:14 2004 Subject: APM: Question: breaking up a numeric variable In-Reply-To: Message-ID: it's in the camel book somewhere.... 1 while $x =~ s!(.*\d)(\d{3})!$1,$2!; cheers. ================================================================ Ezra Pagel Software Engineer Perl/Java/Oracle ezra@jdba.org Austin Logistics, Inc. epagel@austinlogistics.com Austin, Texas (512)-651-5644 From ChrisS at natlplan.com Thu Sep 26 14:14:08 2002 From: ChrisS at natlplan.com (Chris Stansbury) Date: Mon Aug 2 21:23:14 2004 Subject: APM: Question: breaking up a numeric variable References: Message-ID: <3D935C80.1010902@natlplan.com> Use the commify sub below; taken from Perl cookbook. sub commify { # from Perl Cookbook, page 64 # add commas for pretty printing numbers my $text = reverse $_[0]; $text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g; return scalar reverse $text; } Chris Goldilox wrote: >Is there a good way to take a numeric variable of undetermined length > >$var=3423723482309234098; >$var2=3325656; >etc. >and print it out with a comma appropriately placed at every third character >slot from the end, i.e. > >3,423,723,482,309,234,098 >3,325,656 >etc. > >Rhett > >_______________________________________________ >Austin mailing list >Austin@mail.pm.org >http://mail.pm.org/mailman/listinfo/austin > > > > -- ****************************** Chris Stansbury Systems Administrator ChrisS@natlplan.com wrk: 512-327-6481 internet fax 630-839-2619 www.natlplan.com National Plan Administrators ****************************** From Goldilox at teachnet.edb.utexas.edu Thu Sep 26 14:25:24 2002 From: Goldilox at teachnet.edb.utexas.edu (Goldilox) Date: Mon Aug 2 21:23:14 2004 Subject: APM: Question: breaking up a numeric variable In-Reply-To: <3D935C80.1010902@natlplan.com> References: <3D935C80.1010902@natlplan.com> Message-ID: Thanks again to everyone for all their help! From cohen at aus.edsr.eds.com Thu Sep 26 14:41:12 2002 From: cohen at aus.edsr.eds.com (Rich Cohen) Date: Mon Aug 2 21:23:14 2004 Subject: APM: Question: breaking up a numeric variable In-Reply-To: References: Message-ID: <15763.24944.233189.225286@ikelet> Pick up a copy of the Perl Cookbook, by Tom Christiansen and Nathan Torkington (O'Reilly, 1998). It is very good. It has answers to this and about 300 other common questions. And, most pleasingly, for most questions the Cookbook includes a discussion of how the solution is structured, alternative solutions, and relevant trade-offs. -- Rich Goldilox writes: Is there a good way to take a numeric variable of undetermined length $var=3423723482309234098; $var2=3325656; etc. and print it out with a comma appropriately placed at every third character slot from the end, i.e. 3,423,723,482,309,234,098 3,325,656 etc. Rhett _______________________________________________ Austin mailing list Austin@mail.pm.org http://mail.pm.org/mailman/listinfo/austin From mike at stok.co.uk Thu Sep 26 15:23:14 2002 From: mike at stok.co.uk (Mike Stok) Date: Mon Aug 2 21:23:14 2004 Subject: APM: Question: breaking up a numeric variable In-Reply-To: Message-ID: On Thu, 26 Sep 2002, Goldilox wrote: > Is there a good way to take a numeric variable of undetermined length > > $var=3423723482309234098; > $var2=3325656; > etc. > and print it out with a comma appropriately placed at every third character > slot from the end, i.e. > > 3,423,723,482,309,234,098 > 3,325,656 > etc. Have you tried perldoc -q commas This is a good way of searching the perl FAQ on a modern perl installation. Found in /usr/local/mike/lib/perl5/5.8.0/pod/perlfaq5.pod How can I output my numbers with commas added? This one from Benjamin Goldberg will do it for you: s/(^[-+]?\d+?(?=(?>(?:\d{3})+)(?!\d))|\G\d{3}(?=\d))/$1,/g; or written verbosely: [...] It may not be the best way, but you should know about perldoc and the -q flag... Hope this helps, 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 majcher at majcher.com Thu Sep 26 13:47:04 2002 From: majcher at majcher.com (Marc Majcher) Date: Mon Aug 2 21:23:14 2004 Subject: APM: Question: breaking up a numeric variable In-Reply-To: (Goldilox@teachnet.edb.utexas.edu) References: Message-ID: <200209261847.g8QIl4326394@majcher.com> "Goldilox" : : :Is there a good way to take a numeric variable of undetermined length :and print it out with a comma appropriately placed at every third character :slot from the end : 'perldoc -q comma' gives us this: Found in /usr/local/lib/perl5/5.6.1/pod/perlfaq5.pod How can I output my numbers with commas added? This one will do it for you: sub commify { local $_ = shift; 1 while s/^([-+]?\d+)(\d{3})/$1,$2/; return $_; } $n = 23659019423.2331; print "GOT: ", commify($n), "\n"; GOT: 23,659,019,423.2331 You can't just: s/^([-+]?\d+)(\d{3})/$1,$2/g; because you have to put the comma in and then recalculate your position. Alternatively, this code commifies all numbers in a line regardless of whether they have decimal portions, are preceded by + or -, or whatever: # from Andrew Johnson sub commify { my $input = shift; $input = reverse $input; $input =~ s<(\d\d\d)(?=\d)(?!\d*\.)><$1,>g; return scalar reverse $input; } -- DVS Patriotism is voluntary.