The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

CTK::Util - CTK Utilities

VERSION

Version 2.81

SYNOPSIS

    use CTK::Util;
    use CTK::Util qw( :BASE ); # Export only BASE subroutines. See TAGS section

    my @ls = ls(".");

DESCRIPTION

Public utility functions. No function is not exported by default!

FUNCTIONS

All subroutines are listed in alphabetical order

basetime

    $secs = basetime();

The time at which the program began running, in seconds. This function returns result of expression:

    time() - $^T

Tags: BASE, DATE

bload, file_load

    $bindata = bload( $file_or_fh, $onutf8 );

Reading file in binary mode as ':raw:utf8' layer (if $onutf8 is true) or regular binary layer.

Tags: BASE, FILE, ATOM

bsave, file_save

    $status = bsave( $file_or_fh, $bindata, $onutf8 );

Saving file in binary mode as ':raw:utf8' layer (if $onutf8 is true) or regular binary layer.

Tags: BASE, FILE, ATOM

cachedir

    my $value = cachedir();

For example value can be set as: /var/cache

/var/cache is intended for cached data from applications. Such data is locally generated as a result of time-consuming I/O or calculation. The application must be able to regenerate or restore the data. Unlike /var/spool, the cached files can be deleted without data loss. The data must remain valid between invocations of the application and rebooting the system.

Files located under /var/cache may be expired in an application specific manner, by the system administrator, or both. The application must always be able to recover from manual deletion of these files (generally because of a disk space shortage). No other requirements are made on the data format of the cache directories.

See http://www.pathname.com/fhs/pub/ and "cachedir" in Sys::Path

Tags: CORE, BASE, FILE

cdata

    $cdatatext = cdata( $text );

Returns a string "<![CDATA[$text]]>" for plain XML documents.

Tags: BASE, FORMAT

correct_date

    $mydate = correct_date( $date );

Returns date in format dd.mm.yyyy or null ('') if $date is wrongly.

Tags: BASE, DATE

correct_dig

    $mydig = correct_dig( $string );

Returns digits only from string or 0 if string is not correctly.

Tags: BASE, FORMAT

correct_number

    $mynumber = correct_number( $string, $sep );

Placement of separators discharges among digits. For example 1`234`567 if $sep is char "`" (default)

Tags: BASE, FORMAT

current_date

    $date = current_date();

Returns current date in format dd.mm.yyyy

Tags: BASE, DATE

current_date_time

    $datetime = current_date_time();

Returns current date in format dd.mm.yyyy hh.mm.ss

Tags: BASE, DATE

date2dig

    $dd = date2dig( $date );

Returns $date (or current) in format yyyymmdd

Tags: BASE, DATE

date2localtime

    $time = date2localtime( $date );

Returns time from date format dd.mm.yyyy in time() value in seconds since the system epoch (Midnight, January 1, 1970 GMT on Unix, for example).

See "timelocal" in Time::Local

Tags: BASE, DATE

datef

See "dtf"

Tags: BASE, DATE

date_time2dig

    $dtd = date_time2dig( $datetime );

Returns $datetime (or current) in format yyyymmddhhmmss

Tags: BASE, DATE

datetime2localtime

    $time = datetime2localtime( $datetime );

Returns time from datetime format dd.mm.yyyy hh.mm.ss in time() value in seconds since the system epoch (Midnight, January 1, 1970 GMT on Unix, for example).

See "timelocal" in Time::Local

Tags: BASE, DATE

datetimef

See "dtf"

Tags: BASE, DATE

dformat

    $string = dformat( $mask, \%replacehash );

Replace substrings "[...]" in mask and returns replaced result. Data for replacing get from \%replacehash

For example:

    # -> 01-foo-bar.baz.tgz
    $string = dformat( "01-[NAME]-bar.[EXT].tgz", {
                NAME => 'foo',
                EXT  => 'baz',
            } );

See also "fformat" for working with files

Tags: BASE, FORMAT

dig2date

    $date = dig2date_time( $dd );

Returns date (or current) from format yyyymmdd in format dd.mm.yyyy

Tags: BASE, DATE

dig2date_time

    $datetime = dig2date_time( $dtd );

Returns date (or current) from format yyyymmddhhmmss in format dd.mm.yyyy hh.mm.ss

Tags: BASE, DATE

docdir

    my $value = docdir();

For example value can be set as: /usr/share/doc

See "docdir" in Sys::Path

Tags: CORE, BASE, FILE

dtf

    $datetime = dtf( $format, $time );
    $datetime = dtf( $format, $time, 1 ); # in GMT context
    $datetime = dtf( $format, $time, 'MSK' ); # TimeZone (Z) = MSK
    $datetime = dtf( $format, $time, 'GMT' ); # TimeZone (Z) = GMT

Returns time in your format. Each conversion specification is replaced by appropriate characters as described in the following list.

    s, ss, _s - Seconds
    m, mm, _m - Minutes
    h, hh, _h - Hours
    D, DD, _D - Day of month
    M, MM, _M - Month
    Y, YY, YYY, YYYY - Year
    w       - Short form of week day (Sat, Tue and etc)
    W       - Week day (Saturdat, Tuesday and etc)
    MON, mon - Short form of month (Apr, May and etc)
    MONTH, month - Month (April, May and etc)
    Z       - short name of local TimeZone
    G       - short name of TimeZone GMT (for GMT context only)
    U       - short name of TimeZone UTC (for GMT context only)

Examples:

    # RFC822 (RSS)
    $dt = dtf("%w, %D %MON %YY %hh:%mm:%ss %G", time(), 1); # Tue, 3 Sep 2013 12:31:40 GMT

    # RFC850
    $dt = dtf("%W, %DD-%MON-%YY %hh:%mm:%ss %G", time(), 1); # Tuesday, 03-Sep-13 12:38:41 GMT

    # RFC1036
    $dt = dtf("%w, %D %MON %YY %hh:%mm:%ss %G", time(), 1); # Tue, 3 Sep 13 12:44:08 GMT

    # RFC1123
    $dt = dtf("%w, %D %MON %YYYY %hh:%mm:%ss %G", time(), 1); # Tue, 3 Sep 2013 12:50:42 GMT

    # RFC2822
    $dt = dtf("%w, %DD %MON %YYYY %hh:%mm:%ss +0400"); # Tue, 12 Feb 2013 16:07:05 +0400
    $dt = dtf("%w, %DD %MON %YYYY %hh:%mm:%ss ".tz_diff());

    # W3CDTF, ATOM (Same as RFC 3339/ISO 8601) -- Mail format
    $dt = dtf("%YYYY-%MM-%DDT%hh:%mm:%ss+04:00"); # 2013-02-12T16:10:28+04:00

    # CTIME
    $dt = dtf("%w %MON %_D %hh:%mm:%ss %YYYY"); # Tue Feb  2 16:15:18 2013

    # CTIME with TimeZone
    $dt = dtf("%w %MON %_D %hh:%mm:%ss %YYYY %Z", time(), 'MSK'); # Tue Feb 12 17:21:50 2013 MSK

    # Russian date and time format
    $dt = dtf("%DD.%MM.%YYYY %hh:%mm:%ss"); # 12.02.2013 16:16:53

    # DIG form
    $dt = dtf("%YYYY%MM%DD%hh%mm%ss"); # 20130212161844

    # HTTP headers format (See CGI::Util::expires)
    $dt = dtf("%w, %DD %MON %YYYY %hh:%mm:%ss %G", time, 1); # Tue, 12 Feb 2013 13:35:04 GMT

    # HTTP/cookie format (See CGI::Util::expires)
    $dt = dtf("%w, %DD-%MON-%YYYY %hh:%mm:%ss %G", time, 1); # Tue, 12-Feb-2013 13:35:04 GMT

    # COOKIE (RFC2616 as rfc1123-date)
    $dt = dtf("%w, %DD %MON %YYYY %hh:%mm:%ss %G", time, 1); # Tue, 12 Feb 2013 13:35:04 GMT

For more features please use Date::Format and DateTime

Tags: BASE, DATE

eqtime

    eqtime("source/file", "destination/file");

Sets modified time of destination to that of source.

Tags: BASE, FILE, ATOM

escape

    $safe = escape("10% is enough\n");

Replaces each unsafe character in the string "10% is enough\n" with the corresponding escape sequence and returns the result. The string argument should be a string of bytes.

See also URI::Escape

Tags: BASE, FORMAT

execute, exe

    $out = execute( "ls -la" );
    $out = execute( "ls -la", $in, \$err, $binmode );

Executing external (system) command with IPC::Open3 using.

Variables $in, $err and $binmode is OPTIONAL.

$binmode set up binary mode layer as ':raw:utf8' layer (if $binmode is ':raw:utf8', for example) or regular binary layer (if $binmode is true).

See also IPC::Open3

Tags: UTIL, EXT, ATOM

fformat

    $file = fformat( $mask, $filename );

Replace substrings "[FILENAME]", "[NAME]", "[FILEEXT]", "[EXT]" and "[FILE]" in mask and returns replaced result. Data for replacing get from filename:

    [FILENAME] -- Fileneme only
    [NAME]     -- Fileneme only
    [FILEEXT]  -- Extension only
    [EXT]      -- Extension only
    [FILE]     -- = "[FILENAME].[FILEEXT]" ($filename)

For example:

    $file = fformat( "01-[NAME]-bar.[EXT].tgz", "foo.baz" ); # -> 01-foo-bar.baz.tgz

See also "dformat"

Tags: BASE, FORMAT

file_lf_normalize, file_nl_normalize

    file_lf_normalize( "file.txt" ) or die("Can't normalize file");

Runs "lf_normalize" for every string of the file and save result to this file

Tags: BASE, FORMAT

fload, load_file

    $textdata = fload( $file );

Reading file in regular text mode

Tags: BASE, FILE, ATOM

from_utf8

    $win1251_text = from_utf8( $utf8_text )
    $win1251_text = from_utf8( $utf8, "Windows-1251" )

Encodes a string from Perl's internal form into ENCODING and returns a sequence of octets. ENCODING can be either a canonical name or an alias. For encoding names and aliases, see Encode.

Tags: BASE, FORMAT

fsave, save_file

    $status = fsave( $file, $textdata );

Saving file in regular text mode

Tags: BASE, FILE, ATOM

ftp

    %ftpct = (
        ftphost     => '192.168.1.1',
        ftpuser     => 'login',
        ftppassword => 'password',
        ftpdir      => '~/',
        voidfile    => './void.txt',
        #ftpattr    => {}, # See Net::FTP
    );

    $ftpct  = ftp( \%ftpct, 'connect' ); # Returns the connect's object
    $rfiles = ftp( \%ftpct, 'ls' ); # Returns reference to array of directory listing
    @remotefiles = $rfiles ? grep {!(/^\./)} @$rfiles : ();

    ftp( \%ftpct, 'delete', $rfile ); # Delete remote file
    ftp( \%ftpct, 'get', $rfile, $lfile ); # Get remote file to local file
    ftp( \%ftpct, 'put', $lfile, $rfile ); # Put local file to remote file

Simple working with FTP.

See also Net::FTP

Tags: UTIL, EXT, ATOM

ftpgetlist

    $rfiles = ftpgetlist( \%ftpct, $mask);

Returns reference to array of remote source listing by mask (as regexp, optional)

See "ftp"

Tags: UTIL, EXT, ATOM

ftptest

    $status = ftptest( \%ftpct );

FTP connect testing.

See "ftp"

Tags: UTIL, EXT, ATOM

getdirlist

    $listref = getdirlist( $dir, $mask );

Returns reference to array directories of directory $dir by $mask (regexp or scalar string).

See also "ls"

Tags: BASE, FILE, ATOM

getfilelist, getlist

    $listref = getlist( $dir, $mask );

Returns reference to array files of directory $dir by $mask (regexp or scalar string).

See also "ls"

Tags: BASE, FILE, ATOM

getsyscfg, syscfg

Returns all hash %Config from system module Config or one value of this hash

    my %syscfg = syscfg();
    my $prefix = syscfg( "prefix" );

See Config module for details

Tags: API, BASE

isos

Returns true or false if the OS name is of the current value of $^O

    isos('mswin32') ? "OK" : "NO";

See Perl::OSType for details

Tags: API, BASE

isostype

Given an OS type and OS name, returns true or false if the OS name is of the given type.

    isostype('Windows') ? "OK" : "NO";
    isostype('Unix', 'dragonfly') ? "OK" : "NO";

See "is_os_type" in Perl::OSType

Tags: API, BASE

isFalseFlag

    print "Disabled" if isFalseFlag("off");

If specified argument value is set to false then will be normalised to 1.

The following values will be considered as false:

    no, off, 0, false, disable

This effect is case-insensitive, i.e. both "No" or "no" will result in 1.

Tags: BASE, UTIL

isTrueFlag

    print "Enabled" if isTrueFlag("on");

If specified argument value is set to true then will be normalised to 1.

The following values will be considered as true:

    yes, on, 1, true, enable

This effect is case-insensitive, i.e. both "Yes" or "yes" will result in 1.

Tags: BASE, UTIL

lf_normalize, nl_normalize

    my $normalized_string = lf_normalize( $string );

Returns CR/LF normalized string

Tags: BASE, FORMAT

localedir

    my $value = localedir();

For example value can be set as: /usr/share/locale

See "localedir" in Sys::Path

Tags: CORE, BASE, FILE

localstatedir

    my $value = localstatedir();

For example value can be set as: /var

/var - $Config::Config{'prefix'}

/var contains variable data files. This includes spool directories and files, administrative and logging data, and transient and temporary files. Some portions of /var are not shareable between different systems. For instance, /var/log, /var/lock, and /var/run. Other portions may be shared, notably /var/mail, /var/cache/man, /var/cache/fonts, and /var/spool/news.

/var is specified here in order to make it possible to mount /usr read-only. Everything that once went into /usr that is written to during system operation (as opposed to installation and software maintenance) must be in /var. If /var cannot be made a separate partition, it is often preferable to move /var out of the root partition and into the /usr partition. (This is sometimes done to reduce the size of the root partition or when space runs low in the root partition.) However, /var must not be linked to /usr because this makes separation of /usr and /var more difficult and is likely to create a naming conflict. Instead, link /var to /usr/var.

Applications must generally not add directories to the top level of /var. Such directories should only be added if they have some system-wide implication, and in consultation with the FHS mailing list.

See http://www.pathname.com/fhs/pub/ and "localstatedir" in Sys::Path

Tags: CORE, BASE, FILE

localtime2date

    $date = localtime2date( time() )

Returns time in format dd.mm.yyyy

Tags: BASE, DATE

localtime2date_time

    $datetime = localtime2date_time( time() )

Returns time in format dd.mm.yyyy hh.mm.ss

Tags: BASE, DATE

lockdir

    my $value = lockdir();

For example value can be set as: /var/lock

Lock files should be stored within the /var/lock directory structure. Lock files for devices and other resources shared by multiple applications, such as the serial device lock files that were originally found in either /usr/spool/locks or /usr/spool/uucp, must now be stored in /var/lock. The naming convention which must be used is "LCK.." followed by the base name of the device. For example, to lock /dev/ttyS0 the file "LCK..ttyS0" would be created. 5

The format used for the contents of such lock files must be the HDB UUCP lock file format. The HDB format is to store the process identifier (PID) as a ten byte ASCII decimal number, with a trailing newline. For example, if process 1230 holds a lock file, it would contain the eleven characters: space, space, space, space, space, space, one, two, three, zero, and newline.

See http://www.pathname.com/fhs/pub/ and "lockdir" in Sys::Path

Tags: CORE, BASE, FILE

ls

    @list = ls( $dir);
    @list = ls( $dir, $mask );

A function returns list content of directory $dir by $mask (regexp or scalar string)

Tags: BASE, FILE, ATOM

prefixdir

    my $value = prefixdir();

For example value can be set as: /usr

/usr - $Config::Config{'prefix'}

Is a helper function and should not be used directly.

/usr is the second major section of the filesystem. /usr is shareable, read-only data. That means that /usr should be shareable between various FHS-compliant hosts and must not be written to. Any information that is host-specific or varies with time is stored elsewhere.

Large software packages must not use a direct subdirectory under the /usr hierarchy.

See http://www.pathname.com/fhs/pub/ and "prefix" in Sys::Path

Tags: CORE, BASE, FILE

preparedir

    $status = preparedir( $dir );
    $status = preparedir( \@dirs );
    $status = preparedir( \%dirs );
    $status = preparedir( $dir, $chmode );

Preparing directory: creation and permission modification. The function returns true or false.

The $chmode argument should be a octal value, for example:

    $status = preparedir( [qw/ foo bar baz /], 0777 );

Tags: BASE, FILE, ATOM

randchars

    $rand = randchars( $n ); # default chars collection: 0..9,'a'..'z','A'..'Z'
    $rand = randchars( $n, \@collection ); # Defined chars collection

Returns random sequence of casual characters by the amount of n

For example:

    $rand = randchars( 8, [qw/a b c d e f/]); # -> cdeccfdf

Tags: BASE, UTIL

randomize

    $rand = randomize( $n );

Returns random number of the set amount of characters

Tags: BASE, UTIL

read_attributes

Smart rearrangement of parameters to allow named parameter calling. We do the rearrangement if the first parameter begins with a -

    my @args = @_;
    my ($content, $maxcnt, $timeout, $timedie, $base, $login, $password, $host, $table_tmp);
    ($content, $maxcnt, $timeout, $timedie, $base, $login, $password, $host, $table_tmp) =
    read_attributes([
        ['DATA','CONTENT','USERDATA'],
        ['COUNT','MAXCOUNT','MAXCNT'],
        ['TIMEOUT','FORBIDDEN','INTERVAL'],
        ['TIMEDIE','TIME'],
        ['BD','DB','BASE','DATABASE'],
        ['LOGIN','USER'],
        ['PASSWORD','PASS'],
        ['HOST','HOSTNAME','ADDRESS','ADDR'],
        ['TABLE','TABLENAME','NAME','SESSION','SESSIONNAME']
    ],@args) if defined $args[0];

See CGI::Util

Tags: API, BASE

rundir

    my $value = rundir();

For example value can be set as: /var/run

This directory contains system information data describing the system since it was booted. Files under this directory must be cleared (removed or truncated as appropriate) at the beginning of the boot process. Programs may have a subdirectory of /var/run; this is encouraged for programs that use more than one run-time file. 7 Process identifier (PID) files, which were originally placed in /etc, must be placed in /var/run. The naming convention for PID files is <program-name>.pid. For example, the crond PID file is named /var/run/crond.pid.

See http://www.pathname.com/fhs/pub/ and "rundir" in Sys::Path

Tags: CORE, BASE, FILE

scandirs

    @dirs = scandirs( $dir, $mask );

A function returns all directories of directory $dir by $mask (regexp or scalar string) in format: [$path, $name]

Tags: BASE, FILE, ATOM

scanfiles

    @files = scanfiles( $dir, $mask );

A function returns all files of directory $dir by $mask (regexp or scalar string) in format: [$path, $name]

Tags: BASE, FILE, ATOM

sendmail, send_mail

    my $sent = sendmail(
        -to       => 'to@example.com',
        -cc       => 'cc@example.com',     ### OPTIONAL
        -from     => 'from@example.com',
        -subject  => 'My subject',
        -message  => 'My message',
        -type     => 'text/plain',
        -charset  => 'utf-8',              ### OPTIONAL
        -smtp     => '192.168.1.1',        ### OPTIONAL
        -smtpuser => '',                   ### OPTIONAL
        -smtppass => '',                   ### OPTIONAL
        -sendmail => '/usr/bin/sendmail -t', ### OPTIONAL, NOT RECOMMENDED
        -smtpargs => { Debug=> 1, ... },   ### OPTIONAL
        -attach   => [                     ### OPTIONAL
            {
                Type=>'text/plain',
                Data=>'document 1 content',
                Filename=>'doc1.txt',
                Disposition=>'attachment',
            },
            {
                Type=>'text/plain',
                Data=>'document 2 content',
                Filename=>'doc2.txt',
                Disposition=>'attachment',
            },
            {
                Type=>'text/html',
                Data=>'blah-blah-blah',
                Filename=>'response.htm',
                Disposition=>'attachment',
            },
            {
                Type=>'image/gif',
                Path=>'aaa000123.gif',
                Filename=>'logo.gif',
                Disposition=>'attachment',
            },
            ### ... ###
          ],
    );
    print($sent ? 'mail has been sent :)' : 'mail was not sent :(');

Send UTF-8 E-mail. See MIME::Lite for details

Tags: UTIL, EXT, ATOM

sharedir

    my $value = sharedir();

For example value can be set as: /usr/share

The /usr/share hierarchy is for all read-only architecture independent data files. 10 This hierarchy is intended to be shareable among all architecture platforms of a given OS; thus, for example, a site with i386, Alpha, and PPC platforms might maintain a single /usr/share directory that is centrally-mounted. Note, however, that /usr/share is generally not intended to be shared by different OSes or by different releases of the same OS.

Any program or package which contains or requires data that doesn't need to be modified should store that data in /usr/share (or /usr/local/share, if installed locally). It is recommended that a subdirectory be used in /usr/share for this purpose.

Game data stored in /usr/share/games must be purely static data. Any modifiable files, such as score files, game play logs, and so forth, should be placed in /var/games.

See http://www.pathname.com/fhs/pub/ and "datadir" in Sys::Path

Tags: CORE, BASE, FILE

sharedstatedir

    my $value = sharedstatedir();

For example value can be set as: /var/lib

This hierarchy holds state information pertaining to an application or the system. State information is data that programs modify while they run, and that pertains to one specific host. Users must never need to modify files in /var/lib to configure a package's operation.

State information is generally used to preserve the condition of an application (or a group of inter-related applications) between invocations and between different instances of the same application. State information should generally remain valid after a reboot, should not be logging output, and should not be spooled data.

An application (or a group of inter-related applications) must use a subdirectory of /var/lib for its data. There is one required subdirectory, /var/lib/misc, which is intended for state files that don't need a subdirectory; the other subdirectories should only be present if the application in question is included in the distribution.

/var/lib/<name> is the location that must be used for all distribution packaging support. Different distributions may use different names, of course.

See http://www.pathname.com/fhs/pub/ and "sharedstatedir" in Sys::Path

Tags: CORE, BASE, FILE

shuffle

    @cards = shuffle(0..51); # 0..51 in a random order

Returns the elements of LIST in a random order

Pure-Perl implementation of Function List::Util::PP::shuffle (Copyright (c) 1997-2009 Graham Barr <gbarr@pobox.com>. All rights reserved.)

See also List::Util

Tags: BASE, UTIL

slash

    $slashed = slash( $string );

Escaping symbols \ and ' and returns strings \\ and \'

Tags: BASE, FORMAT

spooldir

    my $value = spooldir();

For example value can be set as: /var/spool

/var/spool contains data which is awaiting some kind of later processing. Data in /var/spool represents work to be done in the future (by a program, user, or administrator); often data is deleted after it has been processed.

See http://www.pathname.com/fhs/pub/ and "spooldir" in Sys::Path

Tags: CORE, BASE, FILE

srvdir

    my $value = srvdir();

For example value can be set as: /srv

/srv contains site-specific data which is served by this system.

See http://www.pathname.com/fhs/pub/ and "srvdir" in Sys::Path

Tags: CORE, BASE, FILE

sysconfdir

    my $value = sysconfdir();

For example value can be set as: /etc

The /etc hierarchy contains configuration files. A "configuration file" is a local file used to control the operation of a program; it must be static and cannot be an executable binary.

See http://www.pathname.com/fhs/pub/ and "sysconfdir" in Sys::Path

Tags: CORE, BASE, FILE

syslogdir

    my $value = syslogdir();

For example value can be set as: /var/log

This directory contains miscellaneous log files. Most logs must be written to this directory or an appropriate subdirectory.

See http://www.pathname.com/fhs/pub/ and "logdir" in Sys::Path

Tags: CORE, BASE, FILE

tag

    $detagged = tag( $string );

<, >, " and ' chars convert to &lt;, &gt;, &quot; and &#39; strings.

Tags: BASE, FORMAT

tag_create

    $string = tag_create( $detagged );

Reverse function "tag"

Tags: BASE, FORMAT

to_base64

    $base64_text = to_base64( $utf8_text );

Function to encode strings into the base64 encoding specified in RFC 2045 - MIME (Multipurpose Internet Mail Extensions). The base64 encoding is designed to represent arbitrary sequences of octets in a form that need not be humanly readable. A 65-character subset ([A-Za-z0-9+/=]) of US-ASCII is used, enabling 6 bits to be represented per printable character.

See also MIME::Base64

Tags: BASE, FORMAT

to_cp1251, to_windows1251

    $win1251_text = to_windows1251( $utf8_text )
    $win1251_text = to_windows1251( $utf8, "Windows-1251" )

Encodes a string from Perl's internal form into ENCODING (Windows-1251) and returns a sequence of octets ($win1251_text). ENCODING can be either a canonical name or an alias. For encoding names and aliases, see Encode.

Tags: BASE, FORMAT

to_utf8

    $utf8_text = to_utf8( $win1251_text )
    $utf8_text = to_utf8( $win1251_text, "Windows-1251" )

Decodes a sequence of octets ($win1251_text) assumed to be in ENCODING (Windows-1251) into Perl's internal form and returns the resulting string. As in encode(), ENCODING can be either a canonical name or an alias. For encoding names and aliases, see Encode.

Tags: BASE, FORMAT

touch

    touch( "file" );

Makes file exist, with current timestamp

Tags: BASE, FILE, ATOM

trim

    print '"'.trim( "    string " ).'"'; # "string"

Returns the string with all leading and trailing whitespace removed. Trim on undef returns undef. Original this function see String::Util

Tags: BASE, FORMAT

tz_diff

    print tz_diff( time );

Returns TimeZone difference value

    print dtf("%w, %DD %MON %YYYY %hh:%mm:%ss ".tz_diff(time), time);

Prints RFC-2822 format date

Tags: BASE, DATE

unescape

    $str = unescape(escape("10% is enough\n"));

Returns a string with each %XX sequence replaced with the actual byte (octet).

This does the same as:

    $string =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;

See also URI::Escape

Tags: BASE, FORMAT

variant_stf

    $fixlenstr = variant_stf( "qwertyuiop", 3 ); # -> q.p
    $fixlenstr = variant_stf( "qwertyuiop", 7 ); # -> qw...op

Returns a line the fixed length from 3 to the n chars

Tags: BASE, FORMAT

visokos

    $lybool = visokos( 2012 );

Returns a leap-year or not

Tags: BASE, DATE

webdir

    my $value = webdir();

For example value can be set as: /var/www

Directory where distribution put static web files.

See "webdir" in Sys::Path

Tags: CORE, BASE, FILE

where

    my @ls = which( "ls" );

Get all paths to specified command. Same as which() but will return all the matches.

Based on File::Which

Tags: UTIL, EXT, ATOM

which

    my $ls = which( "ls" );

Get full path to specified command

First argument is the name used in the shell to call the program, e.g., perl.

If it finds an executable with the name you specified, which() will return the absolute path leading to this executable, e.g., /usr/bin/perl or C:\Perl\Bin\perl.exe.

If it does not find the executable, it returns undef.

Based on File::Which

Tags: UTIL, EXT, ATOM

TAGS

:ALL

Exports all functions

:API

Exports functions:

"getsyscfg", "isos", "isostype", "read_attributes", "syscfg"

:ATOM

Exports all function FILE and EXT

:BASE

Exports all function API, FILE, FORMAT, DATE and:

"randchars", "randomize", "shuffle"

:CORE

Exports functions:

"cachedir", "docdir", "localedir", "localstatedir", "lockdir", "prefixdir", "rundir", "sharedir", "sharedstatedir", "spooldir", "srvdir", "sysconfdir", "syslogdir", "webdir"

:DATE

Exports functions:

"basetime", "correct_date", "current_date", "current_date_time", "date_time2dig", "date2dig", "date2localtime", "datef", "datetime2localtime", "datetimef", "dig2date", "dig2date_time", "dtf", "localtime2date", "localtime2date_time", "tz_diff", "visokos"

:EXT

Exports functions:

"exe", "execute", "ftp", "ftpgetlist", "ftptest", "send_mail", "sendmail", "where", "which"

:FILE

Exports all function CORE and:

"bload", "bsave", "eqtime", "file_load", "file_save", "fload", "fsave", "getdirlist", "getfilelist", "getlist", "load_file", "ls", "preparedir", "save_file", "scandirs", "scanfiles", "touch"

:FORMAT

Exports functions:

"cdata", "correct_dig", "correct_number", "dformat", "escape", "fformat", "file_lf_normalize", "file_nl_normalize", "from_utf8", "lf_normalize", "nl_normalize", "slash", "tag", "tag_create", "to_base64", "to_cp1251", "to_utf8", "to_windows1251", "trim", "unescape", "variant_stf",

:UTIL

Exports all function EXT and:

"isFalseFlag", "isTrueFlag", "randchars", "randomize", "shuffle"

HISTORY

See Changes file

DEPENDENCIES

Config, Cwd, Encode, File::Path, File::Spec, IPC::Open3, MIME::Base64, MIME::Lite, Net::FTP, Perl::OSType, Symbol, Time::Local, List::Util

TO DO

See TODO file

BUGS

* none noted

SEE ALSO

CGI::Util, IPC::Open3, List::Util, MIME::Lite, Net::FTP

AUTHOR

Serż Minus (Sergey Lepenkov) http://www.serzik.com <abalama@cpan.org>

COPYRIGHT

Copyright (C) 1998-2019 D&D Corporation. All Rights Reserved

LICENSE

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See LICENSE file and https://dev.perl.org/licenses/