Here is semi-working and working code.
Semi-working
$ cat x1.pl | so
#!/usr/bin/env perl
use strict;
use warnings;
my $a = "$192.168.1.1";
print "$a\n";
$a =~ s/\$//;
print "$a\n";
$ perl x1.pl | so
Use of uninitialized value $192 in concatenation (.) or string at x1.pl line 5.
.168.1.1
.168.1.1
$
Working
$ cat x2.pl | so
#!/usr/bin/env perl
use strict;
use warnings;
my $a="$192.168.1.1";
print "$a\n";
$a =~ s/\$//;
print "$a\n";
$ perl x2.pl | so
$192.168.1.1
192.168.1.1
$
Always use use strict;
and use warnings;
while you’re learning Perl (the first twenty or so years are the hardest).
If your code is not working still, you need to show the equivalent SSCCE (Short, Self-Contained, Correct Example) code and the example output, but it should most definitely include use strict;
and use warnings;
.
2
solved How to remove a $ character from a variable’s value in Perl? [closed]