Here's a non-obfuscated version:
use strict; use warnings; use 5.010; use List::Util qw{ shuffle }; my @numbers = (1 .. 100_000); my @rand_numbers = shuffle @numbers; my @fnames = qw{ joe_IMG_27445.JPG Mary_34555.jpg }; for my $fname (@fnames) { my $rand_number = shift @rand_numbers; my @pieces = split /_/, $fname, 2; my $new_fname = "$pieces[0]_$rand_number.jpg"; say $new_fname; } --output:-- joe_18119.jpg Mary_46301.jpg
In reply to Re: Renaming an image file
by 7stud
in thread Renaming an image file
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |