next
#!/usr/bin/perl -w # iterate a block prematurely perldoc5.8.0
no
#!/usr/bin/perl -w # unimport some module symbols or semantics at compile time perldoc5.8.0
oct
#!/usr/bin/perl -w # convert a string to an octal number perldoc5.8.0
open
#!/usr/bin/perl -w # open a file, pipe, or descriptor perldoc5.8.0
opendir
#!/usr/bin/perl -w # open a directory perldoc5.8.0
ord
#!/usr/bin/perl -w # find a character's numeric representation perldoc5.8.0
pack
#!/usr/bin/perl -w # convert a list into a binary representation perldoc5.8.0
package
#!/usr/bin/perl -w # declare a separate global namespace perldoc5.8.0
pipe
#!/usr/bin/perl -w # open a pair of connected filehandles perldoc5.8.0
pop
#!/usr/bin/perl -w # remove the last element from an array and return it perldoc5.8.0
pos
#!/usr/bin/perl -w # find or set the offset for the last/next m//g search perldoc5.8.0
print
#!/usr/bin/perl -w open (OUT,">test.txt"); print OUT '*' x 20, "\n"; print OUT <STDIN>; close(OUT); ******************** line for testing @ary = (one, two, three); print @ary, "\n"; print "@ary\n"; print "$ary[1]\n"; print ((2+3) ** 2 ) . "\n"; OUTPUT: onetwothree one two three two 25 perldoc5.8.0
printf
#!/usr/bin/perl -w my $val = 23.12345; my $mes = "value ="; printf ("%.2f\n", $val); printf STDOUT "%s %.2f\n\n", $mes, $val; my $format = "%-12s %-12s %.2f\n"; my @ary = ( [qw(Anatoliy Urbanskiy 12.345)], [qw(Seva Urbanskiy 11.456)] ); for ( @ary ) { printf $format, @{$_}; } OUTPUT: 23.12 value = 23.12 Anatoliy Urbanskiy 12.35 Seva Urbanskiy 11.46 perldoc5.8.0
prototype
#!/usr/bin/perl -w # get the prototype of a subroutine perldoc5.8.0
push
#!/usr/bin/perl -w # append one or more elements to an array perldoc5.8.0
q
#!/usr/bin/perl -w # singly quote a string perldoc5.8.0
qq
#!/usr/bin/perl -w # doubly quote a string perldoc5.8.0
qr
#!/usr/bin/perl -w # quote a list of words perldoc5.8.0
quotemeta
#!/usr/bin/perl -w # quote regular expression magic characters perldoc5.8.0
qx
#!/usr/bin/perl -w # backquote quote a string perldoc5.8.0
rand
#!/usr/bin/perl -w # retrieve the next pseudorandom number perldoc5.8.0
read
#!/usr/bin/perl -w # fixed-length buffered input from a filehandle perldoc5.8.0
readdir
#!/usr/bin/perl -w # get a directory from a directory handle perldoc5.8.0
readline
#!/usr/bin/perl -w # fetch a record from a file perldoc5.8.0
readlink
#!/usr/bin/perl -w # determine where a symbolic link is pointing perldoc5.8.0
recv
#!/usr/bin/perl -w # receive a message over a Socket perldoc5.8.0
redo
#!/usr/bin/perl -w # start this loop iteration over again perldoc5.8.0
ref
#!/usr/bin/perl -w # find out the type of thing being referenced perldoc5.8.0
rename
#!/usr/bin/perl -w # change a filename perldoc5.8.0
require
#!/usr/bin/perl -w # load in external functions from a library at runtime perldoc5.8.0
reset
#!/usr/bin/perl -w # clear all variables of a given name perldoc5.8.0
return
#!/usr/bin/perl -w # get out of a function early perldoc5.8.0
reverse
#!/usr/bin/perl -w # flip a string or a list perldoc5.8.0
rewinddir
#!/usr/bin/perl -w # reset directory handle perldoc5.8.0
rindex
#!/usr/bin/perl -w # right-to-left substring search perldoc5.8.0
rmdir
#!/usr/bin/perl -w # remove a directory perldoc5.8.0
scalar
#!/usr/bin/perl -w # force a scalar context perldoc5.8.0
seek
#!/usr/bin/perl -w # reposition file pointer for random-access I/O perldoc5.8.0
seekdir
#!/usr/bin/perl -w # reposition directory pointer perldoc5.8.0
select
#!/usr/bin/perl -w # returns the currently selected filehandle. # sets the current default filehandle for output. perldoc5.8.0
semctl
#!/usr/bin/perl -w # SysV semaphore control operations perldoc5.8.0
semget
#!/usr/bin/perl -w # get set of SysV semaphores perldoc5.8.0
semop
#!/usr/bin/perl -w # SysV semaphore operations perldoc5.8.0
send
#!/usr/bin/perl -w # send a message over a socket perldoc5.8.0
setgrent
#!/usr/bin/perl -w # prepare group file for use perldoc5.8.0
sethostent
#!/usr/bin/perl -w # prepare hosts file for use perldoc5.8.0
setnetent
#!/usr/bin/perl -w # prepare networks file for use perldoc5.8.0
setpgrp
#!/usr/bin/perl -w # set the process group of a process perldoc5.8.0
setpriority
#!/usr/bin/perl -w # set a process's nice value perldoc5.8.0
setprotoent
#!/usr/bin/perl -w # prepare protocols file for use perldoc5.8.0
setpwent
#!/usr/bin/perl -w # prepare passwd file for use perldoc5.8.0
setservent
#!/usr/bin/perl -w # prepare services file for use perldoc5.8.0
setsockopt
#!/usr/bin/perl -w # set some socket options perldoc5.8.0
shift
#!/usr/bin/perl -w # remove the first element of an array, and return it perldoc5.8.0
shmctl
#!/usr/bin/perl -w # SysV shared memory operations perldoc5.8.0
shmget
#!/usr/bin/perl -w # get SysV shared memory segment identifier perldoc5.8.0
shmread
#!/usr/bin/perl -w # read SysV shared memory perldoc5.8.0
shmwrite
#!/usr/bin/perl -w # write SysV shared memory perldoc5.8.0
shutdown
#!/usr/bin/perl -w # close down just half of a socket connection perldoc5.8.0
sin
#!/usr/bin/perl -w # return the sine of a number perldoc5.8.0
sleep
#!/usr/bin/perl -w # block for some number of seconds perldoc5.8.0
socket
#!/usr/bin/perl -w # create a socket perldoc5.8.0
socketpair
#!/usr/bin/perl -w # create a pair of sockets perldoc5.8.0
sort
#!/usr/bin/perl -w # sort a list of values my @files = qw(one two three); # sort lexically my @sorted = sort @files; print "@sorted\n"; # same thing, but with explicit sort routine @sorted = sort {$a cmp $b} @files; print "@sorted\n"; # same thing in reversed order @sorted = sort {$b cmp $a} @files; print "@sorted\n\n"; my @num = qw(12 4 6 2 1 14); # sort numerically ascending @sorted = sort {$a <=> $b} @num; print "@sorted\n"; # sort numerically descending @sorted = sort {$b <=> $a} @num; print "@sorted\n"; # sort using explicit subroutine name sub bynumber { $a <=> $b; } @sorted = sort bynumber @num; print "@sorted\n\n"; # sorted hash by kyes my %hash = ( "one"=>1, "two"=>2, "three"=>3, "four"=>4 ); for ( sort { $a cmp $b } keys ( %hash ) ) { print "$_ => $hash{$_}\n"; } # sorted hash by values for ( sort { $hash{$a} <=> $hash{$b} } keys ( %hash ) ) { print "$hash{$_} => $_\n"; } print "\n"; # sorting by particular field my $family = [ [qw(ana 44)], [qw(ada 44)], [qw(lana 41)], [qw(vlad 11)] ]; print map { $_->[1] ," ", $_->[0], "\n"; } sort { $a->[1] <=> $b->[1] || $a->[0] cmp $b->[0] } @{ $family }; OUTPUT: one three two one three two two three one 1 2 4 6 12 14 14 12 6 4 2 1 1 2 4 6 12 14 four => 4 one => 1 three => 3 two => 2 1 => one 2 => two 3 => three 4 => four 11 vlad 41 lana 44 ada 44 ana perldoc5.8.0
splice
#!/usr/bin/perl -w # add or remove elements anywhere in an array # splice (ARRAY,OFFSET); # splice (ARRAY,OFFSET,LENGTH); # splice (ARRAY,OFFSET,LENGTH,LIST); my @ary = qw( 1 2 3 4 5 6 7 8 9 ); print "ARY: @ary\n"; my @removed = splice(@ary,7); print "ARY: @ary, REM: @removed\n"; @removed = splice(@ary,2,3); print "ARY: @ary, REM: @removed\n"; my @list = qw( 23 24 ); @removed = splice(@ary,1,1,@list); print "ARY: @ary, LIST: @list, REM: @removed\n"; my @removed = splice(@ary,-3); print "ARY: @ary, REM: @removed\n"; OUTPUT: ARY: 1 2 3 4 5 6 7 8 9 ARY: 1 2 3 4 5 6 7, REM: 8 9 ARY: 1 2 6 7, REM: 3 4 5 ARY: 1 23 24 6 7, LIST: 23 24, REM: 2 ARY: 1 23, REM: 24 6 7 perldoc5.8.0
split
#!/usr/bin/perl -w # split up a string using a regexp delimiter # split("DELIMETER",EXPR,LIMIT); # split(/DELIMETER/,EXPR,LIMIT); # split(/DELIMETER/,EXPR); # split("DELIMETER",EXPR); # split(/DELIMETER/); # split my $str = "two=>2 one=>1 three=>3"; my %hash = split(/\s+|=>/,$str); foreach my $key ( sort { $hash{$a} <=> $hash{$b} } keys (%hash) ) { print "$hash{$key} : $key\n"; } my $name = "Anatoliy"; print map { $_,"-" } split(// => $name); print "\n", "=" x 20, "\n"; $str = "1one2two3three4four"; print map { $_, " " } split(/\d+/ => $str); print "\n", "=" x 20, "\n"; $str = "one two three four"; my @ary = split(/\s+/,$str, 3); for ( @ary ) { print "$_\n"; } OUTPUT: 1 : one 2 : two 3 : three A-n-a-t-o-l-i-y- ==================== one two three four ==================== one two three four perldoc5.8.0
sprintf
#!/usr/bin/perl -w # formatted print into a string perldoc5.8.0
sqrt
#!/usr/bin/perl -w # square root function perldoc5.8.0
srand
#!/usr/bin/perl -w # seed the random number generator perldoc5.8.0
stat
#!/usr/bin/perl -w # get a file's status information perldoc5.8.0
study
#!/usr/bin/perl -w # optimize input data for repeated searches perldoc5.8.0
sub
#!/usr/bin/perl -w # declare a subroutine, possibly anonymously perldoc5.8.0
substitution
#!/usr/bin/perl -w # replace a pattern with a string perldoc5.8.0
substr
#!/usr/bin/perl -w # get or alter a portion of a stirng perldoc5.8.0
symlink
#!/usr/bin/perl -w # create a symbolic link to a file perldoc5.8.0
syscall
#!/usr/bin/perl -w # execute an arbitrary system call perldoc5.8.0
sysread
#!/usr/bin/perl -w # fixed-length unbuffered input from a filehandle perldoc5.8.0
sysseek
#!/usr/bin/perl -w # position I/O pointer on handle used with sysread and syswrite perldoc5.8.0
system
#!/usr/bin/perl -w # run a separate program perldoc5.8.0
syswrite
#!/usr/bin/perl -w # syswrite FILEHANDLE,SCALAR,LENGTH,OFFSET # syswrite FILEHANDLE,SCALAR,LENGTH # syswrite FILEHANDLE,SCALAR # # writes LENGTH characters of data from # variable SCALAR to the specified FILEHANDLE. perldoc5.8.0
tell
#!/usr/bin/perl -w # get current seekpointer on a filehandle perldoc5.8.0
telldir
#!/usr/bin/perl -w # get current seekpointer on a directory handle perldoc5.8.0
tie
#!/usr/bin/perl -w # bind a variable to an object class perldoc5.8.0
time
#!/usr/bin/perl -w # return number of seconds since 1970 perldoc5.8.0
times
#!/usr/bin/perl -w # return elapsed time for self and child processes perldoc5.8.0
tr
#!/usr/bin/perl -w # transliterate a string perldoc5.8.0
truncate
#!/usr/bin/perl -w # shorten a file perldoc5.8.0
uc
#!/usr/bin/perl -w # return upper-case version of a string perldoc5.8.0
ucfirst
#!/usr/bin/perl -w # return a string with just the next letter in upper case perldoc5.8.0
umask
#!/usr/bin/perl -w # set file creation mode mask perldoc5.8.0
undef
#!/usr/bin/perl -w # remove a variable or function definition perldoc5.8.0
unlink
#!/usr/bin/perl -w # remove one link to a file perldoc5.8.0
unpack
#!/usr/bin/perl -w # convert binary structure into normal perl variables my $pass = q(abcdcb2$accc); print "Password: $pass\n\n"; # to validate password string # cann't be abc || bca || aaa while ( $pass =~ /(?=([a-zA-Z]{3}))/g ) { my ($a,$b,$c) = unpack "c3", $1; if ( (($a + $c) == 2 * $b) && (abs($b - $a) <= 1) ) { print "$1 INVALID siquances\n"; } else { print "$1 VALID\n"; } } OUTPUT: Password: abcdcb2$accc abc INVALID siquances bcd INVALID siquances cdc VALID dcb INVALID siquances acc VALID ccc INVALID siquances perldoc5.8.0
unshift
#!/usr/bin/perl -w # prepend more elements to the beginning of a list perldoc5.8.0
untie
#!/usr/bin/perl -w # break a tie binding to a variable perldoc5.8.0
use
#!/usr/bin/perl -w # load in a module at compile time perldoc5.8.0
utime
#!/usr/bin/perl -w # set a file's last access and modify times perldoc5.8.0
values
#!/usr/bin/perl -w # return a list of the values in a hash perldoc5.8.0
vec
#!/usr/bin/perl -w # test or set particular bits in a string perldoc5.8.0
wait
#!/usr/bin/perl -w # wait for any child process to die perldoc5.8.0
waitpid
#!/usr/bin/perl -w # wait for a particular child process to die perldoc5.8.0
wantarray
#!/usr/bin/perl -w # get void vs scalar vs list context of current subroutine call perldoc5.8.0
warn
#!/usr/bin/perl -w # print debugging info perldoc5.8.0
write
#!/usr/bin/perl -w # write FILEHANDLE # Writes a formatted record to the specified FILEHANDLE. perldoc5.8.0