in reply to remove tilda from filenames with 1 liner

(Updated, thanks to screamingeagle.) Kill two birds with one stone: for (grep s/~\z//, readdir D) { rename "$_~" => $_ }

_____________________________________________________
Jeff[japhy]Pinyan: Perl, regex, and perl hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Replies are listed 'Best First'.
Re: Re: remove tilda from filenames with 1 liner
by screamingeagle (Curate) on Jan 22, 2002 at 23:02 UTC
    correct me if I'm wrong, but shouldnt the last part of your example be :
    rename "$_~" => $_
    instead of
    rename $_ => "$_~"
Re: Re: remove tilda from filenames with 1 liner
by gav^ (Curate) on Jan 22, 2002 at 06:57 UTC

    What's the difference between \z and $

    gav^

      You should really consult perlre for this. $ can match before a newline at the end of the string, whereas \z matches only at the absolute end of a string. If you have a file that ends in a newline, this is important.

      _____________________________________________________
      Jeff[japhy]Pinyan: Perl, regex, and perl hacker.
      s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;