Hello all, this morning, my friend and I discussed and wrote the below code. The idea behind this Perl script is to create the directory structure and copy the files to the corresponding directory.
#!/usr/bin/perl
use File::Path;
use File::Copy;
use Path::Class;
use File::Basename qw/dirname/;
my $src = "/Vijay/new.txt";
unless (open(MY...
I have a string like this <name>sekar</name>. I want to split this string (i am using perl) and take out only sekar, and push it into an array while leaving other stuff.
I know how to push into an array, but struck with the splitting part.
Does any one have any idea of doing this?
...
I am trying to run bp_genbank2gff3.pl (bioperl package) from another perl script that
gets a genbank as its argument.
This does not work (no output files are generated):
my $command = "bp_genbank2gff3.pl -y -o /tmp $ARGV[0]";
open( my $command_out, "-|", $command );
close $command_out;
but this does
open( my $command_o...
I have a Perl class that contains a hash instance variable for storing other objects. I would like to have a method to print the number of elements in the hash but I am getting the following error message on the line return keys($self->{'_things'});
Type of arg 1 to keys must be hash (not hash element)
package MyClass;
use strict;
sub...
How to create Open Document Format spreadsheet with charts using Perl?
...
I would like to run some command (e.g. command) using perl's system(). Suppose command is run from the shell like this:
command --arg1=arg1 --arg2=arg2 -arg3 -arg4
How do I use system() to run command with these arguments?
...
How to apply a style to cell using OpenOffice::OODoc module in Perl?
I tried:
my $container = odfContainer("report1.ods", create => 'spreadsheet');
my $doc = odfDocument (
container => $container,
part => 'content'
);
# Styles
my $styles = odfDocument (
...
I'm using one-off perl -pi -e commands to do simple search and replace from within a bash script. Most of my regexes work fine, until I get to these:
perl -pi -e 's#\<\?mso-application.*\<Table.*Rows="1"\>#\<Table\>#s' 1.xml
perl -pi -e 's#\</Table.*#\</Table\>#s' 1.xml
Please don't mind the # marks instead of slashes, I didn't want t...
I would like to insert updev.xml to the mainea.xml if $upd_dev_id is not equal. Tried this below but it won't insert. Replace works.
#!c:\perl\bin\perl.exe
use strict;
use XML::Twig;
my $upd_file = "updev.xml" ;
my $main_file = "mainea.xml" ;
# get the info we need by loading the update file
my $t_upd= new XML::Twig();
$t_upd->pars...
Is it possible to use an object as a hash key?
For example, the following code allows me to use an instance of MyClass as a key but when I iterate over the keys and attempt to invoke the get_value method, I get the error:
Can't locate object method "get_value" via package "MyClass=HASH(0x12a4040)" (perhaps you forgot to load "MyClass=H...
A recent question used a sigil invariant syntax %hash->{key} = 1; for hash access, which seems to work fine, but I would have thought it would be a syntax error.
It seems to work for arrays as well:
my @array;
@array->[3] = 6;
Is this behavior documented somewhere? I don't remember reading it, but may have overlooked it.
It seems ...
I've installed the Template module via CPAN on my MacBook Pro and it seemed to install correctly.
But, when I try to run a script that includes the Template module, I get the following:
Can't locate Template.pm in @INC (@INC contains: /Users/purinkle/Sites/rob/modules /Library/Perl/Updates/5.10.0/darwin-thread-multi-2level /Library/...
Hi. I want to use following script:
use FileHandle;
use WWW::Curl::Easy;
use WWW::Curl::Form;
my $file, my $curl, my $curlf, my $return, my $minified;
$file = new FileHandle();
$curl = new WWW::Curl::Easy();
$curl->setopt(CURLOPT_URL, "http://closure-compiler.appspot.com/compile");
$curlf = new WWW::Curl::Form();
$curlf->formadd('out...
I'm using eclipse to work on a project with portions written in Java, C, Perl, and bash. Which version of eclipse should I get for this? I'm currently using 3.5-CDT+perl-plugin and would really like better Java handling with out loosing the C. What plugin should i add for java?
How does Eclipse handle multi-language projects? when I hi...
I'm working in Java, C ,Perl, and Bash (and a little python) on a project that all work together (mostly via RESTfull interfaces) and am looking for an IDE suited to Polyglot programming?
What IDE can i use that has:
jump to definition
call hierarchy
syntax highlighting
across at least these languages:
Java
C
Perl
all from ...
In Perl, working with a paragraph of text in one big long string with no line breaks, how can I use a split and RegEx (or something else) to split the paragraph into chunks of around the same size at a word boundary, for display in a monospaced font?
For example, how do I change this:
"When you have decided which answer is the most hel...
Hi. I'm trying to get Code Closure to work, but unfortunately, there's always an error thrown.
Here's the code:
use LWP::UserAgent;
use HTTP::Request::Common;
use HTTP::Response;
my $name = 'test.js';
my $agent = new LWP::UserAgent();
$agent->agent("curl/7.21.0 (x86_64-pc-linux-gnu) libcurl/7.21.0 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1....
I want to convert 4Test scripts to Perl. I have been using the Parse::RecDescent in Perl, but am still overwhelmed at the task. Here is an example.
An example of 4Test is something like:
ParseSMSPlans (STRING sDir)
{
STRING sFile;
STRING sDirSMSPlan = sDir + "sms_plans\";
STRING sDirPlan = sDir + "plan\";
STRING sDirDeal = sDir + "deal...
If I have an array that contains multiple FLV files like so:
my @src_files = qw (1.flv 2.flv 3.flv 4.flv 5.flv 6.flv 7.flv);
I can call flvbind.exe as an external commandline program to do the merging like so:
my $args = join(' ',@src_files);
my $dest_file = 'merged.flv';
system "flvbind $dest_file $args";
But the usage example for...
Hello,
I wrote a quick script to download files using LWP::Simple library and its getstore() function. It is working rather well, but occasionally downloaded file is not complete. I do not know what is causing this, but when I download it afterward manually using wget in command line file is OK.
I would guess corrupted files are caus...