perl

How to create a file in remote host along with the creation of directory using ssh

Hello, I have a file say /a/b/c/file in my host. I want to create a file on remote host in directory say dest. Now the question is, how do I create a file in remote host as /dest/a/b/c/d/file using perl script and using ssh. Any idea how do I create directories in script.? Thanks. ...

Why do I get 'divide by zero` errors when I try to run my script with Rakudo?

I just built Rakudo and Parrot so that I could play with it and get started on learning Perl 6. I downloaded the Perl 6 book and happily typed in the first demo program (the tennis tournament example). When I try to run the program, I get an error: Divide by zero current instr.: '' pc -1 ((unknown file):-1) I have my perl6 binary in...

Bash scripting "common gotchas" for Python/Perl/Ruby programmers

Background: I grew up on using Perl/Python/Ruby for sysadmin-type tasks and shell scripting. I always avoided Bash scripting whenever I needed anything programmer-ish, like functions, looping or control structures. Back then, I could pick my favorite tool for whatever the job. Problem: Now I am working in a situation where the preferr...

perl - file handling

Hi, I have a list of files on host machine say in directory /src/. The directory has more subdirectories. now this directory is copied onto remote machine after mounting. Now the files are preset in remote machine in directory /dst. Example. If I had /src/a/f1, /src/b/f2 I will have on remote machine /dst/a/f1 ,/dst/b/f2 Now I only ha...

Read chunks of data in Perl

What is a good way in Perl to split a line into pieces of varying length, when there is no delimiter I can use. My data is organized by column length, so the first variable is in positions 1-4, the second variable is positions 5-15, etc. There are many variables each with different lengths. Put another way, is there some way to use the ...

ssh problem - no such file or directory

Hello, I have a script in remote host which I run as ./test /a/b/c/f and it runs perfectly fine on the maching. Now I am on host machine, I run the same script as ssh root@dst "./test /a/b/c/f" and this too runs fine. But from my perl script I execute it using backticks as $file = "/a/b/c/f"; `ssh root\@dst "./test $file"`; or sys...

convert a Perl code to a Bash code

May you convert this tiny code to Bash code : user/bin/perl sleep(300); system("killall -9 perl &"); sleep(5) Thanks in Advance . ...

XML Pull Parser implementation in Perl?

Just as the title asks: are there any XML pull parser implementations in a Perl library? I looked at XML::TokeParser, but it's nine years old! I'm sure there's something out there that is functional? ...

use Win32::Process; My output reports The system cannot find the path specified.

Hello, I am relearning Perl after about 10 years of non use. I did a copy and paste of the two scripts below from one of the answers for a similar question on this site. I have checked and double checked the 'path' and tried several deviations, but I still get the same answer -'The system cannot find the path specified'. Any help would...

How do I send Hex data?

I am trying to communicate with a modbus slave via either modbusTCP or modbus serial. The manuf. (partlow) has an ASCII communications manual (http://www.partlow.com/uploadedFiles/Downloads/1160%20ASCII%20Comms%20Manual.pdf) which, looks like it differs from the standard communication methods (http://en.wikipedia.org/wiki/Modbus). A lot ...

Secondary Order in Heap::Simple

How do I define a secondary ordering to the Heap::Simple interface in Perl? ...

Matching degree-based geographical coordinates with a regular expression

I'd like to be able to identify patterns of the form 28°44'30"N., 33°12'36"E. Here's what I have so far: use utf8; qr{ (?: \d{1,3} \s* ° \s* \d{1,2} \s* ' \s* \d{1,2} \s* " \s* [ENSW] \s* \.? \s* ,? \s* ){2} }x; Needless to say, this doesn't match. Does it have anything to do with the...

I am looking for C++ wrapper around built-in Perl functions

Hi, A while ago I found a library that allowed calling individual built-in Perl functions in C++, I cannot find it now. Can you tell me where I can find it on the net? Thanks. ...

How do I read elements of a hash using foreach?

use Data::Dumper; %hash = ( Key => {test => [[testvalue, 10], [testvalue, 20]]}, Key2 => {test => [[testvalue, 30], [testvalue, 40]]}, ); my $parm = $hash{Key}{test}; foreach my $test_p (@{$parm}) { print Dumper $test_p; } It is not displaying in the way I expect. ...

Is there a working CPAN/CPAN6 like project for perl6?

Im playing around with perl6 lately and was searching for a project similar to cpan. I found cpan6 but i think there is no perl6 code yet. So im looking for some alternative that does not necessarily aim to be a long term solution but is capable to maintain modules and is written in perl6. As rakudo development goes it might be possibl...

How to use Getopt::Long method?

How can I use Getopt::Long method if the input command execution is like this: $ testcmd -option check ARG1 ARG2 ARG3 or $ testcmd ARG1 ARG2 ARG3 ...

Perl: Read MANIFEST.MF file from Java .jar file

I'm trying to figure out how to read the META-INF/MANIFEST.MF file form a java jar file in perl. I'm attempting to use Mail::Header in order to separate the properties in the manifest. This works fine if the manifest file is already extracted from the jar, but I'm trying to figure out how to extract the manifest into memory and then imme...

How to match 2 patterns within a single line.

I have the following Java code fun(GUIBundle.getString("Key1"), GUIBundle.getString("Key2")); I use Perl to parse the source code, to see whether "Key1" and "Key2" is found within $gui_bundle. while (my $line = <FILE>) { $line_number++; if ($line =~ /^#/) { next; } chomp $line; if ($line =~ /GUIBundle\.ge...

Funky 'x' usage in perl

My usual 'x' usage was : print("#" x 78, "\n"); Which concatenates 78 times the string "#". But recently I came across this code: while (<>) { print if m{^a}x } Which prints every line of input starting with an 'a'. I understand the regexp matching part (m{^a}), but I really don't see what that 'x' is doing here. Any explanation w...

converting tiff files to jpg from php

Hi, I am trying to convert a folder of tif files to jpeg so they can be displayed on my website. my current approach is not working. i wrote a perl script with #!/usr/bin/perl opendir(DIR, $ARGV[0]); @files = readdir(DIR); closedir(DIR); foreach $file (@files){ if($file =~ /(.*?)\.tif/){ print "converting $file\n"; `convert -au...