perl

how to call pm files from index file in perl?

I want to use files that are inside cgi-bin folder in perl, I want to call them from index.cgi When I do this: use cgi-bin/file_name it doesn't work, how can I do that? ...

perl + numeration word or parameter in file

hello , I need help about how to numeration text in file. I have also linux machine and I need to write the script with perl I have file name: file_db.txt In this file have parameters like name,ParameterFromBook,NumberPage,BOOK_From_library,price etc Each parameter equal to something as name=elephant My question How to do this by per...

Argument for builder subroutine in a moose object

I'm currently delegating the builder method to all of the objects that extend one of my base classes. The problem that I'm facing is I need all of the objects to either read an attribute of itself or be passed in a value. # In Role: has 'const_string' => ( isa => 'Str', is => 'ro', default => 'test', ); has 'attr...

perl + awk + run awk from system command in perl (problem with syntax?)

I write the following script #!/usr/bin/perl system(" awk -F"=" '{s[$1]++}{print $1s[$1],$2}' OFS="=" /var/tmp/file " ); when I run the script I get: Can't modify string in scalar assignment at ./stam2 line 5, near "" /var/tmp/file " )" Execution of ./stam2 aborted due to compilation errors. what the ...

Error using MIME::lite

I dont know if this error is specific to MIME::lite but I am getting it while I am trying to use smtp email with MIME. No SASL mechanism found at C:/Perl/site/lib/Authen/SASL.pm line 77 at C:/Perl/lib/Net/SMTP.pm line 143 What does this error mean? ...

how to extract quoted strings using perl/awk?

I've a file with 2 lines having key, value pair on each line. "//" is used as comment style. 1. key = "string_key_value" //string key How can I extract string_key_value without quotes? 2. key =100 //integer value How can I extract 100 from here as an integer? I've to re-use these values in another unix command. ...

A way to find the size and location of padding in a struct?

I'm trying to write a tool that will take as input some C code containing structs. It will compile the code, then find and output the size and offset of any padding the compiler decides to add to structs within it. This is pretty straightforward to do by hand for a known struct using offsetof, sizeof, and some addition, but I can't figur...

How to use Perl to parse specified formatted text with regex?

Dear Perl gurus: Question abstract: how to parse text file into two "hashes" in Perl. One store key-value pairs taken from the (X=Y) part, another from the (X:Y) part? 1=9 2=2 3=1 4=6 2:1 3:1 4:1 1:2 1:3 1:4 3:4 3:2 they are kept in one file, and only the symbol between the two digits denotes the difference. ==...

How do I use variables to do substitution in Perl?

I have several text files, that were once tables in a database, which is now disassembled. I'm trying to reassemble them, which will be easy, once I get them into a usable form. The first file, "keys.text" is just a list of labels, inconsistently formatted. Like: Sa 1 # Sa 2 U 328 #* It's always letter(s), [space], number(s), [spac...

Modifying hash within a hash in Perl

What is the shortest amount of code to modify a hash within a hash in the following instances: %hash{'a'} = { 1 => one, 2 => two }; (1) Add a new key to the inner hash of 'a' (ex: c => 4 in the inner hash of 'a') (2) Changing a value in the inner hash (ex: change the value of 1 to 'ONE') ...

perl + print to file_out in place to standard output

hi I have the follwoing script #!/usr/bin/perl open IN, "/tmp/file"; s/(.*)=/$k{$1}++;"$1$k{$1}="/e and print while <IN>; how to print the output of the script to file_out in place to print to standard output? lidia ...

XML to Perl array

Hi, I am facing a scenario like this, I have a XML file, i need to parse it using XML::Simple module (using perl). The output is in Hashes (i use dumper). I need to convert the output (which is in hash ) to a list or an array. Help me please. XML: <employee> <name>John Doe</name> <age>43</age> <sex>M</sex> <departmen...

How do I parse this file and store it in a table?

I have to parse a file and store it in a table. I was asked to use a hash to implement this. Give me simple means to do that, only in Perl. ----------------------------------------------------------------------- L1234| Archana20 | 2010-02-12 17:41:01 -0700 (Mon, 19 Apr 2010) | 1 line PD:21534 / lserve<->Progress good -------------------...

Wanted: a quicker way to check all combinations within a very large hash

Hi perl-warriors, I have a hash with about 130,000 elements, and I am trying to check all combinations within that hash for something (130,000 x 130,000 combinations). My code looks like this: foreach $key1 (keys %CNV) { foreach $key2 (keys %CNV) { if (blablabla){do something that doesn't take as long} } } As you ...

suitable packages in perl for with features mentioned in the subject.

I need the package having below features: needs client based secure file transfer machanism for getting files from multiple directories at the remote machine. Must have features to do ls at remote machine. Must have functions to know the file permissions at remote machine. It have to use single connection for all file transfers. That p...

perl, dbi with sql statement with a like condition

hi all, in my code i must do a simple sql query with a like condition. i've do in this way my $out = "/Users/zero/out.log"; my $filename = "/Users/zero/data.txt"; my $dbh = DBI->connect("DBI:Oracle:sid=$sid;host=$host;port=$port", $user, $pwd) or die "Couldn't connect to database: " . DBI->errstr; my $query = "select SOMETHING from SO...

What is the meaning of a code block after a "use module"?

What is the significance and what is the effect of something like this (I think it is object oriented): use My::Confusing::Code { CITY => { MODIFY => 1, DEFAULT => My::Even::more::complicated->func(), }, STATE => { MODIFY => 1, DEFAULT => 'Concatenat...

Can I make sure Perl code written on 5.10+ will run on 5.8?

Some of the new features of Perl 5.10 and 5.12, such as "say", are defined as features, that you can enable or disallow explicitly using the "feature" pragma. But other additions, like the named capture groups of regexes, are implicit. When I write Perl using a 5.10+ interpreter, but want it to also run on 5.8, can I make Perl complain ...

Parse out the email body using perl

This is my perl code: my $email = Email::Simple->new($brutEmail); my $body = $email->body; print $body; And the result is --0016364d2ceb8da59d048be66a88 Content-Type: text/plain; charset=ISO-8859-1 Mail content email contents email contentss emails contentsss emmails contentsssss emmmail cccontent --0016364d2ceb8da59d048be...

Building a variable depth hash reference data structure in perl

I needed to build a variable depth hash data structure in perl. Eventually I found this piece of code: #!/usr/bin/perl -w use strict; my %hash; my $value = "foo"; my @cats = qw(a b c d); my $p = \%hash; foreach my $item (@cats) { $p->{$item} = {} unless exists($p->{$item}); $p = $p->{$item}; } My question is how and why it works...