From Showell30 at aol.com Wed Nov 1 11:07:06 2000 From: Showell30 at aol.com (Showell30@aol.com) Date: Wed Aug 4 00:07:44 2004 Subject: SPUG: Perl for doing more visual apps Message-ID: <3a.c4562b6.2731a7ba@aol.com> Does anyone in the Seattle Perl community get to do work of a visual/geometric nature? I love Perl, but so far I have used it mostly for traditional things like text processing, networking, web page generation, etc. Has anyone heard of people using Perl to control CAD programs, as an alternative to Auto Lisp? Do any Perl programmers get to use concepts like trigonometry, vector calculus, etc. in their work? Thanks, Steve Howell - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From johnwick at nwlink.com Wed Nov 1 13:00:08 2000 From: johnwick at nwlink.com (john wickliffe) Date: Wed Aug 4 00:07:44 2004 Subject: SPUG: Perl for doing more visual apps References: <3a.c4562b6.2731a7ba@aol.com> Message-ID: <3A006838.5E0E88F0@nwlink.com> Hi Steve! I use perl in my work for Elf Technologies, building tools to control other programs and to process data and billing files. I use the perl/tk modules, and some times the free tool spec/perl to get a faster start on GUI type programs. http://www.sloan.ucsf.edu/~kvale/specperl.html (specperl is a GUI interface that generates perl code a little like VB) john wickliffe TAPCUG webmaster/Web Development Special Interest Group Leader Showell30@aol.com wrote: > Does anyone in the Seattle Perl community get to do work of a > visual/geometric nature? I love Perl, but so far I have used it mostly for > traditional things like text processing, networking, web page generation, > etc. > > Has anyone heard of people using Perl to control CAD programs, as an > alternative to Auto Lisp? Do any Perl programmers get to use concepts like > trigonometry, vector calculus, etc. in their work? > > Thanks, > Steve Howell > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL > Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address > For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From mcglk at serv.net Wed Nov 1 13:29:00 2000 From: mcglk at serv.net (Ken McGlothlen) Date: Wed Aug 4 00:07:44 2004 Subject: SPUG: Perl for doing more visual apps In-Reply-To: <3a.c4562b6.2731a7ba@aol.com> Message-ID: On Wed, 1 Nov 2000 Showell30@aol.com wrote: | Does anyone in the Seattle Perl community get to do work of a | visual/geometric nature? I love Perl, but so far I have used it mostly for | traditional things like text processing, networking, web page generation, | etc. | | Has anyone heard of people using Perl to control CAD programs, as an | alternative to Auto Lisp? Do any Perl programmers get to use concepts like | trigonometry, vector calculus, etc. in their work? Running a game company does have its advantages. In fact, right now, I'm trying to figure out a good way to model meteor hits using Perl. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From jcokos at ccs.net Wed Nov 1 18:26:53 2000 From: jcokos at ccs.net (John Cokos) Date: Wed Aug 4 00:07:44 2004 Subject: SPUG: Process Size Message-ID: <028901c04463$99c80ed0$27e842cf@iwebx1> Apologies in advance for the dumb question .... How can I determine the amount of memory (in kb) that a perl program consumes once compiled and running? John ======================================== John Cokos, President / CEO: iWeb Inc. http://www.iwebsys.com jcokos@ccs.net ======================================== - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From jope at n2h2.com Wed Nov 1 19:05:19 2000 From: jope at n2h2.com (JP Montagnet) Date: Wed Aug 4 00:07:44 2004 Subject: SPUG: Process Size In-Reply-To: <028901c04463$99c80ed0$27e842cf@iwebx1> Message-ID: See Proc::ProcessTable on CPAN, for a solution that works for Linux and various Unixes. On Wed, 1 Nov 2000, John Cokos wrote: > How can I determine the amount of memory (in kb) that > a perl program consumes once compiled and running? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From jope at n2h2.com Wed Nov 1 19:34:02 2000 From: jope at n2h2.com (JP Montagnet) Date: Wed Aug 4 00:07:44 2004 Subject: SPUG: Process Size In-Reply-To: <028901c04463$99c80ed0$27e842cf@iwebx1> Message-ID: It looks like Proc::ProcessTable slurps in the whole process table once, then never refreshes, which may not be what you want. I was thinking it did some fancy tie() magic under the hood, but doesn't look like it. Bah! If you're on Linux, just parse the appropriate field out of /dev/$$/status (or substitute the appropraite PID for $$ if monitoring another program). Similar facilities ought to be available on the Unixes. On Wed, 1 Nov 2000, John Cokos wrote: > How can I determine the amount of memory (in kb) that > a perl program consumes once compiled and running? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From AHands at unforgettable.com Thu Nov 2 06:10:23 2000 From: AHands at unforgettable.com (Adrian Hands) Date: Wed Aug 4 00:07:44 2004 Subject: SPUG: Process Size References: Message-ID: <3A0159AF.CDB9F6ED@unforgettable.com> open(STAT, " If you're on Linux, just parse the appropriate field out of /dev/$$/status - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From tim at consultix-inc.com Thu Nov 2 11:57:14 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:44 2004 Subject: SPUG: Perl JoBs in Kirkland In-Reply-To: ; from Richard and Tania Bennett on Mon, Oct 30, 2000 at 09:58:05AM -0800 References: Message-ID: <20001102175714.K5993@timji.consultix.wa.com> Position: PERL Programmer Skills: Understanding of Linux running Apache, intermediate to advanced knowledge of PERL and/or PHP. Experience with SQL database server desirable. At least 2-4 years experience building commercial web sites. Experience with streaming media technologies a big plus. What is Neptune.com: Neptune.com develops creation, content and communication applications exclusively for broadband ISPs. Using a proprietary technology platform, Neptune.com presents database driven content through a next-generation, broadband interface. As a Neptune employee, you will work with other senior developers and internet professionals to build cutting edge products that will revolutionize the industry over the next 3 years. This is a permanent, onsite, W-2 (non-contract) position. We need to hire several people! Address: 206 Kirkland Ave, Downtown Kirkland, WA. Benefits: We offer stock options and fully paid for medical, dental and vision benefits. Free video games at the arcade across the street. We are located a block from lots of great restaurants and Lake Washington. Please submit resumes to jobs@neptune.com. No recruiters please. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From tim at consultix-inc.com Thu Nov 2 12:00:12 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:44 2004 Subject: SPUG: Perl Authors Needed for Book Message-ID: <20001102180012.M5993@timji.consultix.wa.com> My name is Julia Gilbert and I am an Author Agent for Wrox . You may be familiar with our range of books. Our trademark is "Programmer to Programmer", because Wrox books are written by professional programmers for professional programmers and are subsequently reviewed by professional programmers. We are currently in the process of producing a publication dedicated to professional Perl programming and are seeking authors who have the expertise to write chapters on one or more of the following subjects:- 1) Perl and Relational Databases (access to MS SQL servers via the Sybase drivers, Oracle, and probably a bit of MySQL too. Modules that should be covered include DBI::W32ODBC, Win32::ODBC, Win32::DBIODBC, DBFramework, and Tangram) 2) Embedding Perl into Web Pages (Why embed Perl, Perl-ASP/PerlScript, EmbPerl, ePerl, HTML::Mason) 3) Mathematical and Computational Applications (Perl Math Modules, Mathematical Algorithms with Perl, Matrices, Cryptography) 4) Distributed Perl Programming (IPC, RPC, CORBA) 5) Perl and Other Programming Languages (Using C from Perl, writing with the POSIX.pm module, syscall, Devel::Peek, DynaLoader.pm, Using Perl from C, Converting Perl into C, Converting Perl into Bytecode (and back)) 6) Perl and Unicode ([perlunicode] (I18N.pm), use utf8.pm, use bytes.pm) 7) Locale and Internationalization (use locale, Unicode, Time and Timezones). In addition to these chapters, we need authors to write the following sections: * A section on "Perl IDEs and Editors" * Integrating Perl with IIS * Integrating Perl with Netscape * A set of short sections on web protocols covering MailTools modules, Mail::POP3Client, libnet modules (namely, Net::SMTP, Net::POP3, Net::FTP). We would need your first draft of the chapter(s)/section(s) before the end of November, so please let me know ASAP if you are interested in writing for us. You are welcome to pass my enquiry on to any colleagues who you think may be interested. I look forward to hearing from you soon, Julia Julia Gilbert Author Agent Wrox Press http://www.wrox.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From tom.owskey at attws.com Thu Nov 2 12:19:11 2000 From: tom.owskey at attws.com (Owskey, Tom) Date: Wed Aug 4 00:07:44 2004 Subject: SPUG: Question for somebody Message-ID: <1EED9D7ACD57D311A9AF00805FE2B4D0037CEB71@hq-msg02.nwest.attws.com> Hi can anybody tell me how to destroy an object to keep the program from eating up memory. Thomas Owskey. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From tim at consultix-inc.com Thu Nov 2 12:13:24 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:44 2004 Subject: SPUG: Seattle Perl JoB Message-ID: <20001102181324.A6262@timji.consultix.wa.com> Here are the requirements for the Unix/Perl Developer: * Unix, Perl, Oject-Oriented (3+ years), Prefers: Oracle (8i), Java/JSP. * 9-12 month contract - perm * for contracts, expected 9-12 months @ $50/hr max. DOE * for permanent positions, availability of stock options (yes) * placement through recruiter for contract period! * Will do W-2 and 1099 * No restrictions on 1099 status: Corporation, etc.? * Seattle, WA * No telecommuting possible! * Web site development company converting from Perl/CGI to Java/JSP. * Web site development for Automotive companies! David Tang david@consultnet-nw.com Technical Recruiter ConsultNet, Bellevue, WA 425.637.9700 Office 425.591.7109 Cell 877.287.9526 Toll-Free 425.637.9600 Fax http://www.Consult-Net.com "Empowering the World's largest network of computer professionals." - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From jope at n2h2.com Thu Nov 2 12:24:51 2000 From: jope at n2h2.com (JP Montagnet) Date: Wed Aug 4 00:07:44 2004 Subject: SPUG: Process Size In-Reply-To: <3A00D6F6.A6A4113@nwlink.com> Message-ID: Yeah, realized that typo as soon as I sent my message. D'oh! Bad cold... much cotton in head right now... =( On Wed, 1 Nov 2000, Leary wrote: > JP Montagnet wrote: >> If you're on Linux, just parse the appropriate field out of /dev/$$/status >> (or substitute the appropraite PID for $$ if monitoring another program). >> Similar facilities ought to be available on the Unixes. > > I think you mean /proc/$PID/status yes? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From creede at rrauto.com Thu Nov 2 12:55:34 2000 From: creede at rrauto.com (Creede Lambard) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: Question for somebody References: <1EED9D7ACD57D311A9AF00805FE2B4D0037CEB71@hq-msg02.nwest.attws.com> Message-ID: <004101c044fe$7b47aa10$1f4181ce@rrauto.com> If the object is created properly you should be able to undef it or just let it go out of scope as long as there are no more references to it. I say "if it is created properly" because I've seen some objects that don't seem to work this way. For instance there appears to be a memory leak in Win32::ODBC. Repeatedly creating and destroying Win32::ODBC objects (in my experience at least) causes your process' memory footprint to creep up a step at a time. Usually, though, the above will do the trick. ----- Original Message ----- From: Owskey, Tom To: Sent: Thursday, November 02, 2000 10:19 AM Subject: SPUG: Question for somebody > Hi can anybody tell me how to destroy an object to keep the program from > eating up memory. > > Thomas Owskey. > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL > Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address > For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From cmeyer at helvella.org Thu Nov 2 13:23:48 2000 From: cmeyer at helvella.org (Colin Meyer) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: Seattle Perl JoB In-Reply-To: <20001102181324.A6262@timji.consultix.wa.com> References: <20001102181324.A6262@timji.consultix.wa.com> Message-ID: <20001102112348.B26731@hobart.helvella.org> On Thu, Nov 02, 2000 at 06:13:24PM +0000, Tim Maher/CONSULTIX wrote: > Here are the requirements for the Unix/Perl Developer: > > * Unix, Perl, Oject-Oriented (3+ years), Prefers: Oracle (8i), Java/JSP. > * 9-12 month contract - perm > * for contracts, expected 9-12 months @ $50/hr max. DOE > * for permanent positions, availability of stock options (yes) > * placement through recruiter for contract period! > * Will do W-2 and 1099 > * No restrictions on 1099 status: Corporation, etc.? > * Seattle, WA > * No telecommuting possible! > * Web site development company converting from Perl/CGI to Java/JSP. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Sounds like an anti-perl job to me. Yuck! How about converting Perl/CGI to the ultra fast and cool mod_perl? -C. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From LaurenS at bsquare.com Thu Nov 2 13:18:15 2000 From: LaurenS at bsquare.com (Lauren Smith) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: Question for somebody Message-ID: If you lexically scope variables using 'my', variables will delete themselves when their scope is up. However, this does not mean that the memory is recoverable by the OS. It means that Perl has released the memory for its own future use. Aside from memory leaks, a Perl process should only take up as much space as its peak memory usage. Lauren > -----Original Message----- > From: Owskey, Tom [mailto:tom.owskey@attws.com] > Sent: Thursday, November 02, 2000 10:19 AM > To: spug-list@pm.org > Subject: SPUG: Question for somebody > > > Hi can anybody tell me how to destroy an object to keep the > program from > eating up memory. > > Thomas Owskey. > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL > Replace ACTION by subscribe or unsubscribe, EMAIL by your > Email-address > For daily traffic, use spug-list for LIST ; for weekly, > spug-list-digest > Seattle Perl Users Group (SPUG) Home Page: > http://www.halcyon.com/spug/ > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From ajalis at cobaltgroup.com Thu Nov 2 15:05:33 2000 From: ajalis at cobaltgroup.com (Asim Jalis) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: Process Size In-Reply-To: <028901c04463$99c80ed0$27e842cf@iwebx1>; from John Cokos on Wed, Nov 01, 2000 at 04:26:53PM -0800 References: <028901c04463$99c80ed0$27e842cf@iwebx1> Message-ID: <20001102130533.B14289@xenon.cobaltgroup.com> On Wed, Nov 01, 2000 at 04:26:53PM -0800, John Cokos wrote: > Apologies in advance for the dumb question .... > > How can I determine the amount of memory (in kb) that > a perl program consumes once compiled and running? If you are running the program under Unix you can type "ps ux" (without the quotes) on the command line while your Perl program is running. This will show you the memory foot-print of your process and some other data. Another option on Unix is to type "top". This will give you running data on your processes (ps ux just gives you a snapshot). On Windows you should run Task Manager (on W2K this pops up if you click Alt-Ctrl-Del and then select Task Manager). Then click on the "Processes" tab. One of the columns should list the memory foot-print of the Perl process. Asim - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From dpommert at bestnet.com Thu Nov 2 16:15:12 2000 From: dpommert at bestnet.com (Daniel Pommert) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: Question for somebody -- Releasing memory Message-ID: <8EC7FE6B4722D411848B00A0C9E11CBD8B91E2@EXCH02> As stated by everyone else, normally, when the last reference to an object is eliminated, the object is destroyed and the memory is released to the memory pool. There are some gotchya, however: 1) As mentioned above, sometimes the Perl system, itself has a memory leak. This is rare, is usually minor is size, and can usually be discounted. 2) Reference cycles can cause objects to never be considered to be "free-able". I wrote a routine (which I don't have on me at my present site) that will take a reference and trace down all of the accessible references looking for reference cycles. You would put it in your package's DESTROY method and give it your $this or $self reference. It would tell you if that object contained or referred indirectly to something that had a reference cycle. It is a recursive (set of) routine written in Perl. Its deficiency is that it can't peer into closures. Another way that you could find where you might have a memory leak is to get your program to voluntarily cease execution and then use the caller function in your package's DESTROY method. If (I think) caller(1) says that it was called "during global destruction" then that object is being freed during Mark and Sweep phase of garbage collection. This means that that object was involved in a reference cycle and is (probably) garbage while the program is running. When I was working on a large server program, I encountered some of these "DESTROYed during global destruction" situations that I was unable to clean up. I did use closures quite a bit and am suspicious that that may have been the source of my problem. I'll see if I can bring in the cycle finder routine and post it to this group. Daniel Pommert BEST Consulting (at) AT&T Wireless Systems - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From jcokos at ccs.net Thu Nov 2 16:48:14 2000 From: jcokos at ccs.net (John Cokos) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: Process Size References: <028901c04463$99c80ed0$27e842cf@iwebx1> <20001102130533.B14289@xenon.cobaltgroup.com> Message-ID: <024f01c0451e$fc0511e0$27e842cf@iwebx1> ps ux gives %mem What I need to know is the actual bytes of memory consumed In other words, if you were able to "really" compile the perl script how big would it be? John ======================================== John Cokos, President / CEO: iWeb Inc. http://www.iwebsys.com jcokos@ccs.net ======================================== ----- Original Message ----- From: "Asim Jalis" To: "John Cokos" Cc: Sent: Thursday, November 02, 2000 1:05 PM Subject: Re: SPUG: Process Size > On Wed, Nov 01, 2000 at 04:26:53PM -0800, John Cokos wrote: > > Apologies in advance for the dumb question .... > > > > How can I determine the amount of memory (in kb) that > > a perl program consumes once compiled and running? > > If you are running the program under Unix you can type "ps ux" (without > the quotes) on the command line while your Perl program is running. This > will show you the memory foot-print of your process and some other data. > Another option on Unix is to type "top". This will give you running data > on your processes (ps ux just gives you a snapshot). > > On Windows you should run Task Manager (on W2K this pops up if you > click Alt-Ctrl-Del and then select Task Manager). Then click on the > "Processes" tab. One of the columns should list the memory foot-print > of the Perl process. > > Asim > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL > Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address > For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From jmates at mbt.washington.edu Thu Nov 2 18:00:33 2000 From: jmates at mbt.washington.edu (Jeremy A. Mates) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: Process Size In-Reply-To: <024f01c0451e$fc0511e0$27e842cf@iwebx1> Message-ID: On Thu, 2 Nov 2000, John Cokos wrote: > ps ux gives %mem > > What I need to know is the actual bytes of memory consumed Your ps (or top, or qps*, etc.) with some form of flags should also incude columns for RSS and SHARE, or maybe a SIZE: PID USER PRI NI SIZE RSS SHARE STAT LIB %CPU %MEM TIME COMMAND 25864 jmates -4 -6 6828 6828 1944 S < 0 0.3 6.1 7:46 Maelstrom Though the size values are usualy in kilobytes, not bytes... * qps is a spiffy graphical top for X Windows under Linux or Solaris: http://www.nada.kth.se/~f91-men/qps/ -- Jeremy A. Mates (206) 221-4714 Fax: 685-7301 Senior Systems Administrator K 353B, Health Sciences Center http://www.mbt.washington.edu/ Mail Box 357730 University of Washington Seattle, WA 98195 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From mike at unixgeek.net Thu Nov 2 18:47:53 2000 From: mike at unixgeek.net (Mike) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: Process Size In-Reply-To: References: <024f01c0451e$fc0511e0$27e842cf@iwebx1> Message-ID: <5.0.0.25.0.20001102164659.01821930@pop.ici.net> I have a question related to the topic. Once you: open(STAT,"/proc/$$/status"); what is the format to read from it ect. At 04:00 PM 11/2/2000 -0800, you wrote: >On Thu, 2 Nov 2000, John Cokos wrote: > > ps ux gives %mem > > > > What I need to know is the actual bytes of memory consumed > >Your ps (or top, or qps*, etc.) with some form of flags should also >incude columns for RSS and SHARE, or maybe a SIZE: > > PID USER PRI NI SIZE RSS SHARE STAT LIB %CPU %MEM TIME COMMAND >25864 jmates -4 -6 6828 6828 1944 S < 0 0.3 6.1 7:46 Maelstrom > >Though the size values are usualy in kilobytes, not bytes... > >* qps is a spiffy graphical top for X Windows under Linux or Solaris: > >http://www.nada.kth.se/~f91-men/qps/ > >-- >Jeremy A. Mates (206) 221-4714 Fax: 685-7301 >Senior Systems Administrator K 353B, Health Sciences Center >http://www.mbt.washington.edu/ Mail Box 357730 >University of Washington Seattle, WA 98195 > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL > Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address > For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From starfire at zipcon.net Thu Nov 2 20:18:20 2000 From: starfire at zipcon.net (Richard Anderson) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: Question for somebody References: Message-ID: <00af01c0453c$72b87760$700ff93f@adcom133> This in not correct - memory is freed by Perl's garbage collection algorithm when a lexically scoped variable goes out of scope, unless there is a pathological circular reference situation. If Perl really did not return the memory to the OS until the program exited, recursive subroutines would be impossible in Perl. Richard.Anderson@rayCosoft.com RayCosoft, Professional Services Group Perl/SQL/Unix software engineering www.rayCosoft.com www.zipcon.net/~starfire/home Seattle, WA, USA ----- Original Message ----- From: "Lauren Smith" To: "'Owskey, Tom'" ; Sent: Thursday, November 02, 2000 11:18 AM Subject: RE: SPUG: Question for somebody > If you lexically scope variables using 'my', variables will delete > themselves when their scope is up. However, this does not mean that the > memory is recoverable by the OS. It means that Perl has released the memory > for its own future use. Aside from memory leaks, a Perl process should only > take up as much space as its peak memory usage. > > Lauren > > > -----Original Message----- > > From: Owskey, Tom [mailto:tom.owskey@attws.com] > > Sent: Thursday, November 02, 2000 10:19 AM > > To: spug-list@pm.org > > Subject: SPUG: Question for somebody > > > > > > Hi can anybody tell me how to destroy an object to keep the > > program from > > eating up memory. > > > > Thomas Owskey. > > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > > - - - - - - - > > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > > Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL > > Replace ACTION by subscribe or unsubscribe, EMAIL by your > > Email-address > > For daily traffic, use spug-list for LIST ; for weekly, > > spug-list-digest > > Seattle Perl Users Group (SPUG) Home Page: > > http://www.halcyon.com/spug/ > > > > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL > Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address > For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From tim at consultix-inc.com Thu Nov 2 21:25:16 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: Question for somebody In-Reply-To: <00af01c0453c$72b87760$700ff93f@adcom133>; from Richard Anderson on Thu, Nov 02, 2000 at 06:18:20PM -0800 References: <00af01c0453c$72b87760$700ff93f@adcom133> Message-ID: <20001103032516.B6976@timji.consultix.wa.com> On Thu, Nov 02, 2000 at 06:18:20PM -0800, Richard Anderson wrote: > This in not correct - memory is freed by Perl's garbage collection algorithm > when a lexically scoped variable goes out of scope, unless there is a > pathological circular reference situation. The question is what is meant by "freed"; the UNIX (malloc/free) model is that the memory is marked as available for reuse by the process, but not relinquished to the OS until the program exits. This is justified by the assumption that if memory were really to be relinquished (by diminishing the size of the data segment through brk() or sbrk()) the program might just need it again later anyway, and have to call malloc() once more to get it. I'm not an expert on Perl internals, but I've gotten the impression from some who know more about it than I do that Perl's memory management model is based on this (perfectly sensible, tried and true) UNIX model. > If Perl really did not return the memory to the OS until the program exited, > recursive subroutines would be impossible in Perl. Huh? I don't follow your logic here. Typical C programs don't really relinquish memory until they exit (because most C programmers only call free(), and have never even heard of brk()), and recursion is certainly not uncommon, let alone impossible, in C. *========================================================================* | Dr. Tim Maher, CEO, Consultix (206) 781-UNIX/8649; ask for FAX# | | Email: tim@consultix-inc.com Web: http://www.consultix-inc.com | |Training- TIM MAHER: Unix, Perl DAMIAN CONWAY: Adv. Perl, OOP, Parsing | |CLASSES: 12/5-8: Basic UNIX *Coming in 2000: Database Prog. with Perl | *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From dpommert at bestnet.com Fri Nov 3 13:48:13 2000 From: dpommert at bestnet.com (Daniel Pommert) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: Question for somebody -- Releasing memory Message-ID: <8EC7FE6B4722D411848B00A0C9E11CBD8B91E5@EXCH02> Here is the code that I refered to yesterday. There are 3 routines (and two helper routines). The first is used to find any memory cycles. The second is used to release all memory accessible from a reference. The third is a Unix (System 5) method of getting your memory stats. Brief PODs are included. These aren't perfect, but I found them very useful. -- Daniel Pommert ##------------------------------------------------------------------------- ## ## f i n d _ c y c l e ## ## Find a reference cycle below the reference handed in as a parameter. ## ## Input: ## Parameter: ## $ref - The reference where scanning should begin ## Output: ## Return: ## Scalar context: ## Null if no cycle. A string describing how to get to looped ## item if there is a cycle. ## List context: ## Empty list if no cycle. 2 element list containing the deeper ## and shallower version of the duplicating reference loop. ## =pod =item B Find a reference cycle below the reference handed in as a parameter. =over 4 =item S< Parameters:> =item S< I<$ref>> The reference where scanning should begin. =item S< Returns:> =item S< Scalar context:> Null if no cycle. A string describing how to get to the looped item if there is a cycle. =item S< List context:> Empty list if there is no cycle. A two element list containing the deeper and shallower versions of the duplicated reference loop. =back =cut ## ##------------------------------------------------------------------------- sub find_cycle { my ($ref) = @_; # If not a reference, we are done return '' unless defined($ref) && ref($ref); # Pass off to recursive subroutine. It will return and empty string # or the first cycle encountered. _find_cycle_rec($ref, ''); } ##------------------------------------------------------------------------- ## ## _ f i n d _ c y c l e _ r e c ## ## Internal, recursive routine that supports find_cycle. ## ##------------------------------------------------------------------------- sub _find_cycle_rec { my ($ref, $path, %visited) = @_; my ($frc_res, @frc_arr_res, $k, $v, $i); # Have we been here before? Yes means cycle. return (wantarray ? ($path, $visited{"$ref"}) : $path) if exists $visited{"$ref"}; # So. We have a reference. Note it in the %visited table. $visited{"$ref"} = $path; # If scalar reference if (ref($ref) eq 'REF') { return _find_cycle_rec($$ref, "${path}->", %visited); } # If hash reference elsif (ref($ref) eq 'HASH') { return '' unless %$ref; foreach $k (keys %$ref) { $v = $ref->{$k}; next unless defined($v) && ref($v); if (wantarray) { @frc_arr_res = _find_cycle_rec($v, "${path}->{$k}", %visited); return @frc_arr_res if @frc_arr_res; } else { $frc_res = _find_cycle_rec($v, "${path}->{$k}", %visited); return $frc_res if defined($frc_res) && $frc_res ne ''; } } } # If array reference elsif (ref($ref) eq 'ARRAY') { return '' unless @$ref; foreach $i (0 .. $#{$ref}) { $v = $ref->[$i]; next unless defined($v) && ref($v); if (wantarray) { @frc_arr_res = _find_cycle_rec($v, "${path}->[$i]", %visited); return @frc_arr_res if @frc_arr_res; } else { $frc_res = _find_cycle_rec($v, "${path}->[$i]", %visited); return $frc_res if defined($frc_res) && $frc_res ne ''; } } } # We will ignore CODE and GLOB objects elsif (ref($ref) eq 'CODE' || ref($ref) eq 'GLOB') { return wantarray ? () : ''; } # Otherwise, check the stringification. # If a blessed hash elsif ("$ref" =~ m/=HASH\(/) { return '' unless %$ref; foreach $k (keys %$ref) { $v = $ref->{$k}; next unless defined($v) && ref($v); if (wantarray) { @frc_arr_res = _find_cycle_rec($v, "${path}->{$k}", %visited); return @frc_arr_res if @frc_arr_res; } else { $frc_res = _find_cycle_rec($v, "${path}->{$k}", %visited); return $frc_res if $frc_res ne ''; } } } # If a blessed array reference elsif ("$ref" =~ m/=ARRAY\(/) { return '' unless @$ref; foreach $i (0 .. $#{$ref}) { $v = $ref->[$i]; next unless defined($v) && ref($v); if (wantarray) { @frc_arr_res = _find_cycle_rec($v, "${path}->[$i]", %visited); return @frc_arr_res if @frc_arr_res; } else { $frc_res = _find_cycle_rec($v, "${path}->[$i]", %visited); return $frc_res if defined($frc_res) && $frc_res ne ''; } } } # Otherwise, we haven't found any cycles. Return a null string return wantarray ? () : ''; } ##------------------------------------------------------------------------- ## ## d e l e t e _ s t r u c t u r e ## ## Recurse through structure heirarchy and delete everything. ## ## Input: ## Parameter: ## $ref - The reference where deletion should begin ## Output: ## Return: None ## =pod =item B Recurse through structure heirarchy and delete everything. =over 4 =item S< Parameters:> =item S< I<$ref>> The reference where deletion should begin. =item S< Returns:> None. =back =cut ## ##------------------------------------------------------------------------- sub delete_structure { my ($ref) = @_; # If not a reference, we are done return unless defined($ref) && ref($ref); # Pass off to recursive subroutine. It will return and empty string # or the first cycle encountered. _delete_structure_rec($ref); } ##------------------------------------------------------------------------- ## ## _ d e l e t e _ s t r u c t u r e _ r e c ## ## Internal, recursive routine that supports delete_structure. ## ##------------------------------------------------------------------------- sub _delete_structure_rec { my ($ref, %visited) = @_; my ($frc_res, @frc_arr_res, $k, $v, $i); # Have we been here before? Yes means cycle. Just return. Will be # handled at a higher level. return if exists $visited{"$ref"}; # Don't follow non-references return unless defined($ref) && ref($ref); # So. We have a reference. Note it in the %visited table. $visited{"$ref"} = 1; # If scalar reference if (ref($ref) eq 'REF') { _find_cycle_rec($$ref, %visited); undef $$ref; return; } # If hash reference elsif (ref($ref) eq 'HASH' || "$ref" =~ m/=HASH\(/) { return unless %$ref; foreach $k (keys %$ref) { $v = $ref->{$k}; delete $ref->{$k}; _delete_structure_rec($v, %visited); } return; } # If array reference elsif (ref($ref) eq 'ARRAY' || "$ref" =~ m/=ARRAY\(/) { return unless @$ref; while ($v = shift(@{$ref})) { _delete_structure_rec($v, %visited); } return; } # We will ignore CODE and GLOB objects elsif (ref($ref) eq 'CODE' || ref($ref) eq 'GLOB') { return; } # Otherwise, flag that we don't know what to do else { print STDERR "utility::_delete_structure_rec: Don't know how to delete $ref\n"; return; } } ##------------------------------------------------------------------------- ## ## g e t _ m e m _ s t a t s ## ## Find a reference cycle below the reference handed in as a parameter. ## ## Input: ## Parameters: None ## External: ## /proc/$$/status - Source of memory status information ## Output: ## Return: ## List context: ## Two elements: stack size in bytes, heap size in bytes ## Scalar context: ## A string describing the stack and heap size in bytes ## =pod =item B Find a reference cycle below the reference handed in as a parameter. =over 4 =item S< Parameters:> None. =item S< Returns:> =item S< Scalar context:> A string describing the stack and heap size in bytes. =item S< List context:> Two elements: stack size in bytes, heap size in bytes. =back =cut ## ##------------------------------------------------------------------------- sub get_mem_stats { my ($status, $heap_sz, $stack_sz); # Read the status. Return with bad values if there is a problem. open (STATUS, "; from tim@consultix-inc.com on Thu, Nov 02, 2000 at 06:00:12PM +0000 References: <20001102180012.M5993@timji.consultix.wa.com> Message-ID: <20001103180104.A18207@darkstar.chetlin.org> On Thu, Nov 02, 2000 at 06:00:12PM +0000, Tim Maher/CONSULTIX wrote: > > My name is Julia Gilbert and I am an Author Agent for Wrox > . [snip] > We are currently in the process of producing a publication dedicated to > professional Perl programming and are seeking authors who have the expertise > to write chapters on one or more of the following subjects:- I hate to be a jerk about this, but I would suggest that anyone considering responding to this message take a look at this page: http://www.advogato.org/person/Skud/diary.html?start=81 The company she is talking about is Wrox, the book she is talking about is this one, and it is all 100% true. They have been scouring the internet for Perl people since early October. I received almost this exact note from them in October (changed only to reflect the moved back deadline and including my first name in the first paragraph), and, thinking it was a personal email, responded with interest. I discovered later that they're not paying particularly much, they require all work to be done in MS Word, and that many people had received that exact same letter. When I asked whether they could accept work in another format than .doc since I don't use Windows, they stopped responding to me. Since then, I suspect nearly everyone involved in the Perl community online has received one of these letters. So, consider this a warning. And I apologize for making an issue out of this. -dlc - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From tim at consultix-inc.com Fri Nov 3 22:12:07 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: Python Instructor Needed, Bellevue Message-ID: <20001104041207.A9820@timji.consultix.wa.com> According to Chris Fischer: > > Hi, > > I'm passing along this information to all interested parties: > The Continuing Education Dept. at Bellevue Community College is > currently looking for a person who is fluent in Python to teach a class > Winter Quarter. Previous teaching experience is preferred, but not As the SPUG leader, I'll pass this info on to the Seattle Perl Users Group membership; if we've got any Python people lurking on our list (of nearly 400 readers), maybe this will help us get rid of them! 8-} > BTW, continuing education instructors at BCC make $60/hr., not too > shabby. Please pass this info. along to anyone you think might be > interested. > > Thanks! > > Chris Fischer > ======================================================================== > Contributions/Posts To: linux-list@ssc.com > To Unsubscribe: linux-list-request@ssc.com, "unsubscribe" in message body > Report Problems to: owner-linux-list@ssc.com > List archive at: http://www.ssc.com/mailing-lists/ > I suspect you're thinking of that hourly rate in typical contract programming terms, where you get paid for each hour of work. In educational circles, that kind of figure is typically predicated on actual "contact hours" (i.e., the hours of in-class presentations), and with the typical ratio of preparation time to presentation time being upwards of 3/1, that $60 figure is effectively less than $15/hour. Don't get me wrong, I'm a former CS professor myself and a gung-ho supporter of higher education, but if you look at the revenues taken in by classes of this type, the instructor is typically only receiving a one-digit percentage of the total figure, which, IMHO as a professional software instructor for most of the last two decades, is not enough. (And I didn't even figure in the additional unpaid "office hours" for meeting with students, which would further degrade the hourly rate!) So by all means, if you want to help people learn Python, look into this opportunity, but don't quit your day job to do it! 8-} ========================================================== | Tim Maher, Ph.D. Tel: (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 Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From starfire at zipcon.net Sat Nov 4 11:25:21 2000 From: starfire at zipcon.net (Richard Anderson) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: Using subroutines to return constants References: <20001104041207.A9820@timji.consultix.wa.com> Message-ID: <01cc01c04684$379b83e0$700ff93f@adcom133> Subtitle: Structured coding best practice or performance-crippling hack? Although Perl 5.6 has the convenient constant declaration to fix the value of a variable, most of us are still coding without this bit of syntactic sugar. The traditional way to refer to a constant in Perl is to use a reference to a subroutine that does nothing but return the constant: $PI = sub { 3.1415962 }; Subroutine calls are much slower than variable references, but how much slower? Here's some code that tests this: $VARIABLE = 10; $SUBREF = sub { 22; }; use Benchmark; $count = 1000000; $t = timeit($count, '$var = $VARIABLE'); print "$count loops of a variable reference took:",timestr($t),"\n"; $t = timeit($count, '$var = $SUBREF->()'); print "$count loops of subroutine reference took:",timestr($t),"\n"; I get a performance slowdown factor of 7 for the subroutine call on both Windows and Linux. Pretty nasty hit just to make your code cleaner. Any thoughts on this? Richard.Anderson@rayCosoft.com RayCosoft, Professional Services Group Perl/SQL/Unix software engineering www.rayCosoft.com www.zipcon.net/~starfire/home Seattle, WA, USA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From jimfl at colltech.com Sat Nov 4 13:22:58 2000 From: jimfl at colltech.com (Jim Flanagan) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: Using subroutines to return constants In-Reply-To: <01cc01c04684$379b83e0$700ff93f@adcom133> Message-ID: On Sat, 4 Nov 2000, Richard Anderson wrote: > Subtitle: Structured coding best practice or > performance-crippling hack? > > Although Perl 5.6 has the convenient constant declaration > to fix the value of a variable, most of us are still coding > without this bit of syntactic sugar. The traditional way > to refer to a constant in Perl is to use a reference to > a subroutine that does nothing but return the constant: > > $PI = sub { 3.1415962 }; > > Subroutine calls are much slower than variable references, > but how much slower? Here's some code that tests this: > > Any thoughts on this? If you prototype a subroutine with a null arglist, and the subroutine returns a constant value, then the compiler inlines all of the constant references, and no subroutine call actually takes place at runtime. Consider the following code: use Benchmark; my $VARIABLE = 10; sub SUBCONST () { 10 }; use constant PRAGCONST => 10; timethese 1000000, { variable => sub {$v = $VARIABLE}, pragma => sub {$v = PRAGCONST}, inline => sub {$v = SUBCONST} }; This gives: Benchmark: timing 1000000 iterations of inline, pragma, variable... inline: 4 secs ( 2.14 usr 0.00 sys = 2.14 cpu) pragma: 3 secs ( 2.14 usr 0.00 sys = 2.14 cpu) variable: 2 secs ( 2.19 usr 0.00 sys = 2.19 cpu) The pragma is doing essentially the same thing as the inlined subroutine, except that it is inserting the subroutine definition right into the namespace of the calling routine. Note that my numbers have to be taken with a grain of salt because my Benchmark.pm (RatHead Linux 5.x) seems to be wacky. -- Jim Flanagan Collective Technologies jimfl@colltech.com http://www.colltech.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From briani at activestate.com Sat Nov 4 14:38:55 2000 From: briani at activestate.com (Brian Ingerson) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: Using subroutines to return constants References: <20001104041207.A9820@timji.consultix.wa.com> <01cc01c04684$379b83e0$700ff93f@adcom133> Message-ID: <3A0473DF.B58F4797@activestate.com> Richard Anderson wrote: > > Subtitle: Structured coding best practice or performance-crippling hack? > > Although Perl 5.6 has the convenient constant declaration to fix the value "use constant" preceeds 5.6. I assume that was the convenience that you meant. > of a variable, most of us are still coding without this bit of syntactic > sugar. The traditional way to refer to a constant in Perl is to use a > reference to a subroutine that does nothing but return the constant: > > $PI = sub { 3.1415962 }; Not the tradition I'm familiar with. I think the traditional idiom is: sub PI { 3.1415926 } Then you can say: my $area = PI * $r ** 2; Your way, you'd say: my $area = &$PI $r ** 2; You might as well just defined it as: my $PI = 3.1415926; > > I get a performance slowdown factor of 7 for the subroutine call on both > Windows and Linux. Pretty nasty hit just to make your code cleaner. > > Any thoughts on this? Yes. Perl will "inline" any sub that is prototyped and evaluates to a constant. So using this: sub PI () { 3.1415926 } will effectively replace all references to PI with the constant. "use constant" does the same thing. A good explanation of this is in the new Camel p228. Running this: ----------------8<---------------------------- my $PI_1 = sub { 3.1415962 }; sub PI_2 { 3.1415962 }; sub PI_3 () { 3.1415962 }; use constant PI_4 => 3.1415962; my $PI_5 = 3.1415962; use Benchmark; my $r = 7; timethese(10_000_000, { subref => sub {&$PI_1 * $r ** 2}, sub => sub { &PI_2 * $r ** 2}, inline => sub { PI_3 * $r ** 2}, constant => sub { PI_4 * $r ** 2}, scalar => sub { $PI_5 * $r ** 2}, } ); ----------------8<---------------------------- produces: Benchmark: timing 10000000 iterations of constant, inline, scalar, sub, subref... constant: 13 wallclock secs (13.88 usr + 0.00 sys = 13.88 CPU) inline: 14 wallclock secs (13.73 usr + 0.02 sys = 13.75 CPU) scalar: 14 wallclock secs (13.58 usr + 0.00 sys = 13.58 CPU) sub: 25 wallclock secs (24.37 usr + 0.00 sys = 24.37 CPU) subref: 25 wallclock secs (24.76 usr + 0.00 sys = 24.76 CPU) Just say "use constant" Brian -- perl -e 'use Inline C=>q{SV*JAxH(char*x){return newSVpvf ("Just Another %s Hacker\\n",x);}};print JAxH+Perl' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From sthoenna at efn.org Sun Nov 5 00:32:31 2000 From: sthoenna at efn.org (Yitzchak Scott-Thoennes) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: Question for somebody -- Releasing memory References: <8EC7FE6B4722D411848B00A0C9E11CBD8B91E2@EXCH02> Message-ID: In article <8EC7FE6B4722D411848B00A0C9E11CBD8B91E2@EXCH02>, Daniel Pommert wrote: > As stated by everyone else, normally, when the last reference to an object > is eliminated, the object is destroyed and the memory is released to the > memory pool. > > There are some gotchya, however: > 1) As mentioned above, sometimes the Perl system, itself has a memory leak. > This is rare, is usually minor is size, and can usually be discounted. > 2) Reference cycles can cause objects to never be considered to be > "free-able". There's also: 3) reference count erroneously too high. Some times hairy XS code can increment a reference count and forget to decrement it when appropriate. Devel::Peek::SvREFCNT will return a scalar's actual refcnt for you to look at. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From tim at consultix-inc.com Mon Nov 6 05:29:07 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: TPJ arrived yet? Message-ID: <20001106112907.A1136@guru.consultix.wa.com> SPUGsters, As an advertiser in TPJ who was promised that it would be shipped in September (!!), I'm curious to know if anybody has seen it in Seattle yet. (I called Steve's Fremont News last week, and they hadn't received it; I used to have a subscription, but it ran out without any warning.) How's this for a meeting idea; we get several people to report on different articles and features in the latest TPJ. Each becomes an expert on one article, summarizes it for the group, shows code samples, and answers questions. -Tim P.S. TPJ has a fantastic editor (Jon Orwant) and great content, but the rest of the operation (especially since it was sold to "DearthWeb") is way below par; that's a shame. ========================================================== | Tim Maher, Ph.D. Tel: (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 Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From jsouza at cobaltgroup.com Mon Nov 6 13:07:44 2000 From: jsouza at cobaltgroup.com (Jonathan Souza) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: TPJ arrived yet? References: <20001106112907.A1136@guru.consultix.wa.com> Message-ID: <3A070180.E31BBCE5@cobaltgroup.com> I got mine at least a week ago. Tim Maher/CONSULTIX wrote: > > SPUGsters, > > As an advertiser in TPJ who was promised that it would be shipped in > September (!!), I'm curious to know if anybody has seen it in Seattle > yet. (I called Steve's Fremont News last week, and they hadn't received > it; I used to have a subscription, but it ran out without any warning.) > > How's this for a meeting idea; we get several people to > report on different articles and features in the latest TPJ. > Each becomes an expert on one article, summarizes it for the group, > shows code samples, and answers questions. > > -Tim > P.S. TPJ has a fantastic editor (Jon Orwant) and great content, but > the rest of the operation (especially since it was sold to "DearthWeb") > is way below par; that's a shame. > > ========================================================== > | Tim Maher, Ph.D. Tel: (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 > Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL > Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address > For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ -- Jonathan Souza Software Engineer: Product Development The Cobalt Group: jsouza@cobaltgroup.com tel: 206.269.6363 ext 8289 Direct: 206.219.8289 800.909.8244 Fax: 206.219.8399 Home: courtassassin@home.com Phone: 206.762.1905 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From gfb at sdc.cs.boeing.com Mon Nov 6 13:16:10 2000 From: gfb at sdc.cs.boeing.com (Gareth Beale) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: TPJ arrived yet? Message-ID: <200011061916.LAA06703@klawatti.sdc.cs.boeing.com> I got issue #19 a little over a week ago. Gareth - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From toddw at wrq.com Mon Nov 6 18:22:28 2000 From: toddw at wrq.com (Todd Wells) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: deferencing a hash in an array of hashes Message-ID: <1654BC972546D31189DA00508B318AC801C883F8@charmander.wrq.com> I'm not sure why I'm having a problem with this, but here's the situation: I have a subroutine which builds up an array of hashes in @attributes, and then I want to use one of those hashes as it's returned value. return $attributes[0]; # returns the hash reference in the array. How can I return the de-referenced hash? I seem to be having difficulty. Here's @attributes: DB<5> x @attribs 0 HASH(0x227a8d0) 'defaultvalue' => 'junkchar' 'initialization' => 'atconnection' 'isencrypted' => 'false' 'ishidden' => 'false' 'isreadable' => 'false' 'iswriteable' => 'false' 'name' => 'userID' 'variabletype' => 'cursor' I just figured I'll de-reference it into %hash and return it as a hash rather than a reference... my %hash = %{$attribs[0]}; # this must be wrong return %hash; Alas! This doesn't do what I want, now: DB<6> x %hash 0 'ishidden' 1 'false' 2 'isreadable' 3 'false' 4 'isencrypted' 5 'false' 6 'iswriteable' 7 'false' 8 'defaultvalue' 9 'junkchar' 10 'initialization' 11 'atconnection' 12 'name' 13 'userID' 14 'variabletype' 15 'cursor' Can someone please show me the error of my ways? Ideally, I'd skip the "my %hash = " part altogether and just do something like return %{$attribs[0]}; # or whatever the proper syntax is. Thanks, -Todd - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From ced at carios2.ca.boeing.com Mon Nov 6 18:40:36 2000 From: ced at carios2.ca.boeing.com (ced@carios2.ca.boeing.com) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: deferencing a hash in an array of hashes Message-ID: <200011070040.QAA10016@carios2.ca.boeing.com> > I have a subroutine which builds up an array of hashes in @attributes, and > then I want to use one of those hashes as it's returned value. > return $attributes[0]; # returns the hash reference in the array. > How can I return the de-referenced hash? I seem to be having difficulty. > Here's @attributes: > DB<5> x @attribs > 0 HASH(0x227a8d0) > 'defaultvalue' => 'junkchar' > 'initialization' => 'atconnection' > ... > I just figured I'll de-reference it into %hash and return it as a hash > rather than a reference... > my %hash = %{$attribs[0]}; # this must be wrong > return %hash; > Alas! This doesn't do what I want, now: > DB<6> x %hash > 0 'ishidden' > 1 'false' >... > Can someone please show me the error of my ways? > Ideally, I'd skip the "my %hash = " part altogether and just do something > like > return %{$attribs[0]}; # or whatever the proper syntax is. You're fine. The return statement just unrolls the hash and returns the list of key-value pairs. So, e.g. in sub 'foo' simply: return %{$attribs[0]}; then in the call that invokes 'foo': my %return_hash = foo(); and that automagically populates your hash. Note because a list is being returned, you could have just as well created a simple array: my @return_array = foo(); hope this helps, -- Charles DeRykus - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From toddw at wrq.com Mon Nov 6 19:02:23 2000 From: toddw at wrq.com (Todd Wells) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: deferencing a hash in an array of hashes Message-ID: <1654BC972546D31189DA00508B318AC801C883F9@charmander.wrq.com> Unfortunately, it doesn't seem to be working this way. Maybe you can point out my error. Here's the calling code: my %attributes = get_xml_atts($resultfile, "variablemetadata", 1); and the sub: sub get_xml_atts { my ($file, $element, $occurrence) = @_; if (not defined($occurrence)) {$occurrence = 1;} undef @attribs; $occurrence--; # for indexing $sought_element = $element; $need_attribs = 1; my $parser = new XML::Parser(Handlers => { Start => \&tag_start, End => \&tag_end, Char => \&xml_characters, }); $parser->parsefile("$file"); undef $sought_element; undef $need_attribs; return %{$attribs[$occurrence]}; } And so you see where @attribs is created: sub tag_start { my ($parser, $element, %attribs) = @_; if ($element eq 'error') { $in_error = 1; } if ($AppconnXML::sought_element && ($element eq $AppconnXML::sought_element)) { $in_sought = 1; if ($AppconnXML::need_attribs) { push @AppconnXML::attribs, \%attribs; } } } and when all is said and done %attributes ends up just like this: 0 'ishidden' 1 'false' 2 'isreadable' 3 'false' 4 'isencrypted' 5 'false' 6 'iswriteable' 7 'false' 8 'defaultvalue' 9 'junkchar' 10 'initialization' 11 'atconnection' 12 'name' 13 'userID' 14 'variabletype' 15 'cursor' -Todd -----Original Message----- From: ced@carios2.ca.boeing.com [mailto:ced@carios2.ca.boeing.com] Sent: Monday, November 06, 2000 4:41 PM To: spug-list@pm.org; toddw@wrq.com Subject: Re: SPUG: deferencing a hash in an array of hashes > I have a subroutine which builds up an array of hashes in @attributes, and > then I want to use one of those hashes as it's returned value. > return $attributes[0]; # returns the hash reference in the array. > How can I return the de-referenced hash? I seem to be having difficulty. > Here's @attributes: > DB<5> x @attribs > 0 HASH(0x227a8d0) > 'defaultvalue' => 'junkchar' > 'initialization' => 'atconnection' > ... > I just figured I'll de-reference it into %hash and return it as a hash > rather than a reference... > my %hash = %{$attribs[0]}; # this must be wrong > return %hash; > Alas! This doesn't do what I want, now: > DB<6> x %hash > 0 'ishidden' > 1 'false' >... > Can someone please show me the error of my ways? > Ideally, I'd skip the "my %hash = " part altogether and just do something > like > return %{$attribs[0]}; # or whatever the proper syntax is. You're fine. The return statement just unrolls the hash and returns the list of key-value pairs. So, e.g. in sub 'foo' simply: return %{$attribs[0]}; then in the call that invokes 'foo': my %return_hash = foo(); and that automagically populates your hash. Note because a list is being returned, you could have just as well created a simple array: my @return_array = foo(); hope this helps, -- Charles DeRykus - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From Alex.Leites at esca.com Mon Nov 6 19:43:09 2000 From: Alex.Leites at esca.com (Alex Leites) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: deferencing a hash in an array of hashes In-Reply-To: <412E4E604F90952688256990000708F6.0007090288256990@test.alstom.com> Message-ID: <002301c0485c$15089910$200516ac@esca.com> > I have a subroutine which builds up an array of hashes > in @attributes, and then I want to use one of those > hashes as it's returned value. > > return $attributes[0]; # returns the hash reference in the array. ... just as expected, since the array of hashes is, strictly speaking, the array of hash references. > Alas! This doesn't do what I want, now: > > DB<6> x %hash > 0 'ishidden' > 1 'false' > 2 'isreadable' ... > > Can someone please show me the error of my ways? There is no error, this does do what you want. You did not explain why you think this is wrong ... Is that because you expected %hash to be printed as before, with key => value format? Well, perl debugger won't do that for "simple" hashes ("simple" meaning that there are no references among the values) -- the other format is reserved for more complicated data structures. Try 'x \%hash' if you want to cheat. Or use Data::Dumper. The only other potential source of confusion, as I see it, is that any hash can (and evaluated in list context, will) be regarded as an array with an even number of elements -- -- but this has already been addressed in other replies. Alex Leites - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From toddw at wrq.com Mon Nov 6 19:54:45 2000 From: toddw at wrq.com (Todd Wells) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: deferencing a hash in an array of hashes Message-ID: <1654BC972546D31189DA00508B318AC801C88400@charmander.wrq.com> Yes, as I've discovered thanks to several kind SPUGgers, the debugger output is what had me fooled -- in reality I did it exactly right the first time. My eyes told me I was looking at a flat list rather than key-value pairs. Thanks to all who helped :-) -----Original Message----- From: Alex Leites [mailto:Alex.Leites@esca.com] Sent: Monday, November 06, 2000 5:43 PM To: Todd Wells; 'SPUG' Subject: RE: SPUG: deferencing a hash in an array of hashes > I have a subroutine which builds up an array of hashes > in @attributes, and then I want to use one of those > hashes as it's returned value. > > return $attributes[0]; # returns the hash reference in the array. ... just as expected, since the array of hashes is, strictly speaking, the array of hash references. > Alas! This doesn't do what I want, now: > > DB<6> x %hash > 0 'ishidden' > 1 'false' > 2 'isreadable' ... > > Can someone please show me the error of my ways? There is no error, this does do what you want. You did not explain why you think this is wrong ... Is that because you expected %hash to be printed as before, with key => value format? Well, perl debugger won't do that for "simple" hashes ("simple" meaning that there are no references among the values) -- the other format is reserved for more complicated data structures. Try 'x \%hash' if you want to cheat. Or use Data::Dumper. The only other potential source of confusion, as I see it, is that any hash can (and evaluated in list context, will) be regarded as an array with an even number of elements -- -- but this has already been addressed in other replies. Alex Leites - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From rush at citylinq.com Mon Nov 6 20:13:42 2000 From: rush at citylinq.com (Rush Family) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: TPJ arrived yet? In-Reply-To: <20001106112907.A1136@guru.consultix.wa.com> Message-ID: I am a subscriber and I got the Fall 2000 issue 2 or 3 weeks ago, i.e., mid September. -----Original Message----- From: owner-spug-list@pm.org [mailto:owner-spug-list@pm.org]On Behalf Of Tim Maher/CONSULTIX Sent: Monday, November 06, 2000 3:29 AM To: spug-list@pm.org Subject: SPUG: TPJ arrived yet? SPUGsters, As an advertiser in TPJ who was promised that it would be shipped in September (!!), I'm curious to know if anybody has seen it in Seattle yet. (I called Steve's Fremont News last week, and they hadn't received it; I used to have a subscription, but it ran out without any warning.) How's this for a meeting idea; we get several people to report on different articles and features in the latest TPJ. Each becomes an expert on one article, summarizes it for the group, shows code samples, and answers questions. -Tim P.S. TPJ has a fantastic editor (Jon Orwant) and great content, but the rest of the operation (especially since it was sold to "DearthWeb") is way below par; that's a shame. ========================================================== | Tim Maher, Ph.D. Tel: (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 Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From daniel at chetlin.com Tue Nov 7 00:54:45 2000 From: daniel at chetlin.com (Daniel Chetlin) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: deferencing a hash in an array of hashes In-Reply-To: <002301c0485c$15089910$200516ac@esca.com>; from Alex.Leites@esca.com on Mon, Nov 06, 2000 at 05:43:09PM -0800 References: <412E4E604F90952688256990000708F6.0007090288256990@test.alstom.com> <002301c0485c$15089910$200516ac@esca.com> Message-ID: <20001106225445.A22597@darkstar.chetlin.org> On Mon, Nov 06, 2000 at 05:43:09PM -0800, Alex Leites wrote: > Is that because you expected %hash to be printed as before, with key > => value format? Well, perl debugger won't do that for "simple" hashes > ("simple" meaning that there are no references among the values) -- > the other format is reserved for more complicated data structures. > Try 'x \%hash' if you want to cheat. Or use Data::Dumper. Data::Dumper will do the same thing as the debugger's `x' command. There would be no way for it to work otherwise, as a hash is indistinguishable from an array once it's been pushed onto the stack. It's also indistinguishable from passing several scalars, or two arrays, or an array and a hash, etc. From Data::Dumper's (or `x's) point of view, it's just a bunch of stuff on the stack. The only way for them to see the structure is passing by reference. So `x \%hash' isn't cheating at all, and neither is `Data::Dumper::Dump \%hash'. It's the way to do it. -dlc - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From neil at ourshack.com Tue Nov 7 04:53:59 2000 From: neil at ourshack.com (Neil Ford) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: TPJ arrived yet? In-Reply-To: <20001106112907.A1136@guru.consultix.wa.com>; from tim@consultix-inc.com on Mon, Nov 06, 2000 at 11:29:07AM +0000 References: <20001106112907.A1136@guru.consultix.wa.com> Message-ID: <20001107105359.A436@vaio.binky.demon.co.uk> On Mon, Nov 06, 2000 at 11:29:07AM +0000, Tim Maher/CONSULTIX wrote: > SPUGsters, > > As an advertiser in TPJ who was promised that it would be shipped in > September (!!), I'm curious to know if anybody has seen it in Seattle > yet. (I called Steve's Fremont News last week, and they hadn't received > it; I used to have a subscription, but it ran out without any warning.) > Issue 19 arrived in the UK at the weekend. Seeing as your ad was time sensitive I hope you're persuing some form of recompense. Neil. -- Neil C. Ford neil@ourshack.com / neil@binky.demon.co.uk http://www.binky.ourshack.org - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From amcdowall at hotmail.com Tue Nov 7 13:53:35 2000 From: amcdowall at hotmail.com (ANDRE MCDOWALL) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: Free email & attachment form Message-ID: Hi, Does anyone know where I can find a free script that will allow the user to attach a file to an HTML based email-form? When "Submitted" the file will be sent to an email address. Thanks _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. Share information about yourself, create your own public profile at http://profiles.msn.com. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From cmeyer at helvella.org Tue Nov 7 15:11:43 2000 From: cmeyer at helvella.org (Colin Meyer) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: deferencing a hash in an array of hashes In-Reply-To: <1654BC972546D31189DA00508B318AC801C88400@charmander.wrq.com> References: <1654BC972546D31189DA00508B318AC801C88400@charmander.wrq.com> Message-ID: <20001107131143.E3933@hobart.helvella.org> On Mon, Nov 06, 2000 at 05:54:45PM -0800, Todd Wells wrote: > Yes, as I've discovered thanks to several kind SPUGgers, the debugger output > is what had me fooled -- in reality I did it exactly right the first time. > My eyes told me I was looking at a flat list rather than key-value pairs. The debugger output wasn't fooling you - you were looking at a flat list: ----------------------- %hash = ( 1 => 'a', 2 => 'b', 3 => 'c'); print "$_ => $hash{$_}\n" for sort keys %hash; @a = %hash; print "\n@a\n"; @a = reverse @a; print "\n@a\n"; %hash = @a; print "$_ => $hash{$_}\n" for sort keys %hash; ----------------------- Passing a hash to the debugger's 'x' function (or any other perl sub) evaluates the hash in list context, which turns out to be a list of name => value pairs. -C. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From chris.nord at attws.com Wed Nov 8 14:56:57 2000 From: chris.nord at attws.com (Nord, Chris) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: Perl email Message-ID: Gurus, The below sendmail script originated from the O'reilly Perl Cookbook. The problem that I am having is I am not able to pass the contents of $address into the To: position for use as an address. I get an error returned, "No recipient addresses found in header" If I populate, To: cnord\@mail-wncc.sc.attws.com , then the email is sent on its way, no problem. However the contents of $market displays in Subject:, and the contents of @mdii fills the body of the message. Ideas on how to pass the contents of $address into the To: position? Ideas? Thanx, Chris Nord chris.nord@attws.com > $address = "cnord\@mail-wncc.sc.attws.com"; > > ####################################################################### > open(SENDMAIL, "| /usr/lib/sendmail -oi -t -odq") > or die "Not able to fork sendmail: $!\n"; > > print SENDMAIL<<"EOF"; > From: nldtt\@sc.attws.com > To: $address > Subject: MDII CVN/VCA FOR: $market > > @mdii > > EOF > > close (SENDMAIL) or warn "SENDMAIL did not close nicely"; > ####################################################################### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From jcokos at ccs.net Fri Nov 10 09:59:16 2000 From: jcokos at ccs.net (John Cokos) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: Recursive Inheritance? Message-ID: <009201c04b2f$2dca1b60$27e842cf@iwebx1> I'm getting an odd error from perl... Here's the error: Recursive inheritance detected while looking for method 'debug' in package 'iSQL::Record' at IWeb/iSQL/Record.pm line 53 I have a program, that has the following use statements: use iSQL; use iSQL::Record; use iSQL::Record::Campaign; The object I'm trying to create starts like this: my $obj = new iSQL::Record::Campaign; The iSQL/Record/Campain module only has a few lines in it: package iSQL::Record::Campaign; @ISA = qw( iSQL::Record iSQL ); use vars qw($iSQL $DBH $LOGGING $DEBUG_LEVEL $AUTOLOAD); 1; The iSQL/Record.pm starts off like this: package iSQL::Record; @ISA = ( 'iSQL' ); use vars qw($iSQL $DBH $LOGGING $DEBUG_LEVEL $AUTOLOAD); ... methods excluded for space, but there are many methods here, but the one we, via inheritance are calling is "new", which does exist here. Note, that for testing, the "new" routine does it's bless, and then prints "Hello World" and dies. The call to "die" (or exit) brings up the error above. Note that I was working perfectly fine until I decided to add the "Campaign" module to the mix, as I want Campaign to be a specific type of record, using all of it's methods, but have some additional ones, specific to itself (OOP).... Seems that adding that module to the mix, since it has no methods, should make the calls and functionality in the main program work exactly as before, with the only real difference being the name of the class that ends up being blessed, right? And the iSQL.pm starts off like this: package iSQL; use vars qw($iSQL $DBH $LOGGING $DEBUG_LEVEL $AUTOLOAD); ... methods excluded for space, but there are many methods here, but the one we, via inheritance are calling is "DEBUG", which does exist here The error that I get, according to perldiag indicates that it exhausted over 100 levels of recursion, but I only defined 3, it would seem .... What, here, is causing that error? John ======================================== John Cokos, President / CEO: iWeb Inc. http://www.iwebsys.com jcokos@ccs.net ======================================== - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From ced at carios2.ca.boeing.com Fri Nov 10 14:29:15 2000 From: ced at carios2.ca.boeing.com (ced@carios2.ca.boeing.com) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: Recursive Inheritance? Message-ID: <200011102029.MAA04142@carios2.ca.boeing.com> > I'm getting an odd error from perl... > Here's the error: > Recursive inheritance detected while looking for method 'debug' in package 'iSQL::Record' at IWeb/iSQL/Record.pm line 53 > I have a program, that has the following use statements: ... One thing that may provide a hint about what's going on: ######## add this line ######## BEGIN { $Exporter::Verbose = 1 } ################################ use iSQL; use iSQL::Record; use iSQL::Record::Campaign; .... hth, -- Charles DeRykus - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From sthoenna at efn.org Fri Nov 10 15:53:56 2000 From: sthoenna at efn.org (Yitzchak Scott-Thoennes) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: Recursive Inheritance? References: <009201c04b2f$2dca1b60$27e842cf@iwebx1> Message-ID: <05GD6gzkga2Q092yn@efn.org> In article <009201c04b2f$2dca1b60$27e842cf@iwebx1>, "John Cokos" wrote: > I'm getting an odd error from perl... > > Here's the error: > Recursive inheritance detected while looking for method 'debug' in package 'iSQL::Record' at IWeb/iSQL/Record.pm line 53 Seems like a bug in perl to me. Note that you say the method you are trying to call is named "DEBUG" but the error indicates you called it as "debug". Nevertheless, you shouldn't get this particular error. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From sthoenna at efn.org Mon Nov 13 16:22:23 2000 From: sthoenna at efn.org (Yitzchak Scott-Thoennes) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: Recursive Inheritance? References: <009201c04b2f$2dca1b60$27e842cf@iwebx1> <05GD6gzkga2Q092yn@efn.org> Message-ID: In article <05GD6gzkga2Q092yn@efn.org>, sthoenna@efn.org (Yitzchak Scott-Thoennes) wrote: > In article <009201c04b2f$2dca1b60$27e842cf@iwebx1>, > "John Cokos" wrote: > > I'm getting an odd error from perl... > > > > Here's the error: > > Recursive inheritance detected while looking for method 'debug' in package 'iSQL::Record' at IWeb/iSQL/Record.pm line 53 > > Seems like a bug in perl to me. Note that you say the method you are > trying to call is named "DEBUG" but the error indicates you called it > as "debug". Nevertheless, you shouldn't get this particular error. I can't duplicate this on 5.7.0. What version are you using? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From mmaiza at digimine.com Tue Nov 14 00:49:58 2000 From: mmaiza at digimine.com (Moncef Maiza) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: Using compress::zlib Message-ID: <19C2967B601A1E4B8B13490610E189D71CA8B7@corpexch01.corp.digimine.com> I am using active perl version 5.6 and have installed Compress::Zlib version 1.08. But when I try to use it I get the following error: Compress::Zlib object version 1.03 does not match bootstrap parameter 1.08 at C: /apps/Perl/lib/DynaLoader.pm line 219. Compilation failed in require at D:\Work\data\guru\reformat.pl line 3. BEGIN failed--compilation aborted at D:\Work\data\guru\reformat.pl line 3. All line 3 contains is: use Compress:: zlib ; Does anyone know what the issue is? Thanks. Moncef -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/archives/spug-list/attachments/20001113/81f46b28/attachment.htm From mmaiza at digimine.com Tue Nov 14 11:27:07 2000 From: mmaiza at digimine.com (Moncef Maiza) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: Using compress::zlib Message-ID: <19C2967B601A1E4B8B13490610E189D71CA8B8@corpexch01.corp.digimine.com> Please disregard my last message, I figured that the last problem was due to a multiple installation of the library. I cleaned the mess, re-installed and everything is fine. Thanks. Moncef -----Original Message----- From: Moncef Maiza [mailto:mmaiza@digimine.com] Sent: Monday, November 13, 2000 10:50 PM To: 'spug-list@pm.org' Subject: SPUG: Using compress::zlib I am using active perl version 5.6 and have installed Compress::Zlib version 1.08. But when I try to use it I get the following error: Compress::Zlib object version 1.03 does not match bootstrap parameter 1.08 at C: /apps/Perl/lib/DynaLoader.pm line 219. Compilation failed in require at D:\Work\data\guru\reformat.pl line 3. BEGIN failed--compilation aborted at D:\Work\data\guru\reformat.pl line 3. All line 3 contains is: use Compress:: zlib ; Does anyone know what the issue is? Thanks. Moncef -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/archives/spug-list/attachments/20001114/b705d691/attachment.htm From tim at consultix-inc.com Thu Nov 16 19:05:40 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: Nov. Meeting: Ingy on Inline.pm! Message-ID: <20001117010540.A20907@timji.consultix.wa.com> November 21, 2000 Seattle Perl Users Group Meeting ------------------------------------------------------------ Topic: "Polluting Perl with C, Python, and Other Garbage Using Inline.pm" Speaker: Brian "Ingy" Ingerson, Developer, ActiveState Tool Corp. Time: November 21st, 2000 (Third Tuesday), 7pm-9pm LOCATION: Union Bank of California Bldg, 5th Floor Mtg Room Cost: Free - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Brian's new technique for incorporating "alien language" code directly within Perl programs is a more palatable alternative to the relatively complex traditional "XS" approach. His entertaining and impressive article in the latest Perl Journal describes the basics of using his new CPAN module, but for the inside info, come here this talk! Part I - Inline v0.26 (1st half) * Intro, * Usage, * How it works, * Questions Part II - Inline v0.30 (2nd half) * Custom C Typemapping, * C++, * Python, * The Inline API (for adding new languages) * Other new features * Questions/Comments He will also share some information about what's new at ActiveState. If there's time, he might even explain his dot-sig: perl -e 'use Inline C=>q{SV*JAxH(char*x){return newSVpvf ("Just Another %s Hacker\\n",x);}};print JAxH+Perl' * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * SPUG leader Tim Maher will give out some free books in a drawing, and help guide the discussions as usual. Admission is free and open to the general public. Attendees are encouraged to arrive at the building's 5th & Madison door by 6:45pm, which might be locked at other times. Parking We recommend avoiding the parking lot below the Union Bank building, due to the very hefty fee you'll be assessed if you leave after 9pm. There are plenty of other parking garages in the vicinity that are more affordable, and some on-street parking too. Pre/Post-Meeting Gathering Place Come and pass the pre-meeting time with other SPUGsters at the Rock Bottom brewpub, at 1333 5th Ave., (206) 623-3070, in downtown Seattle. Look to your left, near the bar or pool table, for bizarre yet strangely appealing characters wielding laptops and hearty ales. Attendees tend to arrive after 6pm, and to leave for the meeting by 6:40pm. For more information, including driving directions and street addresses, see http://www.halcyon.com/spug/. ========================================================== | Tim Maher, Ph.D. Tel: (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 Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ ========================================================== | Tim Maher, Ph.D. Tel: (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 Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From tim at consultix-inc.com Mon Nov 20 09:23:28 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: Testing Broken List Message-ID: <20001120152328.A3135@timji.consultix.wa.com> Is it fixed yet? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From briani at activestate.com Mon Nov 20 18:48:06 2000 From: briani at activestate.com (Brian Ingerson) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: C-based OO Perl Message-ID: <3A19C646.EB130224@activestate.com> SPUG, I just figured out how to write Object Oriented Perl using C to implement the classes. With Inline.pm of course. It's very simple, very Perlish, very cool, and a little freaky. Come learn about that, and the rest of the wacky Inline world at tommorrow's SPUG meeting. This will *not* be a rehash of the TPJ article, which was written in August. That was a long time ago :) There's lots of cool new stuff. Brian -- perl -le 'use Inline C=>q{SV*JAxH(char*x){return newSVpvf ("Just Another %s Hacker",x);}};print JAxH+Perl' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From ajalis at cobaltgroup.com Tue Nov 28 15:55:03 2000 From: ajalis at cobaltgroup.com (Asim Jalis) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: ESPUG November Meeting On Wednesday Message-ID: <20001128135503.A4543@xenon.cobaltgroup.com> The November meeting of the Eastside Seattle Perl Users Group (ESPUG) will be this Wednesday, November 29 at 7 pm in Lucent's conference room. Come at 6.45 pm for coffee and socializing. The talk starts at 7 pm. Also the doors lock at 7 pm. I'll see if this can be fixed for future meetings but for this one it would be a good idea to be there on time. Wear something warm if you are going to be late. This month: * Sanford Morton will talk about using Net::IRC and libwww to create IRC bots that can grab and report information off the web (e.g. stock quotes). * Asim Jalis will talk about how to do large-scale programming in Perl. Specific modules I will discuss: Class::Multimethod, Class::Struct, Test::Unit. Some points I will address: - How to make programming more fun than Vegas style slot machines. - How to design objects and keep them changeable using Test::Unit. - How to deploy large Perl programs. - How to integrate popular CPAN modules into your project without tying the project to a specific machine. DATE AND SCHEDULE Wednesday, November 29, 2000 6.45 pm - 7.00 pm : Coffee + Networking 7.00 pm - 9.00 pm : Presentations and Q&A. LOCATION Lucent Technologies 6464 185th Ave NE Redmond, WA 98052 DIRECTIONS - Take 520 East to Redmond-Fall City Road (last exit before end of 520 freeway). - Go Right on "Redmond-Fall City Road" (east). - Straight through 2 lights then left on 185th Ave (halfway up hill, hard left). - Go one short block to the top of the hill and the Lucent Technologies logo will be plainly visible above the main entrance of the building (to the right) - If you get to the Fire Station, you have gone a bit too far. Doors open at 6:45 and the meeting starts at 7:00. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From joshlanza at hotmail.com Tue Nov 28 22:20:26 2000 From: joshlanza at hotmail.com (Joshua Lanza) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: perl newbie with annoying little issue ... Message-ID: hi all -- sorry for the trivial nature of this one: can anyone tell me how to determine if a file is a directory or a leaf? (i'm looking for something similar to java's "isDirectory()" method in the File class) thanks, josh _____________________________________________________________________________________ Get more from the Web. FREE MSN Explorer download : http://explorer.msn.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From ced at carios2.ca.boeing.com Tue Nov 28 16:38:07 2000 From: ced at carios2.ca.boeing.com (ced@carios2.ca.boeing.com) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: perl newbie with annoying little issue ... Message-ID: <200011282238.OAA27270@carios2.ca.boeing.com> > can anyone tell me how to determine if a file is a directory or a leaf? (i'm > looking for something similar to java's "isDirectory()" method in the File > class) perldoc perlfunc There's a full listing of the file test operators there including -d. hth, -- Charles DeRykus - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From tnight at pobox.com Tue Nov 28 17:16:19 2000 From: tnight at pobox.com (Terry Nightingale) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: perl newbie with annoying little issue ... In-Reply-To: Message-ID: On Tue, 28 Nov 2000, Joshua Lanza wrote: > hi all -- sorry for the trivial nature of this one: > > can anyone tell me how to determine if a file is a directory or a leaf? (i'm > looking for something similar to java's "isDirectory()" method in the File > class) That's what Perl's file test operators are for. For example: if (-d $file) { print "$file is a directory!\n"; } elsif (-f $file) { print "$file is a leaf!\n"; } else { print "$file is something else!\n"; } -- Terry Nightingale +1-425-649-9304(v) / +1-425-643-7112(f) Prediction is very difficult, especially of the future. -Niels Bohr - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From sthoenna at efn.org Tue Nov 28 17:30:57 2000 From: sthoenna at efn.org (Yitzchak Scott-Thoennes) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: perl newbie with annoying little issue ... In-Reply-To: Message-ID: On Tue, 28 Nov 2000, Joshua Lanza wrote: > can anyone tell me how to determine if a file is a directory or a leaf? (i'm > looking for something similar to java's "isDirectory()" method in the File > class) Use the built in file tests: print 'file' if -f 'filename'; print 'dir' if -d 'filename'; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From joshlanza at hotmail.com Wed Nov 29 20:28:59 2000 From: joshlanza at hotmail.com (Joshua Lanza) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: perl newbie with annoying little issue ... Message-ID: thanks, all, for the help. it works! i guess i should spend more time with the camel ... >From: Yitzchak Scott-Thoennes >To: Joshua Lanza >CC: spug-list@pm.org >Subject: Re: SPUG: perl newbie with annoying little issue ... >Date: Tue, 28 Nov 2000 15:30:57 -0800 (PST) > >On Tue, 28 Nov 2000, Joshua Lanza wrote: > > > can anyone tell me how to determine if a file is a directory or a leaf? >(i'm > > looking for something similar to java's "isDirectory()" method in the >File > > class) > >Use the built in file tests: >print 'file' if -f 'filename'; >print 'dir' if -d 'filename'; > > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL > Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address > For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > > _____________________________________________________________________________________ Get more from the Web. FREE MSN Explorer download : http://explorer.msn.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From tim at consultix-inc.com Wed Nov 29 17:06:07 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: Free "Perl for SA" book at E-SPUG tonight Message-ID: <20001129230607.E7655@timji.consultix.wa.com> E-SPUGsters, Traffic permitting 8-}, I'll be at tonight's meeting. And in keeping with the spirit of the season, I'll be giving away a copy of "Perl for System Administration", with the usual restriction that you'll have to agree to post your review of the book somewhere, if/when O'Reilly comes looking for one later. *========================================================================* | Dr. Tim Maher, CEO, Consultix (206) 781-UNIX/8649; ask for FAX# | | Email: tim@consultix-inc.com Web: http://www.consultix-inc.com | |Training- TIM MAHER: Unix, Perl DAMIAN CONWAY: Adv. Perl, OOP, Parsing | |CLASSES: 12/12-15: UNIX Fun. *Coming in 2000: Database Prog. with Perl | *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From tim at consultix-inc.com Wed Nov 29 19:06:18 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: ESPUG November Meeting On Wednesday In-Reply-To: <20001128164315.A6713@xenon.cobaltgroup.com>; from Asim Jalis on Tue, Nov 28, 2000 at 04:43:15PM -0800 References: <20001128135503.A4543@xenon.cobaltgroup.com> <20001128234740.A6378@timji.consultix.wa.com> <20001128164315.A6713@xenon.cobaltgroup.com> Message-ID: <20001130010618.A7898@timji.consultix.wa.com> First THE BAD NEWS: Due to unforeseen sudden developments, I won't actually be attending the E-SPUG meeting tonight after all, so we'll need to have the drawing for the free "Perl for Sys Administration" book another time. Sorry . . . Now THE GOOD NEWS: The sudden development has to do with SPUG's favorite Perl guru, Dr. Damian Conway, just agreeing to visit Seattle during mid-February. He'll give a (E-)?SPUG talk and present two two-day classes ("Data Munging" and "Adv. OO Perl") during his visit. This development requires me to immediately launch into a flurry of preparations, which must be finished before my weekend plane ride to an out-of-town class, so my evening is now spoken for! But this is, overall, a Very Good Thing! 8-} Have a good meeting . . . And Sandy et al, please post the code you're presenting somewhere where it's easily accessible! *========================================================================* | Dr. Tim Maher, CEO, Consultix (206) 781-UNIX/8649; ask for FAX# | | Email: tim@consultix-inc.com Web: http://www.consultix-inc.com | |Training- TIM MAHER: Unix, Perl DAMIAN CONWAY: Adv. Perl, OOP, Parsing | |12/12: UNIX 1/15: Perl/DBI 2/20: Data Munging;Perl 2/22: Adv. OO Perl| *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From traciee at wrq.com Wed Nov 29 19:07:10 2000 From: traciee at wrq.com (Tracie Edelson) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: Newbie problem with Win32::OLE Message-ID: <86EDBD151558D311BB5700508B2E03FC03FB12B1@pikachu.wrq.com> I'm pretty comfortable doing basic stuff with Perl but this is my first foray into both Win32 object programming and using modules. However, I am pretty good at winging it :) I adapted the module part of this code straight from the ActiveState documentation for the module. In a nutshell, I am importing some text files from Unix, "converting" them to .csv files. I then open the .csv files in Excel and "save as" Excel files (.xls). The whole thing works great, except that when I open the "converted" .xls files, the data is no longer columnar (it is a single line separated by commas. I give up! Help? #Openview Performance Graphs -- create .csv $rawdata="d:\\OpenView\\rawdata\\"; $csvfolder="d:\\OpenView\\csvfolder\\"; $xlsfolder="d:\\OpenView\\monthlytest\\"; chomp $rawdata; chomp $csvfolder; ############################################################################ ###### opendir RAWDATA, $rawdata or die "Cannot open the directory $rawdata\n"; while ($dirlist= readdir RAWDATA) { chomp $dirlist; if ($dirlist =~ /^\.+/) { }else { foreach ($dirlist) { #print "$dirlist\n"; $file = "$rawdata$dirlist"; open FILE, $file; while ($line = ){ #print "$line\n" $line =~ s/(^\S+)\s(\S+)\s(\S+)\s(\S)/$1,$2,$3,$4/; $csvfile = "$csvfolder$dirlist.csv"; open NEWFILE, ">>$csvfile"; print NEWFILE "$line"; } close NEWFILE; close FILE; } } } opendir CSVFOLDER, $csvfolder or die "Cannot open the directory $csvfolder\n"; while ($dir = readdir CSVFOLDER) { chomp $dir; if ($dir =~ /^\.+/) { }else { foreach ($dir){ use Win32::OLE qw (in with); use Win32::OLE::Const; use Win32::OLE::Const 'Microsoft Excel'; $Win32::OLEWarn=3; #die on errors $ex = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit'); # use the Excel application if it's open, otherwise open new $ex->{Visable} =1; $workbook = $ex->Workbooks->Open("$csvfolder$dir"); $workbook->SaveAs ("$xlsfolder$dir.xls")->{FileFormat}= xlExcel9795->{ReadOnlyRecommended}=False; $ex->ActiveWorkbook->Close(0); } $ex->Quit(); } } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From smorton at pobox.com Wed Nov 29 19:01:12 2000 From: smorton at pobox.com (Sanford Morton) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: ESPUG November Meeting On Wednesday In-Reply-To: <20001130010618.A7898@timji.consultix.wa.com> References: <20001128135503.A4543@xenon.cobaltgroup.com> <20001128234740.A6378@timji.consultix.wa.com> <20001128164315.A6713@xenon.cobaltgroup.com> <20001130010618.A7898@timji.consultix.wa.com> Message-ID: <14885.42712.983584.394851@evrtwa1-ar4-128-038.dsl.gtei.net> Tim Maher/CONSULTIX writes: > Have a good meeting . . . And Sandy et al, please post the code you're > presenting somewhere where it's easily accessible! Ok the slides are at http://www.pobox.com/~smorton/modules/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From Dax.Menardo at reedbusiness.com.au Thu Nov 30 00:25:27 2000 From: Dax.Menardo at reedbusiness.com.au (Menardo, Dax) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: scanning directories Message-ID: <7B0B93DC35D8D2119CD308002BB3E2F70484DFDE@REACS2MAIL> first of all its a Windows environment - booooo, i hear some say..... How do I scan through an unmapped share directory name on a server on the network domain? or even open one..... Lets say: $portal{BASEDIR} = "//machinename/sharedirectory"; opendir(ETC,$portal{BASEDIR}) || die "\nCannot opendir ".$portal{BASEDIR}." \n$!"; eventhough the share permission is set to be read/write/execute for everyone.... the interpreter chucks out an error "cannot open the directory "..... Any Ideas.... - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From danielj at cheshirecat.net Thu Nov 30 00:16:03 2000 From: danielj at cheshirecat.net (Daniel Jacobs) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: scanning directories In-Reply-To: <7B0B93DC35D8D2119CD308002BB3E2F70484DFDE@REACS2MAIL> Message-ID: Do you possibly need to escape the '/' characters? i.e. $portal{BASEDIR} = "\/\/machinename\/sharedirectory"; On Thu, 30 Nov 2000, Menardo, Dax wrote: > first of all its a Windows environment - booooo, i hear some say..... > > How do I scan through an unmapped share directory name on a server on the > network domain? or even open one..... > > Lets say: > > $portal{BASEDIR} = "//machinename/sharedirectory"; > opendir(ETC,$portal{BASEDIR}) || die "\nCannot opendir ".$portal{BASEDIR}." > \n$!"; > > eventhough the share permission is set to be read/write/execute for > everyone.... the interpreter chucks out an error "cannot open the directory > "..... > > Any Ideas.... > > > Daniel Jacobs | danielj@cheshirecat.net | Internet & Unix Consulting "In art and dream, may you proceed with abandon. In life, may you proceed with balance and stealth." - Patti Smith - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From john.brittingham at attws.com Thu Nov 30 00:39:18 2000 From: john.brittingham at attws.com (Brittingham, John) Date: Wed Aug 4 00:07:45 2004 Subject: SPUG: scanning directories Message-ID: Ok.. I'm having a problem deleting files. I have tried: $oldfile="../html/wrt_archive/weekly_archive/*to$twodaysback*\.*"; if ($week_day !~ /Mon/) { print "$oldfile\n"; rm ($oldfile) || warn "having trouble deleting $oldfile: $!"; } I have also tried: $oldfile="../html/wrt_archive/weekly_archive/*to$twodaysback*\.*"; if ($week_day !~ /Mon/) { unlink <$oldfile> || warn "having trouble deleting $oldfile: $!"; } I keep getting an error saying it can not find the file(s). I can run rm ../html/wrt_archive/weekly_archive/*to$twodaysback*\.* from the command line and it will work. What am I doing wrong? -----Original Message----- From: Daniel Jacobs [mailto:danielj@cheshirecat.net] Sent: Wednesday, November 29, 2000 10:16 PM To: spug-list@pm.org Subject: Re: SPUG: scanning directories Do you possibly need to escape the '/' characters? i.e. $portal{BASEDIR} = "\/\/machinename\/sharedirectory"; On Thu, 30 Nov 2000, Menardo, Dax wrote: > first of all its a Windows environment - booooo, i hear some say..... > > How do I scan through an unmapped share directory name on a server on the > network domain? or even open one..... > > Lets say: > > $portal{BASEDIR} = "//machinename/sharedirectory"; > opendir(ETC,$portal{BASEDIR}) || die "\nCannot opendir ".$portal{BASEDIR}." > \n$!"; > > eventhough the share permission is set to be read/write/execute for > everyone.... the interpreter chucks out an error "cannot open the directory > "..... > > Any Ideas.... > > > Daniel Jacobs | danielj@cheshirecat.net | Internet & Unix Consulting "In art and dream, may you proceed with abandon. In life, may you proceed with balance and stealth." - Patti Smith - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From john.brittingham at attws.com Thu Nov 30 01:16:30 2000 From: john.brittingham at attws.com (Brittingham, John) Date: Wed Aug 4 00:07:46 2004 Subject: SPUG: Problem deleting files Message-ID: Sorry... Clicked before I should have .. Lets try this again.. Ok.. I'm having a problem deleting files. I have tried: $oldfile="../html/wrt_archive/weekly_archive/*to$twodaysback*\.*"; if ($week_day !~ /Mon/) { print "$oldfile\n"; rm ($oldfile) || warn "having trouble deleting $oldfile: $!"; } I have also tried: $oldfile="../html/wrt_archive/weekly_archive/*to$twodaysback*\.*"; if ($week_day !~ /Mon/) { unlink <$oldfile> || warn "having trouble deleting $oldfile: $!"; } I keep getting an error saying it can not find the file(s). I can run rm ../html/wrt_archive/weekly_archive/*to$twodaysback*\.* from the command line and it will work. What am I doing wrong? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From tim at consultix-inc.com Thu Nov 30 01:35:11 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:46 2004 Subject: SPUG: Problem deleting files In-Reply-To: ; from Brittingham, John on Wed, Nov 29, 2000 at 11:16:30PM -0800 References: Message-ID: <20001130073511.B8388@timji.consultix.wa.com> On Wed, Nov 29, 2000 at 11:16:30PM -0800, Brittingham, John wrote: > Sorry... Clicked before I should have .. Lets try this again.. > > > Ok.. I'm having a problem deleting files. I have tried: > > $oldfile="../html/wrt_archive/weekly_archive/*to$twodaysback*\.*"; > if ($week_day !~ /Mon/) > { > print "$oldfile\n"; > rm ($oldfile) || warn "having trouble deleting What's rm? Are you using the Shell.pm model, or something similar? If so, make sure you're clear on whether rm returns a shell-level T/F value, or a Perl one; if it's the former case, you need rm && warn! Any chance you're deleting the file correctly but incorrectly suspecting a problem because of the warning being triggered improperly? Also, you don't need that backslash in the $oldfile string; that might make sense for a regular expression, but this is a filename generation expression, in which . is not a special character. It won't end up in $oldfile anyway, so that can't be your problem. > $oldfile: $!"; > } > > I have also tried: > > $oldfile="../html/wrt_archive/weekly_archive/*to$twodaysback*\.*"; > if ($week_day !~ /Mon/) > { > unlink <$oldfile> || warn "having trouble deleting This <$oldfile> expression could be misunderstood as a FILEHANDLE, so you should pad it with some (unquoted) spaces so the interpreter gets the right idea: unlink < $oldfile > || warn "having trouble deleting > $oldfile: $!"; > } > > I keep getting an error saying it can not find the file(s). > I can run rm ../html/wrt_archive/weekly_archive/*to$twodaysback*\.* from the > command line and it will work. > > What am I doing wrong? I'm not sure, but I'd recommend trying the following variation to possibly shed more light on what's visible at the shell end of things: system " set -x; ls -l $oldfile " ; As your teacher in a recent Perl class, I'm glad to see you writing Perl programs and participating in the SPUG list! "Perl On"! -Tim *========================================================================* | Dr. Tim Maher, CEO, Consultix (206) 781-UNIX/8649; ask for FAX# | | Email: tim@consultix-inc.com Web: http://www.consultix-inc.com | |Training- TIM MAHER: Unix, Perl DAMIAN CONWAY: Adv. Perl, OOP, Parsing | |12/12: UNIX 1/15: Perl/DBI 2/20: Data Munging;Perl 2/22: Adv. OO Perl| *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From campbell at geospiza.com Thu Nov 30 12:55:50 2000 From: campbell at geospiza.com (Dave Campbell) Date: Wed Aug 4 00:07:46 2004 Subject: SPUG: Problem deleting files References: Message-ID: <3A26A2B6.3EE66E01@geospiza.com> > Ok.. I'm having a problem deleting files. I have tried: > > $oldfile="../html/wrt_archive/weekly_archive/*to$twodaysback*\.*"; 1) are you sure that your are in the right directory to be using the relative path shown? Why not use absolute paths? 2) I think the syntax for using wildcard name expansion with unlink is: unlink ; #So sayeth the camel... -dave - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From rick.croote at philips.com Thu Nov 30 14:39:37 2000 From: rick.croote at philips.com (rick.croote@philips.com) Date: Wed Aug 4 00:07:46 2004 Subject: SPUG: Problem deleting files Message-ID: <0056910008948121000002L112*@MHS> To backup what Tim said, more so, don't use unlink <$oldfile>, use unlink $oldfile or unlink ($oldfile). Rick john.brittingham@attws.com@SMTP@pm.org on 11/29/2000 11:47:43 PM Sent by: owner-spug-list@pm.org To: spug-list@pm.org@SMTP cc: Subject: SPUG: Problem deleting files Classification: Sorry... Clicked before I should have .. Lets try this again.. Ok.. I'm having a problem deleting files. I have tried: $oldfile="../html/wrt_archive/weekly_archive/*to$twodaysback*\.*"; if ($week_day !~ /Mon/) { print "$oldfile\n"; rm ($oldfile) || warn "having trouble deleting $oldfile: $!"; } I have also tried: $oldfile="../html/wrt_archive/weekly_archive/*to$twodaysback*\.*"; if ($week_day !~ /Mon/) { unlink <$oldfile> || warn "having trouble deleting $oldfile: $!"; } I keep getting an error saying it can not find the file(s). I can run rm ../html/wrt_archive/weekly_archive/*to$twodaysback*\.* from the command line and it will work. What am I doing wrong? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From tuck at whistlingfish.net Thu Nov 30 23:37:02 2000 From: tuck at whistlingfish.net (Matt Tucker) Date: Wed Aug 4 00:07:47 2004 Subject: SPUG: scanning directories In-Reply-To: Message-ID: <27870000.975649022@flashingchance.whistlingfish.net> -- Daniel Jacobs spake thusly: > Do you possibly need to escape the '/' characters? i.e. > > $portal{BASEDIR} = "\/\/machinename\/sharedirectory"; This would do absolutely nothing in Perl. Escaping forward slashes is never necessary unless you're using them as the separator character for regexes or quotes, in which case you should just pick a different separator. I really wish people would take the time to learn what does and doesn't need to be escaped in Perl. Excessive backslashes make code more difficult to read, and I've seen far too much gratuitous use of them. It's too bad, really, because Perl provides enough ways to avoid them (alternate quote characters, heredocs, \Q...\E, etc.) that they're hardly ever necessary for anything other than metacharacters. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 232 bytes Desc: not available Url : http://mail.pm.org/archives/spug-list/attachments/20001130/831ef0f9/attachment.bin From tuck at whistlingfish.net Thu Nov 30 23:48:56 2000 From: tuck at whistlingfish.net (Matt Tucker) Date: Wed Aug 4 00:07:47 2004 Subject: SPUG: Problem deleting files In-Reply-To: <0056910008948121000002L112*@MHS> Message-ID: <30430000.975649736@flashingchance.whistlingfish.net> -- rick.croote@philips.com spake thusly: > To backup what Tim said, more so, don't use unlink <$oldfile>, use > unlink $oldfile or unlink ($oldfile). This wouldn't work, because he's trying to delete files using globbing. The following would work: my $oldfiles = 'foo.*'; unlink < $oldfiles >; As would: use File::Glob qw(:glob); my $oldfiles = 'foo.*'; unlink glob($oldfiles); The first one gives a warning for some reason (haven't looked into why), but the second doesn't. As for why the code isn't working, does it have something to do with mixing up shell variables and perl variables? Doing the following in Perl: $oldfile="../html/wrt_archive/weekly_archive/*to$twodaysback*.*"; unlink glob($oldfile) or warn "Can't delete '$oldfile': $!\n"; and the following on the command line: rm ../html/wrt_archive/weekly_archive/*to$twodaysback*.* What exactly is the $twodaysback variable, and where is it coming from? Although on second thought, if this isn't set in Perl, you'd just be doing: rm ../html/wrt_archive/weekly_archive/*to*.* which should work. Trying doing: system "ls ../html/wrt_archive/weekly_archive/"; to make sure you're in the right directory, and see what you get. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 232 bytes Desc: not available Url : http://mail.pm.org/archives/spug-list/attachments/20001130/b853497f/attachment.bin