As davido and Marshall have pointed out, it would be nice to see some code, even a very bare beginning.
However, a few hints and suggestions:
-
One might be tempted to extract the filename with a regex, but the use of split might be more direct if less elegant. One problem with split is that the fields matching the splitting regex are typically lost, so if you split on multiple spaces and the file name has multiple spaces between file name sub-fields such as
my $string = 'aa bbb a file name cc ddd';
this information is lost. This can be avoided by enclosing the split regex in capturing parentheses, which preserves fields matching the splitting regex, so
my @fields = split /(\s+)/, $string;
and everything can be joined back together again later.
-
Take a look at splice. This built-in will chop n elements off the end of an array such as might be produced by split (and return them, but you don't have to use them) if given a negative offset -n, and delete and return all elements from offset n to the end of an array if given a positive offset. You seem to know the constant field offsets from the start and end of the original string.
-
Last but not least, join, your constant companion.