perl

While SSH'ing following error occures - unable to establish master SSH connection: master process exited unexpectedly

生来就可爱ヽ(ⅴ<●) 提交于 2021-01-28 07:39:58
问题 I have a script which does ssh to number of servers ( @alive_hosts ) stored in an array and executes certain commands on those hosts (these hosts are IP address). ... use Net::Ping; use Net::OpenSSH; use Parallel::ForkManager; #these hosts are the IP addresses my @hosts = ("host1", "host2", "host3", "host4", "host5"); my $p = Net::Ping->new(); foreach my $hostname (@hosts){ my ($ret, $duration, $ip) = $p->ping($hostname); push (@alive_hosts, $hostname) if $ret; } my $ssh; my $command = "perl

Perl: Perl6::Form format

末鹿安然 提交于 2021-01-28 07:03:59
问题 I have file something like this, SR Name Rollno Class 1 Sanjay 01 B 2 Rahul_Kumar_Khanna 09 A Now I need to add "|" between each. So it should look like SR | Name |Rollno | Class| 1 | Sanjay |01 | B | 2 | Rahul_Kumar_Khanna|09 | A | I am using Perl6::form my $text; foreach my $line (@arr) { my ($SR, $Name, $Rollno, $Class) = split (" ", $line); my $len = length $Name; $text = form '| {||||||||} | {||||||||} | {||||||||} | {||||||||}|', $SR, $Name, $Rollno, $Class; print $text; } Here till now

CGI error Can't use an array as a reference

假装没事ソ 提交于 2021-01-28 06:50:26
问题 My configuration is Debian Stretch I verify my Perl code with the command line perl -wcT admin.cgi I have an error in the code at this line: print &select("$id-2",\@values,\@values,@{$FORMAT{$name}}->[1]),"<br /> \n"; The error is: Can't use an array as a reference I also tried with this web editor It seems that the error is : @{$FORMAT{$name}}->[1] 回答1: As you say, the problem is here: @{$FORMAT{$name}}->[1] It appears that $FORMAT{$name} is expected to contain an array reference. And you

How can I write code that optionally uses a module if it exists? [duplicate]

两盒软妹~` 提交于 2021-01-28 06:12:35
问题 This question already has answers here : How can I require an optional Perl module if installed? (8 answers) Closed 2 months ago . If I want to write code that optionally uses a module how can I do it? For example, if I want to write code that warn s Dumping an object if Data::Dumper is available or otherwise just warn s, how can I do that? 回答1: BEGIN { if (eval { require Data::Dumper }) { *dumper = sub { warn(Data::Dumper::Dumper(@_)) }; } else { *dumper = sub { }; } } dumper(...); The

Cannot install Algorithm::AhoCorasick::XS on Windows 10, MSYS2: ‘sigjmp_buf’ does not name a type; did you mean ‘Sigjmp_buf’

爷,独闯天下 提交于 2021-01-28 06:08:43
问题 I am trying to install Algorithm::AhoCorasick::XS on Windows 10, MSYS2: $ perl Makefile.PL Generating a Unix-style Makefile Writing Makefile for Algorithm::AhoCorasick::XS Writing MYMETA.yml and MYMETA.json cp lib/Algorithm/AhoCorasick/XS.pm blib/lib/Algorithm/AhoCorasick/XS.pm Running Mkbootstrap for XS () chmod 644 "XS.bs" "/usr/bin/perl.exe" -MExtUtils::Command::MM -e 'cp_nonempty' -- XS.bs blib/arch/auto/Algorithm/AhoCorasick/XS/XS.bs 644 g++ -c -Wall -std=c++11 -DUSEIMPORTLIB -march=x86

Pick a record from file based on last updated date for a particular event

不想你离开。 提交于 2021-01-28 06:06:11
问题 I have list alarm data, where each alarm will be identified with unique key called eventId . For each of the unique eventId I should pick the latest operation performed on the alarm. Latest action performed can be identified by looking into the lastUpdated field of the alarm. Here in below example, I have two alarms data with eventId 1001 and 1002, and list operations performed on those particular alarms. Below is the code: use strict; use warnings; no warnings 'uninitialized'; use Data:

Perl one-liner, printing filename as part of output

做~自己de王妃 提交于 2021-01-28 05:52:35
问题 I posted a question a month or so ago about how to print out a listing of files and all occurrences of a regular expression in those files. The aim being to get a file like this: file1 A12345 file2 A12399 file2 A12599 file3 A11223 and so on. After some help from Miller and anttix (thanks again!), the expression wound up being: perl -lne 'print "$ARGV $1" while(/\<myxmltag>(..............)<\/myxmltag>/g)' *.XML > /home/myuser/myfiles.txt Now I'd really like to be able to add the file's create

Pick a record from file based on last updated date for a particular event

蹲街弑〆低调 提交于 2021-01-28 05:51:04
问题 I have list alarm data, where each alarm will be identified with unique key called eventId . For each of the unique eventId I should pick the latest operation performed on the alarm. Latest action performed can be identified by looking into the lastUpdated field of the alarm. Here in below example, I have two alarms data with eventId 1001 and 1002, and list operations performed on those particular alarms. Below is the code: use strict; use warnings; no warnings 'uninitialized'; use Data:

Unable to send a mail using perl Mime::Lite

江枫思渺然 提交于 2021-01-28 05:36:08
问题 I am unable to send a mail using MIME::Lite. While sending from my desktop it will through the below errors. Error: "SMTP Failed to connect to mail server: Bad file descriptor" I am using the below mentioned code. use strict; use MIME::Lite; use Net::SMTP; my $from_address = "no-reply@host.com"; my $to_address = "madhan@host.com"; my $cc_address = "madhan@host.com"; my $subject = "Test mail"; my $message_body = "Madhan test mail"; my $namer="madhankumar"; my $regards="Madhan M"; print "

Strawberry Perl and PAR - run time error on other Windows machine: LWP will support https URLs if the LWP::Protocol::https module is installed

允我心安 提交于 2021-01-28 04:40:28
问题 I have two Windows 10 machines, and on one of them, I have installed Strawberry Perl (version 5.30.1 if it matters). My script is using REST::Client, and on this machine, the script runs perfectly. I'm using PAR to make an .exe I can run either the .pl script or the .exe executable; on this machine it runs perfectly. I am using the --execute option when I'm running pp.bat, and include an --xargs= option so that the script can execute and run successfully. Then I copy the .exe to another