Reverse a list of numbers stored in a variable

Sunday, December 30, 2012 , , 0 Comments

In Perl, let's say ,there is a variable:
$j = "12,11,10,9";
If we want to reverse the string list based on the "," and get the output like:
9,10,11,12
Below is the logic to achieve the same:
print join "," ,reverse split /,/, $j

0 comments: