perl

split one line regex in a multiline regexp in perl

删除回忆录丶 提交于 2021-02-05 09:42:36
问题 I have trouble spliting my regex in multiple line. I want my regex to match the line given: * Code "l;k""dfsakd;.*[])_lkaDald" So I created this regex which work: my $firstRegexpr = qr/^\s*\*\s*Code\s+\"(?<Code>((\")*[^\"]+)+)\"/x; But now I want to split it in multiline like this(and want it to match the same thing!): my $firstRegexpr = qr/^\s*\*\s*Code\s+\" (?<Code>((\")*[^\"]+)+)\"/x; I read about this, but I have trouble using it: / ^\s*\*\s*Code\s+\" (?<Code>((\")*[^\"]+)+)\" /x My last

perl bash script don't insert sql query

有些话、适合烂在心里 提交于 2021-02-05 09:30:34
问题 i want to insert a query but not work : my $query1 = $db1->prepare("SELECT host, name, severity FROM XX"); my $query2 = $db2->prepare('UPDATE worldmap_table' . ' SET severity = ?, name = ? WHERE HOST = ?'); $query1->execute; while (my @row = $query1->fetchrow_array) { $query2->execute($row[2]); print "$row[2]\n"; } preparation query 3 my $query3 = $db1->prepare("SELECT host, name, severity FROM XX); preparation query 4 my $query4 = $db2->prepare('UPDATE worldmap_table' . ' SET severity = 6,

Hash content extraction based on condition

若如初见. 提交于 2021-02-05 09:12:18
问题 I have a hash containing node data. I am expecting hash content to be printed in -r_<count> and -d_<count> attributes. Here is the script: use strict; use warnings; use Data::Dumper; my %hash = ( 'Network=Test,Cell=31' => [ 'Network=Test,Unit=RU-1-1,Port=A', 'Network=Test,Unit=RU-1-2,Port=A' ], 'Network=Test,Cell=32' => [ 'Network=Test,Unit=RU-1-1,Port=A', 'Network=Test,Unit=RU-1-2,Port=A' ], 'Network=Test,Cell=33' => [ 'Network=Test,Unit=RU-1-5,Port=A', 'Network=Test,Unit=RU-1-6,Port=A' ], )

Hash content extraction based on condition

我们两清 提交于 2021-02-05 09:11:24
问题 I have a hash containing node data. I am expecting hash content to be printed in -r_<count> and -d_<count> attributes. Here is the script: use strict; use warnings; use Data::Dumper; my %hash = ( 'Network=Test,Cell=31' => [ 'Network=Test,Unit=RU-1-1,Port=A', 'Network=Test,Unit=RU-1-2,Port=A' ], 'Network=Test,Cell=32' => [ 'Network=Test,Unit=RU-1-1,Port=A', 'Network=Test,Unit=RU-1-2,Port=A' ], 'Network=Test,Cell=33' => [ 'Network=Test,Unit=RU-1-5,Port=A', 'Network=Test,Unit=RU-1-6,Port=A' ], )

Hash content extraction based on condition

↘锁芯ラ 提交于 2021-02-05 09:11:05
问题 I have a hash containing node data. I am expecting hash content to be printed in -r_<count> and -d_<count> attributes. Here is the script: use strict; use warnings; use Data::Dumper; my %hash = ( 'Network=Test,Cell=31' => [ 'Network=Test,Unit=RU-1-1,Port=A', 'Network=Test,Unit=RU-1-2,Port=A' ], 'Network=Test,Cell=32' => [ 'Network=Test,Unit=RU-1-1,Port=A', 'Network=Test,Unit=RU-1-2,Port=A' ], 'Network=Test,Cell=33' => [ 'Network=Test,Unit=RU-1-5,Port=A', 'Network=Test,Unit=RU-1-6,Port=A' ], )

How to monitor remote Linux machines and retrieve installed software in Perl?

倾然丶 夕夏残阳落幕 提交于 2021-02-05 08:35:20
问题 I have a couple of Perl scripts that allow me to monitor remote Windows machinses through WMI. Right now I can check CPU usage, Memory usage, Disk usage and Installed Software. But what if I want to do the same job on a remote Linux machine? Ofcourse there's no WMI so I guess I shall use something similar. I have read on another old StackOverflow question that Linux exposes informations through /proc and /sys but can I query them from a remote computer? And how can I do that exactly in Perl?

Unable to install perl modules via cpanm in conda environments

﹥>﹥吖頭↗ 提交于 2021-02-05 07:25:07
问题 I'm trying to install perl modules via cpanm inside conda environment with perl installed. The conda environment was build with following definition: name: perl_env channels: - bioconda - conda-forge - defaults dependencies: - perl=5.26 - perl-app-cpanminus - perl-local-lib - gcc_impl_linux-64 - gxx_linux-64 - openmpi=4.1.0 The environment results with the following packages installed: # Name Version Build Channel _libgcc_mutex 0.1 conda_forge conda-forge _openmp_mutex 4.5 1_gnu conda-forge

Regex: must start with a letter or a number but the rest can be anything

谁说我不能喝 提交于 2021-02-05 07:01:07
问题 I am trying to construct a pattern in order to use in validation. My goal is to have the first character to be a letter or a number, the rest anyhing. i.ex: A'r4nd0m! 9!h3ll0. b1llin6s I thought of: [a-zA-Z0-9_/][.*]++ What would be the solution? Thank you! 回答1: As I’ve commented, a letter or a number is [\pL\pN] . Therefore a string beginning with one of those would match the pattern /^[\pL\pN]/ 回答2: If the first number is a number or letter, you have ^[A-Za-z0-9] . (The ^ matches the

Perl regex with pipes

自闭症网瘾萝莉.ら 提交于 2021-02-05 06:10:03
问题 I'm not exactly a perl monk, so if you could help me digest what does this regex(if it is one) do? my $pathHere = "/some/path/to/file"; my $pathThere = "/some/path/"; $pathHere =~ s|$pathThere||; Perl is not exactly my everyday tool, so I am quite shy on knowledge - I guess it subs the match to the var value, but guessing is not the way to go - the pipes throw me off... Thanks 回答1: In Perl you'd normally use the / as a delimiter in the regexp. $pathHere =~ s/abc/def/; # replace 'abc' with

Perl regex with pipes

亡梦爱人 提交于 2021-02-05 06:09:47
问题 I'm not exactly a perl monk, so if you could help me digest what does this regex(if it is one) do? my $pathHere = "/some/path/to/file"; my $pathThere = "/some/path/"; $pathHere =~ s|$pathThere||; Perl is not exactly my everyday tool, so I am quite shy on knowledge - I guess it subs the match to the var value, but guessing is not the way to go - the pipes throw me off... Thanks 回答1: In Perl you'd normally use the / as a delimiter in the regexp. $pathHere =~ s/abc/def/; # replace 'abc' with