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.
Alternatively to Pradeep's solution, some characters shorter:
#!/usr/bin/perl
my @words = (524210,1713409,311919,1422134,16658312);
$_-- for @words;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With