develooper Front page | perl.beginners | Postings from March 2002

RE: finding example scripts

Thread Previous | Thread Next
Louden, Chris
March 5, 2002 11:45
RE: finding example scripts
Message ID:
Here is what I have so far. It works on an NT PC running Perl from Active
State, but I need to run it on a Novell box. Paths to directories are
different. Im not sure how to type in the paths, the standard
"servername:volume/path/to/dir" does not seem to work. This checks for files
modified in the previous hour on the E drive and moved them to a d:\backups\

use File::stat;
use File::Copy;
use File::Path;
$now = time;
	$YDAY, $ISDAYLITE)= localtime();
$DAY = sprintf("%02d-%02d-%02d", ++$MON, $MDAY, 1900+$YEAR);
$CURR_HOUR = sprintf("%02d", $HOUR);
sub traverse {
    local($dir) = shift;
#print "$dir\n";
    unless (opendir(DIR, $dir)) {
	warn "Can't open $dir\n";
    foreach (readdir(DIR)) {
	next if $_ eq '.' || $_ eq '..' || ($_=~/perlscripts/i) ;
#Skip if these Dirs are found
	$path = "$dir/$_";

	if (-d $path) {		# a directory
	} elsif (-f _) {	# a plain file

	#print "$path\n";	# Print full path to display

          $date_string = (stat($path)->mtime);
		if ($now - $date_string < 3600) {	# is file modified
in the last hour 
		$dest =$dir;
		$dest =~ s/e:/D:\/Backups\/$DAY\/$CURR_HOUR\/Edrive/g;
#Strip out e: & subst i:
		$dest1 = "$dest/$_";
		# print "Backing up $path TO Hourly Backup Drive...\n";
		mkpath ("$dest");
		copy $path, $dest1;

-----Original Message-----
From: Hanson, Robert []
Sent: Tuesday, March 05, 2002 11:26 AM
To: 'Louden, Chris'; Beginners@perl. org (E-mail)
Subject: RE: finding example scripts

I think it is unlikely that you will find any samples on the web like this
(but ya never know).

Frankly though it sounds like a simple problem, maybe less than 10 lines of
code depending on the complexity.  You might want to look at the docs for
File::Find and File::Copy to get some ideas.


-----Original Message-----
From: Louden, Chris []
Sent: Tuesday, March 05, 2002 2:03 PM
To: Beginners@perl. org (E-mail)
Subject: finding example scripts

Anyone know any good site for example scripts,  specifically for moving or
coping files that meet certain criteria?

Chris Louden
Engineering Automation Support
Bechtel Nevada / D.O.E.
702-295-2336 -phone
702-794-1968 -pager

click on the link below to send a text message to my pager:

To unsubscribe, e-mail:
For additional commands, e-mail:

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About