Prints user's IP address and localtime on the page





ranking Sort Sort   |   date Sort Sort   |   member Sort Sort
Syndication

« Previous 1 2 Next »
0
Date Submitted Sat. Mar. 8th, 2008 3:54 PM
Revision 1
Beginner chorny
Tags MD5 | Perl
Comments 0 comments
Digest::MD5 is core from 5.8.
0
Date Submitted Sat. Mar. 8th, 2008 1:41 PM
Revision 1
Beginner chorny
Tags find | Grep | Perl
Comments 0 comments
Usage:
found('asdf',@array);

P.S. In perl 5.10 can be written as
use 5.010;
'asdf'~~@array;
7
Date Submitted Mon. Nov. 6th, 2006 1:48 PM
Revision 1
Helper RobHarrigan
Tags "first | "title | capitalize | case" | letter" | Perl
Comments 3 comments
Function to capitalize the first letter in every word in a string, but only if the entire string is in ALL CAPS.

Example:
"I LIKE TO SCREAM" becomes "I Like To Scream"
"I LIKE to RUN" remains "I LIKE to RUN".
5
Date Submitted Fri. Nov. 3rd, 2006 12:07 PM
Revision 1
Helper jarfil
Tags "Command Line" | Perl
Comments 2 comments
I've found it kind of complicated to strip newline chars from a file with just the commandline. This tiny piece of code does just that.

I've found it especially useful when extracting tabulated data from a grabbed site where each cell is on a different html line. This way I can pre-filter the html, remove the newlines, and insert them again at register boundaries (row end in this case), so that with just a couple more replacement from within a regex enabled text editor I can copy&paste it directly to a database.
0
Date Submitted Mon. Oct. 9th, 2006 1:14 PM
Revision 1
Beginner robert
Tags "record time" | day | hour | localtime | minute | Perl
Comments 3 comments
This perl function will output to a file of your choosing the current localtime as defined by perl's localtime function. It will output the date in ISO 8601 date format plus the current localtime such as:
2006-08-21 09:26:35 am
The function also returns the localtime without the date to the calling environment.
6
Date Submitted Tue. Sep. 26th, 2006 12:56 PM
Revision 1
Scripter sehrgut
Tags C | CGI | escape | URI | URL
Comments 0 comments
Another pull from my growing-towards-beta CGI library: sgcgi_url_unescape().

Note the use strcpy, which is faster than the equivalent memmove()ing. To ensure 64-bit safety, I plan to rename this function and then conditionally compile it to point to either strcpy or a 64-bit-safe memmove() implementation of strcpy.

However, even though copy order isn't guaranteed for strcpy, on 16-bit and 32-bit systems, all known implementations copy byte-by-byte from lower addresses to higher addresses. Some 64-bit optimized compilers may copy 8-byte chunks, making the assumption of full linearity unstable at best.

I know it sounds like I'm justifying use of nonstandard code for convenience . . . *blush* . . . it's just something that putting in a -DPEDANTIC type of preprocessor flag could fix if broken, and its SO much faster!
8
Date Submitted Fri. Sep. 22nd, 2006 12:16 AM
Revision 1
Scripter sehrgut
Tags C | CGI
Comments 0 comments
The best way I've found to keep a suite of CGI environment variables in my C CGI programs is actually just to read them as name-value pairs into a stack. It simplifies parsing and makes the code cleaner and less fragile than using a specialized structure or an ordered array of strings (as well, empty variables are simply not push()ed onto the stack, so memory doesn't have to be allocated for empty strings). Plus, since there are never a huge number of environment variables, and they are all unique (by definition), a search through the stack for a given name takes minimal time. In fact, retrieval of environment variables beats a PHP-like hash-table implementation by a good deal.

In the code below, all you have to keep in mind is that the NVStk is a name/value pair stack (implemented as a singly-linked list with each node containing two char*s). Variable retrieval times can be minimized by adjusting the order of variable names in the char**s passed to sgcgi_getenv(). In fact, the ones below are just about backwards from how they ought to be, since I forgot I was using a stack instead of a queue . . . *blush*

Of course, there are more environment variables you can get, but you have to draw the line between exhaustion and efficiency, and that depends on the project. The variables included here are pretty much overkill for any program you're likely to need.

A nice way to use these types of functions is to wrap them in an accessor function that gets the environment once and keeps it as a static variable, and then on subsequent calls just looks up values in its stack. (If you want to see the NVStk, I can put it up, but it's pretty much a basic linked list.)
6
Date Submitted Thu. Aug. 31st, 2006 8:44 AM
Revision 1
Scripter ctiggerf
Tags API | Database | mysql | Perl
Comments 3 comments
A database API written in Perl for a MySQL.

You will need to edit the settings for your server.

Enojy
12
Date Submitted Thu. Aug. 31st, 2006 8:09 AM
Revision 1
Scripter ctiggerf
Tags Perl
Comments 1 comments
A little function that returns a greeting based on the local time.
5
Date Submitted Thu. Aug. 31st, 2006 7:58 AM
Revision 1
Scripter ctiggerf
Tags Email | Perl | RegExp | Validate
Comments 3 comments
Simple function to check for a valid email address. Makes sure the @ and a . are in the right place. There is most likely a perl package on CPAN that would be more extensive, but this happens to work for my uses.
« Previous 1 2 Next »