Perl highlights
Perl - The only language that looks the same before and after RSA encryption. (Keith Bostic)
Array size
$l = scalar(@array)
$#array
Replace substring
$rez=($initial_value=~s/$to_be_changed/$replacement/g );
Processing binary file
my $file="myfile.dat";
open(F, "< $file") or die "Unable to open filen";
binmode(F);
my $buf;
# blocksize = 1024 bytes
while($buf=sysread(F, $buf, 1024)){
# processing $buf
print $buf;
}
close(F);
Combining shell and perl
#!/bin/bash
# bashperl.sh
echo "This is bash code."
### ( -x strips off text before #!perl line )
#
perl -x bashperl.sh
# Some other bash commands
exit 0
# End of Bash part of the script.
# =======================================================
#!/usr/bin/perl
print "This is perl code.\n";
# some other perl commands
# End of Perl part of the script.
|