Here is this line in perl:
open my $fh_echo, '-|' or exec "$sshstr \"$str\"";
Basically it exec's $sshstr and then the output goes into $fh_echo, somehow. I am curious as to the mechanisms that go behind this operation. Can someone explain what the '-|' means?
Also how does this loads the output into $fh_echo? Does it output it littl...
This is my first Perl script. Ever:
#!/usr/bin/perl
if ($#ARGV < 1) { die("usage: <size_in_bytes> <file_name>\n"); }
open(FILE,">" . $ARGV[0]) or die "Can't open file for writing\n";
# you can control the range of characters here
my $minimum = 32;
my $range = 96;
for ($i=0; $i< $ARGV[1]; $i++) {
print FILE chr(int(rand($range)...
I was trying to format a chat log for a friend that looks like this:
John Smith > hello Jane doe > hey how are you? John Smith > Pretty good thanks
and she wants to format it like this:
John Smith > hello
Jane doe > hey how are you?
John Smith > Pretty good thanks
Simply entering a new line after > is not good enough as it would ...
I have a large list of files, some of which have dates embedded in the filename. The format of the dates is inconsistent and often incomplete, e.g. "Aug06", "Aug2006", "August 2006", "08-06", "01-08-06", "2006", "011004" etc. In addition to that, some filenames have unrelated numbers that look somewhat like dates, e.g. "20202010".
In ...
I'm using a Perl script to dump the contents of a MySQL db. The Perl module I'm using is CPAN's DBI. Is there any way to tell if the state of the db has changed since the last dump so that I don't need to re-dump the db?
...
I'm starting to learn perl, using the Wrox Beginning Perl available on perl.org and have a question regarding a for loop example they provide in Chapter 3.
#!/usr/bin/perl
use warnings;
use strict;
my @count = (1..10);
for (reverse(@count)) {
print "$_...\n";
sleep 1;
}
print "Blast Off!\n"
This is the script they pr...
What would the best way be to take a string from a text file and search and replace another string with the one from the text file?
E.g c:\output.txt has abcd and c:\newfile.txt has Stack overflow is great.
I would like to replace great with abcd.
What would be the best approach to do this?
...
Is there some conviented way to use one constant when defining another constant in perl?
The following obviously does not work
use constant {
MAIN_DIR => "/path/to/some/dir",
PROP_DIR => MAIN_DIR . "/sub_dir",
PROP_FILE => PROP_DIR . "/props.props",
};
The only think I could think of is multiple use constant lines, but...
Ok, read that again. I need to open a windows prompt WITH perl. This is because I want multiple prompts running perl scripts in parallel, but don't want to open them all by hand. So I want a script that I can call (host), tell the number of command prompts to open (clients), path to the client script to run, and even put in inputs if the...
I would like to create a new directory that its content is soft links to the the content of an existing directory, and set full permissions for this new directory.
I know how to this is in bash:
mkdir -m a=rwx new_dir
cd new_dir
ln -s /path/to/old/dir/* .
but having some problems with finding the perl equivalent
...
I have a few blocks of code, inside a function of some object, that can run in parallel and speed things up for me.
I tried using subs::parallel in the following way (all of this is in a body of a function):
my $is_a_done = parallelize {
# block a, do some work
return 1;
...
Hi,
We could see that during our perl program runs which basically connects to SQLserver to insert/delete/update data, the below is called very frequently
sp_tables @table_name='NOXXTABLE'. We see that for many SPID's the call happens a lot of times.
On running sp_tables @table_name='NOXXTABLE' in SQLserver we can see that it returns n...
Firefox 3.6 introduced a [multiple attribute on regular type="file" input elements](
http://hacks.mozilla.org/2009/12/multiple-file-input-in-firefox-3-6/).
I cannot get Perl to process these fields. I can call the field in a list context like this:
my @files = $CGIobject->param("File_Input");
Looping through that will give me the fi...
I have the following scenario:
sub_1 can run immediately
sub_2 can run immediately
sub_3 can run only after sub_1 finishes
sub_4 can run only after sub_1 finishes
sub_5 can run only after sub_2 finishes
sub_6 can run only after sub_2 finishes
sub_7 can run only after both sub_1 and sub_2 finish
sub_8 can run only after both sub_1 and su...
I want to retrive the no of functions(only defined functions and not the calling functions) present in a in a text file(count)
The text file{function.txt}is below
#include<main.h>
#include<mncl.h>
int reg23;
int refid23;
int64 AccounntBalance(char *reg12,char *refid,char **id){ //dis is function1
ref();
if(id>100)
{
do(&ref);
}
...
Hi, i have application with client-server architecture.
client (C program):
generate various DER encoded data
convert DER to PEM (using openssl's PEM_write_bio) with various PEM header
send PEM to server
server (Perl script):
receive PEM data
convert PEM to DER
....
My question is how to convert various PEM data to DER/BER (bin...
Hi - I have one text file (fileA), approx 200 lines, each line with the format
afield1 afield2 afield3 afield4 afield5
and another text file (fileB), approx 300 lines, same format
bfield1 bfield2 bfield3 bfield4 bfield5
I want to create another text file, where if afield1 & bfield1 match, it writes a line like:
"some text" bfield4...
Besides modules that are specific to a given service (like ClearCase::Proc::ClearTool), what modules or built-in functions exist to automate external programs?
...
How can I sort two arrays of coordinates in numerical order by the start coordinates e.g.
my @starts = (100,100,200,300,400,500,525);
my @ends = (150,125,250,350,450,550,550);
but choose the biggest difference if there are two matching in either the starts or ends list? E.g.
my @uniq_starts = (100,200,300,400,500);
my @unique_ends ...
Is there any way to kill an OpenVPN connection with a Linux command or Perl command?
...