Liam Liam - 1 year ago 83
Perl Question

Performing a right trim against a string

I'm attempting to perform the equivalent of a simple right trim in Perl using a regex.

I have the value

assigned to the string
, I'm attempting to trim the colon from the end.

I have the following code which attempts to trim the colon, with this code
is still set to
however. Can anyone suggest what the issue is here?

my $test = '1445:';
$test =~ s/:$//;

Answer Source

That can't be the code you ran because it works.

$ perl -e'
    my $test = "1445:";
    $test =~ s/:$//;
    print "$test\n";

Perhaps $test contained in the code you ran was different. Check with

use Data::Dumper;
local $Data::Dumper::Useqq = 1;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download