Does someone know how to push data into an array as part of a fork process ??
I always get an empty array.
My code looks like this (I am using Parallel::ForkManager):
my $pid;
my $pm = new Parallel:ForkManager(5);
foreach my $element (@list){
$pid = $pm->start and next;
...
$result = ....
...
Hello,
I've got an input text in which I want to replace every string like "match(value)" by "value" (and store all "value" in an array)
i.e:
bla bla bla
bla bla match(value1) bla bla
bla match(value2) bla bla
bla match bla bla
bla match(value3) bla
becomes:
bla...
I am using Parallel::ForkManager to fork a subroutine used in a perl script. This subroutine uses an array (called @array).
My script get confused because (I reckon) of the name of the array is shared by all forked children.
So that, the content of @array might not be the one I expect to be...
I want to delete entries in a mysql table for which timestamp is older than 1 Hour. The mysql syntax is:
DELETE from table WHERE t < DATE_SUB(NOW(), INTERVAL 1 HOUR);
This works fine but I can't get it running through a perl DBI command. The following for instance does not work...
I've got a script that opens a log file and write into it.
I would like this file not to exceed a certain limit (500 lines for instances) i.e if I had line #501 line it's going to remove line #1 and so on...
Is there a nice way to achieve that ?
I've quoted below a basic script that reads a file and prints its content. Whatever the file is (/etc/hosts is just an example), the script adds a space for all the lines following line #1, i.e:
line 1
line 2
line 3
I would like it to return the file as it is, i.e:
line 1
line 2
line 3...
I've got a few perl scripts that use specific modules. I want to run them on many different systems that are not connected to the internet and I would like to save time and to make the installation of these modules easy for other users.
My idea is to create an installation script that will...
Hello,
Not sure if the category "helpful Tip" is rightly choosen.
Anyway, that might benefits to "less advanced" programmers like me.
A few days ago I posted a question related to a fork issue on perl 5.8. I have just found the problem.
The script I quoted was using fork...
I've found a script on the web that uses fork to run several pings in parallel. It works fine on a Linux box running perl 5.00x but it does not work on RedHat 8 with perl 5.8. Is it due to the new multi threading architecture in 5.8 ?
Moreover, I've read on this forum that you can not push...
I am writing a project involving 10 to 20 perl scripts calling subroutines that I have organised in modules (.pm files). I have also one .pm file that contains all my global variables. I am not using packages because I don't feel the need for different namespaces here.
Is it the best and more...
I want to match all the lines of a file against keys in a hash so that there is a match if the line begins with a key. In order to do that I have created a regex that is a join off all the keys separated by "|"
my $regex = join('|', keys %hash);
then I use the following pattern...
I am writing a simple program using the Net::Ping module to ping devices on a network. However, using a timeout of 1s per ping it's going to take 255 seconds to ping a class C.
Is there any way to split the IP range and run multiple pings in parrallel within my perl script ??
Thanks for your...
How to implement a script that returns all the files and directories (including the path) which name contains "$txt" from "$srcdir" ??
I am close to it using the File::Find module but not quite...
Thanks for your help.
I have a file that looks like this:
blabla
!
!
!
bla bla
!
bla
blablabla
!
!
etc...
How to remove all the ! in a series but one so that the result looks like:
blabla
!
bla bla
!
bla
blablabla
!
I am currently writing Perl scripts that use path extensively and I use the "join" function a lot.
I want to use these scripts on both unix and windows and I would like to find a generic way to create my path:
the separator for unix is "/"
for windows it is "\"
Is...
I've got a program that works well. It parses a text file and, using a list of keywords and rules, it splits the text file in differents files. Each of these files contain a part of the original text file. This program uses an array that contains the original text file.
This program will be...
I want to create an array whose name is the name of a scalar.
For instance, if I have:
$name = "arrayname";
I want to use $name to name my array rather than call it @arrayname.
It looks strange but it makes sense in my context as the value of the scalar $name will vary in a loop.
I...
I want to parse a file and push a line into an array only if it begins with a key that is part of a hash. All others lines will have to go in a different array.
I tried to use a foreach loop:
while ($line = <FILE>){
foreach $key (keys %hash){
if ($line =~ /^$key/){
push (@array1, $line)...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.