in reply to reverse is not reversing
Hi, reverse operates on lists:
Add a call to scalar:reverse LIST In list context, returns a list value consisting of the el +ements of LIST in the opposite order. In scalar context, concaten +ates the elements of LIST and returns a string value with all chara +cters in the opposite order. print join(", ", reverse "world", "Hello"); # Hello, w +orld print scalar reverse "dlrow ,", "olleH"; # Hello, w +orld Used without arguments in scalar context, "reverse" revers +es $_. $_ = "dlrow ,olleH"; print reverse; # No output, li +st context print scalar reverse; # Hello, world
#!/usr/bin/perl use warnings; use strict; my $test = ''; $test = "apples"; print scalar reverse $test;
Hope this helps!
|
|---|