Perl Basics
Introduction to Perl
FAQ's
CGI
Regular Expressions

PC Overview
Cool Stuff
My Modules
Success Stories
Links
Perl in the News
Logos
Perl @ msn
Perl Chat

PC Internals
About
Contact
Guest Book
Handy Logos
What's new

Built-in functions

Perl is an interpreted language optimized for scanning arbitrary text files, extracting information from those text files, and printing reports based on that information.
See also
P-friendly

[ home ] - [ search ] - [ sitemap ]

Built-in Functions

Reference Title Sample Code
R1013DBM - Berkeley Database "Runs on NT and Unix!"

use strict;

my ($key, $val, %MYDB);

dbmopen %MYDB, "mydbm", 0666;

while (($key, $val) = each %MYDB)
{
        print $key, " = ", $val, "\n";
R1059File::Find
#!/usr/bin/perl -w

use strict;

use File::Find;

find(\&wanted, 'd:\hersi_pu');

sub wanted {
        return if -d;...
R1064How do I open a file without blocking?
use Fcntl;
sysopen(FH, "/tmp/somefile", O_WRONLY[CHR_PIPE]O_NDELAY[CHR_PIPE]O_CREAT, 0644) or die "can't open /tmp/somefile: $!";
R1063How to start a Perl Module? #!/usr/local/bin/perl -w
use strict;

use XMLSimple;


my $xml = new XMLSimple (ref => 'ABC');


my $res = $xml->parse(verbose => 1, debug => 1);


print "\$res = '...
R1058Locate a position of a substring my $string = 'Hello, World';
my $lookfor = 'o';
my $from = 5;


my $pos = index($string, $lookfor, $from);


print "'$lookfor' is at position $pos of string '$string'\n";
R1038Perl Form / Reporting with Perl  
R1001Random Numbers srand();
my $X = int(rand(10)+1);
print $X;


Let's say you have an array of somethings - for instance sequences of letters (also known as strings). And let's also say you want to pick...
R1031String Encryption

$crypted = crypt("hello", 'az'); # ---> 2AuDleQw6eOSg

print "Password?\n"; $try = <STDIN>; chop $try;

if (crypt($try, '2AuDleQw6eOSg') eq '2AuDleQw6eOSg') {
&n...
R1031Timestamps of a file #!/usr/bin/perl -w

use strict;

my ($atime, $mtime, $ctime) = (stat('test.txt'))[8..10];

printf qq~
Accessed: %s
Modified: %s
Created: %s
~,
get_real_t...
R1051Usage of pack() and unpack() --> hex FF = 255
--> unpack(C, 'A') = 65
--> unpack(C, 'L') = 76
--> unpack(H8,'HALLO') = 48414c4c
--> unpack(B8,'A') = 01000001

--> pack(cccc, 65,66,67,68) = ABCD

Entry 1 to 10 of 12
home - feedback - search - web jobs
© 1998-2004 retoh :)