in reply to Perl version usage

G'day aartist,

The Miscellaneous section of the online perldoc shows, amonst other things, all the deltas. Use this to determine new features (that are available in later versions) and changes to features (which are incompatible with, or require workarounds for, older versions).

Perl 5.10.1 introduced changes which were incompatible with 5.10.0, so it's important to know which of those you're using. Perl 5.18.0 made a number of features experimental that previously weren't: workarounds are documented so you don't get masses of "experimental feature" warnings.

The version you develop in should generally match the version used in production. You can write code in one version that will happily run in an earlier version; however, you'll need to be very aware of all the differences — if you don't have a solid familiarity with those differences, developing and running in the same version is probably the better choice.

Beyond additional features, each new version will include bug fixes, optimisations, and so on: this is a good reason to use the latest stable version. Certain CPAN modules require particular versions: this could be a reason to upgrade. If you're using Unicode, you'll find newer Perl versions support more recent Unicode versions (I wrote a fair bit about that in "Re: printing Unicode works for some characters but not all").

For my personal projects, I usually run the latest 5.x.0. If I see some major benefit introduced in 5.x.1, 5.x.2, or later, I'll upgrade; however, I don't do that very often. I'm currently running 5.26.0; I haven't upgraded to 5.26.1 which, at the time of writing, is the latest stable version.

When I post code in response to questions on this site, I'll generally write code that should be able to be run with any version of Perl 5. When I include a feature introduced in a specific version, I make that very clear (and often provide a workaround for earlier versions).

"Is it ok to use ( I do not have a choice)?"

It's very unclear what you're actually asking here. What does "it" refer to? What do you mean by "ok"? What is the actual "choice" you've been given (or has been forced upon you)? How is that "choice" relevant in this context. If you can answer those questions, or rephrase your original question, I can probably provide a better answer.

"What are the features of newer version of perl you cannot live without or make a good use of it?"

I wouldn't say there are any features I can't live without; although, there are many features that I'll readily use where available (and, perhaps, be a little disappointed when they aren't). There's really too many to list. In "Perl 5.26.0 Available" I listed some of the features I particularly liked in that version.

— Ken

Replies are listed 'Best First'.
Re^2: Perl version usage
by aartist (Pilgrim) on Dec 27, 2017 at 17:40 UTC
    "Is it ok to use ( I do not have a choice)?"

    I wanted to state that.. As a Practical Perl Programmer, is it ok to practice with old-versions of Perl and not bother about new features?

    Thank you for the detailed answer.

      Thanks for the clarification. Unfortunately, I don't think there's a straightforward "Yes" or "No" answer to this.

      In a work situation, you'll often be required to code to a certain version, which could be a very old version. There can be many reasons for this, some are appallingly bad reasons; however, if you've agreed to take on a contract working with legacy code, then you're going to have to develop in an old version.

      In another work scenario, you may be required to upgrade old code to a more recent version. Now it becomes important to understand both the features of old and new versions.

      Even when working with older versions, you should aim to write your code such that it's easily converted to newer versions or, better still, requires no conversion. Just because the old version didn't pick up this classic syntax error:

      for my $item qw(item1 item2 item3) { # do something with $item here }

      does not mean you should include such an unreported error in new code written for an old version. See "perl5180delta: qw(...) can no longer be used as parentheses" if you're unfamiliar with that particular problem; be aware, that's just an isolated example of code that didn't follow the published syntax, but got away with it in earlier versions.

      As already indicated in my original response, I'll tend to avoid newer features in code I supply on this site. I'll generally aim to explain a technique using code that should work with whatever version of Perl the OP is using. If you're in a situation where you're mentoring, I'd recommend a similar approach; for example, use the well-known "@$aref" to initially explain a point, then introduce "$aref->@*" as a newer feature.

      For my personal code, I use a lot of the newest features; although, for anything that's not simply a "let's test this new syntax" script, I avoid experimental features. They will come back to bite you in the bum when their implementation is changed or, when deemed a failed experiment, removed completely. Don't use experimental features in production code.

      Anyway, there's a series of scenarios where "Yes", "No", "Maybe" or "Depends" could all be valid answers. You'll need to make separate judgement calls for each; based on context, requirements, in-house standards and so on.

      — Ken