Perl Programming Tutorials

PERL Programming Tutorials And Articles
  Title / Author Reverse Sort Order Replies
Views
Different Operating Systems use different characters as their path separator when specifying directory and file paths: foo/bar/baz # *nix uses a / foo\bar\baz # Win32 uses a \ foo:bar:baz # Mac OS 9 uses a : foo/bar/baz # Mac OS X uses a / (usually!) In Perl you can generally...
0
4,200
How to direct a browser to display a different HTML page This is actually very simple to do in a CGI script. Instead of the usual header Content-type: text/html #make your script print this Location: URL to display #Don't forget the blank line afterwards. -or- print...
0
8,947
Many times we need to check whether a number is negative or not, here is a very simple subroutine to do that. sub isNegative { my($checkValue) = @_; if(abs($checkValue) != $checkValue) { # the value is negative return 1; }
0
8,875
At some point while writing a CGI script in Perl, many newbies have needed to print all the environment varibles in Perl, sometimes for debugging or for the sake of curiosity. Well, here is the code to print all the CGI environment variables. #!/usr/bin/perl print "Content-type:...
1
3,934
There is a function ucwords() in PHP which capitalizes the first letter of each word. <? $str = "programming forums"; $str = ucwords($str); // now $str = "Programming Forums" ?> I have written a sub-routine in Perl, which gives the same functionality.
1
8,224
When your script writes to a new file, you probably want it to create a new and unique name for the new file, one that doesn't conflict with any existing files, which would be overwritten. One way to create a new file name that's unique is to incorporate the process id and the time into the name....
7
9,372
Introduction Perl is renowned for being a language where you can express complicated commands in a very small amount of space. We'll start with the simplest of programs, which simply reads in characters from the keyboard and repeats them back to the console. In Perl you might write this...
1
5,175
List of common file extensions and their corresponding MIME types in a hash, which can be quite use at times. %mime_types = {'.ai','application/postscript', '.aif','audio/x-aiff', '.aifc','audio/x-aiff', '.aiff','audio/x-aiff', '.asc','text/plain', '.au','audio/basic', ...
1
3,266
Introduction If you're like most people, you probably have a bunch of MP3s scattered around your hard disk. And if you're like most people, you probably also have on your to-do list a plan to inspect and catalog them so that you know exactly what you're listening to. It's just that you...
0
7,451
Everyone knows that Perl is extremely fast when it comes to handling regular expressions and text processing... but have you ever wondered how fast is extremely fast? Well, one of the toys us big kids have at our disposal is the Perl Benchmark module, which lets you test the speed of a Perl script....
0
7,366
I am assuming from now on that you are familiar with substitution operator in perl: s///. A basic example: $str =~ s/apple/orange/; would replace the word "apple" with the word "orange". The separator "/" we used in this example can be replaced with any other non...
0
26,467
Introduction CSV is a comma separated value data file is a physical ASCII file structure that contains records whose values are delimited or separated by commas. CSV is a common file type which can be imported into spreadsheet applications such as MS-Excel, database applications such as...
0
39,309
Introduction POP3 stands for Post Office Protocol version 3, it's application layer Internet Protocol used by various desktop email clients, and web-based email services to fetch email from a remote server over a TCP/IP connection. Until sometime back POP3 was the de facto standard for email...
0
14,879
Introduction May times we require to check whether a process is running or not, may be for the purpose of maintaining a lock file for a process or for some other reason. Here today we'll discuss a technique in which we can do this checking provided the process/pid being checked is checked is...
8
19,323
As Perl programmer we might want to shoot off a mail for some reason or the other, especially if we've used Perl for the web. Perl being such a powerful language, it's can do virtually anything you want to do with it. Sending a mail is a piece of cake, be it using sendmail or using SMTP. CPAN is a...
10
19,484
A very common technique used by many developers is to redirect the user to another URL or the referrer URL after doing some work e.g. processing a form. In Perl all headers have to printed before any actual content is outputed. A very simple way of redirecting to another URL #!/usr/bin/perl ...
3
14,457
Working with dates is a very common feature of any application, be it a web app or a desktop one. Some people consider Perl to be a language where working with dates is hard, but basically it's quite easy if you know how to. Datetime is a common term while refering to date and time together. ...
6
151,736
Introduction We all write programs to run on the terminal to do jobs that take time, like processing logs, sending out newsletter, etc. To know the progress of our task we print some messages to know our program is running well and doing its job. But wouldn't it be nice if we could add a...
5
13,669
Ceil in Perl Cieling is basically outputing the next largest integer for an given real number. ceiling(x) is the smallest integer not less than x Ways to do it in Perl, a) using our own logic my $num = 45.4; my $ceil = int($num + 0.99);
3
72,774
JSON has become a popular data representation format, and can been seen as the successor of XML which used to be the most popular format used for data exchange between systems. Notable examples of JSON being used for data representation are Facebook Graph API & Flickr API, amongst many others....
0
9,025