Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: Changing filename extensions

by supernova95 (Initiate)
on Nov 16, 2021 at 03:51 UTC ( [id://11138864]=note: print w/replies, xml ) Need Help??


in reply to Re: Changing filename extensions
in thread filenames

Forgive me I'm a newbie at Perl, how do I include $dir as part of the path?

Replies are listed 'Best First'.
Re^3: Changing filename extensions
by jwkrahn (Abbot) on Nov 16, 2021 at 03:53 UTC
    rename("$dir/$name.$old", "$dir/$name.$new");

      Given the OP is a Perl newbie, just a further clarification that when running Perl on Windows, forward slashes are preferred to backslashes. This enhances code portability because they work fine in file paths when using Perl on both Unix and Windows (as described in more detail at Re^4: windows perl and paths) and boosts enjoyment because they are easier to type and read than ugly escaped backslashes. :)

      That did the trick, tysm!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-04-25 23:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found