From tim at consultix-inc.com Sun Jan 2 14:54:10 2005 From: tim at consultix-inc.com (Tim Maher) Date: Sun Jan 2 14:54:22 2005 Subject: SPUG: Larry gives up on Perl, embraces Python!! Message-ID: <20050102205410.GA7879@jumpy.consultix-inc.com> For details on Larry's abandonment of Perl, see: http://lxer.com/module/newswire/view/29032 *--------------------------------------------------------------------------* | Tim Maher, PhD (206) 781-UNIX (866) DOC-PERL (866) DOC-UNIX | | tim(AT)Consultix-Inc.Com http://TeachMePerl.Com http://TeachMeUnix.Com | *+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-* | Watch for my upcoming book: "Minimal Perl for UNIX/Linux People" | | 2/14: Minimal Perl 2/15: Hashes & Arrays 2/16-18: Intermediate Perl | *--------------------------------------------------------------------------* From davidinnes at chicagoscience.com Thu Jan 6 16:13:32 2005 From: davidinnes at chicagoscience.com (David Innes (CSG)) Date: Thu Jan 6 16:14:00 2005 Subject: SPUG: More Perl in the News: Why Six Apart is buying LiveJournal In-Reply-To: Message-ID: <200501061417907.SM01672@Float> According to a LiveJournal press release: "Why is Six Apart buying LiveJournal? Lots of reasons: * Our companies are more alike than different. * We both use Perl. " Link: http://www.livejournal.com/users/news/82926.html?style=mine --- In a world increasingly dominated by PHP (according to my informal bookstore shelf-space board-foot index) it's good to know that a majority of bloggers have their heads (or at least their host software) in the right place. -- David Innes ___________________________________ The information contained in this e-mail message may be privileged, confidential, and protected from disclosure. If you are not the intended recipient, any further disclosure or use, dissemination, distribution, or copying of this message or any attachment is strictly prohibited. If you think that you have received this e-mail message in error, please delete it and notify the sender. -----Original Message----- From: spug-list-bounces@mail.pm.org [mailto:spug-list-bounces@mail.pm.org] On Behalf Of Ken Meyer Sent: Friday, October 08, 2004 9:57 AM To: SPUG; SeaBUG; Seattle Linux List; SeaSLUG-list-ALL; Seattle SAGE-Members Subject: SPUG: October 9th GSLUG Meeting: Unix Apps for Doc Creation;Sound Record & Edit Using Audacity The October 2004 meeting of the Greater Seattle Linux Users Group (GSLUG) will be held this Saturday, October 9th, starting promptly at 10:00 AM on the North Seattle Community College campus. Please feel free to forward this announcement as appropriate. ************************************************************* We are confirmed to use room IB 3319. For directions, see the meetings page: http://www.gslug.org/meeting.html ************************************************************* The presentation topics will be: * 10:00am - Overview of Document Formats Available Under Unix, Including an Introduction to LyX for Easy Writing By Jeremy Reed This presentation will be an overview, with examples, of standard documentation formats available under Unix, including nroff (and the mandoc macro), DocBook, LaTeX, and others. Some document processing and conversion tools will also be described. Use of the LyX document editor for easy document creation will be introduced. LyX is a full-featured graphical front-end for LaTeX, and can be used to generate books, articles, reports, etc. The presentation will cover some of the standard uses of LyX, its common features, how to get started using it, and examples of the generation of ready-to-print documents. The audience will be encouraged to share their experiences and advice with document generation under Unix. Jeremy C. Reed's Bio: Jeremy is a journalist, Unix instructor and consultant (for Puget Sound Technology), and open source advocate. http://www.pugetsoundtechnology.com/ http://bsd.reedmedia.net/ --------------- * 11:15am - Audacity By Matt Brubeck Audacity is a free (GPL) audio recorder and multi-track sound editor. Audacity is built on the cross-platform wxWidgets framework, and is available for Linux, Mac OS, and Windows. It is designed for ease of use, and efficient editing of large files with unlimited undo. Presentation topics include: * Introduction to Audacity, with demonstrations of recording, mixing, and editing. * The developer's view: under the hood of Audacity. * Experiences with cross-platform development. * Legal hurdles, including licensing, MP3 patent issues, and trademark issues. * Preview of recent developments in Audacity CVS. The Audacity web site: http://audacity.sourceforge.net/ Matt Brubeck's Bio: Matt Brubeck is one of the maintainers of the free (GPL) Audacity sound editor for Linux, Mac OS, and Windows. He also maintains the Debian package of Audacity, and is currently in the Debian "New Maintainer" process. http://advogato.org/person/mbrubeck/ ------------------------------------------------------------------------ -- The typical GSLUG meeting agenda is as follows: 10:00 AM First Presentation 11:00 AM Break 11:10 AM Raffle Quiz 11:15 AM Second Presentation 12:15 PM Break 12:30 PM Raffle prizes giveaway 12:35 PM GSLUG announcements and business, including discussion of potential future presentation topics Announcements from attendees Requests for assistance with trouble-shooting and installations desired during the ensuing Workshop session 1:00 PM-ish Formal meeting is adjourned; Workshop and social networking opportunities begin, including: * Installation and trouble-shooting assistance For recommendations on preparations to maximize the probability of a successful outcome, it is recommended that you consult the "What to Bring" topic, way down the page at: http://www.gslug.org/meeting.html * Potential break-out discussions about interest-group activities * Informal PGP key signing * Talking, chatting, blathering, etc, etc. 4:00 pm End of meeting ----------------------------------------------------------------------- GSLUG meetings are held regularly on the second Saturday of the month at 10 AM, currently at North Seattle Community College. Meeting announcements are posted to the gslug-announce mail list. To receive reminders for future GSLUG meetings and notice of other GSLUG activities, you are invited to join the list at: http://lists.gslug.org/mailman/listinfo/gslug-announce Directions, agenda, and presenters' bios will also be posted on the GSLUG website, on the home page and at: http://www.gslug.org/meeting.html You are invited to join the gslug-general discussion list at: http://lists.gslug.org/mailman/listinfo/gslug-general A message board alternative may be found at: http://msgboard.gslug.org/ And a new wiki site is at: http://wiki.gslug.org/ ------------------------------------------------------------------------ -- The GSLUG Crew _____________________________________________________________ Seattle Perl Users Group Mailing List POST TO: spug-list@mail.pm.org http://spugwiki.perlocity.org ACCOUNT CONFIG: http://mail.pm.org/mailman/listinfo/spug-list MEETINGS: 3rd Tuesdays, Location Unknown WEB PAGE: http://www.seattleperl.org From sachin_chat at coolgoose.com Thu Jan 6 22:22:39 2005 From: sachin_chat at coolgoose.com (Sachin Chaturvedi) Date: Thu Jan 6 22:42:48 2005 Subject: SPUG: add a path to @INC Message-ID: <1105072959.4114443463@as03.coolgoose.com> i want to modify my @INC and want to add the path /pkg/perl5plus/lib in that . can i get any help in this issue. Thanks sachin From kmeyer at blarg.net Fri Jan 7 02:45:52 2005 From: kmeyer at blarg.net (Ken Meyer) Date: Fri Jan 7 02:45:22 2005 Subject: SPUG: GSLUG January Meeting THIS SATURDAY, January 8th Message-ID: The January 2005, regular meeting of the Greater Seattle Linux Users Group (GSLUG) will be held this Saturday, January 8th, starting promptly at 10:00 AM on the North Seattle Community College campus. ************************************************************* We are confirmed to use room IB 3319. Parking is free on weekends. For directions, please visit the GSLUG monthly meetings web page at: http://www.gslug.org/meeting.html Please feel free to forward this announcement as appropriate. ************************************************************* The presentation topics will be: * 10:00 AM - Making a Go with Linux By Don Huff Management Communication Resource, Inc. is a laser printing and database publishing firm that has the goal of becoming free of Microsoft, and of operating wholly within the open source sphere. The company has several Intel hosts running Apache, PHP, and Informix web servers, and a collection of Mac and MS machines for employee use and testing. On the back-end they use LaTeX and various other tools to compose and manipulate Postscript and PCL print streams that are destined for four Xerox and Cannon production printers, or external suppliers' typesetters. Mr. Huff's talk will focus on MCR's business environment, several actual application scenarios, the challenges and their solutions. Don Huff's Bio Don Huff is currently employed by MCR, of Mayfield Village (east of Cleveland) Ohio; but Don finds it a nicer to live in Seattle. His job entails web support for employees and customers, who are preparing or accessing production data. Don works from a Linux laptop machine, via Comcast, to access MCR's LAN through its firewall, using SSH tunneling. MCR is a small company of less than 20 people, engaged in the business of laser printing and database publishing in the arenas of corporate benefit books, price catalogs, professional association membership lists, paper ballot voting materials, e-commerce and many other things. MCR's principals, including Don, have been in this business since before the PC era. --------------- * 11:15 AM - EtherDrive Storage Blades and the History of Networks and Storage By Sam Hopkins This presentation addresses the history of disks and networking, and how they came together. Mr. Hopkins will explain why EtherDrive storage blades, based on the ATA-Over-Ethernet (AoE) protocol, are the logical next step in the evolution of storage technology. He will show how the Linux device driver glues AoE devices present on a network into the block storage of the system. He will also discuss the applications for, and the performance of, this approach. Starting with the work at IBM in the 50's, the development of disk storage technology has advanced non-stop. We will see how IBM channels, fiber channel, SCSI, SMD, ST506 and ATA all fit into history. The advent of Ethernet networking in the 1970's ushered in a new era of storage: keeping disks on one network node and doing the computation on another. Ethernet continues to affect storage, first with NFS, then iSCSI, and now AoE . AoE is a simple ?Open Standards"-based protocol that is designed to transport disk commands over Ethernet. Using the AoE protocol, multiple Servers can access EtherDrives as block storage devices that are network-connected using standard Ethernet technology. EtherDrive provides Storage Area Network (SAN) functionality without the need for expensive Fiber-Channel networking technology. Unlike iSCSI, the AoE protocol stack does not require processing of TCP/IP, therefore eliminating the need for expensive adapters on each server and providing inherent storage security. EtherDrive? Storage Blades are Ethernet-connected hard disk drives. Using EtherDrive Storage Blades, SAN's can be assembled for less than $1.50 per Gigabyte, including the cost of disk drives and Ethernet switches (a fraction of the cost of traditional SAN). A shared pool of EtherDrive Storage Blades can be expanded to multi-Petabytes. Sam Hopkins' Bio Sam Hopkins is co-author of the AoE protocol and the author of the Linux and FreeBSD device drivers for the AoE protocol. He works for Coraid, Inc., where he is responsible for OS development related to the AoE protocol and EtherDrive Storage Blade implementation. Coraid is a start-up, founded to provide the most affordable and flexible storage possible to the Open Source community. Coraid's products includes the EtherDrive Storage Blade and the RAIDblade RAID front-end. Check this out: http://www.coraid.com --------------------------------------------------------------------- The typical GSLUG meeting agenda is as follows: 10:00 AM First Presentation 11:00 AM Break 11:10 AM Key Announcements and (usually) Raffle Quiz 11:15 AM Second Presentation 12:15 PM Break 12:30 PM Raffle prize giveaway, when available. Prizes typically consist of current books donated by O'Reilly, Addison-Wesley, and author Brian Hatch. Tickets are available for: 1) Arriving at the meeting on time, 2) Winning Trivia Quiz questions, and 3) Donating to GSLUG's room rental fund. 12:35 PM GSLUG business, including: Discussion of potential future presentation topics Announcements by attendees Receiving requests for assistance desired during the ensuing Workshop Session, including trouble-shooting and help with Linux installation (bring your system). 1:00 PM-ish Formal meeting is adjourned; Workshop and social networking opportunities begin, including: * Installation and trouble-shooting assistance For recommendations on preparations to maximize the probability of a successful outcome, it is recommended that you consult the "What to Bring" topic, way down the page at: http://www.gslug.org/meeting.html * Potential break-out discussions about interest-group activities * Informal PGP key signing * Social networking and group discussions 4:00 PM End of meeting ----------------------------------------------------------------------- GSLUG meetings are held regularly on the second Saturday of the month at 10 AM, currently at North Seattle Community College and USUALLY in room 3319. Meeting announcements are posted to the gslug-announce mail list. To receive reminders for future GSLUG meetings and notice of other GSLUG activities, you are invited to join the list at: http://lists.gslug.org/mailman/listinfo/gslug-announce Directions, agenda, and presenters' bios will also be posted on the GSLUG website, on the home page and at: http://www.gslug.org/meeting.html You are invited to join the gslug-general discussion list at: http://lists.gslug.org/mailman/listinfo/gslug-general A message board alternative may be found at: http://msgboard.gslug.org/ And a new wiki site is at: http://wiki.gslug.org/ -- The GSLUG Crew ------------------------------- 30 ---------------------------- From andrew at sweger.net Fri Jan 7 11:13:13 2005 From: andrew at sweger.net (Andrew Sweger) Date: Fri Jan 7 11:13:15 2005 Subject: SPUG: add a path to @INC In-Reply-To: <1105072959.4114443463@as03.coolgoose.com> Message-ID: On Fri, 7 Jan 2005, Sachin Chaturvedi wrote: > i want to modify my @INC and want to add the path /pkg/perl5plus/lib > in that . can i get any help in this issue. In a Perl script or module: use lib '/pkg/perl5plus/lib'; For a one-liner: perl -I/pkg/perl5plus/lib -e '...' For more information: perldoc lib -- Andrew B. Sweger -- The great thing about multitasking is that several things can go wrong at once. From andrew at sweger.net Sun Jan 9 21:01:21 2005 From: andrew at sweger.net (Andrew Sweger) Date: Sun Jan 9 21:01:30 2005 Subject: SPUG: Ignore: testing new mail server Message-ID: This should have arrived through the new mail server. Hope it works. ObPerl: I just had some fun using split() to break up a HTML document into HTML tags and the text found between them. local $/; # enable slurp mode my $file = <>; # slurp file $file =~ s/\n+/ /g; # replace newlines my @parts = split /(?=<)|(?<=>)/s, $file; That regex broken out: / (?= < ) # matches zero width (intercharacter) before '<' | (?<= > ) # matches zero width after '>' /sx; Seemed like a fun way to break up some HTML so I could get at its parts without actually parsing for something more serious (I was interested in the changes to versions of the file sans HTML markup, but needed to retain the markup in the stream). -- Andrew B. Sweger -- The great thing about multitasking is that several things can go wrong at once. From andrew at sweger.net Sun Jan 9 21:13:53 2005 From: andrew at sweger.net (Andrew Sweger) Date: Sun Jan 9 21:14:01 2005 Subject: SPUG: procmail for spug-list (was: testing new mail server) In-Reply-To: Message-ID: On Sun, 9 Jan 2005, Andrew Sweger wrote: > This should have arrived through the new mail server. Hope it works. Looks like it worked. For those using the List-Id header in procmail to sort/filter SPUG messages, it looks like it has changed from: * ^List-Id: .* to * ^List-Id: .* For the extremely lazy: perl -pei 's/(?<=spug-list\\.)mail\\.//' ~/.procmailrc Of course, that assumes you used a pattern that looks just like mine. That also assumes that code actually works. I have no idea. Copy and execute at your own risk. Oh, and it looks like the next SPUG meeting is only a week from this Tuesday. Wow. That snuck up quick on me. I'm checking with the kind person who volunteered to speak this month to make sure he's still interested and will get that information out as soon as possible. His topic will be the Commands::Guarded module. -- Andrew B. Sweger -- The great thing about multitasking is that several things can go wrong at once. From andrew at sweger.net Wed Jan 12 08:33:40 2005 From: andrew at sweger.net (Andrew Sweger) Date: Wed Jan 12 08:33:50 2005 Subject: SPUG: Meeting Announcement -- Commands::Guarded - 18 January 2005 Message-ID: January 2005 Seattle Perl Users Group (SPUG) Meeting ==================================================== Title: Better Scripting with Commands::Guarded Speaker: Trey Harris Meeting Date: Tuesday, January 18, 2005 Meeting Time: 7:00 - 9:00 p.m. (networking 6:30 - 7:00) Location: Amazon.com Pac-Med Building Cost: Admission is free and open to the general public Info: http://seattleperl.org/ =========================================== (Read this next line in a dramatic voice, like a radio announcer. Do this out loud if you're working in a cubicle right now.) See below for amazingly astounding information on... - Speaker Background - Presentation Description - RSVP - Pre-meeting Dinner - Internet Access at Meeting - PGP/GnuPG Key Exchange - Directions to Meeting (I'll try to get the web site updated by tomorrow. I have an urgent matter at hand -- the sound of dripping water were there should not be.) Speaker Background ================== Trey Harris is a system administrator and system architect with over twelve years of experience at academic, financial and technology sites, including Morgan Stanley, VA Linux Systems, and the University of North Carolina. He has been an enthusiastic user of Perl for the entire time -- his first paying job in technology was modifying Tom Christiansen's "vacation" script to work in an Andrew File System environment. He is currently a Senior Systems Engineer at Amazon.com in Seattle. Presentation Description ======================== Programming methodologies have been researched for decades, and some (e.g. abstract datatypes, object orientation, design-by-contract) have stood the test of time. But what about this thing called a "script"? Is it just a term for a sloppily-written program? If not, are standard programming methodologies applicable to scripting? This talk will argue that scripts are qualitatively different from general-purpose programs and that they need a different methodology. The methodology presented, Procedural Test-Oriented Scripting, encapsulates a script as a series of "steps" that have states that must be ensured, along with actions that will bring the state about. A module implementing this methodology, Commands::Guarded, will be introduced to illustrate. A script written with Commands::Guarded is more resilient, more useful, and easier to write than its conventional equivalent. Examples of such scripts will be shown. Finally, the internals of the module, written in pure Perl and available on CPAN, will be discussed. As a module that munges Perl's syntax by introducing a new control flow construct, the ideas may be of interest even to those Perl programmers who do not spend a great deal of time scripting. RSVP ==== If you've signed up and RSVP'd on Meetup.com, great. If you emailed me, great. If you emailed C.J., great. If you haven't done any of that, great. Just show up. But it would be really nice if you took a couple minutes to sign-up on Meetup.com and indicate if you'll be attending. It's not required, but it is immensely helpful to planning and makes things move slicker 'an grass through a goose. If you personally feel that you have a 50% or better chance of showing up at the meeting, please RSVP. Toward that end, I have setup a Perl Meetup.com group, http://perl.meetup.com/86/ Please consider signing up and joining the SPUG meetup.com group. Through the website, you may manage your RSVP for the meeting and request automatic reminders be emailed to you personally. Pre-meeting Dinner ================== Last month, we met at Hing Loon (awesome food, awesome company). This month we'll meet a couple doors to the west at Pho Hoa at 5:30. Please join me for some of the best Vietnamese beef broth noodle soup south of Than Brothers. It's just under a mile away from the Amazon.com office just across the Dr. Jose P. Rizal bridge. Go ahead and email me by 3:00 pm, 18 January, if you're pretty sure you'll make it. But don't let that stop you from showing up. Do try to show up by 5:45 because this place fills up. Pho Hoa II 618 S Weller St (206) 624-7189 (restaurant phone) Map: http://yp.yahoo.com/py/ypMap.py?Pyt=Typ&tuid=10488072&ck=1891460387&tab=B2C&tcat=8903827&city=Seattle&state=WA&zip=98133-7119&uzip=98133&country=us&msa=7600&cs=9&ed=lRzNlK160SzczSFU3T4PJw1VLUcmpFrkhEW2BVlEha_U7d8JRroNqEidMfosvNoffKFxYWVrtx_pFhe9&stat=:pos:0:regular:regT:10:fbT:0 Directions: http://maps.yahoo.com/dd_result?&csz=Seattle+WA+98144-2734&ed=.JMEaK1v1CyvAEYsmBcrhiGmwCqnyHjvmHYTQV0EYEWZStSrTQG12pK9CSFgG3cgCN7DgUt4eP9uFx1bGb9B7vHp1eKzmBNX2VbfJxkIBXCzKSTX.STDwDpT7WgDi6COUlXQdVG.C3W4H853FBM.yDJnqQ--&country=us&tcsz=Seattle+WA+98104&tcountry=us&tcs=9&tname=Pho+Hoa+II&tdesc=(206)+624-7189 Internet Access at Meeting ========================== A link to the Internet will be provided at the meeting (provided you have suitable equipment). Tables, power strips, and Ethernet hubs will be available in limited quantity. 802.11g WiFi will be available. Please use the SSID: SPUG. The beacon will be broadcasting. No WEP/WPA. Please note that the provided network services are _not_ secure. As I'm sure most of you know, it is a trivial matter to "sniff" network traffic. Please use a secure application encryption protocol or other secure VPN solution to protect sensitive information. Use of the the provided network services is at your own risk. Be a good network citizen. The network services are provided gratis by our hosts. Access can be revoked at any time without prior notification. PGP/GnuPG Key Exchange ====================== If you want to exchange PGP/GnuPG signatures, please contact me directly with your public key (now!) and I'll bring fingerprint checklists for participants. Contact me if you want to know more. Oh, and you have to show up at the meeting to exchange ID's and all that, please. Otherwise this whole key exchange thing doesn't work. Directions to Meeting ===================== Please let me know if you find errors or a better route. Thanks. I-5 (from North or South) ------------------------- On I-5, take the S Dearborn St exit and turn West on Dearborn (I-5 Southbound: turn right; I-5 Northbound: turn left) and proceed approximately one or two blocks. Turn right on 8th Ave S (the first light) and proceed North for three blocks. Turn right on S King St and proceed East for approximately five blocks. You will pass under I-5. Turn right on 12th Ave S and proceed South for approximately five blocks. Along this way, you will cross over the Dr. Jose P. Rizal bridge and you should see the Pac-Med tower directly ahead. At this point, notice that you have been going in a circle. Skip to Pac-Med Building below. I-90 (from East) ---------------- On I-90, take the Rainier Ave S (hwy 900) exit Northbound and proceed approximately six blocks. Turn left on S King St and proceed West for approximately two blocks. Turn left on 12th Ave S and proceed South for approximately five blocks. Along this way, you will cross over the Dr. Jose P. Rizal bridge and you should see the Pac-Med tower directly ahead. Pac-Med Building ---------------- Turn right at Charles St (the light after the bridge). The Amazon.com Pac-Med building is visible ahead and on the left as you make the turn and proceed South on Charles (Charles borders the West side of the building). The North parking lot entrance will be the second drive way on the left (the first has a Do Not Enter sign). The parking lot is on the left just past the parking attendant booth. The "carpool only" spaces should be okay to park in after 6:30. Walk to the South entrance of the tower. There is stair next to the parking garage structure that leads to a convenient path that goes around the building to the main entrance on the South side of the building. Enter building and go to the security desk. Sign in and wait to be escorted to the meeting room (just like when we met at Safeco in the U-district, more or less). Yahoo! Maps: http://us.rd.yahoo.com/maps//maps/extmap/*-http://maps.yahoo.com//maps_result?csz=Seattle%2C+WA+98144-2712&state=WA&uzip=98144&ds=n&name=&desc=&ed=uVHuJep_0TqNClJbk4iFOtDnYtddbn81hKmaNuXswR2pUy1qXnoKfGK_rtqkypGYq5f_zb5ghVDwhYc8gzs3td4sOl73q3BVDyr7btbB3VI4IrVR&zoomin=yes&BFKey=&mag=9 MapQuest: http://www.mapquest.com/maps/map.adp?country=US&countryid=US&addtohistory=&searchtab=address&searchtype=address&address=1200+12th+ave+s&city=&state=&zipcode=98144&search=++Search++ From pdarley at kinesis-cem.com Thu Jan 13 07:30:14 2005 From: pdarley at kinesis-cem.com (Peter Darley) Date: Thu Jan 13 07:30:28 2005 Subject: SPUG: CGI.pm issue Message-ID: Folks, I had a problem with CGI.pm, that I was able to resolve, but now I'm just trying to understand exactly what the problem was. The problem was that when I had a textarea form field that had a lot of data in it, the end of the data would be cut off. I tracked this down to the read_from_client sub, which is only called once, so has to return all the data from the post in one go. It wasn't returning all the data however. The original sub looks like this: # Read data from a file handle sub read_from_client { my($self, $fh, $buff, $len, $offset) = @_; local $^W=0; # prevent a warning return undef unless defined($fh); return read($fh, $$buff, $len, $offset); } I checked $len and it always matched the ammount of data that was expected, and offset was always 0, but it wouldn't read all the data in one go. I couldn't find anything that indicated that read had an upper limit on what it would grab in one go. Is there a limit like this? The new sub looks like this: # Read data from a file handle sub read_from_client { my($self, $fh, $buff, $len, $offset) = @_; local $^W=0; # prevent a warning return undef unless defined($fh); # return read($fh, $$buff, $len, $offset); while (read($fh, $Result, $len, $offset)) { $$buff .= $Result; } return 0; } Which works fine. Basically I'm just reading till I run out of data and then returning 0 which is what read should return when it hits an EOF. Anyway, I'm not sure what was causing the origional problem, so I'm not entirely sure that this is a totally safe change. I have done a lot of testing and it seems to behave correctly. Any revelation about what's going on here is appreciated. Thanks, Peter Darley From charles.e.derykus at boeing.com Thu Jan 13 10:21:19 2005 From: charles.e.derykus at boeing.com (DeRykus, Charles E) Date: Thu Jan 13 10:21:42 2005 Subject: SPUG: CGI.pm issue Message-ID: <5DF8FDE8DFE8744388602480FDCC0E3106F3D016@xch-nw-23.nw.nos.boeing.com> I'm actually surprised that this was implemented with 'read' rather than the lower level, faster sysread. It must have been deemed adequate though since textarea usually don't try to pass for the kitchen sink :) Your revision sidesteps a potential OS 'gulp delay' for a ton of data by looping. However, a longer term outage might still occur and be problematic so I'd recommend an alarm and short term timeout mechanism to avoid blocking forever if you really need huge gulps. -- Charles DeRykus -----Original Message----- From: Peter Darley [mailto:pdarley@kinesis-cem.com] Sent: Thursday, January 13, 2005 7:30 AM To: SPUG Subject: SPUG: CGI.pm issue Folks, I had a problem with CGI.pm, that I was able to resolve, but now I'm just trying to understand exactly what the problem was. The problem was that when I had a textarea form field that had a lot of data in it, the end of the data would be cut off. I tracked this down to the read_from_client sub, which is only called once, so has to return all the data from the post in one go. It wasn't returning all the data however. The original sub looks like this: # Read data from a file handle sub read_from_client { my($self, $fh, $buff, $len, $offset) = @_; local $^W=0; # prevent a warning return undef unless defined($fh); return read($fh, $$buff, $len, $offset); } I checked $len and it always matched the ammount of data that was expected, and offset was always 0, but it wouldn't read all the data in one go. I couldn't find anything that indicated that read had an upper limit on what it would grab in one go. Is there a limit like this? The new sub looks like this: # Read data from a file handle sub read_from_client { my($self, $fh, $buff, $len, $offset) = @_; local $^W=0; # prevent a warning return undef unless defined($fh); # return read($fh, $$buff, $len, $offset); while (read($fh, $Result, $len, $offset)) { $$buff .= $Result; } return 0; } Which works fine. Basically I'm just reading till I run out of data and then returning 0 which is what read should return when it hits an EOF. Anyway, I'm not sure what was causing the origional problem, so I'm not entirely sure that this is a totally safe change. I have done a lot of testing and it seems to behave correctly. Any revelation about what's going on here is appreciated. Thanks, Peter Darley _____________________________________________________________ Seattle Perl Users Group Mailing List POST TO: spug-list@pm.org SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list MEETINGS: 3rd Tuesdays, Location: Amazon.com Pac-Med WEB PAGE: http://seattleperl.org/ From pdarley at kinesis-cem.com Thu Jan 13 10:30:42 2005 From: pdarley at kinesis-cem.com (Peter Darley) Date: Thu Jan 13 10:30:55 2005 Subject: SPUG: CGI.pm issue In-Reply-To: <5DF8FDE8DFE8744388602480FDCC0E3106F3D016@xch-nw-23.nw.nos.boeing.com> Message-ID: Charles, Thanks for replying! So, to rephrase this, the OS (or Apache or something) isn't passing the data fast enough for the entire block to get there in time for one read to catch it all, and doing the read repetitively gives it time to catch up. If this isn't what you're saying, let me know. :) Is your concern on the longer term outage that if a client drops during a post my loop will just continue forever? If that's not it, could you elaborate on what the danger might come from? Thanks, Peter Darley -----Original Message----- From: DeRykus, Charles E [mailto:charles.e.derykus@boeing.com] Sent: Thursday, January 13, 2005 10:21 AM To: Peter Darley; SPUG Subject: RE: SPUG: CGI.pm issue I'm actually surprised that this was implemented with 'read' rather than the lower level, faster sysread. It must have been deemed adequate though since textarea usually don't try to pass for the kitchen sink :) Your revision sidesteps a potential OS 'gulp delay' for a ton of data by looping. However, a longer term outage might still occur and be problematic so I'd recommend an alarm and short term timeout mechanism to avoid blocking forever if you really need huge gulps. -- Charles DeRykus -----Original Message----- From: Peter Darley [mailto:pdarley@kinesis-cem.com] Sent: Thursday, January 13, 2005 7:30 AM To: SPUG Subject: SPUG: CGI.pm issue Folks, I had a problem with CGI.pm, that I was able to resolve, but now I'm just trying to understand exactly what the problem was. The problem was that when I had a textarea form field that had a lot of data in it, the end of the data would be cut off. I tracked this down to the read_from_client sub, which is only called once, so has to return all the data from the post in one go. It wasn't returning all the data however. The original sub looks like this: # Read data from a file handle sub read_from_client { my($self, $fh, $buff, $len, $offset) = @_; local $^W=0; # prevent a warning return undef unless defined($fh); return read($fh, $$buff, $len, $offset); } I checked $len and it always matched the ammount of data that was expected, and offset was always 0, but it wouldn't read all the data in one go. I couldn't find anything that indicated that read had an upper limit on what it would grab in one go. Is there a limit like this? The new sub looks like this: # Read data from a file handle sub read_from_client { my($self, $fh, $buff, $len, $offset) = @_; local $^W=0; # prevent a warning return undef unless defined($fh); # return read($fh, $$buff, $len, $offset); while (read($fh, $Result, $len, $offset)) { $$buff .= $Result; } return 0; } Which works fine. Basically I'm just reading till I run out of data and then returning 0 which is what read should return when it hits an EOF. Anyway, I'm not sure what was causing the origional problem, so I'm not entirely sure that this is a totally safe change. I have done a lot of testing and it seems to behave correctly. Any revelation about what's going on here is appreciated. Thanks, Peter Darley _____________________________________________________________ Seattle Perl Users Group Mailing List POST TO: spug-list@pm.org SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list MEETINGS: 3rd Tuesdays, Location: Amazon.com Pac-Med WEB PAGE: http://seattleperl.org/ From MichaelRWolf at att.net Thu Jan 13 18:04:38 2005 From: MichaelRWolf at att.net (Michael R. Wolf) Date: Thu Jan 13 18:05:05 2005 Subject: SPUG: meetup.com Message-ID: <6.1.2.0.0.20050113175643.026f7280@ipostoffice.worldnet.att.net> If you haven't already done so, you can register here http://perl.meetup.com/ to indicat the level of participation that SPUG has. I just became member #32, making us one shy of the most populated group. Anone wanna be the tie breaker? Michael R. Wolf All mammals learn by playing! MichaelRWolf@att.net From spud at spudzeppelin.com Fri Jan 14 08:30:06 2005 From: spud at spudzeppelin.com (Jeff Almeida) Date: Fri Jan 14 08:30:37 2005 Subject: SPUG: CGI.pm issue In-Reply-To: References: <5DF8FDE8DFE8744388602480FDCC0E3106F3D016@xch-nw-23.nw.nos.boeing.com> Message-ID: <20050114163006.GA87563@brighton.offwhite.net> Peter, This may very-well be related to the way that Apache is passing the data. In particular, I'm curious as to the following: * Which version of Apache you're running? * On what OS? * If it's a 2.0-flavored Apache, with which MPM? * If it's a 2.0-flavored Apache, are you running any filters? * What kind of byte count in the textarea was causing the cutoff? jeff :) Also Sprach Peter Darley: >Charles, > > Thanks for replying! > > So, to rephrase this, the OS (or Apache or something) isn't passing the >data fast enough for the entire block to get there in time for one read to >catch it all, and doing the read repetitively gives it time to catch up. If >this isn't what you're saying, let me know. :) > > Is your concern on the longer term outage that if a client drops during a >post my loop will just continue forever? If that's not it, could you >elaborate on what the danger might come from? > >Thanks, >Peter Darley > >-----Original Message----- >From: DeRykus, Charles E [mailto:charles.e.derykus@boeing.com] >Sent: Thursday, January 13, 2005 10:21 AM >To: Peter Darley; SPUG >Subject: RE: SPUG: CGI.pm issue > > >I'm actually surprised that this was implemented with 'read' >rather than the lower level, faster sysread. It must have been >deemed adequate though since textarea usually don't try to >pass for the kitchen sink :) > >Your revision sidesteps a potential OS 'gulp delay' for a ton >of data by looping. However, a longer term outage might still >occur and be problematic so I'd recommend an alarm and short >term timeout mechanism to avoid blocking forever if you really >need huge gulps. > >-- >Charles DeRykus > > >-----Original Message----- >From: Peter Darley [mailto:pdarley@kinesis-cem.com] >Sent: Thursday, January 13, 2005 7:30 AM >To: SPUG >Subject: SPUG: CGI.pm issue > > >Folks, > I had a problem with CGI.pm, that I was able to resolve, but now I'm just >trying to understand exactly what the problem was. > > The problem was that when I had a textarea form field that had a lot of >data in it, the end of the data would be cut off. I tracked this down to >the read_from_client sub, which is only called once, so has to return all >the data from the post in one go. It wasn't returning all the data however. > > The original sub looks like this: > ># Read data from a file handle >sub read_from_client { > my($self, $fh, $buff, $len, $offset) = @_; > local $^W=0; # prevent a warning > return undef unless defined($fh); > return read($fh, $$buff, $len, $offset); >} > > I checked $len and it always matched the ammount of data that was expected, >and offset was always 0, but it wouldn't read all the data in one go. I >couldn't find anything that indicated that read had an upper limit on what >it would grab in one go. Is there a limit like this? > > The new sub looks like this: > ># Read data from a file handle >sub read_from_client { > my($self, $fh, $buff, $len, $offset) = @_; > local $^W=0; # prevent a warning > return undef unless defined($fh); ># return read($fh, $$buff, $len, $offset); > > while (read($fh, $Result, $len, $offset)) > { > $$buff .= $Result; > } > > return 0; >} > > Which works fine. Basically I'm just reading till I run out of data and >then returning 0 which is what read should return when it hits an EOF. > > Anyway, I'm not sure what was causing the origional problem, so I'm not >entirely sure that this is a totally safe change. I have done a lot of >testing and it seems to behave correctly. > > Any revelation about what's going on here is appreciated. > >Thanks, >Peter Darley > >_____________________________________________________________ >Seattle Perl Users Group Mailing List > POST TO: spug-list@pm.org >SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list > MEETINGS: 3rd Tuesdays, Location: Amazon.com Pac-Med > WEB PAGE: http://seattleperl.org/ > >_____________________________________________________________ >Seattle Perl Users Group Mailing List > POST TO: spug-list@pm.org >SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list > MEETINGS: 3rd Tuesdays, Location: Amazon.com Pac-Med > WEB PAGE: http://seattleperl.org/ -- ****************************************************************************** "Modern technology is already in use that makes electronic voting possible, with accurate and almost immediate tabulation and with paper ballot printouts so all voters can have confidence in the integrity of the process." -J.Carter ****************************************************************************** Jeff D. "Spud (Zeppelin)" Almeida Corinth, TX, US From pdarley at kinesis-cem.com Fri Jan 14 11:31:04 2005 From: pdarley at kinesis-cem.com (Peter Darley) Date: Fri Jan 14 11:31:21 2005 Subject: SPUG: CGI.pm issue In-Reply-To: <20050114163006.GA87563@brighton.offwhite.net> Message-ID: Jeff, I can't say what the byte count was. It was less than two pages of text, so definitely less than 10K, probably less than 2K, maby as little as 1K. Next time I'm in the office I can change my test server back and find out for sure. Here's most of the info you asked for: /proc/version: Linux version 2.4.20-8 (bhcompile@stripples.devel.redhat.com) (gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) #1 Thu Mar 13 17:18:24 EST 2003 rpm -qi http: Name : httpd Relocations: (not relocateable) Version : 2.0.40 Vendor: Red Hat, Inc. Release : 21 Build Date: Tue Feb 25 02:07:14 2003 Install Date: Tue Oct 14 05:15:20 2003 Build Host: daffy.perf.redhat.com Group : System Environment/Daemons Source RPM: httpd-2.0.40-21.src.rpm Size : 2493055 License: Apache Software License Signature : DSA/SHA1, Tue Feb 25 07:05:56 2003, Key ID 219180cddb42a60e Packager : Red Hat, Inc. URL : http://httpd.apache.org/ Summary : Apache HTTP Server I'm not sure how to check filters. The lines in /etc/httpd/conf/httpd.conf that talk about filters are: AddOutputFilter INCLUDES .shtml AllowOverride None Options IncludesNoExec AddOutputFilter Includes html I also don't know how to check for MPM. Let me know how to check it and I will. Thanks, Peter Darley -----Original Message----- From: spug-list-bounces@pm.org [mailto:spug-list-bounces@pm.org]On Behalf Of Jeff Almeida Sent: Friday, January 14, 2005 8:30 AM To: Peter Darley Cc: SPUG Subject: Re: SPUG: CGI.pm issue Peter, This may very-well be related to the way that Apache is passing the data. In particular, I'm curious as to the following: * Which version of Apache you're running? * On what OS? * If it's a 2.0-flavored Apache, with which MPM? * If it's a 2.0-flavored Apache, are you running any filters? * What kind of byte count in the textarea was causing the cutoff? jeff :) Also Sprach Peter Darley: >Charles, > > Thanks for replying! > > So, to rephrase this, the OS (or Apache or something) isn't passing the >data fast enough for the entire block to get there in time for one read to >catch it all, and doing the read repetitively gives it time to catch up. If >this isn't what you're saying, let me know. :) > > Is your concern on the longer term outage that if a client drops during a >post my loop will just continue forever? If that's not it, could you >elaborate on what the danger might come from? > >Thanks, >Peter Darley > >-----Original Message----- >From: DeRykus, Charles E [mailto:charles.e.derykus@boeing.com] >Sent: Thursday, January 13, 2005 10:21 AM >To: Peter Darley; SPUG >Subject: RE: SPUG: CGI.pm issue > > >I'm actually surprised that this was implemented with 'read' >rather than the lower level, faster sysread. It must have been >deemed adequate though since textarea usually don't try to >pass for the kitchen sink :) > >Your revision sidesteps a potential OS 'gulp delay' for a ton >of data by looping. However, a longer term outage might still >occur and be problematic so I'd recommend an alarm and short >term timeout mechanism to avoid blocking forever if you really >need huge gulps. > >-- >Charles DeRykus > > >-----Original Message----- >From: Peter Darley [mailto:pdarley@kinesis-cem.com] >Sent: Thursday, January 13, 2005 7:30 AM >To: SPUG >Subject: SPUG: CGI.pm issue > > >Folks, > I had a problem with CGI.pm, that I was able to resolve, but now I'm just >trying to understand exactly what the problem was. > > The problem was that when I had a textarea form field that had a lot of >data in it, the end of the data would be cut off. I tracked this down to >the read_from_client sub, which is only called once, so has to return all >the data from the post in one go. It wasn't returning all the data however. > > The original sub looks like this: > ># Read data from a file handle >sub read_from_client { > my($self, $fh, $buff, $len, $offset) = @_; > local $^W=0; # prevent a warning > return undef unless defined($fh); > return read($fh, $$buff, $len, $offset); >} > > I checked $len and it always matched the ammount of data that was expected, >and offset was always 0, but it wouldn't read all the data in one go. I >couldn't find anything that indicated that read had an upper limit on what >it would grab in one go. Is there a limit like this? > > The new sub looks like this: > ># Read data from a file handle >sub read_from_client { > my($self, $fh, $buff, $len, $offset) = @_; > local $^W=0; # prevent a warning > return undef unless defined($fh); ># return read($fh, $$buff, $len, $offset); > > while (read($fh, $Result, $len, $offset)) > { > $$buff .= $Result; > } > > return 0; >} > > Which works fine. Basically I'm just reading till I run out of data and >then returning 0 which is what read should return when it hits an EOF. > > Anyway, I'm not sure what was causing the origional problem, so I'm not >entirely sure that this is a totally safe change. I have done a lot of >testing and it seems to behave correctly. > > Any revelation about what's going on here is appreciated. > >Thanks, >Peter Darley > >_____________________________________________________________ >Seattle Perl Users Group Mailing List > POST TO: spug-list@pm.org >SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list > MEETINGS: 3rd Tuesdays, Location: Amazon.com Pac-Med > WEB PAGE: http://seattleperl.org/ > >_____________________________________________________________ >Seattle Perl Users Group Mailing List > POST TO: spug-list@pm.org >SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list > MEETINGS: 3rd Tuesdays, Location: Amazon.com Pac-Med > WEB PAGE: http://seattleperl.org/ -- **************************************************************************** ** "Modern technology is already in use that makes electronic voting possible, with accurate and almost immediate tabulation and with paper ballot printouts so all voters can have confidence in the integrity of the process." -J.Carter **************************************************************************** ** Jeff D. "Spud (Zeppelin)" Almeida Corinth, TX, US _____________________________________________________________ Seattle Perl Users Group Mailing List POST TO: spug-list@pm.org SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list MEETINGS: 3rd Tuesdays, Location: Amazon.com Pac-Med WEB PAGE: http://seattleperl.org/ From kmeyer at blarg.net Fri Jan 14 11:51:56 2005 From: kmeyer at blarg.net (Ken Meyer) Date: Fri Jan 14 11:51:34 2005 Subject: SPUG: FW: [Seattle Cisco User's Group] Available Job Opportunity .... Message-ID: FYI. Ken Meyer -----Original Message----- From: Stevo Devo [mailto:ozbergs@yahoo.com] Sent: Friday, January 14, 2005 11:26 AM To: seattleciscousersgroup@yahoogroups.com Subject: Re: [Seattle Cisco User's Group] Available Job Opportunity .... Or you may contact me directly (sberg@renditionnetworks.com) and I will get your resume into the hands of the hiring manager. We have another contract / moonlight opportunity at Rendition Networks (www.renditionnetworks.com) that may be of interest. We are looking at beefing up TrueControl's scripting offering... as you may or may not know we do configuration management on network devices, but we also offer the ability for our customers to write scripts to modify devices - both in the devices' native language (like IOS configuration mode or CatOS mode) and in more generic languages like Perl and Expect. Some examples of our canned scripts are things like changing the banner or setting the NTP server on a group of devices, but we want to offer better scripts out of the box. Here's where I was hoping someone would be able to help... Are you good at scripting and have a solid network background and would be interested in some consulting / moonlighting work? We're looking for both a good scripting person as well as someone that can come up with some good (and useful) scripting examples!! If that's you - please drop me an email with your resume and hourly rate. Thanks -Steve ----- Original Message ----- From: kendalgabel To: seattleciscousersgroup@yahoogroups.com Sent: Thursday, January 13, 2005 6:19 PM Subject: [Seattle Cisco User's Group] Available Job Opportunity .... Hello, I was contacted by a recruiter who was looking for a Network Engineer for a contract position. I thought there might be some people out there who may be interested in this opportunity. I have included the job description below. The recruiter is Crystal Serrato at Volt. Her phone number is 425-702-9000. Good luck, Kendal #:-) >Position: QA Network Engineer > >Tasks > >Quality assurance role that leverages candidate knowledge of network technologies, best practices, management systems and a broad array of network devices. Work with their extensive multi-vendor network lab in the development of a multi-vendor enterprise network management application. > >Test all aspects of the TrueControl network configuration control system, including product features/functionality, network device support, stress and scalability >Create scripts and tools as needed >Act as customer advocate and domain expert on real-world network scenarios >Participate in the design of new product features and evaluate usability >Participate in tier-1/tier-2 product support rotation as needed >Write release notes and knowledge base cases > >Skills Needed: > >Highly motivated, high energy, self-directed. >Bachelors degree or higher in technical/scientific discipline. >Industry experience in network engineering >Experience in Software Quality Assurance / Testing >Strong network device configuration skills and experience (IOS, etc.); preferably across multiple network device vendors (including Cisco, Nortel, Extreme, Foundry, Juniper, F5) >Experience with and interest in network management tools and applications >Demonstrated ability to work efficiently, prioritize, focus and meet deadlines >Good communications skills. >Team player, able to work well with peers, manager and other teams > > >Preferred Skills > >Bachelors degree or higher in technical/scientific discipline. >Experience with Linux or Solaris >Experience with Windows Server 2003 / 2000 >Scripting experience (such as Perl, TCL, Expect or Python) >Test Automation Experience >Network certifications >Experience administering or using a variety of large network management systems (HP OpenView, CA Unicenter, Tivoli, Spectrum, etc.) >Experience in support or quality assurance roles >Knowledge and hands on use of major networking technologies (OSPF, BGP, EIGRP, VLAN, VPN...); broad exposure to real-world device configurations > >Crystal Serrato >Technical Recruiter | Volt Services Group >11261 Willows Road NE, Suite 200 >Redmond, WA 98052 >P: 425-702-9000 F: 425-702-0415 >TF: 1-800-253-9605 From tim at consultix-inc.com Fri Jan 14 23:45:08 2005 From: tim at consultix-inc.com (Tim Maher) Date: Fri Jan 14 23:45:30 2005 Subject: SPUG: Buggy shebang-line parsing Message-ID: <20050115074508.GA7682@jumpy.consultix-inc.com> Fellow mongers, I've found some serious bugs in recent Perl versions in the parsing of non-trivial shebang lines, involving option clusters after the first being disregarded if too many spaces precede the next ones, and the -s option being ignored altogether, if it doesn't come first in some cases. For example: #! /usr/bin/perl -wlnaF'\t' -s # BAD! #! /usr/bin/perl -s -wlnaF'\t' # GOOD! I'd like to write a program to determine more precisely which sequences do and don't work, before submitting my bug report. But to automate that, I'd ideally like to ask Perl itself which options it was using to run the current script, rather than writing code to attempt the exercising of all the requested options, and sense which options were functioning correctly (or not). In other words, I'm looking for something in Perl that's analogous to the shell's $- variable, which reports the options for the interpreter that are currently in effect. Is there such a thing in Perl? If so, what/where/how, etc. -Tim *--------------------------------------------------------------- -----------* | Tim Maher, PhD (206) 781-UNIX (866) DOC-PERL (866) DOC-UNIX | | tim(AT)Consultix-Inc.Com http://TeachMePerl.Com | http://TeachMeUnix.Com | *+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- +-+-+-+-+-* | Watch for my upcoming book: "Minimal Perl for UNIX/Linux | People" | Classes: 2/14: Minimal Perl 2/15: Hashes & | Arrays 2/16-18: Int. Perl | *---------------------------------------------------------------- ----------* From david.dyck at fluke.com Sat Jan 15 09:10:29 2005 From: david.dyck at fluke.com (David Dyck) Date: Sat Jan 15 09:10:23 2005 Subject: SPUG: Buggy shebang-line parsing In-Reply-To: <20050115074508.GA7682@jumpy.consultix-inc.com> References: <20050115074508.GA7682@jumpy.consultix-inc.com> Message-ID: On Fri, 14 Jan 2005 at 23:45 -0800, Tim Maher wrote: > I've found some serious bugs in recent Perl versions in the > parsing of non-trivial shebang lines, involving option clusters after > the first being disregarded if too many spaces precede the next ones, > and the -s option being ignored altogether, if it doesn't come first > in some cases. For example: > > #! /usr/bin/perl -wlnaF'\t' -s # BAD! > > #! /usr/bin/perl -s -wlnaF'\t' # GOOD! 123456789012345678901234567890 Tim Have you eliminated the operating system interaction with the command line? (I see that you are close to 32 characters and perlrun has some warnings about it - see below) Do you need the space between the #! and the interpreter name? Does moving the flags past the 32-character have an effect? I see you are trying to build a test program, but do you have a few short ones that show a good and bad example? David >From perldoc perlrun here are some concerns: Because historically some operating systems silently chopped off kernel interpretation of the #! line after 32 characters, some switches may be passed in on the command line, and some may not; you could even get a "-" without its letter, if you're not careful. You probably want to make sure that all your switches fall either before or after that 32-character boundary. Most switches don't actually care if they're processed redundantly, but getting a "-" instead of a complete switch could cause Perl to try to execute standard input instead of your program. And a partial -I switch could also cause odd results. Some switches do care if they are processed twice, for instance combinations of -l and -0. Either put all the switches after the 32-character boundary (if applicable), or replace the use of -0digits by "BEGIN{ $/ = "\0digits"; }". From tim at consultix-inc.com Sat Jan 15 10:54:08 2005 From: tim at consultix-inc.com (Tim Maher) Date: Sat Jan 15 10:54:25 2005 Subject: SPUG: Buggy shebang-line parsing In-Reply-To: References: <20050115074508.GA7682@jumpy.consultix-inc.com> Message-ID: <20050115185408.GA20324@jumpy.consultix-inc.com> On Sat, Jan 15, 2005 at 09:10:29AM -0800, David Dyck wrote: > On Fri, 14 Jan 2005 at 23:45 -0800, Tim Maher wrote: > > > I've found some serious bugs in recent Perl versions in the > > parsing of non-trivial shebang lines, involving option clusters after > > the first being disregarded if too many spaces precede the next ones, > > and the -s option being ignored altogether, if it doesn't come first > > in some cases. For example: > > > > #! /usr/bin/perl -wlnaF'\t' -s # BAD! > > > > #! /usr/bin/perl -s -wlnaF'\t' # GOOD! > 123456789012345678901234567890 > > Tim > > Have you eliminated the operating system interaction with the command line? > (I see that you are close to 32 characters and perlrun has some warnings > about it - see below) I figure the above example is only 27 characters, and in any case, reordering the arguments fixes the problem, without changing the string length, which smells like a bug to me! > >From perldoc perlrun here are some concerns: > > Because historically some operating systems silently chopped > off kernel interpretation of the #! line after 32 > characters, some switches may be passed in on the command > line, and some may not I'm aware of that warning, but the (somewhat vague) wording could mean that only some ancient systems would exhibit the problem being described, and I'm using Solaris 9.0 and Linux. 8-} In any case, I'm not hitting the the 32 character boundary, as mentioned above. > Do you need the space between the #! and the interpreter name? I remember it being required on some old versions of UNIX I used, and so I'm reluctant to prescribe leaving it out in my book, for fear somebody will try to do that on a system that won't tolerate it. > Does moving the flags past the 32-character have an effect? Not sure, but I know how to find out. 8-} > I see you are trying to build a test program, but do you have a > few short ones that show a good and bad example? > > David You can see my earlier (different) bug report in attachment #1, and a demonstration of the bug described above in attachment #2 (By the way, the bug disappears if the -s option is not kept separate from the others, and only occurs if -F is used; my guess is that anything coming after -F is ignored -- so there are some clues!) Anyway David, thanks for your interest! As you know, many of the examples in my upcoming book rely heavily on shebang lines being parsed correctly, so I'm pretty keen on getting these issues resolved (and it's been 6 months since I submitted the first bug report (#30660), with no action, AFAIK). -Tim *--------------------------------------------------------------------------* | Tim Maher, PhD (206) 781-UNIX (866) DOC-PERL (866) DOC-UNIX | | tim(AT)Consultix-Inc.Com http://TeachMePerl.Com http://TeachMeUnix.Com | *+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-* | Watch for my upcoming book: "Minimal Perl for UNIX/Linux People" | | Classes: 2/14: Minimal Perl 2/15: Hashes & Arrays 2/16-18: Int. Perl | *--------------------------------------------------------------------------* -------------- next part -------------- >From tim@consultix-inc.com Fri Jul 9 09:37:30 2004 This is a bug report for perl from tim@consultix-inc.com, generated with the help of perlbug 1.34 running under perl v5.8.2. ----------------------------------------------------------------- [Please enter your report here] I've either found a bug in Perl, or there's an undocumented "feature" that I've suddenly run into for the first time. Either way, /I don't like it/! 8-{ In short, a parsing rule (or bug) seems to be operating that says after two (or more) spaces are seen on the shebang line, no additional options are recognized! So when one tries to use -s for switch processing, and that switch is preceded by two spaces, the result is that the -switch=whatever argument is /retained/ on the command line, rather than used to set a variable! When the -w option is in the ignored position, that fails to enable warnings. AFAIK, this is not documented behavior, and IMHO, it is not /desirable/ behavior. I've included sample programs and output below, and confirmed that the same results are obtained with Perl versions 5.8.4 and 5.8.2. -Tim Maher tim@teachmeperl.com PROGRAMS: The _sw ending on a test program means the -s option is first, and the -w second, and vice versa. The program invocation in each case is "./scriptname -switch", which should set the $switch variable in the script to 1. Note that there's nothing switch-specific about this "two-space" bug -- that's just the context in which I originally found it, and it demonstrates the faulty behavior well, by (erroneously) leaving the -switch argument in @ARGV, and triggering a "possible typo" warning regarding $switch in that case. The two_space* versions of the programs are expected to work like the one_space ones, but they don't. 2004-07-05 12:31 one_space_sw Page 1 #! /usr/bin/perl -s -w $switch == 1; warn "Arguments are: @ARGV"; 2004-07-05 12:31 one_space_ws Page 1 #! /usr/bin/perl -w -s $switch == 1; warn "Arguments are: @ARGV"; 2004-07-05 12:32 two_spaces_sw Page 1 #! /usr/bin/perl -s -w $switch == 1; warn "Arguments are: @ARGV"; 2004-07-05 12:32 two_spaces_ws Page 1 #! /usr/bin/perl -w -s $switch == 1; warn "Arguments are: @ARGV"; OUTPUT: RUNNING 'one_space_sw': Useless use of numeric eq (==) in void context at ./one_space_sw line 3. Arguments are: at ./one_space_sw line 5. (That's the correct result; warnings enabled, and switch-argument processed) RUNNING 'one_space_ws': Useless use of numeric eq (==) in void context at ./one_space_ws line 3. Arguments are: at ./one_space_ws line 5. (That's the correct result; warnings enabled, and switch-argument processed) RUNNING 'two_spaces_sw': Arguments are: at ./two_spaces_sw line 5. (That's the WRONG result; warnings DISabled; only switch-option recognized) RUNNING 'two_spaces_ws': Useless use of numeric eq (==) in void context at ./two_spaces_ws line 3. Name "main::switch" used only once: possible typo at ./two_spaces_ws line 3. Use of uninitialized value in numeric eq (==) at ./two_spaces_ws line 3. Arguments are: -switch at ./two_spaces_ws line 5. (That's the WRONG result; switch not processed; only warning option recognized) ============================================================== | Tim Maher, Ph.D. tim(AT)TeachMePerl.com | | Seattle Perl Users Group http://www.SeattlePerl.com | | SPUG Wiki Site http://Spugwiki.Perlocity.org | ============================================================== [Please do not change anything below this line] ----------------------------------------------------------------- --- Flags: category=core severity=medium --- Site configuration information for perl v5.8.2: Configured by root at Sat Nov 15 08:54:26 PST 2003. Summary of my perl5 (revision 5.0 version 8 subversion 2) configuration: Platform: osname=linux, osvers=2.4.19-4gb, archname=i686-linux-thread-multi uname='linux jumpy 2.4.19-4gb #1 mon aug 4 23:38:42 utc 2003 i686 unknown ' config_args='-Dusethreads' hint=recommended, useposix=true, d_sigaction=define usethreads=define use5005threads=undef useithreads=define usemultiplicity=define useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O3', cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fno-strict-aliasing' ccversion='', gccversion='3.2', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=4, prototype=define Linker and Libraries: ld='cc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib /usr/ucblib libs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc libc=, so=so, useshrplib=false, libperl=libperl.a gnulibc_version='2.2.5' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic' cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib' Locally applied patches: --- @INC for perl v5.8.2: /local/perl5/site_perl/5.8.2 /usr/lib/perl5/site_perl/5.8.2 /local/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl/5.8.0 /local/perl5/site_perl/5.6.0 /local/perl5/site_perl/5.005 /local/perl5/site_perl/i386-linux /usr/lib/perl5/site_perl/5.8.0/i586-linux-thread-multi /usr/local/lib/perl5/5.8.2/i686-linux-thread-multi /usr/local/lib/perl5/5.8.2 /usr/local/lib/perl5/site_perl/5.8.2/i686-linux-thread-multi /usr/local/lib/perl5/site_perl/5.8.2 /usr/local/lib/perl5/site_perl /local/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl/5.8.0 /local/perl5/site_perl/5.6.0 /local/perl5/site_perl/i386-linux /local/perl5/site_perl/5.005 . --- Environment for perl v5.8.2: HOME=/home/tim LANG=en_US LANGUAGE (unset) LC_COLLATE=POSIX LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/home/tim/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome2/bin:/opt/gnome/bin:/opt/kde3/bin:/opt/kde2/bin:/usr/lib/java/bin:.:/usr/X11R6/bin:/opt/kde/bin:/local/timbin:/local/dtp:/home/tim/bin:/usr/X11R6/bin:/opt/kde/bin:/local/timbin:/local/dtp:/home/tim/bin PERL5LIB=:/local/perl5/site_perl/5.8.2:/usr/lib/perl5/site_perl/5.8.2:/local/perl5/site_perl/5.8.0:/usr/lib/perl5/site_perl/5.8.0:/local/perl5/site_perl/5.6.0:/local/perl5/site_perl/5.005:/local/perl5/site_perl/i386-linux:/usr/lib/perl5/site_perl/5.8.0/i586-linux-thread-multi PERL_BADLANG (unset) SHELL=/bin/bash -------------- next part -------------- contix@jumpy:/tmp> date Sat Jan 15 10:26:02 PST 2005 contix@jumpy:/tmp> nl -ba good 1 #! /usr/bin/perl -s -wlnaF: 2 print "Switch variable is: $switch"; 3 print "F1: $F[0], F2: $F[1]"; contix@jumpy:/tmp> date | ./good -switch=3 Switch variable is: 3 F1: Sat Jan 15 10, F2: 26 contix@jumpy:/tmp> nl -ba bad 1 #! /usr/bin/perl -wlnaF: -s 2 print "Switch variable is: $switch"; 3 print "F1: $F[0], F2: $F[1]"; contix@jumpy:/tmp> date | ./bad -switch=3 Name "main::switch" used only once: possible typo at ./bad line 2. Can't open -switch=3: No such file or directory. [The switch argument was incorrectly interpreted as a filename!] contix@jumpy:/tmp> diff bad good 1c1 < #! /usr/bin/perl -wlnaF: -s --- > #! /usr/bin/perl -s -wlnaF: contix@jumpy:/tmp> From tim at consultix-inc.com Sat Jan 15 14:20:45 2005 From: tim at consultix-inc.com (Tim Maher) Date: Sat Jan 15 14:20:59 2005 Subject: SPUG: Buggy shebang-line parsing In-Reply-To: <20050115074508.GA7682@jumpy.consultix-inc.com> References: <20050115074508.GA7682@jumpy.consultix-inc.com> Message-ID: <20050115222045.GA21652@jumpy.consultix-inc.com> Earlier today I posted a detailed reply to David's reply to my message, but it has never appeared. Anyway, I've attached sample programs that illustrate the problem to this message (one of which has reported bug-id #30660). Enjoy! -Tim P.S. For the bug illustrated with -s , I'm getting the impression that /any/ options supplied after the -F are ignored, and that there's no problem if that option isn't present ============================================================== | Tim Maher, Ph.D. tim(AT)TeachMePerl.com | | SPUG Leader Emeritus spug(AT)TeachMePerl.com | | Seattle Perl Users Group http://www.SeattlePerl.com | ============================================================== -------------- next part -------------- >From tim@consultix-inc.com Fri Jul 9 09:37:30 2004 This is a bug report for perl from tim@consultix-inc.com, generated with the help of perlbug 1.34 running under perl v5.8.2. ----------------------------------------------------------------- [Please enter your report here] I've either found a bug in Perl, or there's an undocumented "feature" that I've suddenly run into for the first time. Either way, /I don't like it/! 8-{ In short, a parsing rule (or bug) seems to be operating that says after two (or more) spaces are seen on the shebang line, no additional options are recognized! So when one tries to use -s for switch processing, and that switch is preceded by two spaces, the result is that the -switch=whatever argument is /retained/ on the command line, rather than used to set a variable! When the -w option is in the ignored position, that fails to enable warnings. AFAIK, this is not documented behavior, and IMHO, it is not /desirable/ behavior. I've included sample programs and output below, and confirmed that the same results are obtained with Perl versions 5.8.4 and 5.8.2. -Tim Maher tim@teachmeperl.com PROGRAMS: The _sw ending on a test program means the -s option is first, and the -w second, and vice versa. The program invocation in each case is "./scriptname -switch", which should set the $switch variable in the script to 1. Note that there's nothing switch-specific about this "two-space" bug -- that's just the context in which I originally found it, and it demonstrates the faulty behavior well, by (erroneously) leaving the -switch argument in @ARGV, and triggering a "possible typo" warning regarding $switch in that case. The two_space* versions of the programs are expected to work like the one_space ones, but they don't. 2004-07-05 12:31 one_space_sw Page 1 #! /usr/bin/perl -s -w $switch == 1; warn "Arguments are: @ARGV"; 2004-07-05 12:31 one_space_ws Page 1 #! /usr/bin/perl -w -s $switch == 1; warn "Arguments are: @ARGV"; 2004-07-05 12:32 two_spaces_sw Page 1 #! /usr/bin/perl -s -w $switch == 1; warn "Arguments are: @ARGV"; 2004-07-05 12:32 two_spaces_ws Page 1 #! /usr/bin/perl -w -s $switch == 1; warn "Arguments are: @ARGV"; OUTPUT: RUNNING 'one_space_sw': Useless use of numeric eq (==) in void context at ./one_space_sw line 3. Arguments are: at ./one_space_sw line 5. (That's the correct result; warnings enabled, and switch-argument processed) RUNNING 'one_space_ws': Useless use of numeric eq (==) in void context at ./one_space_ws line 3. Arguments are: at ./one_space_ws line 5. (That's the correct result; warnings enabled, and switch-argument processed) RUNNING 'two_spaces_sw': Arguments are: at ./two_spaces_sw line 5. (That's the WRONG result; warnings DISabled; only switch-option recognized) RUNNING 'two_spaces_ws': Useless use of numeric eq (==) in void context at ./two_spaces_ws line 3. Name "main::switch" used only once: possible typo at ./two_spaces_ws line 3. Use of uninitialized value in numeric eq (==) at ./two_spaces_ws line 3. Arguments are: -switch at ./two_spaces_ws line 5. (That's the WRONG result; switch not processed; only warning option recognized) ============================================================== | Tim Maher, Ph.D. tim(AT)TeachMePerl.com | | Seattle Perl Users Group http://www.SeattlePerl.com | | SPUG Wiki Site http://Spugwiki.Perlocity.org | ============================================================== [Please do not change anything below this line] ----------------------------------------------------------------- --- Flags: category=core severity=medium --- Site configuration information for perl v5.8.2: Configured by root at Sat Nov 15 08:54:26 PST 2003. Summary of my perl5 (revision 5.0 version 8 subversion 2) configuration: Platform: osname=linux, osvers=2.4.19-4gb, archname=i686-linux-thread-multi uname='linux jumpy 2.4.19-4gb #1 mon aug 4 23:38:42 utc 2003 i686 unknown ' config_args='-Dusethreads' hint=recommended, useposix=true, d_sigaction=define usethreads=define use5005threads=undef useithreads=define usemultiplicity=define useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O3', cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fno-strict-aliasing' ccversion='', gccversion='3.2', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=4, prototype=define Linker and Libraries: ld='cc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib /usr/ucblib libs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc libc=, so=so, useshrplib=false, libperl=libperl.a gnulibc_version='2.2.5' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic' cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib' Locally applied patches: --- @INC for perl v5.8.2: /local/perl5/site_perl/5.8.2 /usr/lib/perl5/site_perl/5.8.2 /local/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl/5.8.0 /local/perl5/site_perl/5.6.0 /local/perl5/site_perl/5.005 /local/perl5/site_perl/i386-linux /usr/lib/perl5/site_perl/5.8.0/i586-linux-thread-multi /usr/local/lib/perl5/5.8.2/i686-linux-thread-multi /usr/local/lib/perl5/5.8.2 /usr/local/lib/perl5/site_perl/5.8.2/i686-linux-thread-multi /usr/local/lib/perl5/site_perl/5.8.2 /usr/local/lib/perl5/site_perl /local/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl/5.8.0 /local/perl5/site_perl/5.6.0 /local/perl5/site_perl/i386-linux /local/perl5/site_perl/5.005 . --- Environment for perl v5.8.2: HOME=/home/tim LANG=en_US LANGUAGE (unset) LC_COLLATE=POSIX LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/home/tim/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome2/bin:/opt/gnome/bin:/opt/kde3/bin:/opt/kde2/bin:/usr/lib/java/bin:.:/usr/X11R6/bin:/opt/kde/bin:/local/timbin:/local/dtp:/home/tim/bin:/usr/X11R6/bin:/opt/kde/bin:/local/timbin:/local/dtp:/home/tim/bin PERL5LIB=:/local/perl5/site_perl/5.8.2:/usr/lib/perl5/site_perl/5.8.2:/local/perl5/site_perl/5.8.0:/usr/lib/perl5/site_perl/5.8.0:/local/perl5/site_perl/5.6.0:/local/perl5/site_perl/5.005:/local/perl5/site_perl/i386-linux:/usr/lib/perl5/site_perl/5.8.0/i586-linux-thread-multi PERL_BADLANG (unset) SHELL=/bin/bash -------------- next part -------------- contix@jumpy:/tmp> date Sat Jan 15 10:26:02 PST 2005 contix@jumpy:/tmp> nl -ba good 1 #! /usr/bin/perl -s -wlnaF: 2 print "Switch variable is: $switch"; 3 print "F1: $F[0], F2: $F[1]"; contix@jumpy:/tmp> date | ./good -switch=3 Switch variable is: 3 F1: Sat Jan 15 10, F2: 26 contix@jumpy:/tmp> nl -ba bad 1 #! /usr/bin/perl -wlnaF: -s 2 print "Switch variable is: $switch"; 3 print "F1: $F[0], F2: $F[1]"; contix@jumpy:/tmp> date | ./bad -switch=3 Name "main::switch" used only once: possible typo at ./bad line 2. Can't open -switch=3: No such file or directory. [The switch argument was incorrectly interpreted as a filename!] contix@jumpy:/tmp> diff bad good 1c1 < #! /usr/bin/perl -wlnaF: -s --- > #! /usr/bin/perl -s -wlnaF: contix@jumpy:/tmp> From david.dyck at fluke.com Sat Jan 15 20:35:11 2005 From: david.dyck at fluke.com (David Dyck) Date: Sat Jan 15 20:35:22 2005 Subject: SPUG: Buggy shebang-line parsing In-Reply-To: <20050115222045.GA21652@jumpy.consultix-inc.com> References: <20050115074508.GA7682@jumpy.consultix-inc.com> <20050115222045.GA21652@jumpy.consultix-inc.com> Message-ID: On Sat, 15 Jan 2005 at 14:20 -0800, Tim Maher wrote: > Earlier today I posted a detailed reply to David's reply to my > message, but it has never appeared. Anyway, I've attached sample > programs that illustrate the problem to this message (one of > which has reported bug-id #30660). Enjoy! http://rt.perl.org/rt3/index.html?q=30660 At first I thought that one vs. two spaces shouldn't make a difference, till I saw in after the -s myself. I think the problem has to do with the way perl processes the command line on the script itself. I started by using strace (on linux) to look at what command line arguments are being passed to perl, then I fired up gdb (I saw where the loop that processed the #!perl line breaks out of the loop when it sees the space, but I haven't thought of a fix for it yet) For a while I was confused because I thought the -s would trigger further -arguments "on the #! line" to become switches to the program, but now I see that the -s is trying to say to get the switches from the "real" command line arguments. In the past, submitted perl5 bugs would make it to the perl5-porters mailing list, but I didn't see your's their yet. David dd:bugs$ cat 2swx #! /usr/bin/perl -s -w $switch == 1; warn "Arguments are: @ARGV"; warn "saw -w\n" if defined $w; warn "saw -foo\n" if defined $foo; while (<>) { print } dd:bugs$ ./2swx -w -foo bar Arguments are: bar at ./2swx line 3. saw -w saw -foo data in bar dd:bugs$ perl ./2swx -w -foo bar Arguments are: bar at ./2swx line 3. saw -w saw -foo data in bar From sthoenna at efn.org Sat Jan 15 22:47:50 2005 From: sthoenna at efn.org (Yitzchak Scott-Thoennes) Date: Sat Jan 15 22:48:03 2005 Subject: SPUG: Buggy shebang-line parsing In-Reply-To: References: <20050115074508.GA7682@jumpy.consultix-inc.com> <20050115222045.GA21652@jumpy.consultix-inc.com> Message-ID: <20050116064750.GA248@efn.org> On Sat, Jan 15, 2005 at 08:35:11PM -0800, David Dyck wrote: > > In the past, submitted perl5 bugs would make it to the perl5-porters > mailing list, but I didn't see your's their yet. I did see it; looked at it briefly and gave up. It was 6 months ago. From tim at consultix-inc.com Sun Jan 16 10:22:38 2005 From: tim at consultix-inc.com (Tim Maher) Date: Sun Jan 16 10:23:21 2005 Subject: SPUG: Buggy shebang-line parsing In-Reply-To: References: <20050115074508.GA7682@jumpy.consultix-inc.com> <20050115222045.GA21652@jumpy.consultix-inc.com> Message-ID: <20050116182238.GA30437@jumpy.consultix-inc.com> On Sat, Jan 15, 2005 at 08:35:11PM -0800, David Dyck wrote: > > For a while I was confused because I thought the -s would trigger > further -arguments "on the #! line" to become switches to the > program, but now I see that the -s is trying to say to get the switches > from the "real" command line arguments. > > David > > dd:bugs$ cat 2swx > #! /usr/bin/perl -s -w > $switch == 1; > warn "Arguments are: @ARGV"; > warn "saw -w\n" if defined $w; > warn "saw -foo\n" if defined $foo; > while (<>) { print } > > dd:bugs$ ./2swx -w -foo bar > Arguments are: bar at ./2swx line 3. > saw -w > saw -foo > data in bar You don't have a test for the -w option being recognized by Perl as enabling warnings there, so you're missing the bug demo. The bug I reported in 7/04 was that the -w on the shebang line with two spaces before it wouldn't get recognized as a request for enabling warnings, which can be demonstrated (using 5.8.0 on this box) like so: tim$ cat no_w # 2 spaces before -w #! /usr/bin/perl -s -w foo; # should trigger a warning print "\$switch is: $switch\n" tim$ no_w -switch=here # -s recognized, but not -w $switch is: here tim$ This time the -s, which has the 2 spaces before it, is overlooked: tim$ cat no_s #! /usr/bin/perl -w -s foo; # should trigger a warning print "\$switch is: $switch\n" tim$ no_s -switch=here # -w recognized, but not -s Unquoted string "foo" may clash with future reserved word at /tmp/no_s line 2. Useless use of a constant in void context at /tmp/no_s line 2. Name "main::switch" used only once: possible typo at /tmp/no_s line 3. Use of uninitialized value in concatenation (.) or string at /tmp/no_s line 3. $switch is: tim$ -- *--------------------------------------------------------------------------* | Tim Maher, PhD (206) 781-UNIX (866) DOC-PERL (866) DOC-UNIX | | tim(AT)Consultix-Inc.Com http://TeachMePerl.Com http://TeachMeUnix.Com | *+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-* | Watch for my upcoming book: "Minimal Perl for UNIX/Linux People" | | Classes: 2/14: Minimal Perl 2/15: Hashes & Arrays 2/16-18: Int. Perl | *--------------------------------------------------------------------------* From cjcollier at colliertech.org Sun Jan 16 18:12:19 2005 From: cjcollier at colliertech.org (C.J. Collier) Date: Sun Jan 16 18:12:40 2005 Subject: SPUG: add a path to @INC In-Reply-To: References: Message-ID: <3711E08C-682D-11D9-A599-000A95CA2B00@colliertech.org> Note that if you want to use C<@INC> to C modules, I believe you need to put the C in a C block, thus: =pod BEGIN { use lib '/foo/bar/baz'; } use Wally; =cut I could be wrong, though. Whee. On Jan 7, 2005, at 9:13 AM, Andrew Sweger wrote: > On Fri, 7 Jan 2005, Sachin Chaturvedi wrote: > >> i want to modify my @INC and want to add the path /pkg/perl5plus/lib >> in that . can i get any help in this issue. > > In a Perl script or module: > > use lib '/pkg/perl5plus/lib'; > > For a one-liner: > > perl -I/pkg/perl5plus/lib -e '...' > > For more information: > > perldoc lib > > -- > Andrew B. Sweger -- The great thing about multitasking is that several > things can go wrong at once. > > > _____________________________________________________________ > Seattle Perl Users Group Mailing List > POST TO: spug-list@mail.pm.org > SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list > MEETINGS: 3rd Tuesdays, Location: Amazon.com Pac-Med > WEB PAGE: http://seattleperl.org/ > From andrew at sweger.net Sun Jan 16 18:53:42 2005 From: andrew at sweger.net (Andrew Sweger) Date: Sun Jan 16 18:53:52 2005 Subject: SPUG: add a path to @INC In-Reply-To: <3711E08C-682D-11D9-A599-000A95CA2B00@colliertech.org> Message-ID: On Sun, 16 Jan 2005, C.J.Collier wrote: > Note that if you want to use C<@INC> to C modules, I believe you > need to put the C in a C block, thus: PODcity! I think you're wrong. But I'll have to write a test now to double-check myself... File: ./ascript.pl -------------------------------------------------------------- #!/usr/lib/perl use warnings; use strict; use lib './mylib'; BEGIN { print "About to load Ned...\n"; use Ned; print "Done loading Ned.\n"; } my $foo = new Ned; $foo->hello; -------------------------------------------------------------- File: ./mylib/Ned.pm -------------------------------------------------------------- package Ned; use warnings; use strict; sub new { my $foo = {}; return bless $foo; # Hey! I wouldn't do this for real. } sub hello { my $thing = shift; print "Hello\n"; } print "Done loading module Ned. Thank you. Come again.\n"; return 1; -------------------------------------------------------------- % perl ./ascript.pl Done loading module Ned. Thank you. Come again. About to load Ned... Done loading Ned. Hello % Note that all of the 'use' clauses are parsed and loaded even the one *inside* the BEGIN block. Thus, there's no point putting bare use clauses inside BEGIN blocks. Usually one uses a require in a BEGIN block (in a module) to conditionally load a module (as the lib pragma does to load File::Spec on MacOS). As long as the lib pragma falls before the 'use' "call" loading your module in a directory located via the lib pragma, it should work. > I could be wrong, though. Whee. See? It happens to the best people too. Not just me. -- Andrew B. Sweger -- The great thing about multitasking is that several things can go wrong at once. From cjcollier at colliertech.org Mon Jan 17 09:34:29 2005 From: cjcollier at colliertech.org (CJ Collier) Date: Mon Jan 17 09:35:30 2005 Subject: SPUG: PacMed ready for us Message-ID: <1105983269.29193.8.camel@cjcoll.desktop.amazon.com> Hey all, Just wanted to let you all know that the PacMed A/V room is ready for us. We'll have outside network connectivity, so feel free to bring your laptops. Andrew, if you bring your wireless toy, I'll be happy to hook up to it. Cheers, C.J. From sachin_chat at coolgoose.com Tue Jan 18 00:16:24 2005 From: sachin_chat at coolgoose.com (Sachin Chaturvedi) Date: Tue Jan 18 00:36:36 2005 Subject: SPUG: to change a file in different folders Message-ID: <1106037384.1566489662@as03.coolgoose.com> i want to modify a file i a file, say output.txt whaich is present in different folders. for eg... there is a line in output.txt source ../setext.cmd and i want to change it to source $testfolder/../setext.cmd. i can do from comand line as perl -pi -e 's/old/new/g' output.txt but since this is in different folders i want to change all the output.txt in one shot calling script which automatically changes the folder one by one calls the above command and work is done From sthoenna at efn.org Tue Jan 18 02:53:14 2005 From: sthoenna at efn.org (Yitzchak Scott-Thoennes) Date: Tue Jan 18 02:53:23 2005 Subject: SPUG: to change a file in different folders In-Reply-To: <1106037384.1566489662@as03.coolgoose.com> References: <1106037384.1566489662@as03.coolgoose.com> Message-ID: <20050118105314.GB324@efn.org> On Tue, Jan 18, 2005 at 02:06:24PM +0550, Sachin Chaturvedi wrote: > i want to modify a file i a file, say output.txt whaich is present in different folders. > for eg... > > there is a line in output.txt > source ../setext.cmd > and i want to change it to > source $testfolder/../setext.cmd. > > i can do from comand line as perl -pi -e 's/old/new/g' output.txt > > but since this is in different folders i want to change all the output.txt in one shot calling script which automatically changes > the folder one by one calls the above command and work is done You can give more than one filename in place of output.txt, and they can include the folder name, so you could do: perl -pi -e 's/old/new/g' foo/output.txt bar/baz/output.txt or: perl -pi -e 's/old/new/g' */output.txt or: find . -name output.txt | xargs perl -pi -e's/old/new/g' From sachin_chat at coolgoose.com Tue Jan 18 03:18:35 2005 From: sachin_chat at coolgoose.com (Sachin Chaturvedi) Date: Tue Jan 18 03:38:46 2005 Subject: SPUG: how to add text at start of a already existing file Message-ID: <1106048315.4292403023@as03.coolgoose.com> hi i want to add text at very start of already existing file. i have tried this code but it is adding only at end open(FH,">>" . $file)or die " can not open \n"; seek FH,0,0 ; print FH $msg . "\n" ; close FH or die " i can not close \n"; i had tried sysopen(FH,$file,O_APPEND|O_WRONLY) sysseek FH,0,0 but it is doing same as said above can any body tell me gow to add text in beginning of file. From sthoenna at efn.org Tue Jan 18 04:20:17 2005 From: sthoenna at efn.org (Yitzchak Scott-Thoennes) Date: Tue Jan 18 04:20:38 2005 Subject: SPUG: how to add text at start of a already existing file In-Reply-To: <1106048315.4292403023@as03.coolgoose.com> References: <1106048315.4292403023@as03.coolgoose.com> Message-ID: <20050118121951.GA4092@efn.org> On Tue, Jan 18, 2005 at 05:08:35PM +0550, Sachin Chaturvedi wrote: > hi i want to add text at very start of already existing file. > i have tried this code but it is adding only at end > > open(FH,">>" . $file)or die " can not open \n"; > seek FH,0,0 ; > print FH $msg . "\n" ; > close FH or die " i can not close \n"; > > > > i had tried sysopen(FH,$file,O_APPEND|O_WRONLY) > sysseek FH,0,0 > but it is doing same as said above Any time you use O_APPEND or >>, anything you write will be put at the end of the file regardless of what your position in the file was. You use open(FH,"+< $file") to open an existing file for reading and writing. Then you need to read in the entire current content of the file, because when you write your $msg out, it will overwrite what's there already. After printing $msg, then print the original file data. So: open(FH,"+< $file") or die "could not open: $!\n"; seek FH, 0, 0; my $content = do { local $/; }; # read in whole file seek FH, 0, 0; print FH $msg, $content; close FH or die "could not close: $!\n"; From sachin_chat at coolgoose.com Tue Jan 18 05:15:35 2005 From: sachin_chat at coolgoose.com (Sachin Chaturvedi) Date: Tue Jan 18 05:35:47 2005 Subject: SPUG: replacing a string occurence in file with other string Message-ID: <1106055335.1131097261@as03.coolgoose.com> hi , i am having a text file , say output.txt. in that i am having variour occurences of strings with same extn like file1.data , file2.data etc. i want to replace all occurences of files names with .data extn with $testname/file1.data , $testname/file2.data etc . From bri at ifokr.org Tue Jan 18 06:59:07 2005 From: bri at ifokr.org (Brian Hatch) Date: Tue Jan 18 06:59:17 2005 Subject: SPUG: how to add text at start of a already existing file In-Reply-To: <20050118121951.GA4092@efn.org> References: <1106048315.4292403023@as03.coolgoose.com> <20050118121951.GA4092@efn.org> Message-ID: <20050118145907.GA18283@ifokr.org> > > hi i want to add text at very start of already existing file. > > i have tried this code but it is adding only at end ... > > You use open(FH,"+< $file") to open an existing file for reading > and writing. Then you need to read in the entire current content > of the file, because when you write your $msg out, it will overwrite > what's there already. After printing $msg, then print the original > file data. So: > > open(FH,"+< $file") or die "could not open: $!\n"; > seek FH, 0, 0; > my $content = do { local $/; }; # read in whole file > seek FH, 0, 0; > print FH $msg, $content; > close FH or die "could not close: $!\n"; How 'bout $ cat unshift_head #!/usr/bin/perl -p -i BEGIN { $msg = "Stuff I want to add.\n"} print $msg if $. == 1; And then to run it $ unshift_head filename Perl writes the rest because of the '-p' and '-i' switches. -- Brian Hatch Those who live by Systems and the sword, die by Security Engineer the arrow. http://www.ifokr.org/bri/ Every message PGP signed -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: Digital signature Url : http://mail.pm.org/pipermail/spug-list/attachments/20050118/5498234a/attachment.bin From haircut at gmail.com Tue Jan 18 08:44:35 2005 From: haircut at gmail.com (Adam Monsen) Date: Tue Jan 18 08:44:48 2005 Subject: SPUG: how to add text at start of a already existing file In-Reply-To: <1106048315.4292403023@as03.coolgoose.com> References: <1106048315.4292403023@as03.coolgoose.com> Message-ID: <9ebd6511050118084422897ec3@mail.gmail.com> On Tue, 18 Jan 2005 17:08:35 +0550, Sachin Chaturvedi wrote: > hi i want to add text at very start of already existing file. > i have tried this code but it is adding only at end [...] use IO::All; my $contents < io('file.txt'); "At start\n" . $contents > io('file.txt'); IO::All could potentially optimize this "prepending". Hmm, a ->prepend() method might be a welcome addition to IO::All. -- Adam Monsen http://adammonsen.com/ From tim at consultix-inc.com Tue Jan 18 10:21:03 2005 From: tim at consultix-inc.com (Tim Maher) Date: Tue Jan 18 10:21:36 2005 Subject: SPUG: how to add text at start of a already existing file In-Reply-To: <20050118145907.GA18283@ifokr.org> References: <1106048315.4292403023@as03.coolgoose.com> <20050118121951.GA4092@efn.org> <20050118145907.GA18283@ifokr.org> Message-ID: <20050118182103.GA5805@jumpy.consultix-inc.com> On Tue, Jan 18, 2005 at 06:59:07AM -0800, Brian Hatch wrote: > > > > hi i want to add text at very start of already existing file. > > > i have tried this code but it is adding only at end > > $ cat unshift_head > #!/usr/bin/perl -p -i > BEGIN { $msg = "Stuff I want to add.\n"} > > print $msg if $. == 1; > > And then to run it > > $ unshift_head filename > > Perl writes the rest because of the '-p' and '-i' switches. > Brian Hatch Those who live by I endorse Brian's solution as the most simple and practical, but I think a better name for it would be "prepend2file". And I'd also add the following statement to the BEGIN block, in order to get a different file extension on the backup file on each run -- that prevents you from trashing the original backup if you run the script twice: $^I=".$$"; # Use PID for uniqueness What the hell, why not add the -s to the shebang line too, and also -w for extra brownie points, and then supply the message string on the command line: $ prepend2file -msg='whatever' filename For those who like this style of programming, I can recommend a nice upcoming book with tons of examples of this sort 8-} -Tim *--------------------------------------------------------------------------* | Tim Maher, PhD (206) 781-UNIX (866) DOC-PERL (866) DOC-UNIX | | tim(AT)Consultix-Inc.Com http://TeachMePerl.Com http://TeachMeUnix.Com | *+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-* | Watch for my upcoming book: "Minimal Perl for UNIX/Linux People" | | Classes: 2/14: Minimal Perl 2/15: Hashes & Arrays 2/16-18: Int. Perl | *--------------------------------------------------------------------------* From MichaelRWolf at att.net Tue Jan 18 12:59:28 2005 From: MichaelRWolf at att.net (Michael R. Wolf) Date: Tue Jan 18 12:59:38 2005 Subject: SPUG: Getting to the heart of Perl In-Reply-To: <20050118182103.GA5805@jumpy.consultix-inc.com> References: <1106048315.4292403023@as03.coolgoose.com> <20050118121951.GA4092@efn.org> <20050118145907.GA18283@ifokr.org> <20050118182103.GA5805@jumpy.consultix-inc.com> Message-ID: <6.1.2.0.0.20050118125518.0267b3f0@ipostoffice.worldnet.att.net> At 10:21 AM 1/18/2005, Tim Maher wrote: >For those who like this style of programming, I can recommend a >nice upcoming book with tons of examples of this sort 8-} >*+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-* >| Watch for my upcoming book: "Minimal Perl for UNIX/Linux People" | >| Classes: 2/14: Minimal Perl 2/15: Hashes & Arrays 2/16-18: Int. Perl | >*--------------------------------------------------------------------------* > WEB PAGE: http://seattleperl.org/ Along the lines of "you just can't make these things up, you just have to keep your eyes open"... How appropriate is it that Tim is teaching Minimal Perl on Valentines' day????? :-) Michael R. Wolf All mammals learn by playing! MichaelRWolf@att.net From MichaelRWolf at att.net Tue Jan 18 13:12:36 2005 From: MichaelRWolf at att.net (Michael R. Wolf) Date: Tue Jan 18 13:12:42 2005 Subject: SPUG: Ride to meeting from Ballard In-Reply-To: References: Message-ID: <6.1.2.0.0.20050118130604.0263c4e0@ipostoffice.worldnet.att.net> SPUGsters, Can I ride with you to the meeting tonight? I'm car-less tonight, and it's a 1 hr bus ride. If you're going for Pho before the meeting, mo bettah. I live in Ballard, but could easily bus to Freemont, or Magnolia to meet you. Thanks, Michael Wolf 206-782-8377 Michael R. Wolf All mammals learn by playing! MichaelRWolf@att.net From tim at consultix-inc.com Tue Jan 18 17:14:39 2005 From: tim at consultix-inc.com (Tim Maher) Date: Tue Jan 18 17:15:02 2005 Subject: SPUG: Doc. bug on glob() in 3rd ed. Camel Message-ID: <20050119011439.GA22778@jumpy.consultix-inc.com> The 3rd ed. Camel, p. 727 on "glob" says [^abc] complements the list (as in C-shell), but it is really ! that does that, as in Bourne/Korn/Bash shells. And this documentation bug is not listed at O'Reilly's errata page for this book. There's a demonstration below; any comments/insights/disproofs? -Tim $ ls !.! ^.^ a.a b.b o.o $ perl -wle '$,="\n"; print <*.*>' !.! ^.^ a.a b.b o.o # 3rd ed. Camel p.727 says circumflex is negater -- NOT! $ perl -wle '$,="\n"; print <*.[^oa]>' ^.^ a.a o.o # It's really "!" that's the negater: $ perl -wle '$,="\n"; print <*.[!oa]>' !.! ^.^ b.b $ Tested on Suse Linux 8.1 with Perl 5.8.0, and SunOs 9.0, with Perl 5.8.5, issuing Perl commands from both C-shell and Bash shell. All results same as shown above. I rest my case! 8-} -- *--------------------------------------------------------------------------* | Tim Maher, PhD (206) 781-UNIX (866) DOC-PERL (866) DOC-UNIX | | tim(AT)Consultix-Inc.Com http://TeachMePerl.Com http://TeachMeUnix.Com | *+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-* | Watch for my upcoming book: "Minimal Perl for UNIX/Linux People" | | Classes: 2/14: Minimal Perl 2/15: Hashes & Arrays 2/16-18: Int. Perl | *--------------------------------------------------------------------------* From tim at consultix-inc.com Tue Jan 18 18:55:35 2005 From: tim at consultix-inc.com (Tim Maher) Date: Tue Jan 18 18:55:46 2005 Subject: SPUG: Doc. bug on glob() in 3rd ed. Camel In-Reply-To: <20050119011439.GA22778@jumpy.consultix-inc.com> References: <20050119011439.GA22778@jumpy.consultix-inc.com> Message-ID: <20050119025535.GB28020@jumpy.consultix-inc.com> On Tue, Jan 18, 2005 at 05:14:39PM -0800, Tim Maher wrote: > > The 3rd ed. Camel, p. 727 on "glob" says [^abc] complements the > list (as in C-shell), but it is really ! that does that, as in > Bourne/Korn/Bash shells. And this documentation bug is not listed at > O'Reilly's errata page for this book. While I'm doing last-minute research for /my/ book, I've got to learn to stop believing what I'm reading in /other/ books! As a case in point, my 3rd edition Camel (7/00) was probably describing the behavior of Perl v5.6.0, and accurately representing the behavior of glob() at that time. However, it seems that File::Glob (which glob() calls) started using bsd_glob() instead of the old Csh-based code some time after the Camel's publication, which accounts for the mismatch between the Camel's pronouncements and the reality of the current state of Perl. So I retract my complaint about the Camel, and re-allocate it to the on-line docs for the Perl versions I tested (5.8.0, 5.8.5). In each, "perldoc -f glob" says csh-style behavior is what glob gives you, which is incorrect at least in regard to the "!" vs "^" character-class complementing character (Perl uses the non-C-sh ! now, rather than the Csh's ^). We can't blame a book for getting out of date, but we can certainly hope that the on-line documentation shipped with Perl itself will be in sync with the software. I'll file a bug report. -Tim *--------------------------------------------------------------------------* | Tim Maher, PhD (206) 781-UNIX (866) DOC-PERL (866) DOC-UNIX | | tim(AT)Consultix-Inc.Com http://TeachMePerl.Com http://TeachMeUnix.Com | *+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-* | Watch for my upcoming book: "Minimal Perl for UNIX/Linux People" | | Classes: 2/14: Minimal Perl 2/15: Hashes & Arrays 2/16-18: Int. Perl | *--------------------------------------------------------------------------* From andrew at sweger.net Tue Jan 18 20:27:57 2005 From: andrew at sweger.net (Andrew Sweger) Date: Tue Jan 18 20:28:07 2005 Subject: SPUG: The SPUG Report, 18 January 2005 Message-ID: The year is off with a bang. Trey Harris' Commands Guarded[1] module will forever change the way I write so-called one-off scripts for system administration and just about everything else that seems to come back to haunt me. I've already built a Debian package for version 0.01. Let me know if you need a copy. Trey says the module documentation[1] essentially covers the presentation in prose form. Pretty sweet for 200 lines or so of code. Looks like about 18 people showed up for the meeting tonight. SPUG is now the largest Perl group represented on Meetup.com[2] with 46 members. Looks like Meetup.com is a great way to manage meetings. 15 people RSVP'd for tonight's meeting (yes or maybe). Thanks for using it. I'm sure I speak for everyone at tonight's meeting in giving our thanks to Trey for showing us that making something better can be easy, painless, and smart. Danke! [1] - http://search.cpan.org/~trey/Commands-Guarded-0.01/Guarded.pm [2] - http://perl.meetup.com/86/ -- Andrew B. Sweger -- The great thing about multitasking is that several things can go wrong at once. From MichaelRWolf at att.net Thu Jan 20 11:38:02 2005 From: MichaelRWolf at att.net (Michael R. Wolf) Date: Thu Jan 20 11:39:11 2005 Subject: SPUG: Cool power-of-2 trick Message-ID: <6.1.2.0.0.20050120111644.02745600@ipostoffice.worldnet.att.net> While reading through the perl-quiz-of-the-week, I noticed this neat test to find if a number is a power of 2. Originally, I didn't even believe it worked so I wrote a little program to test it. The program helped me figure out that it does, in deed, work, and *how* it works. If a number is a pure powere of 2, it only has one bit set. If you subtract 1 from it you have to borrow from that bit, effectively clearing it and setting all the bits below it. If you then bitwise-and the two numbers, you're guaranteed to come up with zero. You can't get zero otherwise. Coooool. foreach $n (1 .. 2<<8) { if (( $n & ($n-1)) == 0){ printf "%4d %10b %10b %10.10b\n" => $n, $n, $n-1, $n&($n-1); } } $n $n $n $n & $n-1 decimal binary binary binary 1 1 0 0000000000 2 10 1 0000000000 4 100 11 0000000000 8 1000 111 0000000000 16 10000 1111 0000000000 32 100000 11111 0000000000 64 1000000 111111 0000000000 128 10000000 1111111 0000000000 256 100000000 11111111 0000000000 512 1000000000 111111111 0000000000 Michael R. Wolf All mammals learn by playing! MichaelRWolf@att.net -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/spug-list/attachments/20050120/46ded945/attachment-0001.htm From MichaelRWolf at att.net Thu Jan 20 11:49:55 2005 From: MichaelRWolf at att.net (Michael R. Wolf) Date: Thu Jan 20 11:50:11 2005 Subject: SPUG: OSCON 2005 Call for proposals due by 2/13 Message-ID: <6.1.2.0.0.20050120114930.024668a0@ipostoffice.worldnet.att.net> http://conferences.oreillynet.com/cs/os2005/create/e_sess Michael R. Wolf All mammals learn by playing! MichaelRWolf@att.net From bri at ifokr.org Thu Jan 20 12:29:53 2005 From: bri at ifokr.org (Brian Hatch) Date: Thu Jan 20 12:30:04 2005 Subject: SPUG: Cool power-of-2 trick In-Reply-To: <6.1.2.0.0.20050120111644.02745600@ipostoffice.worldnet.att.net> References: <6.1.2.0.0.20050120111644.02745600@ipostoffice.worldnet.att.net> Message-ID: <20050120202953.GD18283@ifokr.org> > While reading through the perl-quiz-of-the-week, I noticed this neat test > to find if a number is a power of 2. Originally, I didn't even believe it > worked so I wrote a little program to test it. The program helped me > figure out that it does, in deed, work, and *how* it works. If a number is > a pure powere of 2, it only has one bit set. ... This only works on systems where data is stored in binary. If you're on a machine that uses ternary storage units (-1 0 +1) then it does not work for powers of two, but it does work for powers of three. Of course I'm still waiting for the completely optimal system which uses storage units of 'e' instead of rounding to 3 for simplicity. -- Brian Hatch "Would you like to take Systems and a shower with the food?" Security Engineer -- Bree http://www.ifokr.org/bri/ Every message PGP signed -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: Digital signature Url : http://mail.pm.org/pipermail/spug-list/attachments/20050120/b947ed07/attachment.bin From MichaelRWolf at att.net Thu Jan 20 13:30:28 2005 From: MichaelRWolf at att.net (Michael R. Wolf) Date: Thu Jan 20 13:30:51 2005 Subject: SPUG: Cool power-of-2 trick In-Reply-To: <20050120202953.GD18283@ifokr.org> References: <6.1.2.0.0.20050120111644.02745600@ipostoffice.worldnet.att.net> <20050120202953.GD18283@ifokr.org> Message-ID: <6.1.2.0.0.20050120132554.0278c030@ipostoffice.worldnet.att.net> At 12:29 PM 1/20/2005, Brian Hatch wrote: > > While reading through the perl-quiz-of-the-week, I noticed this neat test > > to find if a number is a power of 2. Originally, I didn't even believe it > > worked so I wrote a little program to test it. The program helped me > > figure out that it does, in deed, work, and *how* it works. If a > number is > > a pure powere of 2, it only has one bit set. >... > > >This only works on systems where data is stored in binary. If you're on >a machine that uses ternary storage units (-1 0 +1) then it does not >work for powers of two, but it does work for powers of three. > >Of course I'm still waiting for the completely optimal system which uses >storage units of 'e' instead of rounding to 3 for simplicity. In a grad school EE/CS class, the professor did a proof on the board that the best computer would, in fact, have each storage unit contain e (approx 2.718281828....?) states. Since that's closer to 3 than 2, it would be better to have a trinary system instead of a binary system. And yes, it was hard for him to continually say trits (instead of bits) without scrambling it up! :-) -8 To muck with an old punch line -- You silly Rabbi, trits are for kids!!!! Michael R. Wolf All mammals learn by playing! MichaelRWolf@att.net From MichaelRWolf at att.net Thu Jan 20 12:02:28 2005 From: MichaelRWolf at att.net (Michael R. Wolf) Date: Thu Jan 20 13:31:53 2005 Subject: SPUG: SPUG presentation Message-ID: <6.1.2.0.0.20050120115141.027c1908@ipostoffice.worldnet.att.net> Trey, Thanks for one of the best presentations I've seen at SPUG. You did a great job of covering newbies, intermediates, and advanced listeners, making sure that each group got something, and that most groups got much more. A good set of perspectives, too -- academic intro, user-centered middle, behind-the-covers closing. And what a great new (OK, old) way to think and program. It really opened a new world for me. Most of programming is held up by a framework of the control structures that we're familiar with. This, being a different control structure, lets us think differently. It reminds me very much of a quote card that I hand out in many of the programming language classes I teach: Language shapes the way we think, and determines what we can think about. -- B. L. Whorf -- as quoted in the Preface to the First Edition of "The C++ Programming Language", Bjarne Stroustrup By adding something to the language, you've added something different to think about. Thanks again for a GREAT presentation, Michael Wolf Michael R. Wolf All mammals learn by playing! MichaelRWolf@att.net -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/spug-list/attachments/20050120/dfba1f52/attachment.htm From MichaelRWolf at att.net Thu Jan 20 14:08:05 2005 From: MichaelRWolf at att.net (Michael R. Wolf) Date: Thu Jan 20 14:08:16 2005 Subject: SPUG: Cool power-of-2 trick In-Reply-To: <6.1.2.0.0.20050120132554.0278c030@ipostoffice.worldnet.att .net> References: <6.1.2.0.0.20050120111644.02745600@ipostoffice.worldnet.att.net> <20050120202953.GD18283@ifokr.org> <6.1.2.0.0.20050120132554.0278c030@ipostoffice.worldnet.att.net> Message-ID: <6.1.2.0.0.20050120135951.027ad828@ipostoffice.worldnet.att.net> At 01:30 PM 1/20/2005, Michael R. Wolf wrote: >At 12:29 PM 1/20/2005, Brian Hatch wrote: > > >> > While reading through the perl-quiz-of-the-week, I noticed this neat test >> > to find if a number is a power of 2. Originally, I didn't even >> believe it >> > worked so I wrote a little program to test it. The program helped me >> > figure out that it does, in deed, work, and *how* it works. If a >> number is >> > a pure powere of 2, it only has one bit set. >>... >> >> >>This only works on systems where data is stored in binary. If you're on >>a machine that uses ternary storage units (-1 0 +1) then it does not >>work for powers of two, but it does work for powers of three. What does a trinary trit-wise &-operator act like? What's the boolean(?) value of each of the trit states? What's the semantic meaning of the lowest-level '&' operator in that context? Here's a binary table for the results of the &-operator: & | 0 1 --+----- 0 | 0 0 1 | 0 1 Analagous to this boolean truth table & | F T --+----- F | F F T | F T What's the trinary logic table? & | -1 0 1 --+--------- -1 | x x x 0 | x x x 1 | x x x What's Boole have to say about its analog? & | -1 0 1 --+--------- -1 | x x x 0 | x x x 1 | x x x Michael R. Wolf All mammals learn by playing! MichaelRWolf@att.net From mark.johnston at pnl.gov Thu Jan 20 14:39:09 2005 From: mark.johnston at pnl.gov (Johnston, Mark) Date: Thu Jan 20 14:39:22 2005 Subject: SPUG: Cool power-of-2 trick Message-ID: <3CA0BC73DFDC2644ABB3F98416F22BC8064AC0@pnlmse29.pnl.gov> SQL uses a sort of three-valued logic -- False, True and Null (in the table below, F, T and N): &| F T N -+------ F| F F N T| F T N N| N N N Of course there is lots of argument over whether Null ought to be considered a "value". --Mark -----Original Message----- From: spug-list-bounces@pm.org [mailto:spug-list-bounces@pm.org] On Behalf Of Michael R. Wolf Sent: Thursday, January 20, 2005 2:08 PM To: Brian Hatch Cc: spug-list@mail.pm.org Subject: Re: SPUG: Cool power-of-2 trick At 01:30 PM 1/20/2005, Michael R. Wolf wrote: >At 12:29 PM 1/20/2005, Brian Hatch wrote: > > >> > While reading through the perl-quiz-of-the-week, I noticed this >> > neat test to find if a number is a power of 2. Originally, I >> > didn't even >> believe it >> > worked so I wrote a little program to test it. The program helped >> > me figure out that it does, in deed, work, and *how* it works. If >> > a >> number is >> > a pure powere of 2, it only has one bit set. >>... >> >> >>This only works on systems where data is stored in binary. If you're >>on a machine that uses ternary storage units (-1 0 +1) then it does >>not work for powers of two, but it does work for powers of three. What does a trinary trit-wise &-operator act like? What's the boolean(?) value of each of the trit states? What's the semantic meaning of the lowest-level '&' operator in that context? Here's a binary table for the results of the &-operator: & | 0 1 --+----- 0 | 0 0 1 | 0 1 Analagous to this boolean truth table & | F T --+----- F | F F T | F T What's the trinary logic table? & | -1 0 1 --+--------- -1 | x x x 0 | x x x 1 | x x x What's Boole have to say about its analog? & | -1 0 1 --+--------- -1 | x x x 0 | x x x 1 | x x x Michael R. Wolf All mammals learn by playing! MichaelRWolf@att.net _____________________________________________________________ Seattle Perl Users Group Mailing List POST TO: spug-list@pm.org SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list MEETINGS: 3rd Tuesdays, Location: Amazon.com Pac-Med WEB PAGE: http://seattleperl.org/ From tallpeak at hotmail.com Thu Jan 20 14:42:38 2005 From: tallpeak at hotmail.com (Aaron W. West) Date: Thu Jan 20 14:43:10 2005 Subject: SPUG: Cool power-of-2 trick References: <6.1.2.0.0.20050120111644.02745600@ipostoffice.worldnet.att.net><20050120202953.GD18283@ifokr.org> <6.1.2.0.0.20050120132554.0278c030@ipostoffice.worldnet.att.net> Message-ID: I wonder if there's a quick way to find the smallest power of two equal to or greater than a given number. -------- Here's some of "e" for you. QPI-Quick Pi v2.70, (c) 2000-2003 S. Pagliarulo Freely distributable, email: s_pagliarulo@hotmail.com mobile AMD Athlon(tm) XP2400+ detected System speed measured at 1.8 GHz Using default training data Computation of e to 4,194,304 digits Method used : Series SUM 1/n! Started : Mon Aug 23 17:38:02 2004 Series size : 769340 (4,194,309 digits) Initialization time : 0.01 Series processing time : 6.18 Final value time : 3.06 Total time : 9.24 seconds Total memory used : 46,910,676 (44.74 MB) CPU utilization : 88.51% e = 2. 7182818284 5904523536 0287471352 6624977572 4709369995 : 50 9574966967 6277240766 3035354759 4571382178 5251664274 : 100 2746639193 2003059921 8174135966 2904357290 0334295260 : 150 5956307381 3232862794 3490763233 8298807531 9525101901 : 200 1573834187 9307021540 8914993488 4167509244 7614606680 : 250 8226480016 8477411853 7423454424 3710753907 7744992069 : 300 .. (300 digits is enough for this email...) ----- Original Message ----- From: "Michael R. Wolf" To: "Brian Hatch" Cc: Sent: Thursday, January 20, 2005 1:30 PM Subject: Re: SPUG: Cool power-of-2 trick At 12:29 PM 1/20/2005, Brian Hatch wrote: > > While reading through the perl-quiz-of-the-week, I noticed this neat > > test > > to find if a number is a power of 2. Originally, I didn't even believe > > it > > worked so I wrote a little program to test it. The program helped me > > figure out that it does, in deed, work, and *how* it works. If a > number is > > a pure powere of 2, it only has one bit set. >... > > >This only works on systems where data is stored in binary. If you're on >a machine that uses ternary storage units (-1 0 +1) then it does not >work for powers of two, but it does work for powers of three. > >Of course I'm still waiting for the completely optimal system which uses >storage units of 'e' instead of rounding to 3 for simplicity. In a grad school EE/CS class, the professor did a proof on the board that the best computer would, in fact, have each storage unit contain e (approx 2.718281828....?) states. Since that's closer to 3 than 2, it would be better to have a trinary system instead of a binary system. And yes, it was hard for him to continually say trits (instead of bits) without scrambling it up! :-) -8 To muck with an old punch line -- You silly Rabbi, trits are for kids!!!! Michael R. Wolf All mammals learn by playing! MichaelRWolf@att.net From MichaelRWolf at att.net Thu Jan 20 15:05:44 2005 From: MichaelRWolf at att.net (Michael R. Wolf) Date: Thu Jan 20 15:05:58 2005 Subject: SPUG: Cool power-of-2 trick In-Reply-To: References: <6.1.2.0.0.20050120111644.02745600@ipostoffice.worldnet.att.net> <20050120202953.GD18283@ifokr.org> <6.1.2.0.0.20050120132554.0278c030@ipostoffice.worldnet.att.net> Message-ID: <6.1.2.0.0.20050120150322.0282a468@ipostoffice.worldnet.att.net> At 02:42 PM 1/20/2005, Aaron W. West wrote: >I wonder if there's a quick way to find the smallest power of two equal to >or greater than a given number. Yes, for some definition of 'quick'. It's iterative, not a constant order. Michael #! /usr/bin/perl -w sub next_power_of_2 { my $num = shift; my $ones = 0; while ($num) { $ones |= $num; $num >>= 1; } return $ones+1; } for my $i (0 .. 2<<4) { printf "%2d is less than this power of two %3d\n", $i, next_power_of_2($i); } 0 is less than this power of two 1 1 is less than this power of two 2 2 is less than this power of two 4 3 is less than this power of two 4 4 is less than this power of two 8 5 is less than this power of two 8 6 is less than this power of two 8 7 is less than this power of two 8 8 is less than this power of two 16 9 is less than this power of two 16 10 is less than this power of two 16 11 is less than this power of two 16 12 is less than this power of two 16 13 is less than this power of two 16 14 is less than this power of two 16 15 is less than this power of two 16 16 is less than this power of two 32 17 is less than this power of two 32 18 is less than this power of two 32 19 is less than this power of two 32 20 is less than this power of two 32 21 is less than this power of two 32 22 is less than this power of two 32 23 is less than this power of two 32 24 is less than this power of two 32 25 is less than this power of two 32 26 is less than this power of two 32 27 is less than this power of two 32 28 is less than this power of two 32 29 is less than this power of two 32 30 is less than this power of two 32 31 is less than this power of two 32 32 is less than this power of two 64 Michael R. Wolf All mammals learn by playing! MichaelRWolf@att.net From MichaelRWolf at att.net Thu Jan 20 19:50:14 2005 From: MichaelRWolf at att.net (Michael R. Wolf) Date: Thu Jan 20 19:50:26 2005 Subject: SPUG: Re: SPUG presentation In-Reply-To: <20050120164054.S56951@bowser.eecs.harvard.edu> References: <6.1.2.0.0.20050120115141.027c1908@ipostoffice.worldnet.att.net> <20050120164054.S56951@bowser.eecs.harvard.edu> Message-ID: <6.1.2.0.0.20050120194028.028355d8@ipostoffice.worldnet.att.net> At 04:49 PM 1/20/2005, Trey Harris wrote: >Thanks, I really appreciate the kind words. > >(Incidentally, I was trained as a linguist, so maybe you've got something >there. As a Chomskyan, I really can't abide a Whorf reference with a >straight face--but I suppose programming languages, as cultural artifact, >are more amenable to such conjecture and don't require full acceptance of >the Weltanschauung of the Sapir-Whorf Hypothesis. :-) > >Trey I've been picking up linguistics on the side in the past few years. I'd been quoting the Whorf statement for years before I started researching him (or his detractors). I've backed off his statement a bit, but I still find it very useful to start a discussion at the beginning of a programing language class. It sets the stage for the kinds of constructs that the language du jour (C, C++, shell, Perl, ...) can (and cannot) do well. A brick is good for some things. It can even open a can, but only if a can opener isn't available, and you're really hungry. Lots of folks in my intro to language-du-jour classes find the discussion helpful as a foundation for the rest of the class. And I find that having had that conversation, I don't have to field as many off-topic (i.e. off-language questions). Not that I mind some off-road travel, mind you. I, too, think it's instructive to go over the edge to get a feel for just where it is. The Whorf quote sets a nice framework for the class. And I do appreciate you challenging the Whorfian hypothesis. It helps me to fit his work into the larger linguistic framework, something I've been actively studying for a while. While we're on the linguistic/author subject.... What are your thoughts on "The Language Instinct". I read it a year ago, and am currently in the middle of "How the Mind Works". I've gotten even more interesting comments about Pinker's thinking. Perhaps we could even pick up a conversation over lunch some time?. It would be interesting to me to engage a formally trained linguist in a discussion of what's worth learning in the literature and where some of the interesting work is going. Thanks, MIchael Michael R. Wolf All mammals learn by playing! MichaelRWolf@att.net From kenslinux at shaw.ca Fri Jan 21 03:37:41 2005 From: kenslinux at shaw.ca (Ken Clarke) Date: Fri Jan 21 03:38:41 2005 Subject: SPUG: Cool power-of-2 trick References: <6.1.2.0.0.20050120111644.02745600@ipostoffice.worldnet.att.net> <20050120202953.GD18283@ifokr.org> <6.1.2.0.0.20050120132554.0278c030@ipostoffice.worldnet.att.net> Message-ID: <005b01c4ffad$9df1a160$37476d18@kens> ----- Original Message ----- From: "Aaron W. West" Sent: Thursday, January 20, 2005 2:42 PM Subject: Re: SPUG: Cool power-of-2 trick >I wonder if there's a quick way to find the smallest power of two equal to > or greater than a given number. Sure, by counting the number of characters in the binary representation of the given number less 1, then raising 2 to the power of the count: $smallest_power_of_two = 2**(length(sprintf "%b", $given_number - 1)); $given_number must be > 1 because subtracting 1 does not produce a zero character binary representation. You know that the answer for all numbers below 2 (including negative numbers) is 1 anyway (2**0 = 1). I also found that it breaks down for given numbers larger than 2**30 but your mileage may vary as they say... There are 10 types of people in the world; those who know binary and those who don't. >> Ken Clarke >> Contract Web Programmer / E-commerce Technologist >> www.PerlProgrammer.net From tim at consultix-inc.com Fri Jan 21 19:24:10 2005 From: tim at consultix-inc.com (Tim Maher) Date: Sat Jan 22 11:24:24 2005 Subject: SPUG: Simplest tool for creating custom modules? Message-ID: <20050122032410.GA25770@jumpy.consultix-inc.com> Friends in Perlity, I'm writing the section for my book on "Creating your own modules", and I'm wondering if I should base the discussion on Exporter.pm, or show the reader one of the more modern tools (esp. if there's one that's becoming accepted as a "new standard"). The advantage of the Exporter.pm approach is that it's quite simple and I already know how it works 8-}, but if my readers would be better off hearing about something newer and shinier that's also simple and won't ostracize them from other JAPHs, I'm open to alternatives. So, would you recommend any of the newer module-making-modules? If so, which ones? -Tim P.S. The readers won't know any OO techniques or anonymous data structures, so I'd like to avoid any hints of that syntax where possible. *--------------------------------------------------------------------------* | Tim Maher, PhD (206) 781-UNIX (866) DOC-PERL (866) DOC-UNIX | | tim(AT)Consultix-Inc.Com http://TeachMePerl.Com http://TeachMeUnix.Com | *+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-* | Watch for my upcoming book: "Minimal Perl for UNIX/Linux People" | | Classes: 2/14: Minimal Perl 2/15: Hashes & Arrays 2/16-18: Int. Perl | *--------------------------------------------------------------------------* From creede at penguinsinthenight.com Sat Jan 22 17:42:43 2005 From: creede at penguinsinthenight.com (Creede Lambard) Date: Sat Jan 22 17:43:01 2005 Subject: SPUG: Simplest tool for creating custom modules? In-Reply-To: <20050122032410.GA25770@jumpy.consultix-inc.com> References: <20050122032410.GA25770@jumpy.consultix-inc.com> Message-ID: <20050123014243.GE5940@igor.penguinsinthenight.com> Unfortunately once you get outside the realm of Exporter you've probably pretty well stepped away from the idea of "minimal Perl." I would guess that anything that doesn't come standard with Perl, you shouldn't get into*. *Except in a chapter on CPAN, of course. I used to use one of the techniques in Damian's OO book On Fri, Jan 21, 2005 at 07:24:10PM -0800, Tim Maher wrote: > Friends in Perlity, > > I'm writing the section for my book on "Creating your own > modules", and I'm wondering if I should base the discussion on > Exporter.pm, or show the reader one of the more modern tools > (esp. if there's one that's becoming accepted as a "new standard"). > > The advantage of the Exporter.pm approach is that it's quite > simple and I already know how it works 8-}, but if my readers > would be better off hearing about something newer and shinier > that's also simple and won't ostracize them from other JAPHs, I'm > open to alternatives. > -- =================================================================== * .~. ( : Creede Lambard : Never rush a miracle man. . / V \ . :------------------------: You get lousy miracles. /( )\ : creede at : --------------------------------^^-^^----: penguinsinthenight : Linux. Reliable and free. Pick any two. : dot com : =================================================================== -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://mail.pm.org/pipermail/spug-list/attachments/20050122/d8e30ed0/attachment.bin From creede at penguinsinthenight.com Sat Jan 22 23:50:03 2005 From: creede at penguinsinthenight.com (Creede Lambard) Date: Sat Jan 22 23:50:15 2005 Subject: SPUG: Simplest tool for creating custom modules? In-Reply-To: <20050123014243.GE5940@igor.penguinsinthenight.com> References: <20050122032410.GA25770@jumpy.consultix-inc.com> <20050123014243.GE5940@igor.penguinsinthenight.com> Message-ID: <20050123075002.GF5940@igor.penguinsinthenight.com> On Sat, Jan 22, 2005 at 05:42:43PM -0800, Creede Lambard wrote: > I used to use one of the techniques in Damian's OO book Ack. Next time read it over before you hit "send." I think I was going to talk about one of the Class modules Damian profiled, then realized that was getting away from the idea of Minimal Perl. Sorry for the hanging thought. -- =================================================================== * .~. ( : Creede Lambard : Never rush a miracle man. . / V \ . :------------------------: You get lousy miracles. /( )\ : creede at : --------------------------------^^-^^----: penguinsinthenight : Linux. Reliable and free. Pick any two. : dot com : =================================================================== -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://mail.pm.org/pipermail/spug-list/attachments/20050122/ef188ec3/attachment.bin From pdarley at kinesis-cem.com Mon Jan 24 08:34:46 2005 From: pdarley at kinesis-cem.com (Peter Darley) Date: Mon Jan 24 08:34:53 2005 Subject: SPUG: Tracing back to a calling sub Message-ID: Folks, I'm trying to figure out if there's a way for a sub to find out what sub called it? The situation that I'm in is that I have a lot of generic subs, such as one that takes a database query string and returns a hash of what was loaded from the database. When it fails, I just get an error from the sub, but it's almost always a error in how I called the sub that caused problems, and it can be hard to go back through my program and find which sub called this sub incorrectly. So, basically what I want to be able to do is have something like: sub MySub { my (%Args) = @_; # Args: Query = The query to run the Lookup on if (! $Args{Query}) {die "A null querry was passed to MySub from $Calling_Sub!"} ... } And it would come up with something like "A null querry was passed to MySub from LookupUserInfo()!" Thanks, Peter Darley From jimfl at tensegrity.net Mon Jan 24 08:50:38 2005 From: jimfl at tensegrity.net (Jim Flanagan) Date: Mon Jan 24 08:51:01 2005 Subject: SPUG: Tracing back to a calling sub In-Reply-To: References: Message-ID: On Mon, 24 Jan 2005, Peter Darley wrote: > I'm trying to figure out if there's a way for a sub to > find out what sub called it? Take a look at the second form of the 'caller' function. This should get you at what you're looking for. my $calling_sub = (caller(0))[3]; There are situations where this won't quite get what you want, for example eval { $foo = (caller(0))[3]; print $foo; } will print "(eval)" in which case you'll have to increase the level in the stack. From pdarley at kinesis-cem.com Mon Jan 24 09:04:53 2005 From: pdarley at kinesis-cem.com (Peter Darley) Date: Mon Jan 24 09:05:01 2005 Subject: SPUG: Tracing back to a calling sub In-Reply-To: <9da72591050124084519fcdbfb@mail.gmail.com> Message-ID: Kirby, That's exactly what I'm looking for. I can write a sub that uses caller(2) that I can use to format the information in a standard way, and then use: die "A null query was passed to MySub from " . GetCaller() . "!" Thanks for your help! Thanks, Peter Darley -----Original Message----- From: Kirby Krueger [mailto:kirbyk@gmail.com] Sent: Monday, January 24, 2005 8:45 AM To: Peter Darley Cc: SPUG Subject: Re: SPUG: Tracing back to a calling sub Check out perldoc -f caller. Is this what you're looking for? -- Kirby On Mon, 24 Jan 2005 08:34:46 -0800, Peter Darley wrote: > Folks, > I'm trying to figure out if there's a way for a sub to find out what sub > called it? The situation that I'm in is that I have a lot of generic subs, > such as one that takes a database query string and returns a hash of what > was loaded from the database. When it fails, I just get an error from the > sub, but it's almost always a error in how I called the sub that caused > problems, and it can be hard to go back through my program and find which > sub called this sub incorrectly. > So, basically what I want to be able to do is have something like: > > sub MySub > { > my (%Args) = @_; > # Args: Query = The query to run the Lookup on > > if (! $Args{Query}) {die "A null querry was passed to MySub from > $Calling_Sub!"} > > ... > } > > And it would come up with something like > "A null querry was passed to MySub from LookupUserInfo()!" > > Thanks, > Peter Darley > > _____________________________________________________________ > Seattle Perl Users Group Mailing List > POST TO: spug-list@pm.org > SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list > MEETINGS: 3rd Tuesdays, Location: Amazon.com Pac-Med > WEB PAGE: http://seattleperl.org/ > From jay at scherrer.com Mon Jan 24 14:10:33 2005 From: jay at scherrer.com (Jay Scherrer) Date: Mon Jan 24 14:10:09 2005 Subject: SPUG: Tracing back to a calling sub In-Reply-To: References: Message-ID: <200501241410.33635.jay@scherrer.com> Couldn't you use a class shift? I know from using Perl::Tk you would call mySub like this: $myinstance->mysub($arg1, $arg2); When this gets passed the -> acts like a comma seperated list. And from the pakage::MySub you would get this: sub MySub { my $this = shift; my (%Args) = @_; if (! $Args{Query}) {die "A null querry was passed to MySub from $this"; } Jay Scherrer On Monday 24 January 2005 08:34 am, Peter Darley wrote: > Folks, > I'm trying to figure out if there's a way for a sub to find out > what sub called it? The situation that I'm in is that I have a lot > of generic subs, such as one that takes a database query string and > returns a hash of what was loaded from the database. When it > fails, I just get an error from the sub, but it's almost always a > error in how I called the sub that caused problems, and it can be > hard to go back through my program and find which sub called this > sub incorrectly. > So, basically what I want to be able to do is have something like: > > sub MySub > { > my (%Args) = @_; > # Args: Query = The query to run the Lookup on > > if (! $Args{Query}) {die "A null querry was passed to MySub from > $Calling_Sub!"} > > ... > } > > And it would come up with something like > "A null querry was passed to MySub from LookupUserInfo()!" > > Thanks, > Peter Darley > > _____________________________________________________________ > Seattle Perl Users Group Mailing List > POST TO: spug-list@pm.org > SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list > MEETINGS: 3rd Tuesdays, Location: Amazon.com Pac-Med > WEB PAGE: http://seattleperl.org/ From pdarley at kinesis-cem.com Mon Jan 24 14:38:43 2005 From: pdarley at kinesis-cem.com (Peter Darley) Date: Mon Jan 24 14:38:53 2005 Subject: SPUG: Tracing back to a calling sub In-Reply-To: <200501241410.33635.jay@scherrer.com> Message-ID: Jay, Wouldn't $myinstance have to be blessed as an object to do that? Thanks, Peter Darley -----Original Message----- From: spug-list-bounces@pm.org [mailto:spug-list-bounces@pm.org]On Behalf Of Jay Scherrer Sent: Monday, January 24, 2005 2:11 PM To: spug-list@pm.org Subject: Re: SPUG: Tracing back to a calling sub Couldn't you use a class shift? I know from using Perl::Tk you would call mySub like this: $myinstance->mysub($arg1, $arg2); When this gets passed the -> acts like a comma seperated list. And from the pakage::MySub you would get this: sub MySub { my $this = shift; my (%Args) = @_; if (! $Args{Query}) {die "A null querry was passed to MySub from $this"; } Jay Scherrer On Monday 24 January 2005 08:34 am, Peter Darley wrote: > Folks, > I'm trying to figure out if there's a way for a sub to find out > what sub called it? The situation that I'm in is that I have a lot > of generic subs, such as one that takes a database query string and > returns a hash of what was loaded from the database. When it > fails, I just get an error from the sub, but it's almost always a > error in how I called the sub that caused problems, and it can be > hard to go back through my program and find which sub called this > sub incorrectly. > So, basically what I want to be able to do is have something like: > > sub MySub > { > my (%Args) = @_; > # Args: Query = The query to run the Lookup on > > if (! $Args{Query}) {die "A null querry was passed to MySub from > $Calling_Sub!"} > > ... > } > > And it would come up with something like > "A null querry was passed to MySub from LookupUserInfo()!" > > Thanks, > Peter Darley > > _____________________________________________________________ > Seattle Perl Users Group Mailing List > POST TO: spug-list@pm.org > SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list > MEETINGS: 3rd Tuesdays, Location: Amazon.com Pac-Med > WEB PAGE: http://seattleperl.org/ _____________________________________________________________ Seattle Perl Users Group Mailing List POST TO: spug-list@pm.org SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list MEETINGS: 3rd Tuesdays, Location: Amazon.com Pac-Med WEB PAGE: http://seattleperl.org/ From jay at scherrer.com Mon Jan 24 16:46:53 2005 From: jay at scherrer.com (Jay Scherrer) Date: Mon Jan 24 16:46:27 2005 Subject: SPUG: Tracing back to a calling sub In-Reply-To: References: Message-ID: <200501241646.53524.jay@scherrer.com> yep your right. Sorry, Jay Scherrer On Monday 24 January 2005 02:38 pm, Peter Darley wrote: >Jay, >???????Wouldn't $myinstance have to be blessed as an object to do >that? >Thanks, >Peter Darley From glim at mycybernet.net Mon Jan 24 19:59:00 2005 From: glim at mycybernet.net (glim@mycybernet.net) Date: Mon Jan 24 19:58:13 2005 Subject: SPUG: Yet Another Perl Conference North America 2005 announces call-for-papers Message-ID: YAPC::NA 2005 (Yet Another Perl Conference, North America) has just released its call-for-papers; potential and aspiring speakers can submit a presentation proposal via: http://yapc.org/America/cfp-2005.shtml The dates of the conference are Monday - Wednesday 27-29 June 2005. The location will be in downtown Toronto, Ontario, Canada. (Note that a different date block was previously announced, but has been moved to accomodate venue availability.) The close of the call-for-papers is April 18, 2005 at 11:59 pm. If you have any questions regarding the call-for-papers or speaking at YAPC::NA 2005 please email na-author@yapc.org We would love to hear from potential sponsors. Please contact the organizers at na-sponsor@yapc.org to learn about the benefits of sponsorship. Other information regarding the conference (e.g. venue, registration specifics) will be announced soon. We look forward to your submissions and a great conference! From andrew at sweger.net Mon Jan 24 20:23:17 2005 From: andrew at sweger.net (Andrew Sweger) Date: Mon Jan 24 20:23:27 2005 Subject: SPUG: Tracing back to a calling sub In-Reply-To: Message-ID: On Mon, 24 Jan 2005, Peter Darley wrote: > sub MySub > { > my (%Args) = @_; > # Args: Query = The query to run the Lookup on > > if (! $Args{Query}) {die "A null querry was passed to MySub from > $Calling_Sub!"} > > ... > } See also: use Carp; # perldoc Carp if (...) { confess "Received null query"; } -- Andrew B. Sweger -- The great thing about multitasking is that several things can go wrong at once. From tim at consultix-inc.com Tue Jan 25 12:49:20 2005 From: tim at consultix-inc.com (Tim Maher) Date: Tue Jan 25 12:49:31 2005 Subject: SPUG: Minimal Perl book has arrived! Message-ID: <20050125204920.GA31349@jumpy.consultix-inc.com> ... well, at least the *cover* has arrived. The book will probably appear in May, but in the meantime, at we can enjoy the cover art! Go to http://www.minimalperl.com , and click on the cover picture for a larger image. I'm quite pleased with the overall effect created by the wizardly figure holding a very bizarre and long pipe, which took a lot of fishing around in the Manning image bank to find. But there is still plenty of time to change some details. So what do you think of it? -Tim *--------------------------------------------------------------------------* | Tim Maher, PhD (206) 781-UNIX (866) DOC-PERL (866) DOC-UNIX | | tim(AT)Consultix-Inc.Com http://TeachMePerl.Com http://TeachMeUnix.Com | *+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-* | Watch for my upcoming book: "Minimal Perl for UNIX/Linux People" | | Classes: 2/14: Minimal Perl 2/15: Hashes & Arrays 2/16-18: Int. Perl | *--------------------------------------------------------------------------* From haircut at gmail.com Tue Jan 25 13:17:14 2005 From: haircut at gmail.com (Adam Monsen) Date: Tue Jan 25 13:17:46 2005 Subject: SPUG: Minimal Perl book has arrived! In-Reply-To: <20050125204920.GA31349@jumpy.consultix-inc.com> References: <20050125204920.GA31349@jumpy.consultix-inc.com> Message-ID: <9ebd651105012513171aeff758@mail.gmail.com> The cover art looks fantastic. What monk is that? He's got a sweet dagger and the longest fricking pipe I've ever seen. Congratulations Tim, this is a great accomplishment! On Tue, 25 Jan 2005 12:49:20 -0800, Tim Maher wrote: > ... well, at least the *cover* has arrived. > > The book will probably appear in May, but in the meantime, > at we can enjoy the cover art! > > Go to http://www.minimalperl.com , and click on the cover picture > for a larger image. > > I'm quite pleased with the overall effect created by the wizardly > figure holding a very bizarre and long pipe, which took a lot of > fishing around in the Manning image bank to find. > > But there is still plenty of time to change some details. So what > do you think of it? > > -Tim > *--------------------------------------------------------------------------* > | Tim Maher, PhD (206) 781-UNIX (866) DOC-PERL (866) DOC-UNIX | > | tim(AT)Consultix-Inc.Com http://TeachMePerl.Com http://TeachMeUnix.Com | > *+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-* > | Watch for my upcoming book: "Minimal Perl for UNIX/Linux People" | > | Classes: 2/14: Minimal Perl 2/15: Hashes & Arrays 2/16-18: Int. Perl | > *--------------------------------------------------------------------------* > _____________________________________________________________ > Seattle Perl Users Group Mailing List > POST TO: spug-list@pm.org > SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list > MEETINGS: 3rd Tuesdays, Location: Amazon.com Pac-Med > WEB PAGE: http://seattleperl.org/ > -- Adam Monsen http://adammonsen.com/ From sthoenna at efn.org Tue Jan 25 13:34:51 2005 From: sthoenna at efn.org (Yitzchak Scott-Thoennes) Date: Tue Jan 25 13:35:05 2005 Subject: SPUG: Minimal Perl book has arrived! In-Reply-To: <20050125204920.GA31349@jumpy.consultix-inc.com> References: <20050125204920.GA31349@jumpy.consultix-inc.com> Message-ID: <20050125213451.GA3020@efn.org> On Tue, Jan 25, 2005 at 12:49:20PM -0800, Tim Maher wrote: > ... well, at least the *cover* has arrived. > > The book will probably appear in May, but in the meantime, > at we can enjoy the cover art! > > Go to http://www.minimalperl.com , and click on the cover picture > for a larger image. > > I'm quite pleased with the overall effect created by the wizardly > figure holding a very bizarre and long pipe, which took a lot of > fishing around in the Manning image bank to find. > > But there is still plenty of time to change some details. So what > do you think of it? I thought the bloodstains left from tucking the knife back under the yellow band without proPerly cleaning it first were a little much. From tim at consultix-inc.com Tue Jan 25 17:35:59 2005 From: tim at consultix-inc.com (Tim Maher) Date: Tue Jan 25 17:36:17 2005 Subject: SPUG: Minimal Perl book has arrived! In-Reply-To: <20050125213451.GA3020@efn.org> References: <20050125204920.GA31349@jumpy.consultix-inc.com> <20050125213451.GA3020@efn.org> Message-ID: <20050126013559.GA19065@jumpy.consultix-inc.com> On Tue, Jan 25, 2005 at 01:34:51PM -0800, Yitzchak Scott-Thoennes wrote: > > > > Go to http://www.minimalperl.com , and click on the cover picture > > for a larger image. > > > I thought the bloodstains left from tucking the knife back under the > yellow band without proPerly cleaning it first were a little much. Yikes! And all this time I thought those were just decorative stripes! -Tim *--------------------------------------------------------------------------* | Tim Maher, PhD (206) 781-UNIX (866) DOC-PERL (866) DOC-UNIX | | tim(AT)Consultix-Inc.Com http://TeachMePerl.Com http://TeachMeUnix.Com | *+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-* | Watch for my upcoming book: "Minimal Perl for UNIX/Linux People" | | Classes: 2/14: Minimal Perl 2/15: Hashes & Arrays 2/16-18: Int. Perl | *--------------------------------------------------------------------------* From KBuff at zetron.com Tue Jan 25 17:07:30 2005 From: KBuff at zetron.com (Kurt Buff) Date: Tue Jan 25 18:46:51 2005 Subject: SPUG: Minimal Perl book has arrived! Message-ID: <054222519C2ED411A68E00508B603AC706534919@zetxch01.zetron.com> Yitzchak Scott-Thoennes said... > On Tue, Jan 25, 2005 at 12:49:20PM -0800, Tim Maher wrote: > > ... well, at least the *cover* has arrived. > > > > The book will probably appear in May, but in the meantime, > > at we can enjoy the cover art! > > > > Go to http://www.minimalperl.com , and click on the cover picture > > for a larger image. > > > > I'm quite pleased with the overall effect created by the wizardly > > figure holding a very bizarre and long pipe, which took a lot of > > fishing around in the Manning image bank to find. > > > > But there is still plenty of time to change some details. So what > > do you think of it? > > I thought the bloodstains left from tucking the knife back under the > yellow band without proPerly cleaning it first were a little much. I don't think those are bloodstains. It's a striped belt... Kurt From charles.e.derykus at boeing.com Tue Jan 25 23:00:48 2005 From: charles.e.derykus at boeing.com (DeRykus, Charles E) Date: Tue Jan 25 23:01:18 2005 Subject: SPUG: Minimal Perl book has arrived! Message-ID: <5DF8FDE8DFE8744388602480FDCC0E3106F3D020@xch-nw-23.nw.nos.boeing.com> > > I thought the bloodstains left from tucking the knife back under the > yellow band without proPerly cleaning it first were a little much. >> Yikes! And all this time I thought those were just decorative stripes! Nah, I'll bet they're wounds ... normally occurring in the vicinity of the foot.