perl

How can I pass arguments from one Perl script to another?

Heya, I have a script which I run and after it's run it has some information that I need to pass to the next script to run. The Unix/DOS commands are like so: perl -x -s param_send.pl perl -x -s param_receive.pl param_send.pl is: # Send param my $send_var = "This is a variable in param_send.pl...\n"; $ARGV[0] = $send_var; print "Ar...

How do I get WWW::Mechanize to work?

This script: use strict; use warnings; use WWW::Mechanize; my $mech = WWW::Mechanize->new( autocheck => 1 ); $mech->get( "http://www.google.com" ); print $mech->content; Produces this error message: Error GETing http://www.google.com: Can't connect to www.google.com:80 (connect: Unknown error) at D:\PERL\try.pl line 5 Wh...

Is something like ConfigParser appropriate for saving state (key, value) between runs?

I want to save a set of key, value pairs (string, int) between runs of a Python program, reload them on subsequent runs and write the changes to be available on the next run. I don't think of this data as a configuration file, but it would fit the ConfigParser capabilities quite well. I would only need two [sections]. It's only a few hu...

Is it feasible to learn Perl and Catalyst at the same time?

Is it feasible to learn Perl and Catalyst at the same time? If so, what would be the typical path? I am experienced .Net/C#/C++ developer but fairly new to Perl ...

Should Perl hashes always contain values?

I had an earlier question that received the following response from the noted Perl expert, Perl author and Perl trainer brian d foy: [If] you're looking for a fixed sequence of characters at the end of each filename. You want to know if that fixed sequence is in a list of sequences that interest you. Store all the extensions in a hash ...

How can I do bulk search and replace with Perl?

Hi: I have the following script that takes in an input file, output file and replaces the string in the input file with some other string and writes out the output file. I want to change the script to traverse through a directory of files i.e. instead of prompting for input and output files, the script should take as argument a directo...

Why does my Perl if condition always evaluate to true?

In Perl, I need to read a .conf file that contains either a 0 or a 1. If the value is one, I need to execute whatever is in the if statement. Here is what I have now: open(CONF, "/var/web/onhit.conf"); if(<CONF>) { print "Hello World!"; } close(CONF); The contents of the if statement always evaluate, even if the .conf file contains...

How do I get t-statistics and p-values of correlations in Perl?

Hi everyone, I'm trying to calculate correlations in Perl. I found out how to calculate correlations between arrays in CPAN, but I can't seem to find out how to get the t-statistics and p-values of those correlations (R gives these automatically). Is that even possible in Perl? I hope someone can help because I need to determine the sig...

How can I write the same text to two separate file handles using Perl?

I need to output the same text to two different files (it is a application requirement, which I am testing). Now, I do not wish to open two file handles, write two lines to each, then close them a dozen times in my code. Is there a simple way, perhaps using a single line in Perl (but not in the CLI!), to send the same text to two differ...

How can I secure connection to SQL Server from Perl DBI?

I need to connect to a secure SQL Server database using Perl DBI. I need to find a way to authenticate the user securely (without fear of eavesdropping, and without storing passwords on the client side). I'm using SQL Server 2008 on Windows Server 2008, and Perl 5.10 on XP. SQL Server supports encrypted connections via something calle...

Is Perl's GetOpt::Long accepting abbreviations of switches a bug?

This is a simple script I have written to test command line argument handling: use Getopt::Long; my $help = 0; GetOptions( 'help|h|?' => \$help, ) or die "Error!"; print "OK\n"; The results I got are as follows: D:\>perl test.pl --help OK D:\>perl test.pl --hell Unknown option: hell Error! at test.pl line 10. D:\>perl test.pl --...

Which MVC framework in Perl has its own standalone server?

I am creating an automated testing framework in Perl for regression tests. I would like to post my results from the test machines. I have used django before where the server ran standalone with no installation needed. Which MVC framework in Perl has its own standalone server? Basically, which of the Perl MVC frameworks is closest to dja...

Need help parsing results from ldap to csv

Hi, I am trying to create a script to generate a csv file with the results of some ldap queries using Net::LDAP but I'm having troubles skipping incomplete lines if one element of the @attributes array is blank. my @attributes = ('cn', 'mail', 'telephoneNumber'); So for example, if a user has no mail listed, or no telephoneNumber li...

Perl getcwd ending forward slashes

I am doing a Perl script to attach another variable to the end of the current working directory, but I am having problems with using the module. 1. If I run getcwd from D:\, the value returned is D:/ (with forward slash) If I run getcwd from D:\Temp\, the value returned is D:/temp (without forward slash) This makes the situation quite ...

Set effective group id of Perl script

I have file permissions issues that I would like to resolve without resorting to making everything world writable. I'm writing files to a NetApp SAN. The directory I'm writing to is owned by the devel user, and has a group of devel with group-writable permissions (0775). The username I'm writing as is in the username and devel groups. ...

How to find difference in csv record

Is there an algorithm or diff-like utilities to find difference between two csv files? Example: file1 ------- key1,value1 key2,value2 key3,value3 key5,value5 key7,value7 file2 ------- key1,value1 key3,value3 key4,value4 key5,value5 key6,value6 With this diff-like utilities it will output 3 types of records: Records that only exists...

Why does my image download with Perl's LWP give me the wrong-sized file?

I am trying to get an image from an HTTP server using Perl. I have the full URL of the file and am attempting to use my $data = LWP::Simple::get $params{URL}; my $filename = "image.jpg"; open (FH, ">$filename"); print FH $data; close (FH); Now, logically, to me at least, this should work. But the files are slightly different sizes,...

How can I extract the HREF value from an HTML link?

My text file contains 2 lines: <IMG SRC="/icons/folder.gif" ALT="[DIR]"> <A HREF="yahoo.com.jp/">yahoo.com.jp/</A> </PRE><HR> In my Perl script, I have: my $String =~ /.*(HREF=")(.*)(">)/; print "$2"; and my output is the following: Output 1: yahoo.com.jp Output 2: ><HR> What I am trying to achieve is have my Perl script automa...

How do I fix "as_number is not a Pari function name" when using Perl Net::SSH::Perl module

All, I run into this problem when trying to run an command via Net::SSH:Perl on another Linux host. Here is the exact error: `as_number' is not a Pari function name Line 1148. 5.8.8/x86_64-linux-thread-multi/Math/Pari.pm I found only one relevant posting and it indicates that it could be some sort of version mismatch between some o...

What text format can I use to present data originally in an Excel spreadsheet?

I have an Excel spreadsheet that has many people's estimates of another person's height and weight. In addition, some people have left comments on both estimate cells like "This estimate takes into account such and such". I want to take the data from the spreadsheet (I've already figured out how to parse it), and represent it in a plain...