perl

How can I send an HTTPS request in Perl without LWP::UserAgent or HTTP::Request?

Hi, I need to send an HTTPS request without using LWP::UserAgent or HTTP::request? What is another method of doing so? This is the request I need to send: POST https://payflowpro.paypal.com/ Connection: close Host: payflowpro.paypal.com Content-Length: 181 Content-Type: text/namevalue X-VPS-CLIENT-TIMEOUT: 30 X-VPS-REQUEST-ID: 124940351...

How do I add lines to the top and bottom of a file in Perl?

I want to add a line to top and bottom of the file. I can do it following way. open (DATA, "</usr/old") || die "cant open old\n"; #file to which line has to be added my @body=<DATA>; close(DATA); open (FILE, ">/usr/new") || die "cant open new\n"; #file after stuff has been added print FILE "9 431"; print FILE "\n"; my $body=@bod...

How to count the number of characters in a file once the starting point has been figured out?

I want to count the number of characters after I have figured out the starting point. __DATA__ 1-thisthestartingpoint COUNTTHENUMBEROFCHARACTERSPRESENTINTHISLINEBEFORETHENEXTSTARTINGPOINT COUNTTHENUMBEROFCHARACTERSPRESENTINTHISLINEBEFORETHENEXTSTARTINGPOINT COUNTTHENUMBEROFCHARACTERSPRESENTINTHISLINEBEFORETHENEXTSTARTINGPOINT 2-nextsta...

Why is Perl script asking for 'global declaration' when I declare something in for loop?

I am reading $digit from infile and want to print it to outfile. But the Perl script is giving an error saying 'Global symbol "$digit" requires explicit package name'. But, if I do declare it globally , $digit='', then the this value is printed to the outfile instead of the value extracted/read from infile. Any suggestions as to what sho...

Can I use XML::Simple with an in-memory string, rather than a file?

XML::Simple documentation says to initiate the data structure with an XML file, using XMLin('[FILENAME]') ... but I have an in-memory string. Can I use it directly, or do I need to save it to the filesystem and then load it into XMLin? ...

SHA1 C# method equivalent in Perl?

I was given C# code and I'm trying to generate the equivalent SHA1 using Perl. public string GetHashedPassword(string passkey) { // Add a timstamp to the passkey and encrypt it using SHA1. string passkey = passkey + DateTime.UtcNow.ToString("yyyyMMddHH0000"); using (SHA1 sha1 = new SHA1CryptoServiceProvider()) ...

How can I loop through a list of functions in Perl?

I have a list of functions in Perl. Example: my @funcs = qw (a b c) Now they all belong to this module Foo::Bar::Stix. I would like to call them iteratively in a loop: foreach $func (@funcs) { Foo::Bar::Stix::$func->(%args) } where args is a hash of arguments. However I keep getting this error: "Bad name after :: ..." at the li...

Perl and Moose: What Moose-based package should I use as replacement for MooseX::Method

To my dismay I noticed that MooseX::Method is no longer maintained and deprecated. The package MooseX-Method-Signatures is advertized as replacement, but its documentation says: This is ALPHA SOFTWARE. Use at your own risk. Features may change. <whine>What should I do </whine> ...

How to enable msg and debug logging with Log::Message::Simple

I'm using Log::Message::Simple and error()s appear immediately. However, calls to debug() and msg() do nothing -- I have to call Log::Message::Simple->stack_as_string() to get these. How can I get this logging to appear immediately? ...

How to create POD and use pod2usage in perl ?

Hi, I want to create a POD for my own custom command and display the syntax for that using pod2usage() function.. Can anyone give me a simple example for it? Regards, Anandan ...

How do I insert a line at a specific row in multiple files on Unix?

I need to insert a line with specific text on the second line (thus moving the other lines down in the file) of hundreds of files in a directory. Any quick Unix tips on how that can be done? ...

Perl DBI - run SQL Script with multiple statements

I have a sql file test.sql used to run some SQL (create object / update / delete / insert) that can look like this CREATE TABLE test_dbi1 ( test_dbi_intr_no NUMBER(15) , test_dbi_name VARCHAR2(100); UPDATE mytable SET col1=1; CREATE TABLE test_dbi2 ( test_dbi_intr_no NUMBER(15) , test_dbi_name V...

How can run an operation on one column of an CSV file in Perl?

Hi, I need to parse and convert an entire column in a simple CSV file that has two columns. John, 128222971326628000 Paul, 128491909317205000 Greg, 128160037933161000 Basically I need to perform some arithmetic on the second column and update the value in the column with the result of this operation while leaving the first column unt...

Is there a Perl module that works similarly to the Unix "which" command?

I was on Perlmonks and found this great listing: http://www.perlmonks.org/?node_id=627015 But it was missing "which", the function that searches for an executable in all the directories in your PATH. (I am porting a Perl script to Windows.) Is there a Perl module that simulates this? ...

How can I compare lines in a file using Perl?

Hi Im supposed to compare lines in a file : KB0005 1019 T IFVATVPVI 0.691 PKC YES KB0005 1036 T YFLQTSQQL 0.785 PKC YES KB0005 1037 S FLQTSQQLK 0.585 DNAPK YES KB0005 1045 S KQLESEGRS 0.669 PKC YES KB0005 1045 S KQLESEGRS 0.880 unsp YES KB204320 1019 T IFVATVPVI 0.699 PKC YES KB204320 1036 T YFLQTSQQL 0.789 PKC YES KB204320 ...

Perl script to run a C executable with an argument while giving standard input through a file?

I want to run and executable ./runnable on argument input.afa. The standard input to this executable is through a file finalfile. I was earlier trying to do the same using a bash script, but that does not seem to work out. So I was wondering whether Perl provides such functionality. I know I can run the executable with its argument using...

Passing a Function Object and Calling it

How do I pass a function, a, to function, b, and have b call a in Perl? ...

Why can't Perl find the library in my t/ directory?

I have a .pm file in my current directory /t, and I inserted this line of code: use lib qw(.); Then I inserted this line of code use TestUtil.pm; where TestUtil.pm is in the current directory, but I keep getting this error: Can't locate TestUtil.pm in @INC (@INC contains: . ........ ( Note that @INC contains the current direc...

How can I get perl on my iPhone 3GS?

Hello I'm trying to get a regular C compiling environment on an iPhone 3GS running OS3.0 . So far I have been unsuccessful in finding a suitable gcc (i mean the complete suite, gcc+headers+libc+whatever else it needs) for it. Does anyone know if it is (yet) available and where ? If not yet, is there any tutorial on the net on how to ...

What's a simple reference or cheat sheet for nested data structures in Perl?

What's a simple reference or cheat sheet for nested data structures in Perl? ...