Browse code

#0000030 use os agnostic dir delimiters

René Wagner authored on 01.10.2019 21:54:48
Showing 1 changed files

... ...
@@ -8,12 +8,13 @@ use strict;
8 8
 use feature qw(say);
9 9
 use Cwd;
10 10
 use File::Basename;
11
+use File::Copy;
11 12
 use File::Find;
12 13
 use File::Find::Rule;
13
-use File::Copy;
14
+use File::Spec::Functions;
14 15
 use Switch;
15 16
 
16
-my $VERSION = '0.3';
17
+my $VERSION = '0.4';
17 18
 my $PROGRAM = 'JpegDivider';
18 19
 
19 20
 my $SUBFOLDER = 'JPEG';
... ...
@@ -46,7 +47,7 @@ sub main
46 47
 	say "subfolder        : $SUBFOLDER";
47 48
 	say '';
48 49
 	
49
-	my $destination_dir = "$dir\/$SUBFOLDER";
50
+	my $destination_dir = catdir($dir, $SUBFOLDER);
50 51
 	if ( $move_flag && ! -d $destination_dir )
51 52
 	{
52 53
 		mkdir $destination_dir or die "Could not create destination dir $_ : $!";
... ...
@@ -60,15 +61,16 @@ sub main
60 61
 		$move_counter++;
61 62
 		if ( $move_flag )
62 63
 		{
63
-			if ( move($file, $destination_dir. '/' .basename($file) ) )
64
+			if ( move($file, catfile($destination_dir, basename($file)) ) )
64 65
 			{ 
65
-				say "moved.";
66
+				print "moved.";
66 67
 			}
67 68
 			else
68 69
 			{
69
-				say "move failed: $!";
70
+				print "move failed: $!";
70 71
 			}
71 72
 		}
73
+		say '';
72 74
 	}
73 75
 	
74 76
 	say "\r\nfound $move_counter jpeg files to subfolder.";