in reply to stat and permissions

Did you read the perldoc for sprintf? It has more information. They're identical except sprintf "prints" to a string (what you want) and printf goes to your output.