perl

Why does perlbrew fail while installing perl-5.12.2?

When I try to install Perl 5.12.2 with perlbrew, I get an error at the end because the CPANPLUS tests fail. Making utilities make[1]: Entering directory `/home/dave/perl5/perlbrew/build/perl-5.12.2/utils' make[1]: Nothing to be done for `all'. make[1]: Leaving directory `/home/dave/perl5/perlbrew/build/perl-5.12.2/utils' cd t &...

Why should I use <ARGV> or <> instead of <STDIN> in Perl?

Quoting from Perl::Critic::Policy::InputOutput::ProhibitExplicitStdin Perl has a useful magic filehandle called *ARGV that checks the command line and if there are any arguments, opens and reads those as files. If there are no arguments, *ARGV behaves like *STDIN instead. This behavior is almost always what you want if you want to cr...

How can I convert CGI input to UTF-8 without Perl's Encode module?

Through this forum, I have learned that it is not a good idea to use the following for converting CGI input (from either an escape()d Ajax call or a normal HTML form post) to UTF-8: read (STDIN, $_, $ENV{CONTENT_LENGTH}); s{%([a-fA-F0-9]{2})}{ pack ('C', hex ($1)) }eg; utf8::decode $_; A safer way (which for example does not allow bog...

Why does this Perl code use a 1; statement?

Possible Duplicate: Why do you have to put a 1; at the end of a Perl 5 module? From this page Perl::Critic::Policy::Subroutines::RequireFinalReturn, this is a code sample package Password; # every time the user guesses the password wrong, its value # is rotated by one character my $password; sub set_password { $password =...

What pitfalls does this Perl code have?

I have written some code to print formatted arrays (first line = no of inputs, second line = max width of numbers). The star can be any sort of marker to differentiate some elements from the rest. $ cat inp.txt 6 2 1 * 2 3 4 9 12 * $ cat inp.txt | ./formatmyarray.pl ____ ____ ____ ____ ____ ____ | * | | | | | * | | 1 | ...

Other solutions/languages that are superior to the TCL-based Expect?

I am amazed by how Expect (TCL) can automate a lot of things I normally could not do. I thought I could dig deeper into Expect by reading a book, but before I do that I want to ask if there are other solutions/languages that could do what Expect does? Eg. I have read that people compare Expect with Awk and also Perl. Could Awk and Per...

What does "service not available" mean in Perl's Mail::Sender?

I'm trying to send mails from Perl using the Mail::sender module. But I keep getting -4 return messages. The manual says -4 is service not available. What does that mean? ...

File Manipulation: Scripting Question

I have a script which connects to database and gets all records which statisfy the query. These record results are files present on a server, so now I have a text file which has all file names in it. I want a script which would know: What is the size of each file in the output.txt file? What is the total size of all the files present ...

What does "user $to unknown on host $smtp" mean in Perl's Mail::Sender?

I'm using Mail::Sender to send mail from Perl. I have a valid SMTP server (it works if I do a telnet). However, I get an error -6 on a MailMsg. The doc shows -6 as local user $to unknown on host $smtp What does this mean? Is it unable to locate the receiver? my $rec=(new Mail::Sender)->MailMsg( {smtp=>'smtp.example.net', ...

How should I update a hash of hashes when using multi-threading in Perl?

I have been spending the last hours trying to figure this out and now I'm really confused. This is the outline of my task. I should write a Perl subroutine that gets a reference to a hash of hashes. I have another sub (helper) that gets a single inner hash and does some stuff to with, including adding keys. sub helper { $href = sh...

How can I structure CGI programs that move page to page?

I have a general question about Perl CGI programs. For a few applications, not using MVCs, developers write CGI programs, may be using CGI.pm or some other way they like and for moving from screen to sceen, a new CGI program is written, (with - CVS TAGS, Perl headers etc etc..). But what I feel is if there is some stuff (subroutine or b...

How can I format URLs nicely in Perl?

Hello! I have a bunch of URLs that I have to turn into links: for my $url (@url_list) { say "<a href='$url'>$url</a>"; } Is there a module for making the visible URL nicer? A bit like this: http://www.foo.com/ → www.foo.com http://www.foo.com/long_path → www.foo.com/lo… I know a simple regex will probably do here, but I’m spoi...

How can I tell Perl to run some code every 20 seconds?

How can I tell Perl to run some code every 20 seconds? ...

Which thread pool manager is recommended for Perl?

I only know of Thread::Pool which is apparently not supported in recent Perl versions, and Thread::Pool::Simple which lacks almost any documentation. So which thread pool manager can I use under Perl v5.10.1 or and higher? ...

Is there some lightweight user preference support in CPAN?

I want to have my Perl program support both Win32 Registry and the similar feature in Linux. GConf maybe a good idea, but it's too heavy. Is there some lightweight user preference support in CPAN? ...

How can I retrieve data between tags, in Perl ?

I'm developing a perl script. This is my input string in a file new.txt: <ID>1</ID> <CLASS>One</CLASS> <NAME>Saran</NAME> This is my code which simply prints the three lines: #!/usr/bin/perl open(FILEHANDLE1,"new.txt") or die "Can't Open: $!\n"; while($line=<FILEHANDLE1>) { print "$line"; } close FILEHANDLE1; I need it to displa...

How can I run a macro in an Excel file I open with Perl?

How can I run a macro in an Excel file I open with Perl? ...

issues with getting multiple select param values from jquery, javascript back to perl cgi page

Hi, I have been working on this for 1 hour with no such luck. Any help would be appreciated. I have a cgi script with which creates these select param values: print "Please select a dkversion to compare : <br><br>"; print "<select name='dkversion' id='dkversion' size='6' multiple='multiple'>"; foreach my $values ('ASDF123GS v0.01 mod...

Why can't I build Perl modules that load Socket.so on Solaris 10?

I am trying to build Convert::ASN1 module but I get an error in the process. I am using Perl 5.12.0 on Solaris 10. perl Makefile.PL runs without trouble, same for make, but 'make test' throws this error: MOST CRUCIAL PART OF IT IMO: t/00prim.t ....... Can't load '/usr/local/lib/perl5/5.12.0/sun4-solari +s/auto/Socket /Socket.so' for mo...

How can I display Extended ASCII Codes characters in Perl?

How to display 192 character symbol ( └ ) in perl ? ...