I want to rename some files from foo.jpg.1 to foo.jpg. They all have a numeric extension and can be jpeg, jpe or jpg.
Why doesn't this (air) code work?
Is it possible to use this string comparison or something like it?
Instead I used a simple switch (again some air code)
Why doesn't this (air) code work?
Code:
#!/usr/bin/perl
# use strict;
# use warnings;
my $name = $_;
my $file_ext_original = ($name =~ m/([^.]+)$/)[0];
if($file_ext_original eq ["1", "2", "3", "4", "5", "6", "7", "8", "9"]) {
print "$name needs to be renamed\n";
} else {
print "$name is good\n";
}
Is it possible to use this string comparison or something like it?
Code:
$file_ext_original eq ["1", "2", "3", "4", "5", "6", "7", "8", "9"]
Instead I used a simple switch (again some air code)
Code:
use 5.010;
given ($file_ext_original) {
when (["1", "2", "3", "4", "5", "6", "7", "8", "9"]) {
print "$name needs to be renamed\n";
}
default {
# print "$name is good\n";
}
}