Reputation: 13
i tried to print something variable. but sometime it will print delay or incomplete. below is my part of my code.
my $ltc1v = $data->{PartNumber}->{rev} . "\n";
chomp $ltc1v;
($result)=$check1=~ /:\s*(.+)$/;
print "{{ $result }}\n";
print "{{ $ltc1v }}\n";
if ($result eq $ltc1v )
{}
sometime result show good and able to match if condition.
{{ 0x000b }}
{{ 0x000b }}
but sometime it will show as below and not able to match if condition.
}}0x000b
{{ 0x000b }}
FYI, i used below command to auto flushing as well
$| = 1;
Upvotes: 0
Views: 105
Reputation: 4336
I will add my standard recommendation here:
Whenever you are not sure why your output doesn't look like you expect, check what your data contains.
use Data::Dumper;
local $Data::Dumper::Useqq = 1;
print Dumper $result;
# print Dumper \@array, \%hash;
Upvotes: 1
Reputation: 385789
$check1
contains a Carriage Return.
If you have chomp($check1);
, replace it with $check1 =~ s/\s+\z//;
.
If you don't have chomp($check1);
, just add $check1 =~ s/\s+\z//;
.
Upvotes: 0
Reputation: 98398
Looks like sometimes your data ends with a carriage return character. You can remove that with $result =~ y/\r//d;
.
Or don't include it in what you match:
($result)=$check1=~ /:\s*(.+?)\r?$/;
Upvotes: 1