how to subtract 1 from all array elements in perl

perl

Solution

Try this

#!/usr/bin/perl

my @words = (524210,1713409,311919,1422134,16658312);

@words = map { $_ - 1 } @words;

Problem

I have an array which contains values. I need to subtract 1 from each array elements & save there itself. For Example: ``` chop $tve_005; @words = split (/,/, $tve_005); ``` and now `@words` contains: ``` 524210 1713409 311919 1422134 16658312 ``` But infact values need to be used in the rest of the codes are: (subtract by 1 always) ``` 524209 1713408 311918 1422133 16658311 ``` How can I subtract and save it the same array.

Original source