Tag Archives: perl

Perl IO::Socket::INET6::sockaddr_in6 redefined error

Yesterday I installed spamassassin package on a server running RHEL 6.8. Then this morning, I received an email alert with the following message:

Subroutine IO::Socket::INET6::sockaddr_in6 redefined at /usr/share/perl5/Exporter.pm line 67.
 at /usr/share/perl5/IO/Socket/INET6.pm line 21.
Subroutine IO::Socket::INET6::sockaddr_in6 redefined at /usr/share/perl5/Exporter.pm line 67.
 at /usr/share/perl5/IO/Socket/INET6.pm line 21.
Subroutine IO::Socket::INET6::sockaddr_in6 redefined at /usr/share/perl5/Exporter.pm line 67.
 at /usr/share/perl5/IO/Socket/INET6.pm line 21.
Subroutine IO::Socket::INET6::sockaddr_in6 redefined at /usr/share/perl5/Exporter.pm line 67.
 at /usr/share/perl5/IO/Socket/INET6.pm line 21.

This seems to be a bug exists in an old version of IO::Socket::INET6. Upgrading this package should fix the problem:

# cpan IO::Socket::INET6

Ref: http://stackoverflow.com/questions/23909848/perl-iosocketinet6sockaddr-in6-redefined-error

Warning: Use of “localtime” without parentheses is ambiguous

While looking at the log produced by Request Tracker (RT) 4.2.12, I noticed there was a warning message about using “localtime” without parentheses.

Here’s the actual error message:

[warning]: Warning: Use of "localtime" without parentheses is ambiguous 
at /opt/rt4/sbin/../lib/RT/Interface/Email.pm line 526.

The solution which I found from here, fixed the problem:

On line 526 of file /opt/rt4/sbin/../lib/RT/Interface/Email.pm, replace:

localtime with localtime().

Thanks to the chap who posted the solution.

How to remove a newline at end of file

Those who know me know that I don’t like Perl. Sometimes in life the thing you don’t like could be best tool/friend.

I need to remove a newline character from a text file: layouts/partials/pagination.html.

git diff layouts/partials/pagination.html
diff --git a/layouts/partials/pagination.html b/layouts/partials/pagination.html
index 00c1124..d8dd981 100644
--- a/layouts/partials/pagination.html
+++ b/layouts/partials/pagination.html
@@ -15,4 +15,4 @@
         
         {{ end }}
     {{ end }}
-
\ No newline at end of file
+

The easiest way to do this is to run the following command:

$ perl -pi -e 'chomp if eof' layouts/partials/pagination.html

Thanks Perl and this Stack Overflow question.

Setting proxy for CPAN

To enable CPAN behind proxy:

# perl -MCPAN -e shell
Terminal does not support AddHistory.

cpan shell -- CPAN exploration and modules installation (v1.9402)
Enter 'h' for help.

cpan[1]> o conf init /proxy/

If you're accessing the net via proxies, you can specify them in the
CPAN configuration or via environment variables. The variable in
the $CPAN::Config takes precedence.

 <ftp_proxy>
Your ftp_proxy? []

 <http_proxy>
Your http_proxy? [webproxy.yourdomain.com:8080]

 <no_proxy>
Your no_proxy? []

If your proxy is an authenticating proxy, you can store your username
permanently. If you do not want that, just press RETURN. You will then
be asked for your username in every future session.

Your proxy user id? []

Please remember to call 'o conf commit' to make the config permanent!

cpan[2]> o conf commit
commit: wrote '/usr/share/perl5/CPAN/Config.pm'

Ref: http://abhijit.name/setting_cpan_for_proxy.html