Technology TidBits

Answers to various technical questions on php programming, mysql, linux, and many more categories.



Showing: 1-20 of 20  
Questions:
What's the format for Perl's stat command?
Here's a common setup for using the stat command:($device,$inode,$file_mode,$num_link,$uid,$gid,$dev_id,$size,$access_time,$mod_time,$change_time,$block_size,$blocks) = stat($filename); You use this routine to get the time (current...
Not rated 07/02/2009 Comments: 0
How do I find a list of perl modules on my system?
Run this command from your prompt / command line:find `perl -e 'print "@INC"'` -name '*.pm' -print (Taken from CPAN: http://www.perl.com/doc/manual/html/pod/perlmodlib.html)...
Not rated 07/03/2009 Comments: 0
How can I create a CSV from a CGI script?
On occasion, you'd like a cgi script to send data back in CSV format. This is often used for downloading...
Not rated 06/30/2009 Comments: 0
How can I get the time in Perl?
Here's a subroutine I use for getting the current date/time in a readable format. Often times it comes in handy...
rating 06/30/2009 Comments: 0
How can I redirect users to a static page after running a CGI program?
From a CGI, you often want to send a user to a "thank you" or confirmation page. Here are two...
Not rated 06/30/2009 Comments: 0
How do I go about writing a Perl module?
Run this command from a unix prompt:h2xs -AXc -n Module_Name This generates a bunch of nice files, from which you...
Not rated 07/03/2009 Comments: 0
How do I create a hash of lists in Perl?
  Sometimes it's nice to have a hash element point to a list of items, rather than just a value.  To...
Not rated 06/30/2009 Comments: 0
I want to uppercase all the words in a string?
This comes from page 20 of "Perl Cookbook" by O'reilly and Associates: use locale; $string = "this is a string";...
Not rated 06/30/2009 Comments: 0
How can I get multiple checkbox values using CGI.pm?
Assuming you have a form with fields like so: <input type="checkbox" name="color" value="red">Red<br><input type="checkbox" name="color" value="blue">Blue<br><input type="checkbox" name="color" value="green">Green<br> Within your Perl...
Not rated 06/30/2009 Comments: 0
How do a I fix a "bad interpreter" error with my CGI script?
This is probably the result of using a Windows or DOS based text editor, which adds line breaks in the...
Not rated 06/30/2009 Comments: 0
I need to get rid of all non-alphanumeric characters from a string - how can I do it?
In Perl, a simple regular expression will handle this. Here's an example: $var = "This string has some ' bogus...
Not rated 06/30/2009 Comments: 0
How can I keep leading zeros when building a CSV file?
Some data looks like a number on the surface, but really is not meant to be used that way. Zip...
rating 07/03/2009 Comments: 0
How to print a hash of hashes for debugging?
It is usually useful to verify what you have in variables during coding / testing.  Otherwise, you may waste time...
rating 06/30/2009 Comments: 0
How do I get the username of the user running the script?
Use the special variable $< So with the code: $username = getpwuid($<); You can get the unix username running the script.  ...
Not rated 06/30/2009 Comments: 0
How do I fix this error: Argument "O_RD" isn't numeric in subroutine entry at /usr/lib/perl5/5.8.5/i386-linux-thread-multi/DB_Fi le.pm line 278?
Apparently, somewhere along the line, the global "O_RD" changed to "O_RDONLY" - so you need to update the code in...
Not rated 06/26/2009 Comments: 0
How can I get bounced emails from my email CGI or PHP script?
It seems that most cgi / php scripts that send email do not get bounces.  So you never know if...
Not rated 06/30/2009 Comments: 0
How can I get my Perl code indented to look nice?
Well, I found this to work on unix (unless you use a lot of hashes):   indent -br -brs This helps for...
Not rated 06/16/2009 Comments: 0
Perl regular expression to find non-printable characters?
Here's a quick perl regex to find non-printing / control characters: /[\x80-\xFF]/ You can use this in conditionals, substitutions, etc. to find...
Not rated 06/29/2009 Comments: 0
How can I tie into my vbulletin user database from a perl script?
Sometimes you may want to verify a username / password matches up to a valid vbulletin user, from a perl...
Not rated 09/06/2010 Comments: 0
Checking for spam in perl scripts?
One thing I noticed is that a lot of spam bots post junk strings to the form, and you can...
Not rated 09/06/2010 Comments: 0



Powered by KnowledgebasePublisher 1.1
Superb Internet
Content provided by Roberts WebForge, Inc.