in reply to Alternatives for index() ... substr() ?

Hi zarath,

The first thing I would recommend is to use variable names that clearly state what they contain.

My first idea was perhaps to use unpack, but since you are saying that "these strings can be pretty much anything with any number of characters", that is probably not going to work.

Although this might sound paradoxical, the clearest and cleanest way to retrieve your data might be to use just a long regex using the constant strings as delimiters between the pieces you want to capture. Something like this (to be completed and tested):

my ($date, $file, $source_dir, $destination ...) = ($text =~ /(.{19}) +FATAL: Error while copying ([^ ]+?) from ([^ ]+?) to .../);

Update: when I started writing this answer, there was no other response, but it took me so long to write this answer that I finally posted a quarter of an hour later than Eily, and just said almost the same thing.

Update 2:: note that, the solution above is based on the data you've shown. I have assumed that the file and directory names you want to capture don't contain any space. If there can be spaces in your data to be captured, this would have to be slightly changed (thanks to Eily for pointing out the possibility that some of the data to be captured may contain spaces). Similarly, if the parts you want to capture may contain the strings "to" or "from", this might also be a problem. So you have to know very well your data in order to take your detailed decisions on how exactly to build your regex or regexes.