From rspier at pobox.com Mon Sep 5 23:28:32 2005 From: rspier at pobox.com (Robert Spier) Date: Mon, 05 Sep 2005 23:28:32 -0700 Subject: [LA.pm] Event! Event! My kingdom for an event! Message-ID: A social meeting, involving chopsticks. Thursday, September 15th, 2005 7pm Toluca Garden 10000 Riverside Dr Toluca Lake, CA 91602-2537 (818) 980-3492 http://xrl.us/hfzo http://losangeles.citysearch.com/profile/320577 [ If people RSVP, I will make reservations. Otherwise, we'll all just show up and test our luck. This date got picked out of a hat because everyone who responded to my previous message picked a different day of the week. (i.e. no two people picked the same day.) ] From rspier at pobox.com Mon Sep 12 23:59:04 2005 From: rspier at pobox.com (Robert Spier) Date: Mon, 12 Sep 2005 23:59:04 -0700 Subject: [LA.pm] [Reminder[ Event! Event! My kingdom for an event! In-Reply-To: References: Message-ID: [Reminder post... especially for the 4 new folks who subscribed this week. You know who you are.] A social meeting, involving chopsticks. Thursday, September 15th, 2005 7pm Toluca Garden 10000 Riverside Dr Toluca Lake, CA 91602-2537 (818) 980-3492 http://xrl.us/hfzo http://losangeles.citysearch.com/profile/320577 [ If people RSVP, I will make reservations. Otherwise, we'll all just show up and test our luck. This date got picked out of a hat because everyone who responded to my previous message picked a different day of the week. (i.e. no two people picked the same day.) ] From dpisoni at shopzilla.com Mon Sep 12 10:39:10 2005 From: dpisoni at shopzilla.com (David Pisoni) Date: Mon, 12 Sep 2005 10:39:10 -0700 Subject: [LA.pm] (job posting) Shopzilla (formerly BizRate.com) Message-ID: <0CB1040F-AE73-4064-B003-B075B6D9EA7C@shopzilla.com> Hello, Robert has (again) benevolently granted me permission to post my open positions to the list. Shopzilla (known to many of you as BizRate.com) is hiring developers and architects to the Web Engineering and Search groups. I am the Director of Web Engineering (read, I am not a recruiter nor a PHB.) Our department is responsible for the entire middle-tier of web applications, and all of our code is perl/Apache/mod_perl. The search group has a mix of different functions and disciplines, their positions are also listed below. We're looking for sharp perl engineers and architects to help us produce quality, cutting-edge web applications. I'll include the standard copy of our postings once, and break out the open position levels' requirements/descriptions separately. Note that some of these postings have multiple openings with the same qualifications. Please email me at dpisoni at shopzilla dot com if you are interested or have questions. Enjoy, David Pisoni dpisoni at shopzilla dot com Director, Web Engineering Shopzilla, Inc. "Education is a progressive discovery of our own ignorance." -Will Durant, historian (1885-1981) ------------------------------------------------------------------------ --------------- Common copy: Shopzilla, formerly BizRate.com, is a leading shopping search engine on the Web. With an index of over 30 million products from more than 50,000 stores, gathered, organized and presented using all proprietary leading-edge technology, Shopzilla provides consumers the best way to find virtually anything for sale, anywhere, and at the best price. In addition to our flagship site(http:// www.shopzilla.com), Shopzilla also powers shopping search for many of the Web's largest consumer sites including AOL, Lycos, Time Warner's RoadRunner, and many others. The company is privately held, profitable and based in West Los Angeles. At Shopzilla, our goal is to build the greatest shopping service ever conceived by mankind. To that end, we strive very hard to hire the smartest people. We're an environment where great ideas shape our vision and true passion drives us to the best solutions to the most challenging problems at the intersection of shopping and search. If that sounds like something you'd like to be involved in, please read on. Shopzilla offers great benefits including medical, dental and vision plans, life insurance, 401(k) plan, flexible spending account, generous vacation benefits -- and we even provide FREE catered lunch every single day! So, if you are the super-star type -- the one all look to as the smartest in your area of expertise -- love challenging yourself, and are searching for a place to work where people care, your ideas matter and you can make a real difference to helping millions of consumers, then we need to talk. Shopzilla is an Equal Opportunity Employer. Positions: Sr. Software Engineer, Web Engineering: As our Sr. Software Engineer, you will: ? Develop core technology, including the design/architecture of new solutions, the refinement of existing code, and the optimization of dynamic web content. ? Work with production team to fulfill requests in the project queue, assessing impact and involving the data systems and network operations team when necessary ? Write design specifications, programming specifications, and documentation ? Develop and maintain web applications written in Object Oriented perl, operating on a Linux/Apache/mod_perl platform. ? Develop systems and API's for interfacing with open and proprietary network services and complex business logic/algorithms. ? Develop systems and API's for interfacing with partner companies and trading partners. Your qualifications include: ? 6+ years of experience in software engineering, OOD/OOA/OOP ? 4+ years of Perl Development ? mod_perl, Apache, XML, HTML, and Unix skills ? Strong software architecture skills (UML a plus) ? Balancing short-term requests with long-term product vision is required ? Experience working with others, both developers and non- technical people during the analysis, design, and execution phases of an engineering project is required ? Experience with source control systems, CVS or Subversion a plus ? Ability to learn and contribute quickly and work independently ? Creativity and effective written and verbal communications are essential ? Candidates for this position should enjoy web based applications development, including gathering requirements and feedback from internal customers, and providing suggestions Software Architect, Web Engineering: As our Software Architect, you will: ? Develop core technology, including the design/architecture of new solutions and the refactoring and refinement of existing systems. ? Collaborate with product management staff in producing project functional specification, including feasibility assessments, engineering time estimates and strategic value assessments. ? Produce design documents from functional specifications. Design documents contain high-level architectural direction and planning that engineers use in implementing software projects. ? Contribute to engineering implementation process in a mentoring role. Occasionally act as implementation engineer. ? Participate with Web Engineering management in steering future direction of Web Engineering projects. Your qualifications include: ? 8+ years of experience in software engineering, OOD/OOA/OOP ? Perl/mod_perl, Apache, XML, HTML and Unix skills ? Skilled in structured application design demonstrated by the ability to clearly translate business requirements into a system design ? Ability to formally communicate architectural designs and plans (UML a plus) ? Domain experience in n-tier web application development; working experience with web and networking protocols and concepts ? Excellent communication and interpersonal skills ? Experience working with others, both developers and project/business owners during the analysis, design, and execution phases of an engineering project is required. ? Ability to mentor individuals and interact as a member of an engineering team Software Engineer, Search Operations: As a member of this team, you will: ? Share responsibility and ownership of Shopzilla.Inc?s search team?s backend tools and data flows. ? Design and develop critical data flows feeding directly into the core search engine and external tools. ? Interact with the search analytics and operations teams and generate information. ? Work closely with the operations team to diagnose and provide solutions to issues arising on production service. Qualifications: ? BS CS or equivalent required, MS CS preferred. 5+ years experience with Perl development on Unix and/or Linux platforms. Experience with Sybase ASE databases and knowledge of SQL is a plus. Strong Object Oriented Programming skills highly desirable Highly motivated person willing to work in fast-paced environment. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/losangeles-pm/attachments/20050912/895972f8/attachment-0001.html From rspier at pobox.com Tue Sep 13 11:42:00 2005 From: rspier at pobox.com (Robert Spier) Date: Tue, 13 Sep 2005 11:42:00 -0700 Subject: [LA.pm] Anyone want to move to seattle? References: Message-ID: Because she was so nice about it, I'm passing this on. Anyone who wants more information, please contact her directly. -R === Forwarded Message: Subject: RE: Perl Developers needed Date: Tue, 13 Sep 2005 11:10:59 -0700 From: "Daina Wilburn" Thanks Robert,=20 Yes, we ARE located in downtown Seattle. Because the performance requirements are so important to our core products, our bar for Perl developers is very high, and consequently we are continuously hitting the very limit of available Perl developers in our area, even though we have a very active Perl Users Group here. So we are now opening up our search across the US. I certainly understand and accept your position on posting. However, if you know of ANYONE who would be interested in relocating to the Seattle area for a truly exciting Perl position, if you would be so kind as to have them contact me, I would really appreciate it. I would be happy to send you one of our job descriptions for reference purposes. Thanks again! All the best! Daina Wilburn Recruiter W H I T E P A G E S.C O M | I N C 206.812.9216 | (Direct) =20 dwilburn at whitepages.com www.whitepagesinc.com From Todd.Cranston-Cuebas at Ticketmaster.com Tue Sep 13 13:18:24 2005 From: Todd.Cranston-Cuebas at Ticketmaster.com (Todd Cranston-Cuebas) Date: Tue, 13 Sep 2005 13:18:24 -0700 Subject: [LA.pm] [JOB] Your Chance to Learn Perl "On the Job" Message-ID: <71D28C8451BFD5119B2B00508BE26E640A6B3092@pasmail3.office.tmcs> Looks like it's job posting day at the LA-PM! Rob approved my posting this job but I promise to not abuse this privilege. As many of you know, Ticketmaster is a big perl/mod_perl company. In fact, some of you may have even interviewed for a prior position. I especially wanted to post to LA-PM because some things have changed that are important for potential job hunters. Ticketmaster has historically interviewed people based very much on their perl expertise. That make sense given our rapid growth in this industry and our focus on perl. However, I have a number of new open positions for our core engineering team where proficiency in perl is **NOT** a requirement. Why bring that to the attention of a perl advocacy group? To be totally honest, you will be coding in perl here. It's what we do. However, we're currently looking for solid engineers with either a strong CS background, or equivalent work experience, to join our team and hone their perl skills on the job. In order for this to work, we expect a solid background in software development and solid object-oriented coding skills. The only other real requirement is that the applicant feel very comfortable in a linux/unix development world. So, if you're looking to learn perl where you'll be surrounded by perl gurus, this is really a tremendous opportunity. If you're already a perl wizard, well then "yeah!" of course we'd love to talk with you too! Ticketmaster has excellent benefits (Medical/Dental/Vision, 401K, FSA, etc.) and we foster a work hard/play hard attitude (in fact, I just got back from a company sponsored night at the King Tut exhibit!). We have new positions available for associate, mid, and senior-level engineers. Please contact you directly if you have any questions. Appended below is our "CANNED" or generic mid-level job description. Call for more details. Regards, Todd todd cranston-cuebas -- senior technical recruiter tcc at ticketmaster.com ticketmaster (NASDAQ: IACI) 8800 sunset blvd . west hollywood, ca . 90069 voice 310-360-2436 . mobile: 310-422-3347 -------------CANNED JOB DESCRIPTION------------- Develop core back-end technologies for a leader in open-source , high-volume, high-transaction web systems. As part of Ticketmaster product development group, you will be responsible for integrating new functionality into our existing code base, with an emphasis on perl development, as well as aiding in the implementation of new core technologies. If you love perl/mod_perl, you'll fit right in! If you're a solid engineer but would need to "bone up" on perl, then please do contact us. We're looking for smart, capable, engineers to join the team. Title: Software Engineer Location: West Hollywood, California Department: Product Development ESSENTIAL FUNCTIONS: 75%: Coding/Development: Primarily perl development in a Linux/UNIX environment, however, C/C++ skills highly valued. 10%: Design: Design and architecture of solutions and enhancements to the Ticketmaster.com code base. 15%: Troubleshooting: code review/debugging/troubleshooting Education/Experience: * 2+ years professional software engineering experience * "Classic" engineering skills, ideally C/C++, other Object-oriented development, perl, operating systems. * Strong Linux or Unix background * Exposure to web architectures * RDBMS experience Preferred Education/Experience/Knowledge: * Perl! * C/C++ programming for the web (specifically apache 2.0, apache API, C module development) * Significant RDMS systems (Oracle and mySQL ideal) * Exposure to algorithm/data structure design and implementation * Past experience as a system administrator * Degree in Computer Science or Mathematics Competitive compensation and benefits package offered. Qualified applicants should send their resume and salary history to techjobs at ticketmaster.com with "TMO-T93-LAPM" indicated in the subject line. To learn more about other Ticketmaster and IAC career opportunities, visit the IAC/InterActiveCorp job board at http:jobsearch.iac-careers.com. Ticketmaster is committed to creating a diverse work environment and proud to be an equal opportunity employer. Due to the high volume of responses, we will only respond to those candidates that most closely match our requirements. Thank you for your interest in Ticketmaster, an operating business of InterActiveCorp (NASDAQ: IACI). From jamespitts at yahoo.com Tue Sep 13 13:31:30 2005 From: jamespitts at yahoo.com (James Pitts) Date: Tue, 13 Sep 2005 13:31:30 -0700 (PDT) Subject: [LA.pm] Perl Positions at Boingo Wireless Message-ID: <20050913203131.70074.qmail@web50411.mail.yahoo.com> Fellow PMs, Boingo Wireless is looking for two perl engineers. I have been working here as a perl developer for over a year and I have learned a lot about what it takes to run a global wifi network. There are big challenges here for perlish people, and our location in breezy Santa Monica next to Yahoo and MTV is great. Email me or my manager Chris Angelli (cangelli at boingo.com) if you would like the official, full-length job description. Here's brief summary of each opening (which do overlap quite a bit): Internal Tools Engineer - develop MVC apps used by employees to manage the network - help build out the business layer (involving perl and java) - problem domains: geodata, db design, app caching and optimization, UIs, web services Network Apps Engineer - develop apps which provide data to thousands of Boingo sw clients - work with operations to keep the network running - problem domains: data format design, client-server architecture We develop apps on Win XP or on RH (it is up to the developer to choose). - James __________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com From ofer at netapt.com Tue Sep 13 14:03:43 2005 From: ofer at netapt.com (Ofer Nave) Date: Tue, 13 Sep 2005 14:03:43 -0700 (PDT) Subject: [LA.pm] Perl Positions at Boingo Wireless In-Reply-To: <20050913203131.70074.qmail@web50411.mail.yahoo.com> Message-ID: So that's where Chris Angelli works now... she's awesome (was my boss at HomePage.com). -ofer On Tue, 13 Sep 2005, James Pitts wrote: > Fellow PMs, Boingo Wireless is looking for two perl engineers. > > I have been working here as a perl developer for over a year and I have > learned a lot about what it takes to run a global wifi network. There > are big challenges here for perlish people, and our location in breezy > Santa Monica next to Yahoo and MTV is great. > > Email me or my manager Chris Angelli (cangelli at boingo.com) if you would > like the official, full-length job description. Here's brief summary of > each opening (which do overlap quite a bit): > > Internal Tools Engineer > - develop MVC apps used by employees to manage the network > - help build out the business layer (involving perl and java) > - problem domains: geodata, db design, app caching and optimization, > UIs, web services > > Network Apps Engineer > - develop apps which provide data to thousands of Boingo sw clients > - work with operations to keep the network running > - problem domains: data format design, client-server architecture > > We develop apps on Win XP or on RH (it is up to the developer to > choose). > > - James > > > > > __________________________________ > Yahoo! Mail - PC Magazine Editors' Choice 2005 > http://mail.yahoo.com > _______________________________________________ > Losangeles-pm mailing list > Losangeles-pm at pm.org > http://mail.pm.org/mailman/listinfo/losangeles-pm > From rspier at pobox.com Thu Sep 15 14:21:10 2005 From: rspier at pobox.com (Robert Spier) Date: Thu, 15 Sep 2005 14:21:10 -0700 Subject: [LA.pm] [Reminder[ Event! Event! My kingdom for an event! In-Reply-To: References: Message-ID: Tonight! There's a reservation in my name: "Robert". (As opposed to one of those other names people call me.) See ya'll there. -R > A social meeting, > involving chopsticks. > > Thursday, > September 15th, > 2005 > > 7pm > > Toluca Garden > 10000 Riverside Dr > Toluca Lake, CA 91602-2537 > (818) 980-3492 > > http://xrl.us/hfzo > http://losangeles.citysearch.com/profile/320577 From rspier at pobox.com Fri Sep 16 20:15:34 2005 From: rspier at pobox.com (Robert Spier) Date: Fri, 16 Sep 2005 20:15:34 -0700 Subject: [LA.pm] "LA Perl Company/Job List" Message-ID: As I've recently re-discovered, the Los Angeles area Perl jobs market is pretty hot. In order to help facilitate people finding perl jobs in the area, I'd like to put together a list (that will be on the website) of Los Angeles area companies that are looking for perl programmers. If you represent such a company, and want to be listed, please send me the following: - Company Name - Contact Person and Title - Contact Email and/or Phone - URL I'll put it on the website, and hopefully get some folks hired. This isn't for specific job listings, but "hey, we're sometimes (or right now) looking for perl folk" listings. -R From rspier at pobox.com Mon Sep 19 13:15:48 2005 From: rspier at pobox.com (Robert Spier) Date: Mon, 19 Sep 2005 13:15:48 -0700 Subject: [LA.pm] "LA Perl Company/Job List" In-Reply-To: References: Message-ID: FYI, the list is here: http://la.pm.org/jobs.html -R From warren_e_gibbons at yahoo.com Tue Sep 20 11:30:43 2005 From: warren_e_gibbons at yahoo.com (warrenGibbons) Date: Tue, 20 Sep 2005 11:30:43 -0700 (PDT) Subject: [LA.pm] "LA Perl Company/Job List" In-Reply-To: Message-ID: <20050920183043.30064.qmail@web50415.mail.yahoo.com> This is great! Thanks a bunch google-man!! --- Robert Spier wrote: > > FYI, > > the list is here: > > http://la.pm.org/jobs.html > > -R > _______________________________________________ > Losangeles-pm mailing list > Losangeles-pm at pm.org > http://mail.pm.org/mailman/listinfo/losangeles-pm > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From pete at peterbenjamin.com Thu Sep 22 11:21:05 2005 From: pete at peterbenjamin.com (Peter Benjamin) Date: Thu, 22 Sep 2005 11:21:05 -0700 Subject: [LA.pm] perl CGI querying of directory filenames most efficient method? Message-ID: <6.1.2.0.2.20050922105523.04b42b58@peterbenjamin.com> I hope I've written an email that can be understood. My advise is to read it all the way through before replying, as it is a complex "overall" efficiency question, involving just not the perl CGI code, but also the web server needing the same directory. -- What would be the most CPU/IO efficient method to test whether the following filenames exist to get images to display on a web page, where any matching filenames should be displayed? Only one file from the following possibilities the client would be uploading: skunumber.jpg skunumber.gif skunumber.medium.jpg skunumber.medium.gif skunumber.large.jpg skunumber.large.gif Currently, it uses if-elsif-elsif-elsif... using the -e test against the full pathname. Plus any matching names from this list: skunumber.A.jpg (second image to display with the one above) skunumber.B.jpg (third, etc...) skunumber.C.jpg skunumber.D.jpg This uses 4 if statements using the -e test against the full pathname. So, either 0, 1, or 2 to 5 images might be displayed. Would it be faster to get the entire directory listing of 12,000 images (and growing) with this type of statement: cd pathname; foreach $filename ( ) { if-elsif-else } Maybe a readdir would be even faster? Remember that File Caching may make these questions immaterial, as the web server needs to access the same images/ folder as well, and that needs to be taking into consideration for the overall efficiency, which I did not address in the questions below. Questions: Does the Unix File Cache also cache directory information? I imagine it does, so this CGI script would not have to access the hard drive to get the list of files, but just get it from RAM, for each and every -e test, or for the foreach, or readdir methods. Would the -e test have to go to the hard drive each time? Or would the entire directory 'file' be in the File Cache as well in that case? Which would mean both methods are efficient, and either would do fine. I might do a comparison testing in a loop, but then that would not simulate a CGI script, unless the script was invoked by an outer loop coded in a shell script to create new PIDs each time (avoid using the directory contents that would be "buffered" in File IO cache, or even in the perl buffers). What comparison testing method would you use? Right now it is "cheaper" programmer time wise to do -e testing than add a database field to store the values, which one might imagine would be faster , but even then the directory contents needs to be accessed in order to web serve the image, and having the directory contents in File Cache due to the web server using it means the database field might not be any faster than either the if-elsif-else or foreach methods. Pete From jleader at alumni.caltech.edu Thu Sep 22 15:10:23 2005 From: jleader at alumni.caltech.edu (Jeremy Leader) Date: Thu, 22 Sep 2005 15:10:23 -0700 Subject: [LA.pm] perl CGI querying of directory filenames most efficient method? In-Reply-To: <6.1.2.0.2.20050922105523.04b42b58@peterbenjamin.com> References: <6.1.2.0.2.20050922105523.04b42b58@peterbenjamin.com> Message-ID: <43332BCF.4090706@alumni.caltech.edu> Peter Benjamin wrote: > Questions: > > Does the Unix File Cache also cache directory > information? I imagine it does, so this CGI script would > not have to access the hard drive to get the list of files, > but just get it from RAM, for each and every -e test, > or for the foreach, or readdir methods. Think of it as a disk cache, rather than a file cache. That is, it caches recently accessed disk blocks, whether they belong to files or directories. > Would the -e test have to go to the hard drive each time? > Or would the entire directory 'file' be in the File Cache > as well in that case? Which would mean both methods are > efficient, and either would do fine. Yes, I'd expect the directory blocks to be cached, unless the directory was really huge or there was a whole lot of other disk access going on at the same time. What does "ls -sd $dir" give as the number of blocks in the directory? > I might do a comparison testing in a loop, but then that > would not simulate a CGI script, unless the script was > invoked by an outer loop coded in a shell script to > create new PIDs each time (avoid using the directory > contents that would be "buffered" in File IO cache, > or even in the perl buffers). > > What comparison testing method would you use? > > Right now it is "cheaper" programmer time wise to do -e > testing than add a database field to store the values, > which one might imagine would be faster , but even then > the directory contents needs to be accessed in order > to web serve the image, and having the directory > contents in File Cache due to the web server using > it means the database field might not be any faster > than either the if-elsif-else or foreach methods. If the web server is opening these files (to serve their contents), then the -e tests won't add much cost, I believe. -- Jeremy Leader jleader at alumni.caltech.edu leaderj at yahoo-inc.com (work) From pete at peterbenjamin.com Thu Sep 22 17:14:08 2005 From: pete at peterbenjamin.com (Peter Benjamin) Date: Thu, 22 Sep 2005 17:14:08 -0700 Subject: [LA.pm] perl CGI querying of directory filenames most efficient method? In-Reply-To: <43332BCF.4090706@alumni.caltech.edu> References: <6.1.2.0.2.20050922105523.04b42b58@peterbenjamin.com> <43332BCF.4090706@alumni.caltech.edu> Message-ID: <6.1.2.0.2.20050922170635.04b3ed98@peterbenjamin.com> At 03:10 PM 9/22/2005, Jeremy Leader wrote: Yes, I'd expect the directory blocks to be cached, I keep RAM amount exceeding the amount of web root and database tables size, so everything ought to fit in RAM. There is 26 meg of RAM free right now. I like that. unless >the directory was really huge or there was a whole lot of >other disk access going on at the same time. Well, given the amount of RAM, I expect even huge directories to have all blocks present in RAM, and never swapped. Most of the disk access will be log writing, so there is little to no collisions in R/W action to the hard drive. My replacement colo will have multiple hard drives. :-) >What does >"ls -sd $dir" give as the number of blocks in the directory? > ls -sd images 296 images > ls -ld images drwxrwxr-x 8 pete pete 294912 Sep 22 12:28 images >If the web server is opening these files (to serve their >contents), then the -e tests won't add much cost, I >believe. I concur. I like to back up my "belief" with testing, but I can not see how to cheaply test this. It involves two computers, one remotely doing http requests for the web CGI to test for, insert into the dynamic page, and the web server to then get a request from the remote computer for the images. It's involved, and time consuming to set up, so is not inexpensive. The next issue I have is with FTP uploading to the directory means a customer GUI download of all the filenames, and that takes like 30 seconds for 12000 names. When that doubles and triples, it will become a head ache. I can disable ls, but ... Is there any good solutions out there now for this issue? From metaperl at gmail.com Fri Sep 23 02:42:27 2005 From: metaperl at gmail.com (Terrence Brannon) Date: Fri, 23 Sep 2005 02:42:27 -0700 Subject: [LA.pm] perl CGI querying of directory filenames most efficient method? In-Reply-To: <6.1.2.0.2.20050922105523.04b42b58@peterbenjamin.com> References: <6.1.2.0.2.20050922105523.04b42b58@peterbenjamin.com> Message-ID: On 9/22/05, Peter Benjamin wrote: > > I hope I've written an email that can be understood. > My advise is to read it all the way through before > replying, as it is a complex "overall" efficiency > question, involving just not the perl CGI code, > but also the web server needing the same directory. > > -- > > What would be the most CPU/IO efficient method to > test whether the following filenames exist to > get images to display on a web page, where any > matching filenames should be displayed? > > Only one file from the following possibilities > the client would be uploading: You really could generate a static page right after the upload instead of generating a page on demand when requested. skunumber.jpg > skunumber.gif > skunumber.medium.jpg > skunumber.medium.gif > skunumber.large.jpg > skunumber.large.gif > > Currently, it uses if-elsif-elsif-elsif... using the -e test > against the full pathname. > > Plus any matching names from this list: > > skunumber.A.jpg (second image to display with the one above) > skunumber.B.jpg (third, etc...) > skunumber.C.jpg > skunumber.D.jpg > > This uses 4 if statements using the -e test against the full pathname. my @displayable = grep { -e $_ } @candidate_files ; So, either 0, 1, or 2 to 5 images might be displayed. > > Would it be faster to get the entire directory listing of > 12,000 images (and growing) with this type of statement: 12,000 images in one directory is suspicious isn't it? Why not have a directory per sku number? or a directory per user? There must be some way to partition your data set so that one directory is not holding everything. cd pathname; > foreach $filename ( ) { > if-elsif-else > } foreach my $file () { # note the "/" so that each sku's files are in a separate directory... I'm not sure about efficiency, but you might look into inodes and how they relate to storing files in a directory. Each inode can only hold X amount of file info. On ext2 and ext3 you get 3 options when creating an ext filesystem, one for a directory holding a bunch of itty-bitty teensy weensy files, one for people downloading a huge files (like videos and music) and one for in-between. Maybe a readdir would be even faster? Why has speed become an issue? Correctness is much more important in my view... get a few more machines and load-balance. :) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/losangeles-pm/attachments/20050923/e9f3e3dc/attachment.html From ben_tilly at operamail.com Fri Sep 23 12:34:54 2005 From: ben_tilly at operamail.com (Benjamin J. Tilly) Date: Sat, 24 Sep 2005 03:34:54 +0800 Subject: [LA.pm] perl CGI querying of directory filenames most efficient method? Message-ID: <20050923193454.8AE083AA515@ws5-8.us4.outblaze.com> "Peter Benjamin" wrote: > > I hope I've written an email that can be understood. > My advise is to read it all the way through before > replying, as it is a complex "overall" efficiency > question, involving just not the perl CGI code, > but also the web server needing the same directory. [...] I read through, and here is one "big picture" kind of optimization. Squeezing the maximum out of a single machine is not as good an optimization strategy as it is to make it possible to have multiple machines going at once behind a load balancer. Your entire described design smells of a problem which is forcing you to rely on a single machine, and if that machine fails, then what? A common strategy for this kind of problem is to store information about what files you have in a database, and then use something like http://search.cpan.org/~jesus/Spread-3.17.3-1.07/Spread.pm to mirror those files on all of your webservers. > Would it be faster to get the entire directory listing of > 12,000 images (and growing) with this type of statement: Red flag alert! What kind of filesystem do you have? Many filesystems, eg ext3, store directory contents as a linked list. That means that when the directory gets large, the process of finding specific files slows down. If this is becoming a performance problem (running some benchmarks is the best way to say whether it is) then I would suggest either switching to a filesystem that handles lots of files in one directory (eg reiserfs) or else using a nested directory structure. A common first strategy is to store foo.jpg as f/foo.jpg. (You can easily get more sophisticated, of course.) >From past experience I wouldn't worry about this too much with a few thousand files, but I'd worry about it big time if I expected this to grow to a few hundred thousand files. Of course note that if you use the multiple webserver strategy that I indicate above, you can just buy another webserver... [...] > Maybe a readdir would be even faster? Remember that > File Caching may make these questions immaterial, as > the web server needs to access the same images/ folder > as well, and that needs to be taking into consideration > for the overall efficiency, which I did not address > in the questions below. If a readdir processed in Perl is faster than several exists checks, then you definitely have room to optimize your filesystem! (Note: It is not always worth doing all possible optimizations.) > Questions: > > Does the Unix File Cache also cache directory > information? I imagine it does, so this CGI script would > not have to access the hard drive to get the list of files, > but just get it from RAM, for each and every -e test, > or for the foreach, or readdir methods. Of course if you really have a CGI script, then there are more obvious optimizations that you still have left. Namely, mod_perl. :-) BTW the answer to your question is that it does, but the filesystem has to do real work to process the cache to find specific files. > Would the -e test have to go to the hard drive each time? > Or would the entire directory 'file' be in the File Cache > as well in that case? Which would mean both methods are > efficient, and either would do fine. > > I might do a comparison testing in a loop, but then that > would not simulate a CGI script, unless the script was > invoked by an outer loop coded in a shell script to > create new PIDs each time (avoid using the directory > contents that would be "buffered" in File IO cache, > or even in the perl buffers). > > What comparison testing method would you use? I would use a loop, because you want to isolate a single performance factor. I would also suggest accessing the whole directory once before benchmarking to avoid I/O differences between runs. > Right now it is "cheaper" programmer time wise to do -e > testing than add a database field to store the values, > which one might imagine would be faster , but even then > the directory contents needs to be accessed in order > to web serve the image, and having the directory > contents in File Cache due to the web server using > it means the database field might not be any faster > than either the if-elsif-else or foreach methods. Databases are not magic. They store data just like a filesystem has to, and they add extra complexity on top. A filesystem should generally be faster at very straightforward tasks. This should be a straightforward task. (OK, filesystems are optimized for specific kinds of access. If your filesystem is not optimized for what you're doing, while a database is, then the database can be faster. For instance if your filesystem does not handle well having many files in one directory, and your database has the right index, your database should be faster.) Cheers, Ben From webmaster at familink.com Wed Sep 28 10:14:37 2005 From: webmaster at familink.com (FamiLink Admin) Date: Wed, 28 Sep 2005 10:14:37 -0700 Subject: [LA.pm] little help?? Message-ID: <006401c5c450$6e6110d0$6801a8c0@familinklat1> Hello all. Please let me know if this is a good place for my questions. I am trying to read a log file and get a list of how many times an IP address get blocked each hour by category PO. An example line in the log with a block is: ------------- [2005-09-28 10:05:03 -7:00] 127.0.0.1 71.32.59.249 216.163.137.3 - http://www.playboy.com/ blocked 0 PO ------------- What I have kinda works but I am not sure if it is the best practice. This is the first time programming in perl and this is what I have so far: sub Scanlog { local($ipb) = @_; open my $slog, "-|", "tail -n 50000 $log" or die "Unable to open $log:$!\n"; open (OUTPUT,">/etc/squid/iplist.txt"); open (OUTPUT2,">/etc/squid/SuspendIpList.txt"); while (<$slog>){ # assigns each line in turn to $_ # use an array slice to select the fields we want @data = (split ,$_)[1,4,10,5,7]; $hr = (split /:/ ,$data[0])[0]; $ip = "$data[1]"; if($flag eq $data[2]){ if($hr eq $hour){ foreach (/$data[2]/){ $matches += 1 ; } if($matches > $blocklimit){ $ip1 = "$data[1]/32"; print OUTPUT "$matches,", "$hour, ","$ip1, ", "@data","\n"; print OUTPUT2 "$ip1\n"; $matched = $matches; $matches = 0; }}}} close (OUTPUT); close (OUTPUT2); ------------------- I will take and help I can get. Ryan Lamberton -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/losangeles-pm/attachments/20050928/d022dd9a/attachment.html From bobmath at sbcglobal.net Wed Sep 28 13:34:11 2005 From: bobmath at sbcglobal.net (Bob Mathews) Date: Wed, 28 Sep 2005 13:34:11 -0700 Subject: [LA.pm] little help?? In-Reply-To: <006401c5c450$6e6110d0$6801a8c0@familinklat1> References: <006401c5c450$6e6110d0$6801a8c0@familinklat1> Message-ID: <11142cfd5d21b10c621ba24e144d86ac@sbcglobal.net> On Sep 28, 2005, at 10:14 AM, FamiLink Admin wrote: > What I have kinda works but I am not sure if it is the best practice. First piece of general advice: use strict; use warnings; at the top of every program. It looks like your code will not work when you first add those lines, but you will build character by making it work again. Second piece of general advice: indent consistently. It will make your code much more readable. > ??? local($ipb) = @_; You want "my", not "local". Local is for use with global variables, which are bad. I'm guessing you learned from a very old perl book which predated "my". > ??????? open my $slog, "-|", "tail -n 50000 $log" or die "Unable to > open $log:$!\n"; This code doesn't work. Try it when $log doesn't exist -- it won't die (though you will see an error message from tail). Paranoia time: are you certain that $log doesn't contain anything dangerous that will make the shell misbehave? Probably not, but if you're putting this in a CGI script that takes $log as a parameter, it's something you need to think about. > ??????? open (OUTPUT,">/etc/squid/iplist.txt"); > ??????? open (OUTPUT2,">/etc/squid/SuspendIpList.txt"); Using open with a bareword filehandle name like this is the old style. It makes global filehandles, and once again, globals are bad. Using "open my $foo" like you did in the previous line is the new style. Mixing styles makes the code look crufty, but isn't necessarily bad. Include error detection. At least slap an "or die" on the end of the open statement. That way, you'll know what's wrong if your /etc/squid directory gets set read-only one day. Imbedding important pieces of information (like the output file names) in the code is considered bad form. Pull those up to the top of the program in a constant declaration, is my advice, though other advices are possible. Here's the adjusted version of the code: use constant IP_LIST_FILE => "/etc/squid/iplist.txt"; ... sub Scanlog { open my $output, ">", IP_LIST_FILE or die "Can't write @{[IP_LIST_FILE]}: $!"; ... print $output "blah blah blah\n"; ... close $output; } > ?????? # use an array slice to select the fields we want > ??????? @data = (split ,$_)[1,4,10,5,7]; It would be a good idea to include, in a comment in your code, an example of a properly formatted input line. Future generations of program maintainers would also appreciate explanations of the different fields, but producing that level of documentation starts to get tedious. Keeping all your data in the @data array makes things hard to understand. When I see $data[2] in the code, I have to look at the array slice and see that $data[2] corresponds to field 10 from the source line, then count fields on the line to see that it means the category, PO. It's better to use descriptive variable names, like this: my ($time, $ip, $category, $other_ip, $url) = (split " ", $_)[1,4,10,5,7]; Yes, I see you used @data in a print statement later on, but weirding the entire body of the loop just to make a print statement look nice is the Wrong Thing. > ??????? $hr = (split /:/ ,$data[0])[0]; I prefer this. Matter of taste. my ($hr) = split /:/, $time; > ??????? foreach (/$data[2]/){ > ??????? $matches += 1 ; > ??????? } I'm not sure what you wanted this to do, but I'm pretty sure it doesn't do it. You're taking the last thing from the line and using it as a dynamic regex, implicitly matching against the entire line. That will always match (unless $data[2] contains metacharacters (in which case it might explode) or $data[2] is empty (in which case something unexpected will happen)). Dynamic regexes are slow, error-prone, and generally to be avoided if possible. Also, your "foreach" loop is really behaving like an "if". > ??????? print OUTPUT "$matches,", "$hour, ","$ip1, ", "@data","\n"; Why the extra quotes and commas? print OUTPUT "$matches,$hour,$ip/32,$category,$other_ip,$url\n"; > $matched = $matches; $matched and $matches are globals, and globals are bad. What I tell you three times is true. > }}}} Yuck. Most people put each closing bracket on its own line, so they can see where it matches up. -bob From bobmath at sbcglobal.net Wed Sep 28 14:07:03 2005 From: bobmath at sbcglobal.net (Bob Mathews) Date: Wed, 28 Sep 2005 14:07:03 -0700 Subject: [LA.pm] little help?? In-Reply-To: <006401c5c450$6e6110d0$6801a8c0@familinklat1> References: <006401c5c450$6e6110d0$6801a8c0@familinklat1> Message-ID: <48a511374ee76e15a0a72fbc394028b0@sbcglobal.net> On Sep 28, 2005, at 10:14 AM, FamiLink Admin wrote: > ??????? while (<$slog>){???? # assigns each line in turn to $_ Oh, one other thing. Best practice dictates that you do a local $_; before assigning to $_, even the implicit assignment in a while loop. (This is not needed with a foreach loop, because those do their own localization.) That's kind of ugly, though, so if I want my code to be pretty I just forgo the implicit $_ and write something like this: while (my $line = <$slog>) { ... } I got an off-list reply that thought I was being a little too hard on you. Didn't really mean to be that way, so sorry if it seemed that way. Good luck with your perl hacking! -bob From webmaster at familink.com Wed Sep 28 16:35:43 2005 From: webmaster at familink.com (FamiLink Admin) Date: Wed, 28 Sep 2005 16:35:43 -0700 Subject: [LA.pm] Spam:***, Re: little help?? References: <006401c5c450$6e6110d0$6801a8c0@familinklat1> <48a511374ee76e15a0a72fbc394028b0@sbcglobal.net> Message-ID: <010001c5c485$5b58fc20$6801a8c0@familinklat1> Bob, Thank you for the help (no hardness taken)!... This is what I have now (below and this time the whole thing): I think I have include all that you talked about but I am not sure what to do about: >Paranoia time: are you certain that $log doesn't contain anything dangerous >that will make the shell misbehave? Probably not, but if you're putting >this in a CGI script that takes $log as a parameter, it's something you >need to think about. Also, the sub scanlog does write the information to the files but it does not return anything back to the main program and I also get the error: Use of uninitialized value in split at ./test.pl line 9. Also, is there a better way of counting the number of times each IP address gets blocked with category PO? Each time I get to the blocklimit it writes to the file but I really just want the max number of blocks over the limit. It will write the same IP each time it gets over the blocklimit though. ------------------------------------------------------------------------------ #!/usr/bin/perl -w require Mail::Send; $|=1; # no buffering use constant IP_LIST_FILE => "/etc/squid/iplist.txt"; use constant SUSPEND_FILE => "/etc/squid/SuspendIpList.txt"; use constant LOG_FILE => "/opt/n2h2/logs/filter_log"; my $sysop = "webmaster\@familink.com"; my $flag = "PO"; my $hour = (split, localtime)[2]; my $blocklimit = 5; my $matches = 0; my $matched = 0; { ($matched,$ip,$hour,$time,$category,$url) = &Scanlog($flag,$hour,$blocklimit,$matches,); if($matched > $blocklimit){ $msg = new Mail::Send Subject=>'SuspendIpList', To=>"$sysop"; $fh = $msg->open; print $fh "Someone has tried to access $matches banned sites today\n"; print $fh "Their IP address ($ip) has been added to /etc/squid/SuspendIpList.txt\n"; print $fh "To unblock them, remove their entry from the file and run squid -k reconfigure\n"; print $fh "$matches, $ip, $hour, $time, $category, $url\n"; $fh->close; # complete the message and send it $matched = 0; } else{ open my $output2, ">", SUSPEND_FILE or die "Can't write @{[SUSPEND_FILE]}: $!"; print $output2 "10.0.0.252/32\n"; close $output2; } } sub Scanlog { my ($flag,$hour,$blocklimit,$matches,)=@_; open my $slog, "-|", "tail -n 25000 @{[LOG_FILE]}" or die "Unable to open $log:$!\n"; open my $output, ">", IP_LIST_FILE or die "Can't write @{[IP_LIST_FILE]}: $!"; open my $output2, ">", SUSPEND_FILE or die "Can't write @{[SUSPEND_FILE]}: $!"; while (my $line = <$slog>){ # assigns each line in turn to $line #use an array slice to select the fields we want my ($time, $ip, $url, $category) = (split " ", $line)[1,4,7,10]; my ($hr) = split /:/, $time; if($flag eq $category and $hr eq $hour){ $matches += 1 ; } if($matches > $blocklimit){ print $output "$matches, $ip, $hour, $time, $category, $url\n"; print $output2 "$ip/32\n"; $matched = $matches; $matches = 0; } } close $output; close $output2; return($matched,$ip,$hour,$time,$category,$url); } ------------------------------------------------------------------ Ryan Lamberton ----- Original Message ----- From: "Bob Mathews" To: "FamiLink Admin" Cc: Sent: Wednesday, September 28, 2005 2:07 PM Subject: Spam:***, Re: [LA.pm] little help?? On Sep 28, 2005, at 10:14 AM, FamiLink Admin wrote: > while (<$slog>){ # assigns each line in turn to $_ Oh, one other thing. Best practice dictates that you do a local $_; before assigning to $_, even the implicit assignment in a while loop. (This is not needed with a foreach loop, because those do their own localization.) That's kind of ugly, though, so if I want my code to be pretty I just forgo the implicit $_ and write something like this: while (my $line = <$slog>) { ... } I got an off-list reply that thought I was being a little too hard on you. Didn't really mean to be that way, so sorry if it seemed that way. Good luck with your perl hacking! -bob From rspier at pobox.com Wed Sep 28 16:38:21 2005 From: rspier at pobox.com (Robert Spier) Date: Wed, 28 Sep 2005 16:38:21 -0700 Subject: [LA.pm] little help?? In-Reply-To: <48a511374ee76e15a0a72fbc394028b0@sbcglobal.net> References: <006401c5c450$6e6110d0$6801a8c0@familinklat1> <48a511374ee76e15a0a72fbc394028b0@sbcglobal.net> Message-ID: > I got an off-list reply that thought I was being a little too hard on > you. Didn't really mean to be that way, so sorry if it seemed that way. > Good luck with your perl hacking! I didn't think you were being hard. Just detailed. Most beginners would be lucky to get such a detailed and thorough response. -R From pete at peterbenjamin.com Wed Sep 28 18:16:48 2005 From: pete at peterbenjamin.com (Peter Benjamin) Date: Wed, 28 Sep 2005 18:16:48 -0700 Subject: [LA.pm] little help?? In-Reply-To: References: <006401c5c450$6e6110d0$6801a8c0@familinklat1> <48a511374ee76e15a0a72fbc394028b0@sbcglobal.net> Message-ID: <6.1.2.0.2.20050928175937.04ce33a8@peterbenjamin.com> At 04:38 PM 9/28/2005, Robert Spier wrote: >> I got an off-list reply that thought I was being a little too hard on >> you. Didn't really mean to be that way, so sorry if it seemed that way. >> Good luck with your perl hacking! > >I didn't think you were being hard. Just detailed. Most beginners >would be lucky to get such a detailed and thorough response. It was a good newbie perl style bootstrap, just what I thought was being asked for. I'd tend to use a CPAN module for parsing the log file, as the split using the default RE does not give good results when there are quoted strings, quoted due to embedded blanks, which the CPAN module takes care of. A split RE is possible to handle the parsing... it's hard to write. Reducing the log file for testing to just the needed records would eliminate debugging the parsing. grep RE logfile > testfile As I've got RAM I would have done the whole perl differently. I'm so lazy instead of finding the actual code I use, here it is real fast (this ought not to compile, so you must fix it). my $br; $br = "\n"; # For CLI output # $br = "
\n"; # For html output my $fn = $ARGV[0]; open ( $log, "<$fn" ) || die ( "Error: Unable to open input filename: $fn${br}Message: $!$br" ); my @rec = <$log>; close $log; my @matches = grep /RE_here/, @rec; my %seenIP; foreach my $rec ( @matches ) { my ( ..., $ip, .... ) = split( /RE_here/, $rec ); $seenIP{$ip}++; } foreach my $ip ( sort keys %seenIP ) { my $count = $seenIP{"$ip"}; print "$ip\t$count$br"; } exit; You can see my standard convention for "open || die" that includes the filename and error message. And the slurp of the log file is fast. The grep reduces the troubleshooting of subsequent code. The %seen method is from an ORA perl book, and pretty standard fair now a days. Best re-use the %seen method whenever counting matches. It's fast and QED. Thus, the two foreach loops ought to be in a newbie's library sooner, not later. The sort is not quite in numeric order, left as homework for the student. Anyone have something that sorts IP numerically? In one code line? ;-) From bobmath at sbcglobal.net Wed Sep 28 19:59:47 2005 From: bobmath at sbcglobal.net (Bob Mathews) Date: Wed, 28 Sep 2005 19:59:47 -0700 Subject: [LA.pm] little help?? In-Reply-To: <010001c5c485$5b58fc20$6801a8c0@familinklat1> References: <006401c5c450$6e6110d0$6801a8c0@familinklat1> <48a511374ee76e15a0a72fbc394028b0@sbcglobal.net> <010001c5c485$5b58fc20$6801a8c0@familinklat1> Message-ID: <093c294c6891476090870557a915f29a@sbcglobal.net> On Sep 28, 2005, at 4:35 PM, FamiLink Admin wrote: > ...I am not sure what to do about: > >> Paranoia time: are you certain that $log doesn't contain anything >> dangerous that will make the shell misbehave? Probably not, but if >> you're putting this in a CGI script that takes $log as a parameter, >> it's something you need to think about. You're using a constant for the filename now, so no worries. The original code looked like this: open my $slog, "-|", "tail -n 50000 $log" Which is a big problem if someone manages to set $log to something like "foo;rm -rf *". Try it out, but make sure you're in a directory that doesn't contain anything important. > Also, the sub scanlog does write the information to the files but it > does not return anything back to the main program It does return stuff, but a lot of it is undefs. You have some scoping trouble going on, it looks like. The standard reference is Coping With Scoping (http://perl.plover.com/FAQs/Namespaces.html). Also consider the output from this: my $x = 42; print "x = $x\n"; { my $x = 23; print "x = $x\n"; } print "x = $x\n"; > and I also get the error: > Use of uninitialized value in split at ./test.pl line 9. By my count, line 9 is: my $hour = (split, localtime)[2]; Split followed by a comma means split(), which splits $_, which must be undefined. Think you want to ditch the split in that statement. > Also, is there a better way of counting the number of times each IP > address gets blocked with category PO? Each time I get to the > blocklimit it writes to the file but I really just want the max number > of blocks over the limit. It will write the same IP each time it gets > over the blocklimit though. Not sure I understand you fully, but you might want to total up the number of blocks for each ip thusly: $blocks{$ip}++; And then print out the totals once you've processed the entire file. while (my ($ip, $count) = each %blocks) { ... } > $|=1; # no buffering Don't think this is doing anything for you. It's only setting autoflush on STDOUT, and you're not printing very much there. -bob From md5 at embody.org Wed Sep 28 20:00:17 2005 From: md5 at embody.org (Mike Dillon) Date: Wed, 28 Sep 2005 20:00:17 -0700 Subject: [LA.pm] Spam:***, Re: little help?? In-Reply-To: <010001c5c485$5b58fc20$6801a8c0@familinklat1> References: <006401c5c450$6e6110d0$6801a8c0@familinklat1> <48a511374ee76e15a0a72fbc394028b0@sbcglobal.net> <010001c5c485$5b58fc20$6801a8c0@familinklat1> Message-ID: <20050929030017.GA23088@hygelac.int.embody.org> begin FamiLink Admin quotation: > Also, the sub scanlog does write the information to the files but it does > not return anything back to the main program and I also get the error: > > Use of uninitialized value in split at ./test.pl line 9. > ------------------------------------------------------------------------------ > #!/usr/bin/perl -w > require Mail::Send; > $|=1; # no buffering > use constant IP_LIST_FILE => "/etc/squid/iplist.txt"; > use constant SUSPEND_FILE => "/etc/squid/SuspendIpList.txt"; > use constant LOG_FILE => "/opt/n2h2/logs/filter_log"; > my $sysop = "webmaster\@familink.com"; > my $flag = "PO"; > my $hour = (split, localtime)[2]; This is your old friend $_ biting you in the ass again. The comma after split is the problem. Using split with no arguments is basically the same as doing "split ' ', $_". Since $_ is undefined, you're getting a warning. Really, though, you shouldn't be trying to split the string returned from localtime. You should use it in list context like so: my $hour = (localtime)[2]; In list context, localtime returns a numeric list of the parts of time. This avoids putting localtime into scalar context where you are forced to have to parse it with split. Many built-in Perl functions have this dual mode of operation in scalar versus list mode. A good explanation can be found at . -md From md5 at embody.org Wed Sep 28 20:36:18 2005 From: md5 at embody.org (Mike Dillon) Date: Wed, 28 Sep 2005 20:36:18 -0700 Subject: [LA.pm] Spam:***, Re: little help?? In-Reply-To: <20050929030017.GA23088@hygelac.int.embody.org> References: <006401c5c450$6e6110d0$6801a8c0@familinklat1> <48a511374ee76e15a0a72fbc394028b0@sbcglobal.net> <010001c5c485$5b58fc20$6801a8c0@familinklat1> <20050929030017.GA23088@hygelac.int.embody.org> Message-ID: <20050929033618.GA24033@hygelac.int.embody.org> begin Mike Dillon quotation: > The comma after split is the problem. Using split with no arguments is > basically the same as doing "split ' ', $_". Since $_ is undefined, > you're getting a warning. > > Really, though, you shouldn't be trying to split the string returned > from localtime. You should use it in list context like so: > > my $hour = (localtime)[2]; > > In list context, localtime returns a numeric list of the parts of time. > This avoids putting localtime into scalar context where you are forced > to have to parse it with split. > > Many built-in Perl functions have this dual mode of operation in scalar > versus list mode. A good explanation can be found at > . Looks like I was a little confused. To be clear, you weren't actually using localtime in scalar context, although with correct split syntax you would have been. In your case, split was returning an empty list in front of the list returned by localtime, making it so that that part actually worked the same as my suggestion, just with a warning. -md From pete at peterbenjamin.com Thu Sep 29 10:56:42 2005 From: pete at peterbenjamin.com (Peter Benjamin) Date: Thu, 29 Sep 2005 10:56:42 -0700 Subject: [LA.pm] Spam:***, Re: little help?? In-Reply-To: <20050929030017.GA23088@hygelac.int.embody.org> References: <006401c5c450$6e6110d0$6801a8c0@familinklat1> <48a511374ee76e15a0a72fbc394028b0@sbcglobal.net> <010001c5c485$5b58fc20$6801a8c0@familinklat1> <20050929030017.GA23088@hygelac.int.embody.org> Message-ID: <6.1.2.0.2.20050929104822.04a466d0@peterbenjamin.com> At 08:00 PM 9/28/2005, Mike Dillon wrote: >> my $hour = (split, localtime)[2]; I've read a lot of code that uses perl shortcuts. It's obtuse. Not a new argument regarding perl. For a programmer new to perl, though, I feel spelling out the full import of the functionality of the line can often lead to faster code re-use. For example: my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); is a copy and paste from Perl/html/lib/Pod/perlfunc.html#item_localtime and I just use it, over and over, rather than try to recall what subscript is the hour. When more than just the hour is needed, I know exactly what variables to use. Yes, do read shortcut code, and understand that shortcut is there and how the shortcut works for it's scope and context, as that can lead to very advance use of perl, and in one line do something that would otherwise take 10 lines. But when first starting to use perl... I advise to learn the easy way, where the perl Help copy and paste method is quite clear, and debugging is non-existent, resulting in faster time to working code, and moving on to the next perl project. From terrymcintyre at yahoo.com Thu Sep 29 15:26:10 2005 From: terrymcintyre at yahoo.com (terry mcintyre) Date: Thu, 29 Sep 2005 15:26:10 -0700 (PDT) Subject: [LA.pm] Spam:***, Re: little help?? In-Reply-To: <6.1.2.0.2.20050929104822.04a466d0@peterbenjamin.com> Message-ID: <20050929222610.29645.qmail@web30608.mail.mud.yahoo.com> I often use a similar method, but to avoid the warning messages about unused variables, the following twist: # ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) my (undef,undef,$hour) = localtime(time); --- Peter Benjamin wrote: > At 08:00 PM 9/28/2005, Mike Dillon wrote: > >> my $hour = (split, localtime)[2]; > > I've read a lot of code that uses perl shortcuts. > It's obtuse. Not a new argument regarding perl. > my > ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) > = localtime(time); > > is a copy and paste from > Perl/html/lib/Pod/perlfunc.html#item_localtime > and I just use it, over and over, rather than try to > recall what > subscript is the hour. > > When more than just the hour is needed, I know > exactly what variables to use. > > Yes, do read shortcut code, and understand that > shortcut is there > and how the shortcut works for it's scope and > context, as that > can lead to very advance use of perl, and in one > line do something > that would otherwise take 10 lines. But when first > starting to use > perl... I advise to learn the easy way, where the > perl Help copy > and paste method is quite clear, and debugging is > non-existent, > resulting in faster time to working code, and moving > on to the > next perl project. > > > _______________________________________________ > Losangeles-pm mailing list > Losangeles-pm at pm.org > http://mail.pm.org/mailman/listinfo/losangeles-pm > Terry McIntyre UNIX for hire software development / systems administration / security 213-291-5169 or 2132915169 at tmomail.com ( text ) terrymcintyre at yahoo.com __________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com From Peter at PSDT.com Thu Sep 29 16:03:19 2005 From: Peter at PSDT.com (Peter Scott) Date: Thu, 29 Sep 2005 16:03:19 -0700 Subject: [LA.pm] Spam:***, Re: little help?? In-Reply-To: <20050929222610.29645.qmail@web30608.mail.mud.yahoo.com> References: <6.1.2.0.2.20050929104822.04a466d0@peterbenjamin.com> <20050929222610.29645.qmail@web30608.mail.mud.yahoo.com> Message-ID: <6.1.2.0.2.20050929155816.023a9320@mail.webquarry.com> use Time::localtime; my $hour = localtime->hour; At 03:26 PM 9/29/2005, terry mcintyre wrote: >I often use a similar method, but to avoid the warning >messages about unused variables, the following twist: > ># >($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) >my (undef,undef,$hour) = localtime(time); > >--- Peter Benjamin wrote: > > > At 08:00 PM 9/28/2005, Mike Dillon wrote: > > >> my $hour = (split, localtime)[2]; > > > > I've read a lot of code that uses perl shortcuts. > > It's obtuse. Not a new argument regarding perl. > > my > > >($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) > > = localtime(time); > > > > is a copy and paste from > > Perl/html/lib/Pod/perlfunc.html#item_localtime > > and I just use it, over and over, rather than try to > > recall what > > subscript is the hour. > > > > When more than just the hour is needed, I know > > exactly what variables to use. > > > > Yes, do read shortcut code, and understand that > > shortcut is there > > and how the shortcut works for it's scope and > > context, as that > > can lead to very advance use of perl, and in one > > line do something > > that would otherwise take 10 lines. But when first > > starting to use > > perl... I advise to learn the easy way, where the > > perl Help copy > > and paste method is quite clear, and debugging is > > non-existent, > > resulting in faster time to working code, and moving > > on to the > > next perl project. -- Peter Scott Pacific Systems Design Technologies http://www.perldebugged.com/ http://www.perlmedic.com/ From bobmath at sbcglobal.net Thu Sep 29 16:20:34 2005 From: bobmath at sbcglobal.net (Bob Mathews) Date: Thu, 29 Sep 2005 16:20:34 -0700 Subject: [LA.pm] localtime (was: little help??) In-Reply-To: <20050929222610.29645.qmail@web30608.mail.mud.yahoo.com> References: <20050929222610.29645.qmail@web30608.mail.mud.yahoo.com> Message-ID: On Sep 29, 2005, at 3:26 PM, terry mcintyre wrote: > I often use a similar method, but to avoid the warning messages about > unused variables, the following twist: > # ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) > my (undef,undef,$hour) = localtime(time); Is there an unused variable warning in perl? I've never seen one. The assign-to-undef trick is a good one to know, but I would like to suggest that it can be taken too far. my (undef, undef, undef, undef, undef, undef, undef, $yday) = localtime; (Also, I think it only works in fairly recent perls.) Let's face it -- the localtime interface is garbage. On Sep 29, 2005, at 4:03 PM, Peter Scott wrote: > use Time::localtime; > my $hour = localtime->hour; Hear, hear. From pete at peterbenjamin.com Thu Sep 29 18:44:07 2005 From: pete at peterbenjamin.com (Peter Benjamin) Date: Thu, 29 Sep 2005 18:44:07 -0700 Subject: [LA.pm] Spam:***, Re: little help?? In-Reply-To: <6.1.2.0.2.20050929155816.023a9320@mail.webquarry.com> References: <6.1.2.0.2.20050929104822.04a466d0@peterbenjamin.com> <20050929222610.29645.qmail@web30608.mail.mud.yahoo.com> <6.1.2.0.2.20050929155816.023a9320@mail.webquarry.com> Message-ID: <6.1.2.0.2.20050929183930.03ff6708@peterbenjamin.com> At 04:03 PM 9/29/2005, Peter Scott wrote: >use Time::localtime; >my $hour = localtime->hour; I do like this approach to grabbing frequently used values when you need "just one" this works out to less typing, or copy and pasting. I like to gather my "use" statements at the top of the perl file. So it means pasting in two places, and more prone to error when re-using code, but it's the modern architect to use objects, even if slow. As I learned to program for efficiency, so long ago, use of objects to set one value... Now is the time to talk about including hundreds of lines of perl code to compile and just use a few of them. >At 03:26 PM 9/29/2005, terry mcintyre wrote: >>I often use a similar method, but to avoid the warning >>messages about unused variables, the following twist: >> >># ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) >>my (undef,undef,$hour) = localtime(time); These warnings bother you a lot? Why? I do wish I could suspress just that one.