Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: oneliner cat like capability

by stevieb (Canon)
on Oct 29, 2019 at 20:57 UTC ( [id://11108087]=note: print w/replies, xml ) Need Help??


in reply to oneliner cat like capability

"I am looking at doing and getting better with oneliners from the command line."

If that's the case, I would highly recommend adding -wMstrict to your one-liners, right after the perl command, like so: perl -wMstrict -insert_other_stuff_here.

It does appear through other responses that you're a beginner really trying to learn, so throwing the switches I've recommended into the mix while you're learning will provide you the benefit of learning both one liners, and the work involved in making full-blown Perl scripts and modules reliable and as trustworthy as possible. You want your code to operate flawlessly under use warnings (an expanded -w) and use strict (-Mstrict). Very few Perl coders trust code without these present.

I know that using one-liners are typically for one-off type things, but for a relative newcomer to the language, a few extra keystrokes across one-liners will get you into the proper mindset so when you want to use them for more advanced things, you'll be able to do so on the fly quickly, and reliably.

Replies are listed 'Best First'.
Re^2: oneliner cat like capability
by gradius85 (Novice) on Oct 30, 2019 at 14:01 UTC

    Thank you for the help and suggestions. Yes... I am new to Pearl and really trying to learn the language. I also appreciate the pointer for using 'strict' and 'warnings' to get into the proper mind set of using Perl.

      For all standard code strict and warnings or some non-core version of them like strictures is really necessary to sane code. For one-liners… it will help with learning but it will definitely get in the way of brevity and fun. I never use them on the command line unless vetting a weird issue and I use Perl on the command line every day.

Log In?
Username:
Password:

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

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

    No recent polls found