perl-module

PERL : How to create table from an array?

坚强是说给别人听的谎言 提交于 2020-01-04 09:05:30
问题 I have an array like this @array = ( 1, some 9-digit number-1, some 9-digit number-2, 2, some 9-digit number-3, some 9-digit number-4 .....and so on ); Now I want to print this in a table as 1 some 9-digit number-1 some 9-digit number-2 2 some 9-digit number-3 some 9-digit number-4 3 some 9-digit number-5 some 9-digit number-6 I also want to print the table to a text file. What logic would be the best ? Thanks 回答1: I figured it out. I used Text::Table Thanks – John F use Text::Table; my $tb =

How we can create a Unique Id in Perl

99封情书 提交于 2020-01-03 07:23:12
问题 I want to create a UniqueId . Is there a function I can call, such that every time when I use that it will give me a new Id, always with a different value? 回答1: The better way you can use this also use UUID::Generator::PurePerl; sub create_search_id { my $this =shift; my $args=shift; my $ug = UUID::Generator::PurePerl->new(); my $uuid1 = $ug->generate_v1(); return $uuid1; } From here you can learn about Link 回答2: Use Data::UUID to generate unique IDs: use Data::UUID; $ug = Data::UUID->new;

How do we convert UUID to date in perl

旧街凉风 提交于 2020-01-02 08:11:14
问题 I am very new to Perl language. How to convert the UUID to date format 2011-04-22 ? For example, I have UUID like this 118ffe80-466b-11e1-b5a5-5732cf729524 . How to convert this to date format? 回答1: The module UUID::Tiny has a method called time_of_UUID() that might help: time_of_UUID() This function accepts UUIDs and UUID strings. Returns the time as a floating point value, so use int() to get a time() compatible value. Returns undef if the UUID is not version 1. my $uuid_time = time_of_UUID

How do we convert UUID to date in perl

自闭症网瘾萝莉.ら 提交于 2020-01-02 08:11:12
问题 I am very new to Perl language. How to convert the UUID to date format 2011-04-22 ? For example, I have UUID like this 118ffe80-466b-11e1-b5a5-5732cf729524 . How to convert this to date format? 回答1: The module UUID::Tiny has a method called time_of_UUID() that might help: time_of_UUID() This function accepts UUIDs and UUID strings. Returns the time as a floating point value, so use int() to get a time() compatible value. Returns undef if the UUID is not version 1. my $uuid_time = time_of_UUID

How do I sort a list of IP addresses and compute a class and netmask for each? [closed]

有些话、适合烂在心里 提交于 2019-12-31 07:59:34
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I have 2 options. One is that I have a array that has a list of IPs. For example my @Ip=(); # array that has the IPs below in it Sample input: 108.0.0.30 108.0.0.30 108.0.0.30 192.168.1.1 192.168.1.2 10.0.0.1 I need a program that can sort such an array and tell which network class and subnet mask it is. For

Perl IPTables Module Installation Error

我是研究僧i 提交于 2019-12-31 06:47:12
问题 I've been trying to install the IPTables module for perl http://metacpan.org/pod/IPTables::IPv4 and I've been running into errors during installation. I've tried installing using the CPAN in shell as well as downloading the tarball form the link above. Both installation give me errors. I am not sure how to get the dump from CPAN but what I can get is a dump of my shell when I run the MAKE file from the tarball: [root@localhost IPTables-IPv4-0.98]# make make -C libiptc/ all make[1]: Entering

Perl script to read a csv file from a particular row to end of file

冷暖自知 提交于 2019-12-27 07:06:25
问题 I have a CSV file my.csv with this content: abc,yyy efg,zzz zsc,vvv uvw,ggg Depending upon the value in variable $X I need to read from that particular value until the end of the file. For example: If $X = efg , the output would be: efg,zzz zsc,vvv uvw,ggg For $X = zsc : zsc,vvv uvw,ggg This is the script I developed, which reads in a CSV file's whole content and displays it: use strict; use warnings; open(my $data, '<', $file) or die "Could not open '$file' $!\n"; while (my $line = <$data>)

Perl script to read a csv file from a particular row to end of file

杀马特。学长 韩版系。学妹 提交于 2019-12-27 07:02:36
问题 I have a CSV file my.csv with this content: abc,yyy efg,zzz zsc,vvv uvw,ggg Depending upon the value in variable $X I need to read from that particular value until the end of the file. For example: If $X = efg , the output would be: efg,zzz zsc,vvv uvw,ggg For $X = zsc : zsc,vvv uvw,ggg This is the script I developed, which reads in a CSV file's whole content and displays it: use strict; use warnings; open(my $data, '<', $file) or die "Could not open '$file' $!\n"; while (my $line = <$data>)

Perl script to read a csv file from a particular row to end of file

荒凉一梦 提交于 2019-12-27 07:02:32
问题 I have a CSV file my.csv with this content: abc,yyy efg,zzz zsc,vvv uvw,ggg Depending upon the value in variable $X I need to read from that particular value until the end of the file. For example: If $X = efg , the output would be: efg,zzz zsc,vvv uvw,ggg For $X = zsc : zsc,vvv uvw,ggg This is the script I developed, which reads in a CSV file's whole content and displays it: use strict; use warnings; open(my $data, '<', $file) or die "Could not open '$file' $!\n"; while (my $line = <$data>)

Return multiple values from a function in hash

旧城冷巷雨未停 提交于 2019-12-25 18:18:18
问题 I have created a function which essentially logs into a router,executes a command, parses the command output and prints the Peer status and Peer ip Function returns the values as expected. In addition to status and peer ip if i want to return 3 more values say for eg: $session_id, $session_state and $time. How do I do that with hash ? I want the function to return all the five values in a Hash. sub session_status { my ($self,$interface_name) = @_; my $status = 0; my $peer_ip = 0; #command to