Let's say I have a baseline file like this:
4.1.27-4.1.2-amd64-1cccde6e81b2c42b
cmos2q installed and running
lm-sensors2q installed and running
lspci2q installed and running
mcelog2q installed and running
mpt2q not needed
pmbus2q installed and running
smartmon2q installed and running
And a...
I have a piece of codes constructing an email sender:
sub getSender {
my $host = hostname;a # use Sys::Hostname;
my $domain = 'xyz.com';
my $char = '.';
my $from;
if($host =~ /$domain/) {
# hostname() may return a string like foo.bar.xyz.com and in this case
# we want to...
I know this line works:
print "OK!! Child($$, $pid) $res ended with ", $? >> 8; print "\n";
But how do I assign the line above into a variable? e.g.
$logMsg .= "OK!! Child($$, $pid) $res ended with ", $? >> 8;
$logMsg .= "\n";
While compiling it, I got this:
Useless use of right bitshift...
A simple code just like this:
my $cmd = "gwsh root\@$ip \"uname -r\"";
my $ret = `$cmd`;
When I ran the code at cmd prompt, it's fine.
But when it's run in a cron job, $cmd returns nothing.
What did I miss here?
Many thanks.
Hi Experts,
I have a very simple script listed below:
#! /usr/bin/perl
my $cmd = "ssh root\@198.18.154.133 \"/a/sbin/tcpdump -v -n -i eth0 port 11640 -w /tmp/mytcpdump.pcap 2>/dev/null\" 2>/dev/null &";
system($cmd);
my $cmd2 = "/usr/bin/ssh root\@198.18.154.130 \"cd /tmp; ./go_load...
I am having difficulties in installing XML::LibXML.
Below is my system:
% cat /etc/issue
Ubuntu 14.04.2 LTS \n \l
% perl -v
This is perl 5, version 18, subversion 2 (v5.18.2) built for x86_64-linux-gnu-thread-multi
(with 41 registered patches, see perl -V for more detail)
I have...
Please take a look at the piece of code below:
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
my ($debug, $emailAddr, $fussy, $fussier);
GetOptions( # This is line 8
"d" => \$debug,
"e=s" => \$emailAddr,
"fussy" => \$fussy,
"fussier" => \$fussier,
) || die;
if($fussy) {...
At first, please take a look at the piece of code:
#!/usr/bin/perl
use Data::Dumper;
my @a1 = ('a','b');
my %h1;
for(my $i = 0; $i <= $#a1; $i++) {
$h1{$i} = \@a1;
}
my @a = (\%h1);
print Dumper(\@a);
exit;
A test run:
% tt.pl
$VAR1 = [
{
'1' => [...
Sample codes:
use Data::Dumper;
my %h;
$h{a} = undef;
$h{b} = '';
$h{c} = 'z';
print Dumper(\%h); # Dumper can distinguish the difference between $h{a} and $h{b}
foreach my $k (keys(%h)) {
# The following block cannot distinguish the difference between $h{a} and $h{b}
if(!$h{$k}) {...
Hi Experts,
Assume there is an m by n all-digit matrix:
X11 X12 ... X1n
X21 X22 ... X2n
...
Xmn Xmn ... Xmn
I need help to write a method that somewhat like 'order by' in ansi sql. This method shall be able to sort the matrix by ANY number of column indices passed in at cmdline.
For example...
Please take a look at the small sample code here.
I just don't understand why it actually finds a match!!
#!/usr/bin/perl -w
my $str = "group=1,101,102";
my $ip = "1.1.1.1";
if($str =~ /$ip/) {
print "The string contains this IP!!\n"
}
else {
print "The string does not contain this...
Hi Experts,
Please take a look at a small demo program including file structure below:
[VM] perl 25 % pwd
/tmp/perl
[VM] perl 26 % ls -l *
-rwxr-xr-x 1 test staff 133 2013-09-18 12:20 run.pl*
lib:
total 4
-rw-r--r-- 1 test staff 233 2013-09-18 12:20 utils.pm
[VM] perl 27 % cat run.pl...
% perl -V
......
......
@INC:
/etc/perl
/usr/local/lib/perl/5.10.1
/usr/local/share/perl/5.10.1
/usr/lib/perl5
/usr/share/perl5
/usr/lib/perl/5.10
/usr/share/perl/5.10
/usr/local/lib/site_perl
.
Is there a way I can recompile perl so that...
My company has multiple product lines and the version numbers are in different format.
For instance, one product line's version numbers may look like this: 5, 5.2, 5.11. The highest version in this example is 5.11. Therefore, we cannot simply sort them numerically.
Another product line's...
I wrote a small piece of codes that does not run as I expected:
my $x1 = undef;
my $x2 = 0;
my $x3 = -1;
my $x4 = 1;
my @arr = ($x1, $x2, $x3, $x4);
for(my $i = 0; $i <= $#arr; $i++) {
if($arr[$i]) {
print "\$i = $i, \$arr[$i] = $arr[$i]\n";
}
else {
if($arr[$i] == 0) { # This...
I am trying to use p4perl. But I am stuck in step one - to install p4perl.
I did a search on this forum and found no threads related to perforce and/or p4perl. Therefore, I'll keep my questions short for now though I may have many follow-up questions later.
According a release note at perforce...
I wrote a small piece of codes to test out ReadOnly.pm.
use Readonly;
Readonly::Hash my %readOnlyHash1 => (
'key11'=>{
'key21'=>1,
'key22'=>1,
},
'xyz'=>{
'abc'=>1,
},
);
Readonly::Hash my %readOnlyHash2 => (
'xyz'=>{
'abc'=>1,
},
);
my $k1 = 'key11';
my $k2 =...
A sample log file somewhat look like this:
x11:x12:x13:...:x1m:value1
x21:x22:x23:...:x2m:...:x2n:value2
x31:x32:x33:...:x3i:value3
x41:x42:x43:...:x4i:...:x4j:value4
Note that --
1) In each row, the elements are delimited by ':';
2) The number of elements in each row may very, i.e. m, n, i...
I need to find a string match at Microsoft site. Out of its web page, there could be one or more strings look like this:
<a class="download" onclick="return false;" href="confirmation.aspx?id=36888"...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.