with the time localized for the standard Greenwich time zone.
Typically used as follows:
-
+ # 0 1 2 3 4 5 6 7 8
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
gmtime(time);
All array elements are numeric, and come straight out of a struct tm.
In particular this means that $mon has the range 0..11 and $wday has
-the range 0..6. Also, $year is the number of years since 1900, I<not>
-simply the last two digits of the year.
+the range 0..6 with sunday as day 0. Also, $year is the number of
+years since 1900, I<not> simply the last two digits of the year.
If EXPR is omitted, does C<gmtime(time())>.
-In a scalar context, prints out the ctime(3) value:
+In a scalar context, returns the ctime(3) value:
$now_string = gmtime; # e.g., "Thu Oct 13 04:54:34 1994"
-Also see the F<timegm.pl> library, and the strftime(3) function available
-via the POSIX module.
+Also see the timegm() function provided by the Time::Local module,
+and the strftime(3) function available via the POSIX module.
=item goto LABEL
=item grep EXPR,LIST
-This is similar in spirit to, but not the same as, L<grep(1)>
+This is similar in spirit to, but not the same as, grep(1)
and its relatives. In particular, it is not limited to using
regular expressions.
=item join EXPR,LIST
-Joins the separate strings of LIST or ARRAY into a single string with
+Joins the separate strings of LIST into a single string with
fields separated by the value of EXPR, and returns the string.
Example:
print $key, '=', $ENV{$key}, "\n";
}
-To sort an array by value, you'll need to use a C<sort{}> function.
+To sort an array by value, you'll need to use a C<sort> function.
Here's a descending numeric sort of a hash by its values:
foreach $key (sort { $hash{$b} <=> $hash{$a} } keys %hash)) {
with the time analyzed for the local time zone. Typically used as
follows:
+ # 0 1 2 3 4 5 6 7 8
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
localtime(time);
All array elements are numeric, and come straight out of a struct tm.
In particular this means that $mon has the range 0..11 and $wday has
-the range 0..6 and $year is year-1900, that is, $year is 123 in year
-2023. If EXPR is omitted, uses the current time ("localtime(time)").
+the range 0..6 with sunday as day 0. Also, $year is the number of
+years since 1900, that is, $year is 123 in year 2023.
+
+If EXPR is omitted, uses the current time (C<localtime(time)>).
In a scalar context, returns the ctime(3) value:
$now_string = localtime; # e.g., "Thu Oct 13 04:54:34 1994"
-Also see the Time::Local module, and the strftime(3) function available
-via the POSIX module.
+Also see the Time::Local module, and the strftime(3) and mktime(3)
+function available via the POSIX module.
=item log EXPR
Returns the sine of EXPR (expressed in radians). If EXPR is omitted,
returns sine of $_.
-For the inverse sine operation, you may use the POSIX::sin()
+For the inverse sine operation, you may use the POSIX::asin()
function, or use this relation:
sub asin { atan2($_[0], sqrt(1 - $_[0] * $_[0])) }
For delays of finer granularity than one second, you may use Perl's
syscall() interface to access setitimer(2) if your system supports it,
-or else see L</select()> below.
+or else see L</select()>.
See also the POSIX module's sigpause() function.
@articles = sort {$a cmp $b} @files;
# now case-insensitively
- @articles = sort { uc($a) cmp uc($b)} @files;
+ @articles = sort {uc($a) cmp uc($b)} @files;
# same thing in reversed order
@articles = sort {$b cmp $a} @files;
Not all fields are supported on all filesystem types. Here are the
meaning of the fields:
- dev device number of filesystem
- ino inode number
- mode file mode (type and permissions)
- nlink number of (hard) links to the file
- uid numeric user ID of file's owner
- gid numeric group ID of file's owner
- rdev the device identifier (special files only)
- size total size of file, in bytes
- atime last access time since the epoch
- mtime last modify time since the epoch
- ctime inode change time (NOT creation time!) since the epoch
- blksize preferred block size for file system I/O
- blocks actual number of blocks allocated
+ 0 dev device number of filesystem
+ 1 ino inode number
+ 2 mode file mode (type and permissions)
+ 3 nlink number of (hard) links to the file
+ 4 uid numeric user ID of file's owner
+ 5 gid numeric group ID of file's owner
+ 6 rdev the device identifier (special files only)
+ 7 size total size of file, in bytes
+ 8 atime last access time since the epoch
+ 9 mtime last modify time since the epoch
+ 10 ctime inode change time (NOT creation time!) since the epoch
+ 11 blksize preferred block size for file system I/O
+ 12 blocks actual number of blocks allocated
(The epoch was at 00:00 January 1, 1970 GMT.)
doing many pattern matches on the string before it is next modified.
This may or may not save time, depending on the nature and number of
patterns you are searching on, and on the distribution of character
-frequencies in the string to be searched--you probably want to compare
+frequencies in the string to be searched -- you probably want to compare
run times with and without it to see which runs faster. Those loops
which scan for many short constant strings (including the constant
parts of more complex patterns) will benefit most. You may have only
-one study active at a time--if you study a different scalar the first
+one study active at a time -- if you study a different scalar the first
is "unstudied". (The way study works is this: a linked list of every
character in the string to be searched is made, so we know, for
example, where all the 'k' characters are. From each search string,
symbolic links, produces a fatal error at run time. To check for that,
use eval:
- $symlink_exists = (eval 'symlink("","");', $@ eq '');
+ $symlink_exists = (eval {symlink("","")};, $@ eq '');
=item syscall LIST
=item tr///
-The translation operator. See L<perlop>.
+The translation operator. Same as y///. See L<perlop>.
=item truncate FILEHANDLE,LENGTH
=item y///
-The translation operator. See L<perlop>.
+The translation operator. Same as tr///. See L<perlop>.
=back