umasuresh has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,
Is there a way to preserve the timestamp while backing up a file using the  -i switch?
e.g.
perl -e 's/old/new/g;' -pi.bak somefile
UPDATE Got it, thanks!
By default, this command preserves the timestamp!

Replies are listed 'Best First'.
Re: Preserving timestamp with -i switch
by AR (Friar) on Sep 19, 2011 at 19:29 UTC

    Please post what you found, so others searching for the same problem can learn from your solution.

Re: Preserving timestamp with -i switch
by duyet (Friar) on Sep 20, 2011 at 06:07 UTC

    Use -p option in cp to preserve mode, ownership, timestamp

    for i in `find . -type f -print`; do cp -p $i ${i}_bk;done