I don't return the backup filename, because I hate globals. {grin}sub get_file { my $name = shift; my $no_backup_flag = shift; unless ($no_backup_flag) { my $suffix = "aaa"; $suffix++ while -e "$name.$suffix"; local $^I = ".$suffix"; local $/ = \4096; local *ARGV; @ARGV = $name; print while <>; } local *ARGV; @ARGV = $name; local $/ = wantarray ? $/ : undef; # act like `` in scalar vs list c +ontext <>; }
-- Randal L. Schwartz, Perl hacker
In reply to Re: Get file make backup
by merlyn
in thread Get file make backup
by tachyon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |