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

Hi all,

can you please help me to understand the full meaning of the condition:

 if ($file !~ /\.tar(\.gz)?$/)

does it mean: if $file diferent of .tar or .gz do...

thank you in advance

best regards.

Replies are listed 'Best First'.
Re: meaning of if ($file !~ /\.tar(\.gz)?$/)
by hdb (Monsignor) on Apr 08, 2013 at 15:47 UTC

    Matches all $file except .tar and .tar.gz endings.

    if ( $file !~ # scalar $file tested for not matching /\.tar # an ending of .tar (\.gz)? # followed by an optional .gz $ # at the end of the name /x)

      Hi,

      thank you, your answer is clear.

      it was the optional part that confused me :(

      best regards.