DEV Community

Tib
Tib

Posted on • Updated on

What is X in Perl?

What is pip or gem?

cpanm or cpm

Where is my REPL?

Use perl debugger perl -de2 or one of the REPL (e.g. reply)

Is there any gemfile or requirements.txt?

cpanfile or cpmfile (NEW!)

(and more... e.g. with dzil)

What is package.json?

META.json and META.yml see doc

And gemfile.lock or package-lock.json?

cpanfile.snapshot or carton.lock

And what about Virtualenv?

Virtual envs are not as much vital in Perl, but there is plenv or perlbrew

Bundler?

carton

Other tips for Perl beginners

  • Usually no variable methods (variable.method) but methods on variables (method(variable)) e.g. split
  • ; is mandatory (with few exceptions but please forget)
  • Indentation not meaningful

Top comments (7)

Collapse
 
matthewpersico profile image
Matthew O. Persico

Indentation not meaningful

I prefer to describe this "Whitespace is not punctuation". Indentation is certainly meaningful for the readers of your code (which includes yourself after a few weeks on another project). For the love of Turing, INDENT your code. Given all the fancy-shmancy, shiny editors out there that will autoindent for you there is no reason not to indent. Just because you don't have to, doesn't mean you shouldn't. Especially if you are coming from a language that forces you to indent. Why drop that habit?

Collapse
 
matthewpersico profile image
Matthew O. Persico

; is mandatory (with few exceptions but please forget)

A semicolon ends a statement. It's what allows multi-line statements to appear without annoying backslashes. The only place I remember that you don't need one is at the end of a block:

for (...) {
statement1;
statement2;
statement3
}

However, you frequently see this code:
funccall (
arg1,
arg2,
arg3,
);

Notice the comma at the end of arg3? It's there so when you add arg4, It Just Works. So if you are willing to do that, put the semicolon after statement3 so that when you add statement4, It Just Works.

Don't be afraid of punctuation. We've been using it for hundreds of years and it has made reading so much easier; it does the same in programing.

Collapse
 
grinnz profile image
Dan Book

Great recommendations. Some notes:

The author of Devel::REPL does not generally recommend it unless there is functionality you want that hasn't been written yet for Reply.

carton.lock is just the old name for cpanfile.snapshot and this is a Carton/cpm version pinning file, not really related to cpanfiles.

May be worth noting that META.json/META.yml are always autogenerated and should never be edited by hand.

Collapse
 
raigaurav profile image
Gaurav Rai

Great article.
Some more -

What is NumPy in Perl(data science) ?
PDL

What is PyTorch/Apache MXNet in Perl (Machine learning and Deep learning) ?
AI::MXNet

What is IPython in Perl (Jupyter Networks)?
Devel-IPerl

What is ggplot2 in Perl (data visualization package for the statistics) ?
Chart::GGPlot

What is Dash in perl (analytical web applications)?
Dash - in early stage

Collapse
 
thibaultduponchelle profile image
Tib

Thank you !! 😃

Collapse
 
matthewpersico profile image
Matthew O. Persico

This is a great article in both directions; it is just as useful for Perlers moving to Python. Thank you.

Collapse
 
thibaultduponchelle profile image
Tib

Thank you for the kind words :)