perl

How can I convert messages in an mbox file to UTF-8?

Hello, I am trying to modify the below program to ensure each msg is converted to utf-8 using Encode::decode(), but I am unsure of how and where to place this to make it work. #!/usr/bin/perl use warnings; use strict; use Mail::Box::Manager; open (MYFILE, '>>data.txt'); binmode(MYFILE, ':encoding(UTF-8)'); my $file = shift || $ENV{...

How can I set the line length limit in Text::Wrap?

Hello, I would like to know if there was a way to set a width for lines outputted to aid in formatting, to make sure that lines always wrap after a certain amount. I will be using the code below to sort and print emails, and would prefer messages that are on very long lines are neatly broken up, but I am unsure how to do this. I have at...

How can I strip HTML and attachments from emails?

Hello, I am using the program below to sort and eventually print out email messages. Some messages may contain attachments or HTML code, which would not be good for printing. Is there an easy way to strip attachments and strip HTML but not the text formatted by HTML from the messages? #!/usr/bin/perl use warnings; use strict; use Mail:...

Why isn't HTML::Obliterate obliterating my HTML?

Hello, I am trying to use the following code, which I have not been able to test yet, because I get the following errors: #!/usr/bin/perl use warnings; use strict; use Text::Wrap; use Mail::Box::Manager; use HTML::Obliterate qw(extirpate_html); open (MYFILE, '>>data.txt'); binmode(MYFILE, ':encoding(UTF-8)'); my $file = shift || $E...

What are "unstacked calls in outer" in Perl's Devel::DProf?

I am profiling a Perl application with perl -d:DProf. When running dprofpp on the resulting tmon.out file, I get warnings like these: Compress::Zlib::__ANON__ has 5 unstacked calls in outer Compress::Zlib::AUTOLOAD has -5 unstacked calls in outer What is an unstacked call? Who or what is "outer"? What do the numbers mean? How can the...

How can I split a string into chunks of two characters each in Perl?

How do I take a string in Perl and split it up into an array with entries two characters long each? I attempted this: @array = split(/../, $string); but did not get the expected results. Ultimately I want to turn something like this F53CBBA476 in to an array containing F5 3C BB A4 76 ...

What is the smallest program possible to parse an email message header?

the homework: http://www.cs.rit.edu/~waw/networks/prob1.082.html Ok, I am still confused why this question was asked for my data communications and networks class, but here is the question from my homework: Write a computer program that reads the header on an e-mail message and deletes all lines except those that begin with ...

Why does the EPIC eclipse plugin not show any info in "Explain Errors/Warnings"?

I use the "EPIC" plugin to Eclipse for Perl development, but in the "Explain Errors/Warnings" view there's no info at all, even though I have some compilation errors. Do I need to do anything special to get EPIC to display useful info in that view? What is that view for anyway? ...

How can I write out or read in a Perl hash of arrays?

I have a program in Perl I'm working on where I would need multiple keys, and a way of giving each key multiple values and follow that by being able to both read them in and write them out to an external file depending on if the key matches what the person enters into standard input. I've looked across several sites and have found inform...

How can I invoke an object dynamically in Perl Moose OOP?

Here is classical object model: class ViewBase { void DoSomethingForView() { } //May be virtual } class View1 : ViewBase //(derived class from ViewBase) { void DoSomethingForView() { } void DoSomethingForView1Special() { } } class View2: ViewBase //(another derived class from ViewBase) { void DoSomethingForView2S...

Can I embed Strawberry Perl in a VC++ 6.0 compiled application or use Inline::C with the compiler mismatch?

I am looking at embedding perl 5.10 in a large C++ application compiled with VC++ 6.0. This leads to two questions. 1) Is it a bad idea to simply use Strawberry Perl as a dependency rather than compile my own perl with VC++ 6.0? Would Strawberry even work given the compiler mismatch? I presume Strawberry is compiled with mingw. I wo...

How can I match a quote-delimited string with a regex?

If I'm trying to match a quote-delimited string with a regex, which of the following is "better" (where "better" means both more efficient and less likely to do something unexpected): /"[^"]+"/ # match quote, then everything that's not a quote, then a quote or /".+?"/ # match quote, then *anything* (non-greedy), then a quote Assu...

How can I get BerkeleyDB for ActivePerl 5.10?

I'm trying to find out where a BerkeleyDB PPM is for ActivePerl 5.10. Anyone have a clue where to find this, or how to build it? I had found a lead here. They claim BerkeleyDB 0.33 had built ok for Perl 5.10. They provide a link to the PPM, but not to the supporting zip file. So I got around it, manually getting the ppm and the zip and ...

How can I execute a given function on every element of a complicated data structure in Perl?

I want to decode all the HTML entities in a complicated data structure. Basically I'm looking for a "super map()" function. Here's what I have so far: sub _html_decode { my $self = shift; my $ref = shift; if (ref($ref) eq "HASH") { $self->_html_decode_hash($ref) } if (ref($ref) eq "ARRAY") { $self->_...

Why can't Nginx POST to my Perl backend?

EDIT: So I just found out that GET methods indeed work, but POST methods however do not work! That might be significant. So I am on Debian Etch, running Nginx. Nginx does not normally serve cgi/pl files so I have followed a guide to get my backend working. http://technotes.1000lines.net/?p=23 My backend works fine on Apache but I had ...

What's the efficiency and quality of this shuffling algorithm?

This recent question about sorting randomly using C# got me thinking about the way I've sometimes shuffled my arrays in Perl. @shuffled = sort { rand() <=> rand() } @array; The proposed solution in the mentioned question is Fisher-Yates shuffle, which works in a linear time. The question is: how efficient is my snippet and is such sh...

How do I use multiple Template Toolkit TTSite views on a Catalyst site?

I use Template Toolkit to generate views of pages in Catalyst. To do some basic Ajax, I want to have some output pages not use the TTSite style, but a much more basic structure. Do I put something special into the stash to use a .tt2 file without the header/footer/etc that automatically comes with the rest of my templates? (site gener...

What is the difference between the scalar and list contexts in Perl?

What is the difference between the scalar and list contexts in Perl and does this have any parallel in other languages such as Java or Javascript? ...

What's the easiest way to detect compilation failures, missing packages, etc in a Perl application?

I have a Perl application someone else wrote and I'm trying to make it run on my local machine. But I keep getting an error in one of the modules, which appears to be based on a missing module somewhere. What are some good tools or practices to track this thing down? ...

Are there any decent Perl plugins for Eclipse?

I'm using EPIC, but it seems to have some drawbacks. Are there any other Perl plugins for Eclipse? ...