perl

issue accessing elements of hash in perl

妖精的绣舞 提交于 2021-02-08 05:30:11
问题 I have the below hash: my %releaseMap = {"rel1.2.3" => { "supporedPorts" => ["lnx86", "lnppc"], "branch" => ["DEV"], }, "rel2.4" => { "supporedPorts" => ["lnx86", "lnppc"], "branch" => ["DEV"], } }; I want to get the values rel1.2.3 and rel2.4 in the variable $rel, I want to get the values lnx86 and lnppc in $port and I want to get the value DEV in $branch. I am new to the Hash concept in perl, I am not able to figure out how this can be done. Can someone please help. Thanks 回答1: Assuming you

Updating the @INC variable during installation of a conda package

时光总嘲笑我的痴心妄想 提交于 2021-02-08 05:03:43
问题 I am trying to install a conda package of a Perl module. So far I'm able to create the package using conda-build . For that I have a recipe containing a build.sh and a meta.yaml files. I then install it using conda-install in a new environment, I'd like to be able able to run some Perl scripts located in the Perl module I just installed. All those steps work well but when I'm running some scripts I have an error saying : Can't locate PMP/util.pm in @INC (you may need to install the PMP::util

Why does perlbrew fail while installing perl-5.12.2?

落爺英雄遲暮 提交于 2021-02-08 04:15:50
问题 When I try to install Perl 5.12.2 with perlbrew, I get an error at the end because the CPANPLUS tests fail. Making utilities make[1]: Entering directory `/home/dave/perl5/perlbrew/build/perl-5.12.2/utils' make[1]: Nothing to be done for `all'. make[1]: Leaving directory `/home/dave/perl5/perlbrew/build/perl-5.12.2/utils' cd t && (rm -f perl; /bin/ln -s ../perl perl) ./runtests choose t/base/cond....................................................ok t/base/if...................................

Why does perlbrew fail while installing perl-5.12.2?

杀马特。学长 韩版系。学妹 提交于 2021-02-08 04:14:27
问题 When I try to install Perl 5.12.2 with perlbrew, I get an error at the end because the CPANPLUS tests fail. Making utilities make[1]: Entering directory `/home/dave/perl5/perlbrew/build/perl-5.12.2/utils' make[1]: Nothing to be done for `all'. make[1]: Leaving directory `/home/dave/perl5/perlbrew/build/perl-5.12.2/utils' cd t && (rm -f perl; /bin/ln -s ../perl perl) ./runtests choose t/base/cond....................................................ok t/base/if...................................

Why does perlbrew fail while installing perl-5.12.2?

女生的网名这么多〃 提交于 2021-02-08 04:12:16
问题 When I try to install Perl 5.12.2 with perlbrew, I get an error at the end because the CPANPLUS tests fail. Making utilities make[1]: Entering directory `/home/dave/perl5/perlbrew/build/perl-5.12.2/utils' make[1]: Nothing to be done for `all'. make[1]: Leaving directory `/home/dave/perl5/perlbrew/build/perl-5.12.2/utils' cd t && (rm -f perl; /bin/ln -s ../perl perl) ./runtests choose t/base/cond....................................................ok t/base/if...................................

How do I remove duplicate values from an array in Perl? [duplicate]

好久不见. 提交于 2021-02-08 02:22:33
问题 This question already has answers here : How do I remove duplicate items from an array in Perl? (11 answers) Closed 7 years ago . I have multiple values for each key in the hash. Here, I print the values of each key print "$var:",join ',',@{$hash{$var}},"\n"; Output of the above print statement is: ABC:1,2,3,1,4,2, DEF:9,3,4,5,3,5, Now, I want to remove duplicates in the values. The desired output is, ABC:1,2,3,4 DEF:9,3,4,5 Can someone help me in this? Thanks 回答1: Personally, I like how List

replacing telnet with ssh

為{幸葍}努か 提交于 2021-02-07 20:34:16
问题 I have some programs that use the Net::Telnet module to connect to several servers. Now the administrators have decided to replace the Telnet service for SSH, keeping everything else like before (for example the user accounts) I've taken a look at Net::SSH2 and I see that I would have to change most part of the programs. Do you know of other SSH modules, better suited for this same replacement? The client is a Windows box (ActiveState Perl or Cygwin Perl) 回答1: Net::OpenSSH! And check the

Is possible to access ATTR for Perl packages without defining a getter?

戏子无情 提交于 2021-02-07 20:13:54
问题 I am currently working on a Perl 5.8 project. I have package that looks like: package Foo::Bar; use strict; use warnings; use Class::Std; our @EXPORT_SAFE = qw(Class::Std); my %baz :ATTR; sub BUILD { my ($self, $ident, $args) = @_; $baz{$ident} = $$args{something}; } I am not exposing baz with any getter, but I would like to fetch it's content for unit testing purposes. There is any way to do it in Perl? e.g. in Ruby you can some_instance.instance_variable_get("@#{name}") Thank you very much

“handshake error: Wrong response line” when connecting to websocket

北城以北 提交于 2021-02-07 18:20:47
问题 I'm trying to connect to a websocket with the following Perl code: use AnyEvent; use AnyEvent::WebSocket::Client 0.12; my $client = AnyEvent::WebSocket::Client->new; $client->connect("wss://example.com")->cb(sub { my $connection = eval { shift->recv }; # This line is generating the error if($@) { # handle error... warn $@; return; } # send a message through the websocket... $connection->send(''); # receive message from the websocket... $connection->on(each_message => sub { my($connection,

Accessing IPv6 resolvable URL with port (e.g. localhost:12345) results in Bad Address in Strawberry Perl 5.30.1

旧时模样 提交于 2021-02-07 16:22:05
问题 When using strawberry perl 5.30.1 under Windows 10 with IPv6 enabled, URLs with Portnumbers cannot be resolved properly due to what appears to be a bug in the DNS parser of Perl. For the following test, we have a simple webserver listening on Port 8810 for all interfaces. Port 12345 does NOT host anything. Following is the script we use for reproduction: use strict; use warnings; use LWP::UserAgent; my $ua = LWP::UserAgent->new(); my $result=$ua->get("http://localhost:8810/"); print "(DNS