You are here:
| Subject | Date Asked |
| file renaming | 10/31/2011 |
| Q: I have 32 folders with the year 1972 to 2011 and in each folder there are many more sub folders ... A: Of course. This is off the top of my head, but something *like* this should work: <pre> my $dir ... | |
| Help with regexp | 9/14/2011 |
| Q: Justin, My question is more related to help with regular expressions, so I hope you can help me. ... A: Your regex would look something like: ... | |
| regex easy | 9/8/2011 |
| Q: I have a file renaming utility that takes regex. I need to know what I need to do to rename the ... A: This isn't really a job for a regex. I'd do something like: my $filename = q{32037-JUSTIN'S}; my ... | |
| perl | 8/10/2011 |
| Q: how can i declare a variable in strict mode without using my (keyword) A: I'm not sure I understand your question. Specifically, why you would want to do that. The point of ... | |
| retrieving images from html files | 7/22/2011 |
| Q: I thought this would be easy but I cant seem to get it right. I need to go through an html file and ... A: I fear the site's formatting may have completely borked what you sent me, but if you wanted all of ... | |
| 500 Internal Server Error | 5/8/2011 |
| Q: I keep getting a 500 internal server error when I try to upload a video to my video sharing website. ... A: A 500 error can be any one of dozens of things. Generally it means the upload program didn't run, ... | |
| CGI Help | 3/31/2011 |
| Q: Justin, I need some help again. In my CGI script, I have this line: @Special = ... A: You would want something like: my @names = qw( drizzt rylore ); my $name_char = q{}; foreach my ... | |
| CGI Help | 3/31/2011 |
| Q: Justin, I need some help again. In my CGI script, I have this line: @Special = ... A: You're going through the array, and then assigning a variable on its result. The next time you get ... | |
| Seach and Replace Arrays | 3/25/2011 |
| Q: Justin, I'm trying to find a way to search an array of words and to replace them with an array of ... A: I'd do something like this: my %replacements = ( badword1 => 'replacement1', badword2 => ... | |
| End of string terminator | 1/22/2011 |
| Q: I am trying to teach myself perl and have a problem with the script below returing: Can't find ... A: Not really -- later versions of perl will tell you where the opening bracket is that it thinks isn't ... | |
| End of string terminator | 1/21/2011 |
| Q: I am trying to teach myself perl and have a problem with the script below returing: Can't find ... A: That error means you opened ( somewhere but didn't close it. If you look at the second last line ... | |
| upload file | 10/4/2010 |
| Q: I have a web site and members who have to login. I have a file that I need to have a member download ... A: What you're looking for isn't really a function of the language. If you tried to lock out the user, ... | |
| Perl/CGI | 6/2/2010 |
| Q: I have donation website I constructed for a foundation. The site is built simply in CSS, html, and ... A: You need to escape any double quotes that can be found in your string. Better yet, do this: print ... | |
| get value pairs from non encoded string | 5/26/2010 |
| Q: When I use CGI qw/:standard Vars()/; I get this: $VAR1 = 'POSTDATA'; $VAR2 = '<?xml version="1.0" ... A: POSTDATA contains an XML file. You'll need to use something like XML::Simple or XML::Parser to get ... | |
| receive and send response to java from perl | 5/19/2010 |
| Q: I need to know how to receive an http post coming from java to my perl script and then send back a ... A: Perl can do anything. :) The fact that they're using a commandline shouldn't matter; as long as ... | |
| perl pattern match in multiple lines | 12/2/2009 |
| Q: i am new to perl and i have trouble in searching patterns for multiple lines. Any help/suggestion is ... A: It appears my program got screwed in the paste. Also, you can't do it that way. If @grep_results ... | |
| find and replace | 11/17/2009 |
| Q: I have one html file. I am reading the file line by line, and I want to find every occurrence of the ... A: When you do that, perl things you're ending the regular expression at </ and then you're giving it ... | |
| Testing HTML forms with cgi on Windows | 10/24/2009 |
| Q: I need to test out a HTML form which has a cgi script to it on my Windows PC. I tested the cgi out ... A: You'll need to run an actual webserver to run the CGI. If it's a Perl scripts, you'll need to ... | |
| CGI script | 10/15/2009 |
| Q: I'm trying to read in name-value pairs from a POST where the value pairs are "CD=2&CD=3&CD=4 I need ... A: Your best bet is to use the CGI script, which will parse it for you. Then, you'd do something like. ... | |
| Perl XML:Simple | 9/30/2009 |
| Q: I'm trying to user xml:simple to break down an xml doc that I'm receiving from another website. I've ... A: Yes, you'll likely need a foreach or something like that to traverse the data. Your best bet is to ... | |
| XML::Simple | 8/29/2009 |
| Q: I have an xml doc that is pulled from another site a copy is saved to a temp file on my server then ... A: Opening and writing to lib/temp/$id.xml isn't very safe. I'd suggest something more like this: use ... | |
| perl assignment question | 6/7/2009 |
| Q: I don't understand what is being assigned to the $paper variable in the line below. I've checked 3 ... A: You're assigning an empty hash reference. It's the exact same as. my %hash = (); my $paper = ... | |
| Can't open a file with an extensionless script. | 5/29/2009 |
| Q: I am using the code at the bottom in myscript.pl to open a counter file, get the number then ... A: Whether or not there's an extension on the file should not change the way it operates. The only ... | |
| PERL + HTML | 5/8/2009 |
| Q: so I want to know if somehow I can use both of them at the same time? Actually I want to know if I ... A: Yes, you can do this. You'd have to write a perl script that would interpret the incoming form post ... | |
| Perl Programming Question | 5/8/2009 |
| Q: ...I'm new to Perl and trying to pick up on things along the way. I'm trying to create a Perl ... A: In the else clause on your subroutine, you have this: return $prev_dt; $prev_dt = $a; So the ... | |
| non-working DBM script | 5/7/2009 |
| Q: I am trying to get this script to work. The main html page is a simple 3-field entry form to enter a ... A: You can run your scripts on the command line and use them like you would in a browser to see if your ... | |
| data extraction | 4/15/2009 |
| Q: Justin: I am not sure who to ask, so I'll try you. In my medical practice, I must verify ... A: Yes, just about any language should be able to perform that functionality for you -- Perl, PHP, ASP, ... | |
| My First Perl Program | 3/23/2009 |
| Q: My Perl program that is getting a diagnostic (Global symbol "$filename" requires explicit package ... A: Neil, The issue is the 'use strict'. It enables variable declaration to use them. In the first ... | |
| Perl TCP Socket how to handle large records | 3/7/2009 |
| Q: Howdy I have looked all over the place and can't seem to find how to do this in Perl. There ... A: How are you currently doing this in Perl? Reason I ask is because most of that kind of stuff is ... | |
| Declare variable dynamically | 3/3/2009 |
| Q: I have a following array: use strict; my @arr=qw(computer laptop telephone); The contents of @arr ... A: Doing that is generally considered a bad practice, as it requires you to disable strict references ... | |
| Text encoding and perl | 2/10/2009 |
| Q: I have a CLOB in an oracle database that contains various scientific symbols such as the micro (Alt ... A: The way this question gets answered is different based on which version of perl it is you're using. ... | |
| Array, sort | 1/17/2009 |
| Q: I have a text file that contains lines like: name1/value1 name1/value2 name2/value3 name3/value4 etc ... A: Your best bet is to read the entire file into memory, and then sort the arrays as you see fit. ... | |
| Appending data to large file | 1/14/2009 |
| Q: I wonder if you could help. I have a large text file (300,000 - 500,000 lines) in a specific format. ... A: Something like this would do it: open my $fh, '<', 'file1'; my $term_1 = <$fh>; my $term_2 = <$fh>; ... | |
| Unicode | 12/11/2008 |
| Q: We use a third-party sms gateway to send out sms from our server. To send non usual characters ... A: The word тест is Unicode characters #1090, #1077, #1089, #1090. 1090 in hex ... | |
| edit | 12/4/2008 |
| Q: this is a piece of document(copied from IRC channel in Xchat in XP version) i would like to edit by ... A: Unfortunately, I don't know the character mapping for the Chinese characters for the date, but you ... | |
| script to check for files added to a directory in a time interval | 11/21/2008 |
| Q: Can you please tell me how to check if a file has been created into a directory within a time ... A: To get a file's modification time, simply: my $create_time = -M "some_file.txt"; Then $create_time ... | |
| looking for a way to write a regex line | 11/13/2008 |
| Q: In my auction Script, the Description Line contains: <DIV ALIGN=center> <TABLE WIDTH=98% ... A: That is most certainly not what you want, because [] means a character class, which would cause the ... | |
| performing an action on multiple files | 11/4/2008 |
| Q: Hey, I'm pretty new to Perl and couldn't quite answer my question with the current answers to ... A: You can just use the glob operator to get what you want: Something like: FILE: foreach my $file ... | |
| Write back to file | 10/30/2008 |
| Q: Hey, I'm writing a script that has to do something like this: Read Line1 from File1 Look through ... A: This is a tricky subject in general. You'd be overwriting in normal cases. An example I just ... | |
| File locking etc | 9/16/2008 |
| Q: On a server with a high traffic, what is the best way to be sure that 2 users won't update the same ... A: Depending on your operating system, you're going to want to look into real file locking. Either via ... | |
| perl Regular Expression '~' usage | 9/8/2008 |
| Q: I would like to know about Perl Regular Expression syntax, which usually contains the tilde sign ... A: =~ is a perl operator that means 'run this variable against this regular expression. $group =~ ... | |
| Perl encoding problem | 9/4/2008 |
| Q: Greetings! Hope that you will understand my problem :) 1- Perl script: #!/usr/bin/perl use CGI; ... A: There's a few issues that could be at-hand here. First, upload the file in BINARY mode, since ... | |
| CGI redirect with extra content header | 8/4/2008 |
| Q: What I want is a redirect page saying something like "processing your request... you will be ... A: What you'll need to do is send them a static html page that says, 'please wait while we process', ... | |
| Generate pdf using perl | 7/30/2008 |
| Q: I want to create and generate pdf file using perl but without installing any tool in Unix platform. ... A: No, you can't create a PDF without first installing some ps2pdf tools, or some Perl modules. Unless ... | |
| Write die command to log file | 7/29/2008 |
| Q: This is password generating file, In this file, I have the following lines timeout=10; ... A: $SIG{__DIE__} is the handler that handles die()s. Its default is something like: warn @_; exit 1; ... | |
| Write die command to log file | 7/29/2008 |
| Q: This is password generating file, In this file, I have the following lines timeout=10; ... A: To catch a die, you'd have to write a SIGDIE handler, or instead of dying, just print to the file ... | |
| Upload Multiple Large Files | 7/23/2008 |
| Q: I am trying to set up a site to design calendars using my users pictures. In order to do that I have ... A: Unfortunately, unless your provider gives you a higher timeout, it's going to continue to happen ... | |
| changing IP's Path problems? | 7/9/2008 |
| Q: Judy Loper Artdsign.com Hi I am definitely not a perl programmer. I have changed my IP and can ... A: I would suggest there's something wrong with the server's configuration or the script's settings, as ... | |
| to run linux commands using cgi | 6/7/2008 |
| Q: how to run linux commands using cgi A: There's a few ways to do that. The first, and most simple is: $output = `/bin/ls /`; Anything you ... | |
| Script that works but still gives Internal server error | 6/4/2008 |
| Q: I have taken an old cgi script that is working on one of my sites and stripped it down to serve a ... A: No, that won't work like you hoped. Making e-mails go in any other content type than text/plain is ... | |
| Script that works but still gives Internal server error | 6/1/2008 |
| Q: I have taken an old cgi script that is working on one of my sites and stripped it down to serve a ... A: There's one of two things going on that's causing this issue. #1: It's not sending headers before ... | |
| Error produced on form submit | 5/29/2008 |
| Q: I've set up a form for a client and used mailform.cgi. I have checked all the code in the script and ... A: This error means one of two things: 1) The script is outright crashing. or, 2) It's not sending ... | |
| é -> é | 5/7/2008 |
| Q: I'm using a Perl script called SmartyPants <http://daringfireball.net/projects/smartypants/> to ... A: There's a bunch of issues to make sure of before going ahead with this. The biggest one being ... | |
| Perl on Microsoft word document | 5/6/2008 |
| Q: Can a perl script be used to parse/edit (i.e. recognize fonts) in Microsoft Word document? A: Parsing MS Word documents is a bit of a crap shoot in that they changed their standard for every ... | |
| Devel::Size | 4/30/2008 |
| Q: I'm trying to use "Devel::Size" which is an extension module to check memory usage of a Perl ... A: It sounds like your Solaris build environment is not set up correctly. You can find instructions ... | |
| Devel::Size | 4/30/2008 |
| Q: I'm trying to use "Devel::Size" which is an extension module to check memory usage of a Perl ... A: If you're running debian, there's two options for installing the module. The first, is the debian ... | |
| Simple Perl Scripting | 3/8/2008 |
| Q: I am new to Perl and programming in general and you may feel this question is very simple but your ... A: There is a CPAN module I'd suggest using in this place: Date::Parse. It will parse dates in ... | |
Top Expert on this page
Any question relating to Perl including its internals, data structures, speed, memory usage, syntax, version changes, extra CPAN modules, code standards, code cleanup, or just silly problems.
I have been writing Perl code professionally for almost 10 years. I have modules on CPAN, have Perl code that's included in the latest versions of Redhat, Debian, etc. I have done professional Perl work for many household names including Ticketmaster, Interflora, and allbookstores.com.
Education/Credentials
Only work experience and a love of all things Perl.

©2012 About.com, a part of The New York Times Company. All rights reserved.