perl

How can I plot a time series graph with Perl?

I have some data from a database (SQLite), mapping a value (an integer) to a date. A date is a string with this format: YYYY-MM-DD hh:mm. The dates are not uniformly distributed. I want do draw a line graph with the dates on X and the values on Y. What is the easiest way to do this with Perl? I tried DBIx::Chart but I could not make it ...

Escaping whitespace within nested shell/perl scripts

I'm trying to run a perl script from within a bash script (I'll change this design later on, but for now, bear with me). The bash script receives the argument that it will run. The argument to the script is as follows: test.sh "myscript.pl -g \"Some Example\" -n 1 -p 45" within the bash script, I simple run the argument that was passe...

How do I store a 2d array in a hash in Perl?

I am struggling through objects in perl, and am trying to create a 2d array and store it in a hash field of my object. I understand that to create a 2d array I need an array of references to arrays, but when I try to do it I get this error: Type of arg 1 to push must be array (not hash element) The constructor works fine, and set_seqs wo...

How can I convert a string into a regular expression that matches itself in Perl?

How can I convert a string to a regular expression that matches itself in Perl? I have a set of strings like these: Enter your selection: Enter Code (Navigate, Abandon, Copy, Exit, ?): and I want to convert them to regular expressions sop I can match something else against them. In most cases the string is the same as the regular exp...

How can I save email to a file with Perl?

Hello, I learning Perl and I want to create a simple application that gets all my emails and save they to a file, but how I can do this? Thanks. ...

What does the _ in [a-zA-Z0-9_] mean?

What does the underscore mean in the following regex? [a-zA-Z0-9_] The _ seems to make no difference so I don't understand the purpose of it. ...

How do I remove email headers?

Hello, I learning Perl and doing a home made project to my family (a subscription project). The Perl application that uses Net::POP3 connect to my mailbox and save all my emails to a file (Mail.txt). When I open this file I see a lot of junk, as below. What i can do to remove this? Thanks. Return-Path: Received: from [unix socket] by...

How do I return nothing from a subroutine?

I want to validate a condition before doing the next step, but only raise a warning and skip the current value instead of die-ing. How do I rewrite validate_me() subroutine without returning any value? (Update) please note that the following code works as expected, it just that I want something else instead of returning 1 or 0 from val...

How do I use map() to apply an operation to each element of a hash in Perl?

I've got a piece of code that works fine. It basically loops through each element of a hash using foreach() and applies a transformation to it using a regular expression, like so : foreach my $key ( keys( %{$results} ) ) { $results->{$key}{uri} =~ s/\".*\/(.*\.*(gif|jpe?g|png))\"/\/resources\/uploads\/$1/gi; } $results is a hashref...

"inappropriate ioctl for device"

Hi All, I have a perl script running in a aix box. The script tries to open a file from a certain directory and it fails to read the file because file has no read permission. but i get a different error saying "inappropriate ioctl for device" Shouldn't it say something like file doesn't have read permission or something? What does t...

I'm new to Perl and have a few regex questions

I'm teaching myself Perl and I learn best by example. As such, I'm studying a simple Perl script that scrapes a specific blog and have found myself confused about a couple of the regex statements. The script looks for the following chunks of html: <dt><a name="2004-10-25"><strong>October 25th</strong></a></dt> <dd> <p> [Cont...

gVim perl tags under Win32 - should I use Perl::Tags ?

Hi, I am a newbie when it comes to gVim, Perl & test scripts, so I hope this is not a stupid question? I have successfully installed Perl::Tags 0.26 under Linux and OS X but am getting installation test errors under WIN32 -- also see perl.cpan.testers My questions are: (i) Does VIM need Perl::Tags or can I rely on exuberant ctags to g...

How can prevent a space from being appended to the tab-completed word using Perl's Term::Readline?

I am using tab completion support of Term::ReadLine::Gnu module. Every time I do a tab, I get a space after the completed word. For example: If i have a word "complete" as a possible completion. After prompt I pressed tab and I am getting it like: "complete " where these is a space at the end of the completed word. What I want is: ...

Why does my script use so much more memory when run with mod_perl?

I'm trying to learn how to profile perl memory. I have a very simple Perl hello-world script and I want to know its size in memory. I use GTop utility to measure the memory (recommended in mod_perl book by Stas Beckman). GTop provides the results that confuse me. When I run the script from the command line GTop says: 7M. When I run i...

How do I linkify text in Perl?

I have some text I want to linkify, which I can reasonably do with a regex (search for http/https or www) but I'm worried about XSS complications. What's a safe way to do this in Perl? ...

How can I disable Log4perl output for a particular class?

I would like to use Log4perl in a project but disable it for a certain class (which is, in this case Net::Amazon). I thought this would be an easy one, but somehow I failed. I tried using use Log::Log4perl (:easy_init); use Net::Amazon; my $amz = Net::Amazon->new( ... ); my $log = Log::Log4perl->easy_init($DEBUG); $log = $log->get_log...

How can I get the last changed directory in Perl?

Apache version 2.2.11 (Unix) Architecture x86_64 Operating system Linux Kernel version 2.6.18-164.el5 Ok, here is what I have working. However, I may not be using File::Util for anything else in the rest of the script. My directory names are 8 digits starting at 10000000 . I was comparing the highest found number with stat last create...

How do I get the email content from Mail::Message?

Edited Now my code is like this: #!/usr/bin/perl # import packages use Net::POP3; use Getopt::Long; use Mail::Message; use strict; use warnings; # read command line options # display usage message in case of error GetOptions ('h|host=s' => \$host, 'u|user=s' => \$user, 'p|pass=s' => \$pass) or die("Input error...

How to script a google search without google license key?

Hello all, I'm looking at 'pygoogle' python library for google search, call from my python script. But google doesn't give out license key anymore, and looks like pygoogle needs license key to work. Does anyone have suggestions of libraries to use for scripting web searches? Languages doesn't matter. It can be in python, perl, lisp, fo...

How can I set default values using Getopt::Std?

I am trying to collect the values from command line using Getopt::Std in my Perl script. use Getopt::Std; $Getopt::Std::STANDARD_HELP_VERSION = 1; getopts('i:o:p:'); my $inputfile = our $opt_i; my $outputfile = our $opt_o; my $parameter_value = our $opt_p; Here the first two variables ($inputfile,$outputfile) are mandatory but the las...