Help for this page

Select Code to Download


  1. or download this
    my $atime = $info->atime; # time of last access (seconds since epoch)
    my $mtime = $info->mtime; # time of last data modification
    my $ctime = $info->ctime; # time of last file status change
    
  2. or download this
    # if no argument given, default to current directory
    my $startdir = cwd();
    ...
    $startdir = "@ARGV";
    # convert /usr/bin to _usr_bin for filename
    ($startdir = $startdir) =~ s/\//_/g;
    
  3. or download this
    my $startdir = $ARGV[0] || cwd();
    $startdir =~ s/\//_/g;
    
  4. or download this
    # get the current date to append to output filename
    my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(tim
    +e);
    ...
    if ( $cday < 10 ) { $cday = "0" . $cday; }
    my $cdate = "_$cday" . "_$cmonth" . "_$cyear";
    $txtfileout = "permrestore" . $startdir . $cdate;
    
  5. or download this
    my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(tim
    +e);
    my $txtfileout = sprintf "permrestore%s_%02d_%02d_%04d", $startdir, $m
    +day, $mon, $year;
    
  6. or download this
    use POSIX qw( strftime );
    my $txtfileout = strftime "permrestore" . $startdir . "_%d_%m_%Y", loc
    +altime;
    
  7. or download this
    # subroutines
    sub time_as_date($)
    ...
    my $date = localtime($time);
    return $date;
    }
    
  8. or download this
    my $size = $info->size; # size in bytes
    # ...
    my $adate = time_as_date($atime);
    my $mdate = time_as_date($mtime);
    my $cdate = time_as_date($ctime);
    
  9. or download this
    my $perms = sprintf("%04o", $mode & 07777);
    
    # ...
    
    print "\# ORIG PERM = $filename\t$uid\t$gid\t$perms\t$mdate";
    
  10. or download this
    sub time_as_date($)
    
    # ...
    
    sub print_info($)
    
  11. or download this
    use File::Find ();
    
    # ...
    
    sub find(&@) { &File::Find::find }
    
  12. or download this
    *name = *File::Find::name;
    
  13. or download this
    *name = \$File::Find::name;
    
  14. or download this
    print "\n Do you want to continue (y/n)? ";
    $answer = <STDIN>;
    
  15. or download this
    #!/usr/bin/perl
    use strict;
    ...
        print "chmod $perms $filename\n";
        print "chown $uid:$gid $filename\n";
    }, @ARGV ? @ARGV : '.';
    
  16. or download this
    #!/bin/bash
    if [ "$1" ] ; then DIR="$1" ; else DIR="$PWD" ; fi
    SCRIPT="permrestore${DIR//\//_}$( date +_%d_%m_%Y )";
    permrestore "$DIR" | tee "$SCRIPT"
    chmod a+x "$SCRIPT"
    
  17. or download this
    #!/bin/bash
    
    ...
    
    find "$DIR" -printf "$FORMAT" | tee "$SCRIPT"
    chmod a+x "$SCRIPT"