Search notes:

Perl cheat sheet

pwd

Using Cwd and getcwd:
use Cwd;
my $cwd = getcwd();

Files

Extract suffix/extension from a file

my ($extension) = $filename =~ /(\.[^.]*$)/;
Using Perl module File::Basename and fileparse.
use File::Basename;
my ($file_without_suffix, $directory, $suffix) = fileparse ('/foo/bar/baz/file.pl', qr/\..[^.]*$/);

Get a relative file path

use File::Spec;

my $full_path = '/absoulte/path/to/a/file';
my $path      = '/absoulte/path';

my $relative_path=File::Spec->abs2rel($full_path, $path);
print $relative_path;
# prints:
#   to/a/file

Processing command line options

Use Perl module Getopt::Long
use Getopt::Long;

GetOptions(
    'option'  => \my $option,
    'v'       => \my $verbose,
    'help'    => \my $help
);

if ($option) {
   ...
}

See also

Perl

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758193826, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Perl/cheat-sheet(90): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78