Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Delete last line of file with regex

by ForgotPasswordAgain (Priest)
on Jul 23, 2020 at 01:38 UTC ( [id://11119689]=note: print w/replies, xml ) Need Help??


in reply to Delete last line of file with regex

If it's not a huge file, I'd use File::Slurp (or maybe File::Slurper if the issues it fixes are relevant for your case).

@lines = read_file($file); pop @lines if $lines[-1] =~ /^##/; write_file($file, @lines);

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-04-19 05:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found