Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

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

by filipebean (Novice)
on Apr 08, 2013 at 15:43 UTC ( [id://1027539]=perlquestion: print w/replies, xml ) Need Help??

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1027539]
Approved by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-24 19:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found