perl's questions - English 1answer

59.558 perl questions.

I have a file where each line is a base64-encoded XML document. The decoded XML documents may contain new line characters. I would like to grep out each XML document containing a given word. The ...

I am using the below mentioned code to process a file. Even thought I have enough space to process the file I am getting out of memory. The same script works fine for small files. #!/bin/ksh Perl -p ...

I have to work with scripts that puke scary amounts of prints so I grep 50% out, merge some lines that reduces another 30% and color the remaining 20% for easier reading... but the coloring seems like ...

The following is a code adapted from this link for getting the weather and displaying on i3blocks. #!/bin/bash METRIC=1 #Should be 0 or 1; 0 for F, 1 for C if [ -z $1 ]; then echo echo "...

I has a file that contain information like below 1:2=14 3:4=15 2:1=16 4:3=17 I would like to create a hash that treat key {1:2} same with key {2:1} $hash{1:2} = $hash{2:1} so when i print all ...

I'd like to use a moderate amount of forwarding to other controllers in a Mojolicious::Lite app. I thought I could use ->to (docs) do something like (get '/x')->to('Route#bar'); get '/y' =>...

I am back again with a question. I have been trying all night and not winning. I am trying to print when a catergory begins, then print a description of the items in the catergory, print the items ...

class method and object method are different in terms of using them in Perl programming or what are advantage if i use the class method instead of object method and vice-versa.

I started programming with Perl and have a problem to put the output from a switch (Cisco) in a variable. Example: I want to send the command show version to the switch ($easy->send_command("show ...

I am trying to combine two API results into one JSON. I am trying to add a new key 'status' and assign the values of the second API to that key. $ua->get_p( $url => $header )->then( ...

I have an integer value in perl, let's say $runid = 1, I need to create a new directory named R_00001 using mkdir R_$runid from the perl script. I am not able to append zeroes. "printf" does the trick ...

On a web server (not mine) with JavaScript pages (probably generated with a Java API) there is a page accessible with authentication. On this page there is a form that I can access with a Perl script ...

I recently migrated to a new server due to hardware issues. The old server ran Centos 7 as does the new one. I don't remember for sure the Perl version on the old server but I believe it was the ...

This is my text file: animal, cola, husband, 36 animal, wilma, wife, 31 animal, pebbles, kid, 4 brutal, george, husband, 41 brutal, jane, wife, 39 brutal, elroy, kid, 9 cosa, homer, husband, 34 cosa,...

How do references in Perl work

3 answers, 148 views perl
Can anyone explain the push statement in the following Perl code to me? I know how push in perl works but I can't understand what the first argument in following push command represents. I am trying ...

I want to parse a license file which somehow has contents like this. COMPONENTS="A0000 B0000 G0000" The quotation marks are necessarily there in the file to mark start and end to components in a ...

I have a fixed-sized array where the size of the array is always in factor of 3. my @array = ('foo', 'bar', 'qux', 'foo1', 'bar', 'qux2', 3, 4, 5); How can I cluster the member of array such that we ...

I wrote some code that creates a hash from an array. I created one liner $seens to remove duplicates, instead of building hash tables, this will remove duplicates from my keys and values. I ...

Accessing a hash

3 answers, 68 views perl
How do I further access this hash? Upon using below dumper, print Dumper(\%LinkData); The result is $VAR1 = { 'AlternativeTo::Source' => { '...

I have this xml file test1.xml: <body> <message> <name>gandalf</name> <attributes> <value key="1">1</value> <...

I'm reading tweetylicious source from github to study Mojolicious framework: However I'm confused by below piece code ladder sub .... What does it mean in Perl? It looks not a regular Perl grammer. ...

I have a Perl CGI script which invokes HTML form, takes input, and process it. I want to upload the resultant file to the same localhost server (apache2) but after processing, it generates the ...

I'm reading a mojo example from: https://mojolicious.org/ Below is the code: use Mojolicious::Lite -signatures; # Render template "index.html.ep" from the DATA section get '/' => sub ($c) { $c-&...

Could anyone help explain the grammer about "has usage ...", "has description ..." in below cgi.pm? package Mojolicious::Command::cgi; use Mojo::Base 'Mojolicious::Command'; use Mojo::Server::CGI; ...

Recently I read a blog post saying that it is a good practice to develop Perl applications just as you would develop a CPAN module. (Here it is – thanks David!) One of the reasons given was that you ...

Intro I am currently working with an existing Perl/R project. I need to pass multiple variables from a Perl page to an R script. This project currently uses the example as shown bellow. var.pl -->...

It appears that string context (while a real thing, and mentioned in "Programming Perl" chapter "2.7.1. Scalar and List Context" as a sub-idea of scalar context), isn't clearly documented anywhere I ...

I want to extract lines between 2 timestamps from this log file # Time: 180517 12:45:53 # User@Host: root[root] @ localhost [] # Thread_id: 265682 Schema: ytpbilling QC_hit: No # Query_time: 3....

There are multiple installers for cpan modules available; I know of at least CPAN.pm (comes with perl,) CPANPLUS, and cpanminus. What is the difference between the three? What situations call for ...

I have a very simple DiscordBOT doing some administrative tasks. One of the features is (or should be) our "emoji based polls". We make a post, with emojis listing the options complete with arrows ...

I'm actually trying to learn the perl code and I’ve got some problem with my last code with mechanize. I just want to create a bot to login on my favorite website. I’ve already do it with ...

I have this path ../../Capture.jpg. So far I've figured out this incomplete regex: '[../]+'. I want to check if user puts in the right path like ../../image file name. The file extensions can be jpg, ...

I'm trying to use Visual Studio Code for Perl (on Debian 9). I have installed VSCode extensions: Code Outline (by Patryk Zawadzki); Perl (by Henrik Sjooh). Extension code-outline works great for .pl ...

I have a module called: modem.pm and I have a bunch of code of such. Converting as hash and passing it though a subroutine. package rawr::modem; use rawr::boot::xc; use Exporter; use vars qw(@ISA @...

I have an Oracle WebLogic config.xml file read into a string. I'm looking to update a series of lines in it. I've verified that I'm reading the file, getting the lines set, and able to update the ...

I'm trying to print some text as a simple PDF file. I used the following code, and I got a PDF file, but each letter shows as a box. For example five boxes shown for "Hello", and six boxes for "Hello1"...

use LWP::UserAgent; use Data::Dumper; my $ua = new LWP::UserAgent; $ua->agent("AgentName/0.1 " . $ua->agent); my $req = new HTTP::Request POST => 'http://example.com'; $req->content('port=...

How can I match letters a,b,c once in any combination and varying length like this: The expression should match these cases: abc bc a b bca but should not match these ones: abz aab cc x

I am trying to extract the src value from a tag, so far I seem to be able to extract the string between the src value and the final quotation mark in the string String: <img border="0" src="...

I would like to grab the contents of any value between pairs of <tag></tag> tags. <tag> This is one block of text </tag> <tag> This is another one </tag> The ...

Can anyone explain the difference between \w and \b regular expression meta-characters? It is my understanding that both these meta-characters are used for word boundaries. Apart from this, which ...

I'm trying to extract all the user names from the source (https://tmi.twitch.tv/group/user/twitchpresents/chatters), but so far I'm only able to get like the first "name". Goal is to get all the ...

In RegEx, I want to find the tag and everything between two XML tags, like the following: <primaryAddress> <addressLine>280 Flinders Mall</addressLine> <...

Hi i'm trying to make my ./cat.pl script work like cat in unix... i am attempting to make my cat script be able to read any file for example ./cat.pl perl.txt - i want to see the output of the file ...

I'm currently working on Perl script that will mock node values based on specific criteria. I have similar parents nodes with in a file, out of which on specific criteria I should replace/edit child ...

I am trying to parse through an XLSX file (getting the value for each cell, row by row,) using Spreadsheet::ParseXLSX. Within my loop that goes through each row, I've tried pulling the values with ...

I fully understand that a hash is unsorted, but I was under the impression that it always keeps keys/values relationship. I am not understanding this behaviour at all. When I push from an array, do ...

I have tried with simple program of infinite loop, I ran it using PERL script and tried to KILL it after sleep of 10, but my program is not killing the child-process and runs in infinite loop. //C ...

I have a test-case where multiple fork is used to create grandchild and the parent process is in infinite loop, I am implementing a perl script to kill the process. Currently it is working for single ...

I'm trying to install mod_perl 2.0.10 so we can upgrade our Apache from 2.2 to 2.4. I've got Apache 2.4.26 up and running by itself, but we also need mod_perl installed for a couple of our modules to ...

Language

Popular Tags