perl Questions

12

Solved

I have written this code, but it does not work. Can someone point out the issue? sub match_ip() { my $ip = "The IP address is 216.108.225.236:60099"; if($ip =~ /(\d{1-3}\.\d{1-3}\.\d{1-3}\.\d{1-...
Gusman asked 15/4, 2012 at 12:20

9

Solved

Having read a number of questions/answers over the past few weeks, I have seen the use of \d in perl regular expressions commented on as incorrect. As in the later versions of perl \d is not the sa...
Junia asked 20/5, 2009 at 23:9

3

Solved

Is there a limit to the number of capture groups in a regular expression? I used to think it was 9 ($1 ... $9), but haven't found anything in the perlre docs to confirm this. And in fact, the follo...
Powerdive asked 14/12, 2022 at 15:29

9

Solved

In Perl most of my print statements take the form print "hello." . "\n"; Is there a nice way to avoid keeping all the pesky "\n"s lying around? I know I could make a new function such as myprin...
Tades asked 24/5, 2010 at 18:40

7

Solved

I have been using this code to check if a string is empty: if ($str == "") { // ... } And also the opposite with the not equals operator... if ($str != "") { // ... } This s...
Sphinx asked 11/1, 2010 at 23:16

4

Solved

In Perl 5, when we have a named array, e.g. @a, getting the elements from index $N onwards is simple with a bit of slicing: my @result = @a[$N..$#a]; Is there a standard way to do the same with ...
Lawless asked 9/11, 2011 at 21:35

1

Solved

I have a 2D array, and I want to put the first element into a simple array: use strict; use warnings; use Data::Dump; my @matrix = ([1,2,3], [4], [5,6]); my @array = (7,8,9); my @list = $matrix[0...
Baptlsta asked 8/12, 2022 at 14:49

4

I need to handle URI (i.e. percent) encoding and decoding in my Perl script. How do I do that? This is a question from the official perlfaq. We're importing the perlfaq to Stack Overflow.
Sophomore asked 22/12, 2010 at 15:12

4

I am using perlbrew. I have installed lots of cpan modules under perlbrew perl-5.20.2. Is there a way (or what is the best way) to do a tarball installation of my perl-5.20.2 plus all the CPAN modu...
Saddlecloth asked 12/3, 2015 at 15:50

3

Solved

In perl, you have three main data types, "scalars, arrays of scalars, and associative arrays of scalars". What exactly is perl trying to convey with the name "scalar"? What's th...
Unfair asked 28/4, 2021 at 1:48

3

Solved

I have implemented some perl scripts and in some cases i have to pass some command line args into my program.Usability perspective i have decided to add some bash completion script into my project....
Nesta asked 15/7, 2017 at 6:34

3

I made a perl script to change owner of a file owned by some other user. Script is complete. My administrator save that in /sbin directory and set uid for it using chmod u+s name_of_script. But whe...
Implode asked 6/2, 2014 at 8:9

8

Solved

What is an easy way to test if a folder is empty in perl? -s, and -z are not working. Example: #Ensure Apps directory exists on the test PC. if ( ! -s $gAppsDir ) { die "\n$gAppsDir is not acce...
Kenney asked 20/12, 2010 at 20:14

4

Solved

I currently have a Perl script that runs an external command on the system, gathers the output, and performs some action based on what was returned. Right now, here is how I run this (where $cmd is...
Streamlined asked 17/11, 2009 at 22:34

6

Solved

I have number and need to add the suffix: 'st', 'nd', 'rd', 'th'. So for example: if the number is 42 the suffix is 'nd' , 521 is 'st' and 113 is 'th' and so on. I need to do this in perl. Any poin...
Mendelevium asked 6/7, 2012 at 21:31

6

Solved

I have a CSV file that I use split to parse into an array of N items, where N is a multiple of 3. Is there a way i can do this foreach my ( $a, $b, $c ) ( @d ) {} similar to Python?
Unbuckle asked 8/7, 2010 at 22:9

21

Solved

What I'm looking for is something like: @list = qw(1 2 3 4 5 6); foreach (@list) { #perl magic goes here print "i: $i, j:$j\n"; } returns: i:1, j:2 i:3, j:4 i:5, j:6 In response to a very ...
Mackenziemackerel asked 20/2, 2009 at 14:41

16

Solved

I am seeing both of them used in this script I am trying to debug and the literature is just not clear. Can someone demystify this for me?
Moonlit asked 24/9, 2008 at 20:12

4

Solved

I'm trying to use a negative lookahead in perl in command line: echo 1.41.1 | perl -pe "s/(?![0-9]+\.[0-9]+\.)[0-9]$/2/g" to get an incremented version that looks like this: 1.41.2 but its ju...
Foremost asked 19/6, 2019 at 4:25

4

Solved

I am writing a script which is likely to be modified by users. Currently I am storing the configuration settings inside the script. It exists in the form of a hash-of-hashes. I would like to guard...
Lorrinelorry asked 21/11, 2008 at 20:37

2

Solved

I just added a new file to the PDL::IO::Touchstone distribution and noticed that CPAN's indexer says version is undef since $VERSION is missing: module : PDL::IO::MDIF version: undef in file: PD...
Cigar asked 31/10, 2022 at 1:48

4

Solved

What would be the easiest way to compile a simple Perl script to an executable under Windows with Strawberry Perl (as I understand it's possible and free)? In the past I've used ActiveState compil...
Metz asked 1/6, 2010 at 8:59

5

Solved

In Chapter 4, Section 4.8 (Computing Union, Intersection, or Difference of Unique Lists), the Perl Cookbook provides this technique for getting the intersection of two lists of integers: @a = (1, ...
Dhar asked 20/10, 2011 at 20:54

9

Solved

Postgres DB is already installed. I'm not using system perl I have installed another perl in "/srv/data203806/Migration/CPAN/localperl/bin". When I'm trying to install, It is asking for PATH TO pg_...
Rhea asked 8/3, 2014 at 3:46

7

Solved

I have a text file to parse in Perl. I parse it from the start of file and get the data that is needed. After all that is done I want to read the last line in the file with data. The problem is tha...
Gerri asked 29/3, 2012 at 8:57

© 2022 - 2024 — McMap. All rights reserved.