perl

embedding html created by a perl method, in the place it is being called upon

Hi All, I am very new to perl coding, I am calling a method, which again calls some other method and then generate an html code. I need to embed the htmlcode in my current code, so as to add that to the current html code. I am calling the method like this my $test = $frek->xyz(); where xyz generated an html. now i need to embed the $...

postgresql can't load perl module

Hi, Iam having problem creating postgresql function in plperl CREATE OR REPLACE FUNCTION zm_json (TEXT, TEXT) RETURNS TEXT AS $$ use JSON::XS; # do something return $json_out; $$ LANGUAGE plperl; When i want to create function above iam getting ERROR: creation of Perl function "zm_json" failed: Unable to load JSON/XS.pm into...

How do I do an exact word match on a variable in ksh?

I used the following syntax as part of a ksh script to verify if the word Validation exists in LINE_FROM_FILE. [[ "${LINE_FROM_FILE##*Validation}" != "${LINE_FROM_FILE}" ]] && print "match Validation" The problem of this syntax is that it is also matching words like Valid or ValidationVALID etc. and my goal is to exactly match the wor...

Access hash reference data using strings representing the hash structure

Let's assume that I have a complex hash reference $hash_ref, and I would like to access data in it by doing something like this: my $string1 = "{books}"; my $string2 = "{31335}->{book_name}"; print Dumper($hash_ref->$string1->$string2); Of course, this doesn't work, but I hope it explains what I'd like to do. Obviously, there are man...

substition regex, with capture

hi all, maybe this is a stupid question but : i run perl 5.8.8 and i need to replace any underscore preceded by a number, with "0". running : $var =~s /(\d)_/$10/g; obviously does not work as $10 is interpreted as... well... $10, not "$1 followed by 0" moreover, as runing perl5.8, i can't do $var=~s/(?<n1>\d)\_/$+{n1}0/g; any i...

Parsing SpreadsheetML Using Perl

What's the best way to parse a file in SpreadsheetML format with Perl? I've tried Spreadsheet::ParseExcel, but it doesn't recognize the format. Here's the error I get when trying that module: No Excel data found in file It looks like CPAN doesn't have a module that can parse it as far as I can see. What's the easiest way to do it? ...

Perl while loop / reading file

I'm new to Perl and I have a problem when reading a file line by line. I started with a tutorial which suggested using a while loop. That worked fine, however I wanted to have an option to break out of the loop in case of an error. I know I can use the "last" keyword, but I don't like that very much, I would like to include it in the whi...

Unable to pass a hash and a string to a function, together in perl!

I am basically trying to pass a string and a hash to a subroutine in perl. sub coru_excel { my(%pushed_hash, $filename) = @_; print Dumper(%pushed_hash); } But it seems data is getting mixed up. The dumped data also includes the $filename. here is the output. ................... $VAR7 = 'Address'; $VAR8 = [ '223 VIA...

How to avoid malformed URI sequence error ?

I'm working with perl. I have data saved on database as  “ and I want to escape those characters to avoid having malformed URI sequence error on the client side. This error seems to happen on fire fox only. The fix I found while googling is not to use decodeURI , yet I need this for other characters to be displayed correctly. Any h...

What does this Perl code do?

In cPanel, they tell you to insert this code into the beginning of Perl files. I'm not sure what it does. I've tried code with and without this in the beginning of the file and it seems to all work the same. I haven't tested that out with cron running the code, but only as myself. By "tested it out", I mean using print lines, databas...

encode url not encoding

Hi all. I am working in a template in Moveable Type and would like to do the following: <a href="http://twitter.com/share?url=&lt;$mt:EntryPermalink encode_url="1" $>">Twitter</a> It all works but I'm worried that the current link or at some point even if I use a title mt tag that it might not be right for the browser address bar. I ...

Perl: How to get IO::Socket::INET timeout after X seconds ?

I'm trying to connect to some host, using invalid port, and i want to get timeout after X seconds. How to do that ? My code: $sock = new IO::Socket::INET( PeerAddr => $_[0], PeerPort => $_[1], Proto => 'tcp', Timeout => 2 ); ...

How do I input an Enter using perl?

I have a perl script that I need to tweak. The script runs and asks me the manually put in an IP address but I want to hard code in the IP address when it asks me to input it so I need to tell the script to type in the IP and then hit enter to proceed with the script. Can somebody please tell me how to do this? I'm sure this is probabl...

Regexp Question - Negating a captured character

I'm looking for a regular expression that allows for either single-quoted or double-quoted strings, and allows the opposite quote character within the string. For example, the following would both be legal strings: "hello 'there' world" 'hello "there" world' The regexp I'm using uses negative lookahead and is as follows: (['"])(?:(?!\1...

perl + test perl syntax in my shell script (ksh)

hi all I used the following syntax (part of ksh script) to verify if Validation word exist in LINE_FROM_FILE [[ "${LINE_FROM_FILE##*Validation}" != "${LINE_FROM_FILE}" ]] && print "match Validation" the problem of this sytax that its also match word like Valid or ValidationVALID etc and my target to match exactly the Validation ...

Csh alias with perl one-liner evaluates when alias is created and not when alias is used

I know, I know, I should use a modern shell... Anyway, so here is the alias: alias p4client echo `p4 info | perl -ne 's/Client name: (.*)$/print $1/e'` I also know there is probably a better way to get the p4 client name. This is just an example. So, can anyone tell me a nice and clean way to get this to evaluate this when I invoke...

perl - regex help parsing hostname from log

I need help with my regex to grab my host information from this logfile: Tue Aug 24 10:22:14 2010: test1.colo_lvm:check:INFO: host=test1.dom.colo.name.com Tue Aug 24 10:22:14 2010: test1.colo_lvm:check:INFO: "/home/bin64"/admin --user="foo-bar" --password="*****" --host="test1.dom.colo.name.com" --port="9999" --socket="/tmp" variable...

Regex: Finding the nth match

I am trying to write a regex to match the nth match. As I am new to regex please help me in solving this. Input: DECLARE numerator NUMBER; BEGIN SELECT x, y INTO numerator, denominator FROM result_table, secondTable WHERE sample_id = 8; delete from xyz where id=17; Match first WHERE or match second WHERE. Also please suggest me som...

How to find out if a Perl hash is multidimensional?

Assuming I have a hash like this: $hash_ref = { 'hashes' => { 'h1' => { 'klf' => '1', 'moomooland' => '1' }, 'h2' => { 'klf' => '2', 'moomooland' => '2' }, 'h3' => { 'klf' => '3', 'moomooland' => '3' } }, 'keys' => { 'k1' => 'key1', 'k2' => 'key2', 'k3' => 'key3' } } How could I find out, as easy as ...

Perl DBI fetchall_hashref

Consider the following table: mysql> select * from vCountryStatus; +-------------+------------+------+---------+--------+-----------------+ | CountryName | CountryISO | Code | Status | Symbol | CurrencyName | +-------------+------------+------+---------+--------+-----------------+ | Brazil | BR | 55 | LIVE | BRL ...