Mohd Mohtashim has Published 238 Articles

POSIX Function strftime() in Perl

Mohd Mohtashim

Mohd Mohtashim

Updated on 29-Nov-2019 06:41:03

15K+ Views

You can use the POSIX function strftime() in Perl to format the date and time with the help of the following table. Please note that the specifiers marked with an asterisk (*) are locale-dependent.SpecifierReplaced byExample%aAbbreviated weekday name *Thu%AFull weekday name *Thursday%bAbbreviated month name *Aug%BFull month name *August%cDate and time representation ... Read More

Epoch time in Perl

Mohd Mohtashim

Mohd Mohtashim

Updated on 29-Nov-2019 06:33:42

9K+ Views

You can use the time() function in Perl to get epoch time, i.e., the numbers of seconds that have elapsed since a given date, in Unix is January 1, 1970.Example Live Demo#!/usr/local/bin/perl $epoc = time(); print "Number of seconds since Jan 1, 1970 - $epoc";OutputWhen the above code is executed, it ... Read More

Format Date and Time in Perl

Mohd Mohtashim

Mohd Mohtashim

Updated on 29-Nov-2019 06:32:04

410 Views

You can use localtime() function in Perl to get a list of 9-elements and later you can use the printf() function to format date and time based on your requirements as follows −Example Live Demo#!/usr/local/bin/perl ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(); printf("Time Format - HH:MM:SS"); printf("%02d:%02d:%02d", ... Read More

GMT Time in Perl

Mohd Mohtashim

Mohd Mohtashim

Updated on 29-Nov-2019 06:30:24

819 Views

The function gmtime() in Perl works just like localtime() function but the returned values are localized for the standard Greenwich time zone. When called in list context, $isdst, the last value returned by gmtime, is always 0. There is no Daylight Saving Time in GMT.You should make a note on ... Read More

Current Date and Time in Perl

Mohd Mohtashim

Mohd Mohtashim

Updated on 29-Nov-2019 06:28:47

544 Views

Let's start with localtime() function in Perl, which returns values for the current date and time if given no arguments. Following is the 9-element list returned by the localtime function while using in list context −sec, # seconds of minutes from 0 to 61 min, # minutes of hour from ... Read More

Perl Operators Precedence

Mohd Mohtashim

Mohd Mohtashim

Updated on 29-Nov-2019 06:26:47

222 Views

The following table lists all operators from highest precedence to lowest in Perl Programming.

Perl Miscellaneous Operators

Mohd Mohtashim

Mohd Mohtashim

Updated on 29-Nov-2019 06:24:37

218 Views

There are following miscellaneous operators supported by Perl language. Assume variable a holds 10 and variable b holds 20 then −Sr.No.Operator & Description1.Binary operator dot (.) concatenates two strings.Example− If $a = "abc", $b = "def" then $a.$b will give "abcdef"2xThe repetition operator x returns a string consisting of the ... Read More

Perl Logical Operators

Mohd Mohtashim

Mohd Mohtashim

Updated on 29-Nov-2019 06:22:29

324 Views

There are following logical operators supported by Perl language. Assume variable $a holds true and variable $b holds false then −Sr.No.Operator & Description1andCalled Logical AND operator. If both the operands are true then the condition becomes true.Example− ($a and $b) is false. 2&&C-style Logical AND Operator copies a bit to the ... Read More

Perl Bitwise Operators

Mohd Mohtashim

Mohd Mohtashim

Updated on 29-Nov-2019 06:18:22

389 Views

Bitwise operator works on bits and performs bit by bit operation. Assume if $a = 60; and $b = 13; Now in binary format they will be as follows −$a = 0011 1100 $b = 0000 1101 ----------------- $a&$b = 0000 1100 $a|$b = 0011 1101 $a^$b = 0011 0001 ... Read More

Perl Assignment Operators

Mohd Mohtashim

Mohd Mohtashim

Updated on 29-Nov-2019 06:15:04

260 Views

Assume variable $a holds 10 and variable $b holds 20, then below are the assignment operators available in Perl and their usage −Sr.No.Operator & Description1=Simple assignment operator, Assigns values from right side operands to left side operandExample−$c = $a + $b will assigned value of $a + $b into $c2+=Add ... Read More

Advertisements