in reply to Re: Specific instance of a repeated string
in thread Specific instance of a repeated string

Instead of using a regex followed by a split, try using just a regex.
if ( $filename =~ /(.*)(\d+)\.(.*)$/ ) { $prefix = $1; $digit = $2; $suffix = $3; } else { print "Error etc\n"; }
You may need to tweak the regex. I am unable to test it from my current location.

Replies are listed 'Best First'.
Re^3: Specific instance of a repeated string
by Ionizor (Pilgrim) on Aug 13, 2003 at 02:12 UTC

    Unfortunately this won't do what I need it to do. This will only work for files that look like foo01.bar. Some of my files look like: foo10bar.baz. This regex also assumes that it's the last number in the filename that I want to operate on which isn't always the case.

    Thanks for the suggestion though, it is appreciated.

    --
    Grant me the wisdom to shut my mouth when I don't know what I'm talking about.