I have a application generating logs in every 5 sec. The logs are in below format.
11:13:49.250,interface,0,RX,0
11:13:49.250,interface,0,TX,0
11:13:49.250,interface,1,close,0
11:13:49.250,interface,4,error,593
11:13:49.250,interface,4,idle,2994215
and so on for other interfaces...
I am working to convert these into below CSV format:...
I have been using Process.Start to launch executables (.exe) files. Now I need to execute a .pl file with some arguments. can I still use Process.Start or I need a different approach?
EDIT :- I am having to mark this question unanswered as I am getting the following error when I try to call the perl file from the CSharp code:- (When I c...
I need to write some scripts to carry out some tasks on my server (running Ubuntu server 8.04 TLS). The tasks are to be run periodically, so I will be running the scripts as cron jobs.
I have divided the tasks into "group A" and "group B" - because (in my mind at least), they are a bit different.
Task Group A
import data from a file ...
I am getting started with Test::More, already have a few .t test scripts. Now I'd like to define a function that will only be used for the tests, but across different .t files. Where's the best place to put such a function? Define another .t without any tests and require it where needed? (As a sidenote I use the module structure created ...
I have a string that has a file path:
$workingFile = '/var/tmp/A/B/filename.log.timestamps.etc';
I want to change the directory path, using two variables to note the old path portion and the new path portion:
$dir = '/var/tmp';
$newDir = '/users/asdf';
I'd like to get the following:
'/users/asdf/A/B/filename.log.timestamps.etc'
...
Say I have an environment variable myvar:
myvar=\tapple\n
When the following command will print out this variable
perl -e 'print "$ENV{myvar}"'
I will literally have \tapple\n, however, I want those control chars to be evaluated and not escaped. How would I achieve it?
In the real world $ENV residing in substitution, but I hope th...
I'm capturing some output from an external program:
my $cmd = "grep -h $text $file2 $file1 | tail -1 | awk '{print \$NF }' ";
my $port_number;
$port_number =`$cmd`;
print "port No : ==$port_number==";
The output has extra whitespace around the port number:
port No : == 2323
==
and I tried chomp but it's not working.
...
I'm all for learning and continual improving one’s self, and I believe you should have as many tools as possible in your toolbox. However, I was wondering if it was worth it learning Python, since I already know a couple of dynamic interpreted languages, including Perl. My background is mostly C/C++/Java/C#, but I’ve programmed in Perl q...
I'm currently refactoring a test suite built up by a colleague and would like to use Test::Class[::Most] while doing so. As I started I figured out I could really use a couple of Moose roles to decouple code a little bit. However, it seems it's not quite possible -- I'm getting error messages like this one:
Prototype mismatch: sub My::T...
I have a parallelized automation script which needs to call many other scripts, some of which hang because they (incorrectly) wait for standard input or wait around for various other things that aren't going to happen. That's not a big deal because I catch those with alarm. The trick is to shut down those hung grandchild processes when t...
I'm trying to decrypt a Perl code which I'm not familiar with, somehow related to HashRef.
I'm using Amazon::S3, but my question is a general Perl question. See the code below:
use Amazon::S3;
my $s3 = Amazon::S3->new( ... );
my $response = $s3->buckets;
Documentation (here) sais, about s3->buckets:
Returns undef on error, else HASHR...
I have a large text file I would like to put on my ebook-reader, but the formatting becomes all wrong because all lines are hard wrapped at or before column 80 with CR/LF, and paragraphs/headers are not marked differently, only a single CR/LF there too.
What I would like is to replace all CR/LF's after column 75 with a space. That would...
In my perl code I've previously used the following two styles of writing which I've later found are being discouraged in modern perl:
# Style #1: Using & before calling a user-defined subroutine
&name_of_subroutine($something, $something_else);
# Style #2: Using ($$) to show the number of arguments in a user-defined sub
sub name_of_sub...
I'm interested in playing around with the Parrot VM, but all the tutorials (and many of the docs) seem out-of-date. There there any up-to-date tutorials out there in the interwebs?
...
This question comes from a need to ensure that changes I've made to code doesn't affect the values it outputs to text file. Ideally, I'd roll a sub to take in two filenames and return 1or return 0 depending on whether the contents are identical or not, whitespaces and all.
Given that text-processing is Perl's forté, it should be quite e...
I am new to Perl coding.
I am facing a problem while executing a small script I have:
open is not able to find the file which I am giving as an argument.
The file is available:
ls -l DLmissing_months.sql
-rwxr-xr-x 1 tlmwrk61 aimsys 2842 May 16 09:44 DLmissing_months.sql
My Perl script:
#!/usr/local/bin/perl
use strict;
use...
I want to SSH to a server and execute a simple command like "id" and get the output of it and store it to a file on my primary server. I do not privileges to install Net::SSH which would make my task very easy. Please provide me a solution for this. I tried using backticks but I am not able to store the output on the machine from which m...
I am processing a file full of unix time strings. I want to convert them all to human readable.
The file looks like so:
1153335401
1153448586
1153476729
1153494310
1153603662
1153640211
Here is the script:
#! /bin/bash
FILE="test.txt"
cat $FILE | while read line; do
perl -e 'print scalar(gmtime($line)), "\n"'
done
This is not work...
Using Perl's XML::LibXSLT necessitates that I use XSLT 1.0, which means that I am stuck without XSLT 2.0 features. Is there a way that I can still pad text cleanly in a plain-text output from my processing? What I want is:
<values>
<headers>
<header>Header 1</header>
<header>Header 2</header>
</headers>
<va...
I'm trying to identify and condense single (uppercase) characters in a string.
For example:
"test A B test" -> "test AB test"
"test A B C test" -> "test ABC test"
"test A B test C D E test" -> "test AB test CDE test"
I have it working for single occurrences (as in the first above example), but cannot figure out how to chain it for m...