Which Perl Module To Include To Use String Length Function?

HI all,
I'm writing a perl script to automate VM UUID transformation into a format used by our ServiceNow CMDB/discovery.

Anyone know which perl module to include to use the string length function?

Alternately, how would I determine which perl modules exist that are available to include, vs. which functions each module contains?

thanks in advance,
Tracy Wiseman, software engineer, Silicon Valley


Similar Content



*** ERROR: PERL Module Apache::DBI Is Not Installed !

Hello,

I am configuring OCS Server using the following two documentations:

http://wiki.centos.org/HowTos/OCSNG
http://www.howtoforge.com/how-to-ins...-on-centos-5.5

Getting below error during installaton:

""Checking for DBI PERL module...
Found that PERL module DBI is available.
Checking for Apache:BI PERL module...
*** ERROR: PERL module Apache:BI is not installed !
Checking for DBD::mysql PERL module...
Found that PERL module DBD::mysql is available.
Checking for Compress::Zlib PERL module...
Found that PERL module Compress::Zlib is available.
Checking for XML::Simple PERL module...
Found that PERL module XML::Simple is available.
Checking for Net::IP PERL module...
Found that PERL module Net::IP is available.
*** ERROR: There is one or more required PERL modules missing on your computer !
Please, install missing PERL modules first.""

i have googled for the solution unsuccessfully.
please help me in installing the missing perl module.

thanks in advance..

--
Anil Anji

How To Install Perl Module On RHEL?

Hello,

I need to install perl-Expect, so, I executed:

Code:
#  yum install -y perl-Expect
Error: Package: perl-Expect-1.21-14.el7.noarch (epel)
           Requires: perl(IO::Pty) >= 1.03
Error: Package: perl-Expect-1.21-14.el7.noarch (epel)
           Requires: perl(IO::Tty)

Okay, I need to install perl(IO::Pty)

I launched
Code:
# yum install -y "perl(IO::Pty)"
No package perl(IO::Pty) available.
Error: Nothing to do

So, how to install all required perl modules to the RHEL?

Perl Script Not Running Via Cron

Hi All,

I have perl script which I am trying to run on 1st Monday via cron job.
So I scheduled it as follows:

0 0 1-7 * * root ["$(date '+%a')" = "Mon"] && /usr/bin/perl script.pl

But then it didn't run so checked cron log and it seemed like its missing the command. so added a \ in front of %a and then it picked up the whole command as per cron log.

But still it didnt ran the script. I then change the script to just && echo "test">/tmp/test

Still nothing. if I run it as /usr/bin/perl script.pl it runs though

Thanks in advance.

Perl One Liner To Delete Line In Csv File If One Columns Is Toobig

I have a little bash script that cats out a file and tells me if there is a line
where the 11th column has more than 6 characters in it.
It emails me where there is a bad line in a file - bead meaning that it will break a
donwstream process.

anyhow when i get the email saying that there is a bad file i just log in to the pc via
vpn and the I sed out the lines from the file that I get in the email. The bad lines are
always in danny.csv not danny1.csv
It has been the same lines killing the downstream process for a few weeks, so i put the "sed -i's" into
the script and it does it automagically.

[CODE]
for i in danny.csv danny1.csv
do
cat /come/and/play/with/$i | perl -ne 'print if length((split /,/)[10]) > 6' | mail -s "danny.csv bad line" casper@casperr.com
done

#it would be nice to find a perl change the file in place
sed -i '/D,642,0642,UBF,EVL,,M,,S,S,FOREVER,213,213,/d' /come/and/play/with/us/danny.csv
sed -i '/D,642,0642,UBF,EVL,,M,,S,S,QSP-U=C,4,4,/d' /come/and/play/with/us/danny.csv
[CODE]

However when a new line gets put into this file, I am going to have to log in and take out the line.
SO I have been trying to write a perl one liner that will edit the file in place, like sed, and make a
backup of the file. I just need a perl one liner that will delete any line where the 11th columns has more
than 6 characters in it.
[CODE]
perl -p -i.bak -e 's/\,\w{7}\,//g - which does not work.
[CODE]
I tried something like this:

[CODE]
perl -nle 'print if /\,\w{7}\,/' /come/and/play/with/us/danny.csv
[CODE]
but that does not catch the QSP-U=C and it catches more lines than just the
FOREVER. for a solutinog I need to focus on the the 11th column.

Disable Warning Messages In Perl..

Hi All,

I'm not a perl programmer, so please help me to disable warning messages. I tried like commenting 'use strict' and 'use warning' in perl program. But it is not working.

All I want is to disable warning messages.

Please note its not actual ping program, But a perl wrapper for ping to display ping output in color (Cope).

Below is output:

Code:
$ ./ping google.com
given is experimental at /usr/local/share/perl/5.20.2/App/Cope.pm line 255.
when is experimental at /usr/local/share/perl/5.20.2/App/Cope.pm line 256.
when is experimental at /usr/local/share/perl/5.20.2/App/Cope.pm line 259.
when is experimental at /usr/local/share/perl/5.20.2/App/Cope.pm line 262.
given is experimental at /usr/local/share/perl/5.20.2/App/Cope/Extra.pm line 119.
when is experimental at /usr/local/share/perl/5.20.2/App/Cope/Extra.pm line 120.
given is experimental at /usr/local/share/perl/5.20.2/App/Cope/Extra.pm line 159.
when is experimental at /usr/local/share/perl/5.20.2/App/Cope/Extra.pm line 160.
when is experimental at /usr/local/share/perl/5.20.2/App/Cope/Extra.pm line 161.
PING google.com (173.194.36.4) 56(84) bytes of data.
64 bytes from bom04s01-in-f4.1e100.net (173.194.36.4): icmp_seq=1 ttl=57 time=67.8 ms
64 bytes from bom04s01-in-f4.1e100.net (173.194.36.4): icmp_seq=2 ttl=57 time=68.1 ms
64 bytes from bom04s01-in-f4.1e100.net (173.194.36.4): icmp_seq=3 ttl=57 time=66.6 ms
64 bytes from bom04s01-in-f4.1e100.net (173.194.36.4): icmp_seq=4 ttl=57 time=66.6 ms
^C
--- google.com ping statistics ---
4 packets transmitted, 4 received, 0 packet loss, time 3004ms
rtt min/avg/max/mdev = 66.687/67.353/68.155/0.743 ms

Works fine when error redirected to /dev/null
Code:
$ ./ping google.com 2>/dev/null
PING google.com (173.194.36.1) 56(84) bytes of data.
64 bytes from bom04s01-in-f1.1e100.net (173.194.36.1): icmp_seq=1 ttl=57 time=68.4 ms
64 bytes from bom04s01-in-f1.1e100.net (173.194.36.1): icmp_seq=2 ttl=57 time=66.6 ms
64 bytes from bom04s01-in-f1.1e100.net (173.194.36.1): icmp_seq=3 ttl=57 time=66.4 ms
^C
--- google.com ping statistics ---
3 packets transmitted, 3 received, 0 packet loss, time 2003ms
rtt min/avg/max/mdev = 66.419/67.179/68.421/0.885 ms

Unfortunately, I cannot use output error redirection because all the perl programs are in PATH.

Actual ping perl program:
Code:
#!/usr/bin/env perl
use App::Cope;
use App::Cope::Extra qw[ping_time percent_b];
use Regexp::Common qw[net];

sub process {

  # header
  line qr{^PING (\S+)} => 'blue bold underline';

  # ping replies
  line qr{time=([0-9.]+ ms)\b}    => \&ping_time;
  mark qr{\($RE{net}{IPv4}\)}     => 'blue';
  line qr{(?:icmp_seq|ttl)=(\d+)} => 'bold';
  line qr{^(?:\d+ bytes )?[Ff]rom ([^:\s]+)} => 'blue bold';

  # final ping statistics
  line qr{(\d+% packet loss)} => \&{ percent_b 0, 1, 26 };
  line qr{min/avg/(?:max/mdev|ewma/max)\s=\s
	  ([0-9.]+)/    # minimum
	  ([0-9.]+)/    # average
	  ([0-9.]+)/    # maximum or moving average
	  ([0-9.]+\sms) # mean deviation or maximum
       }x => ( \&ping_time ) x 4;

}

run( \&process, real_path, @ARGV );

Code:
$ head -n15 /usr/local/share/perl/5.20.2/App/Cope.pm
#!/usr/bin/env perl
package App::Cope;
#use strict;
#use warnings;
use 5.010_000;
use Carp;

our $VERSION = '0.99';

=head1 NAME

App::Cope - Functions for the B<cope> program

=head1 SYNOPSIS

Code:
$ head -n15 /usr/local/share/perl/5.20.2/App/Cope/Extra.pm
#!/usr/bin/env perl
package App::Cope::Extra;
#use strict;
#use warnings;
use 5.010_000;

=head1 NAME

App::Cope::Extra - Pre-defined highlighting syntax for common patterns

=head2 SYNOPSIS

  use App::Cope::Extra;

  line qr{User: (\S+)} => \&{ user 'yellow' };

Thanks

Cannot Say Hello To The World Due To 'code 1'

/************************************************************
*
* Project 0: My First Program in C++
*
* Author: xxx xxxx
* Date: 18 January 2015
*
* This is the canonical first program for C++.
* Its purpose is to show that one knows how to create a program in
* one's particular programming environment.
*
************************************************************/

#include <bjarne/std_lib_facilities.h>

int main()
{
cout << "Hello, world!\n";

return 0;
}

I compiled the hello world program as my prof instructed.
then I used C+c C+c, delete 'make -k' and replaced with 'g++ -o proj0 -std=c++11 proj0.cc', choose to save the file, and it goes 'compilation exited abnormally with code 1'

note that I do all these by making SSH connection with computer in lab with a linux system

FYI, the whole thing is:

-*- mode: compilation; default-directory: "~/private/cs1/proj0/" -*-
Compilation started at Sun Jan 18 21:15:54

g++ -o proj0 -std=c++11 proj0.cc
In file included from /usr/include/c++/4.9.2/locale:41:0,
from /usr/include/c++/4.9.2/iomanip:43,
from /usr/local/include/bjarne/std_lib_facilities.h:220,
from proj0.cc:14:
/usr/include/c++/4.9.2/bits/locale_facets_nonio.h:1869:5: error: template-id do_get<> for String std::messages<char>::do_get(std::messages_base::catalog, int, int, const String&) const does not match any template declaration
messages<char>::do_get(catalog, int, int, const string&) const;
^
/usr/include/c++/4.9.2/bits/locale_facets_nonio.h:1869:62: note: saw 1 template<> , need 2 for specializing a member function template
messages<char>::do_get(catalog, int, int, const string&) const;
^

Compilation exited abnormally with code 1 at Sun Jan 18 21:15:55

How To Pass String Variable As Command Parameter In Shell Script?

Hello Friends,

I want to pass string variable with its value taken by user as command parameter in shell script, example below:-

echo "Enter New Password:="
read password


perl -pi -e
's/PASSWORD=.*?,/$password,/' abc.txt

Please let me know...
Thanks In advanced.

How To Recover From A Botched Graphics Card Driver Install

OK,

Lastnight I decided to finally attempt to install the dedicated ATI/AMD Catylist drivers. After all I was successfull with the HP drivers, right...

No matter which grub selection I make, getting in is broken, except of course for the Windows XP Pro x64 entry, that works just fine. I'm here with you today, because of the Fedora 21 Live DVD, (slooooww).

Here is the drivers log file:

==========================================================
Supported adapter detected.
Check if system has the tools required for installation.
Uninstalling any previously installed drivers.
Unloading radeon module...
rmmod: ERROR: Module radeon is in use
Unloading drm module...
rmmod: ERROR: Module drm is in use by: ttm drm_kms_helper radeon
[Message] Kernel Module : Trying to install a precompiled kernel module.
[Message] Kernel Module : Precompiled kernel module version mismatched.
[Message] Kernel Module : Found kernel module build environment, generating kernel module now.
AMD kernel module generator version 2.1
doing Makefile based build for kernel 2.6.x and higher
rm -rf *.c *.h *.o *.ko *.a .??* *.symvers
make -C /lib/modules/3.18.3-201.fc21.x86_64/build SUBDIRS=/usr/lib/modules/fglrx/build_mod/2.6.x modules
make[1]: Entering directory '/usr/src/kernels/3.18.3-201.fc21.x86_64'
CC [M] /usr/lib/modules/fglrx/build_mod/2.6.x/firegl_public.o
/usr/lib/modules/fglrx/build_mod/2.6.x/firegl_public.c:6396:12: warning: ‘KCL_fpu_save_init’ defined but not used [-Wunused-function]
static int KCL_fpu_save_init(struct task_struct *tsk)
^
CC [M] /usr/lib/modules/fglrx/build_mod/2.6.x/kcl_acpi.o
/usr/lib/modules/fglrx/build_mod/2.6.x/kcl_acpi.c: In function ‘KCL_ACPI_Slot_No_Hotplug’:
/usr/lib/modules/fglrx/build_mod/2.6.x/kcl_acpi.c:845:21: error: ‘struct acpi_device_flags’ has no member named ‘no_hotplug’
tdev->flags.no_hotplug = true;
^
scripts/Makefile.build:257: recipe for target '/usr/lib/modules/fglrx/build_mod/2.6.x/kcl_acpi.o' failed
make[2]: *** [/usr/lib/modules/fglrx/build_mod/2.6.x/kcl_acpi.o] Error 1
Makefile:1385: recipe for target '_module_/usr/lib/modules/fglrx/build_mod/2.6.x' failed
make[1]: *** [_module_/usr/lib/modules/fglrx/build_mod/2.6.x] Error 2
make[1]: Leaving directory '/usr/src/kernels/3.18.3-201.fc21.x86_64'
Makefile:88: recipe for target 'kmod_build' failed
make: *** [kmod_build] Error 2
build failed with return value 2
[Error] Kernel Module : Failed to compile kernel module - please consult readme.
[Reboot] Kernel Module : dracut
==========================================================

I just rebooted without attempting to configure the card, as per the ATI/AMD warning stating that it's important to do so, because my thinking was derailed due to seeing errors, and the install program said I needed to reboot. Afterall, I just couln't believe that with a "Failed to compile kernel module" error, it would actually keep the changes I'd made, that surely Linux had a failsafe in place for such circumstances. In other words, I'm also a newbie, and just don't know how many hoops of fire one has to jump through to be at peace with linux.

Can anyone please help be get back into my install, I've already set up so many things, there's just got to be a way, right?


Thanks in Advance!


JustAnotherHuman

How To Know The Loading Sequence/time Of Modules During Boot?

Hello,
the "lsmod" give the list of the loaded modules/drivers.
How to know when was theier loading time (start/end) ?
Is there any existing log file where that information can be seen ?
For another topic, see http://www.linuxquestions.org/questi...ml#post5362257, I am thinking the unfinished loading of a specific module (ehci-pci or other pci driver) or the loading of a module before another one, could disturb the loading of a module e1000e during a cold boot.
Thanks a lot for any help.

Printing a bootchart? http://www.bootchart.org/images/bootchart.png
Something else?

Time Out For Linux Commands

I am calling lsof command in perl script,but due to node issue it's getting stucked .
Because of this script is unable to exit and finish execution. please help.