perl Questions

6

Solved

Can someone please help me? In Perl, what is the difference between: exec "command"; and system("command"); and print `command`; Are there other ways to run shell commands too?
Hemelytron asked 28/4, 2009 at 21:47

2

Solved

The company I'm working at uses Perl for all "backend related" stuff. However, we would like to use some real-time communication between server-processes and connected clients via browser. We are ...
Bouley asked 27/11, 2012 at 9:59

9

Solved

I'm using Perl's DBI module. I prepare a statement using placeholders, then execute the query. Is it possible to print out the final query that was executed without manually escaping the parameter...
Fioritura asked 6/11, 2009 at 12:27

13

Solved

I am trying to figure out a way of checking for the existence of a value in an array without iterating through the array. I am reading a file for a parameter. I have a long list of parameters I do...
Gyrostat asked 18/5, 2010 at 19:3

7

Solved

How do I compare two hashes in Perl without using Data::Compare?
Way asked 13/8, 2009 at 17:59

5

Solved

I can't find the Perl module Image::Magick anywhere. It is gone from CPAN. What happened to it? Where can I get it? Is there a problem with CPAN, or with the module?
Cuzco asked 4/10, 2023 at 4:1

15

Solved

Is there a simple way in Perl that will allow me to determine if a given variable is numeric? Something along the lines of: if (is_number($x)) { ... } would be ideal. A technique that won't thro...
Dniester asked 15/8, 2008 at 19:43

7

Solved

Possible Duplicate: How do I find a user's home directory in Perl? I'm running Ubuntu. Whenever I pass a Perl script a path that starts with ~ (e.g. ~/Documents/file.txt) it fails fi...
Weakness asked 28/10, 2010 at 14:19

5

Solved

I would like to create a temp file, write to the file-handle then call an external program with the filename. The problem is I would normally want to close the file after writing to it and before ...
Eckman asked 18/10, 2010 at 13:16

5

For some reason, whenever I run any Perl module (like cpanm), I've been getting this response: ListUtil.c: loadable library and perl binaries are mismatched (got handshake key 0xdb00080, needed ...
Croy asked 9/7, 2017 at 20:12

4

Solved

I'm working on the "Error Handling and Reporting" chapter of Mastering Perl. In perlvar's entry for $@, it says: The Perl syntax error message from the last eval() operator. If $@ is the null str...
Enwrap asked 21/7, 2013 at 19:49

4

Solved

perl --version prints all this: This is perl 5, version 26, subversion 1 (v5.26.1) built for darwin-thread-multi-2level Copyright 1987-2017, Larry Wall Perl may be copied only under the terms of...
Stevestevedore asked 26/3, 2018 at 21:10

2

Solved

I am using Perl 5.34.1 and Python 3.10.12. The following script takes 16 seconds in Python: import re patt = re.compile(r"W(X|Y+)+Z") print(patt.search("WYYYYYYYYYYYYYYYYYYYYYYYYYYYY...
Methyl asked 27/9, 2023 at 13:48

8

Solved

I sometimes want to match whitespace but not newline. So far I've been resorting to [ \t]. Is there a less awkward way?
Dani asked 12/8, 2010 at 15:0

34

Solved

I have a file which contains several thousand numbers, each on its own line: 34 42 11 6 2 99 ... I'm looking to write a script which will print the sum of all numbers in the file. I've got a solut...
Gig asked 23/4, 2010 at 23:36

7

Solved

I have a huge text file (~1.5GB) with numerous lines ending with ".Ends". I need a linux oneliner (perl\ awk\ sed) to find the last place '.Ends' appear in the file and add a couple of li...
Bohon asked 19/11, 2022 at 20:45

2

Solved

I am trying to upgrade Perl from version 5.16 to 5.26 and hashes are randomized differently now. Is there a way to return to the old behavior of 5.16? I have an issue with the new behavior, because...
Pent asked 20/9, 2023 at 7:35

2

Solved

I have a variable that is entered at a prompt: my $name = <>; I want to append a fixed string '_one'to this (in a separate variable). E.g. if $name = Smith then it becomes 'Smith_one' I...
Exhortation asked 17/9, 2012 at 12:41

15

Solved

Using awk, I can print a number with commas as thousands separators. (with a export LC_ALL=en_US.UTF-8 beforehand). awk 'BEGIN{printf("%\047d\n", 24500)}' 24,500 I expected the same format to ...
Lengthwise asked 30/10, 2015 at 18:1

13

Solved

I keep the name of the subroutine I want to call at runtime in a variable called $action. Then I use this to call that sub at the right time: &{\&{$action}}(); Works fine. The only thing...
Tevere asked 16/12, 2009 at 16:0

2

Solved

Consider: use 5.016; use warnings "all"; use Data::Dumper; my @abc = (1, 2, 3); my @bbb = @abc[1..2]; my @ccc = @abc[1...2]; my @ddd = @abc[1....2]; say Dumper "@bbb"; # Outp...
Unheardof asked 11/9, 2023 at 9:51

7

Solved

I have a file called test.txt which looks like this: Line 1 Line 2 Line 3 Line 3 Line 3 Line 4 Line 8 I need some code which will randomize these lines BUT GUARANTEE that the same text cannot appe...
Fatidic asked 7/9, 2023 at 10:30

1

Solved

I was reading the documentation for the attributes module and came across a method call notation I've never seen: use attributes (); attributes::->import(__PACKAGE__, \$x, 'Bent'); The doc did ...
Winou asked 5/9, 2023 at 16:53

3

Solved

I want to create a simple IO object that represents a pipe opened to another program to that I can periodically write to another program's STDIN as my app runs. I want it to be bullet-proof (in tha...
Car asked 13/5, 2012 at 6:34

2

Solved

I have an array like the following: my @a = ('%d %d', 10, 20); I'd like to use the elements of this array as the arguments for a function. If I just try using it directly, it gets interpreted i...
Gyrostat asked 24/11, 2015 at 15:38

© 2022 - 2024 — McMap. All rights reserved.