Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Seekers of Perl Wisdom

( #479=superdoc: print w/replies, xml ) Need Help??

If you have a question on how to do something in Perl, or you need a Perl solution to an actual real-life problem, or you're unsure why something you've tried just isn't working... then this section is the place to ask. Post a new question!

However, you might consider asking in the chatterbox first (if you're a registered user). The response time tends to be quicker, and if it turns out that the problem/solutions are too much for the cb to handle, the kind monks will be sure to direct you here.

User Questions
Is ActivePerl repositories go free again?
No replies — Read more | Post response
by exilepanda
on Apr 30, 2017 at 00:39
    Dear monks,

    Story part 1: Days ago, I was looking for where to download PDK9.5(doesn't matter), and while I stepped in some page under ActiveState(from search result), I saw something alike mentioning ActivePerl will go free in the future. Because I was in a rush, I only glanced the page for few second (and can't find them again as my browser clear history per close)

    Story part 2: Yesterday, I was trying my best luck to install some modules in my very old machine using Perl 5.16 in WinXP, and when I hit on ppm.. I saw the repositories are all updated. I can tell there was something like redirected, 403 sort of before, seem I need a business license to access those repositories, but I could update them again yesterday.

    Can somebody tell if the repositories open for free again (for any perl version)?? Since I involved many machines, so I don't sure maybe I saw those redirect 403 from other machine.

Are there any modules using source filter to capture code?
1 direct reply — Read more / Contribute
by LanX
on Apr 29, 2017 at 17:47
Get url
4 direct replies — Read more / Contribute
by kepler
on Apr 29, 2017 at 17:25


    I'm having some troubles regarding a simple get for an url,

    Even using this script, I get a null result (in several hosts except one, bluehost):
    #!/usr/bin/perl use LWP::Simple; use warnings; print "Content-type: text/html\n\n"; my $url = " +ry/2.5_week.atom"; my $data = get $url; print "$url\n$data";

    Can someone help me out?

    Thanks, Kepler
Videos from LPW 2016?
No replies — Read more | Post response
by LanX
on Apr 29, 2017 at 15:59
using Skype
2 direct replies — Read more / Contribute
by louhevly
on Apr 29, 2017 at 13:19

    Greetings oh wise ones,

    My mother is in her 90s and lives alone in her own apartment in a retirement home in the States. I live in Europe and would like to write a Perl script that calls her landline phone every morning at 9am (this could be on a cronjob). If she answers, the program should report success and exit; if no answer, then call 10 minutes later. If after 30 minutes there is no answer, then call a different number requesting that someone check her room.

    My Skype account allows me to call Skype-to-landline for pennies, which is what I'm doing now manually. I searched for Skype on CPAN and found quite a number of modules described, but I thought it might save time asking here if someone knew just which module might be appropriate for what I'm trying to do.

    Thanks in advance, Lou

HASH value error
2 direct replies — Read more / Contribute
by pdahal
on Apr 29, 2017 at 01:58
    I am a beginner in perl. I need to parse an XML file and store the results into CSV file. The problem I am facing is I am getting the output like "HASH(0x3de3350)" instead of PubMed IDs like "16466327" in CSV file. How can i handle this?
Convert weekday to numerical date
3 direct replies — Read more / Contribute
by james28909
on Apr 28, 2017 at 23:23

    Hello again wise monks :)

    I have a list of weekdays:

    my @weekdays = qw( Today Yesterday Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday );

    I need to format these weekdays into an absolute numerical date based off of scalar localtime. eg:

    my ($local_weekday, $local_month, $local_numerical_date) = split (/\s+ +/, scalar localtime), 3; __END__ Fri Apr 28 'Yesterday' would be '27'

    I need to use $local_weekday and $local_numerical_date (eg. 'fri 28') to format @weekdays from the list. eg. 'wednesday' to eg. '26'.

    Also, i never need to check what the numerical date in the future is, it is always current date or earlier. I am pretty sure there is a way to loop while subtracting but I cant figure it out lol.

    If I can be any more clear on anything please let me know. I have tried to explain it the best i can :)

    EDIT: changed 'wednesday 27' to just '27' and added 'Yesterday' would be '27' to __END__

Array of variables
7 direct replies — Read more / Contribute
by Michael W
on Apr 27, 2017 at 11:38
    my @Variables = ( $Map_Request_Date,$Map_Due_Date,$Map_Cutover_Date,$ +Map_Complete_Date,$Map_Approved_Date); foreach $Date_Ref (@Variables) { print $Date_Ref; $Date_Ref =~ s/ +/ /; #When day is a single digit it creates two wh +ite spaces ($Month,$Day,$Year,$Time)= split / /, $Date_Ref,4; my %Months = ( 'Jan' => '01', 'Feb' => '02', 'Mar' => '03', 'Apr' + => '04', 'May' => '05', 'Jun' => '06', 'Jul' => '07', 'Aug' + => '08', 'Sep' => '09', 'Oct' => '10', 'Nov' => '11', 'Dec' +=> '12' ); if (length($Day) == 1) {$Day = "0$Day";}#Add 0 to the front of sing +le digit days @Variable[$X]=$Year."-".$Months{$Month} ."-" . $Day ; $X=$X+1; }

    Working on a date issue from sql to html format

    previous only used an array of variables to read from

    this time I want to place the value back into the array of variables

    this line: @Variable$X=$Year."-".$Months{$Month} ."-" . $Day ;

    all the code works until I try to write the new variable back in

how i capture a script error to a file ?
5 direct replies — Read more / Contribute
by gabrielsousa
on Apr 27, 2017 at 08:28
    how i capture a script error to a file ?
    did this, but dont work :(
    local $SIG{__DIE__} = sub { my $message = shift; system qq(echo "$message" >> log.err); };
Convert KMail emails to Claws
4 direct replies — Read more / Contribute
by peterr
on Apr 27, 2017 at 01:41

    I'm using a Perl script to convery KMail emails to Claws email. There were a few errors

    #!/usr/bin/perl -w # * This file is free software; you can redistribute it and/or modify + it # * under the terms of the GNU General Public License as published by # * the Free Software Foundation; either version 2 of the License, or # * (at your option) any later version. # * # * This program is distributed in the hope that it will be useful, b +ut # * WITHOUT ANY WARRANTY; without even the implied warranty of # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # * General Public License for more details. # * # * You should have received a copy of the GNU General Public License # * along with this program; if not, write to the Free Software # * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 021 +10-1301, USA. # * # * Copyright 2003-2007 Paul Mangan <> # * # * 2007-02-25: several fixes for kmail 1.9.6 # --kmaildir now expects the full path # renamed from to kmail-mailbox2claws-ma # * 2003-10-01: add --debug and --dry-run options # * 2003-09-30: updated/improved by Matthias Förste <itsjustme@users.> # * 2003-05-27: version one ## script name : ## script purpose : convert a Kmail mailbox into a Claws Mail mailbox ## USAGE: --kmaildir=/full/path/to/kmail/m +ailbox ## tested with Kmail version 1.9.6 use strict; use Getopt::Long; use File::Find; my $kmaildir = ''; my $iNeedHelp = ''; # dont actually change anything if set(useful in conjunction with debu +g) my $PRETEND = ''; # print debug info if set my $DEBUG = ''; my $claws_tmpdir = "$ENV{HOME}/claws_tmp"; GetOptions("kmaildir=s" => \$kmaildir, "help" => \$iNeedHelp, "dry-run" => \$PRETEND, "debug" => \$DEBUG); if ($kmaildir eq "" || $iNeedHelp) { if (!$iNeedHelp) { print "No directory name given\n"; } print "Use the following format:\n"; print "\ --kmaildir=full-path-to-kmail +-dir\n\n"; exit; } my $count = 1; my $MAIL_dir = "$kmaildir"; my $find_opts = { wanted => \&process }; if (-d $MAIL_dir) { find($find_opts , ($MAIL_dir)); } else { print "\n$MAIL_dir is not a directory !\n"; exit; } unless ($PRETEND) { mkdir("$claws_tmpdir", 0755); system("mv $claws_tmpdir $ENV{HOME}/Mail"); print "\n\nSucessfully converted mailbox \"$MAIL_dir\"\n"; print "Start claws-mail and right-click \"Mailbox (MH)\" and "; print "select \"Rebuild folder tree\"\n"; print "You may also need to run \"/File/Folder/Check for "; print "new messages in all folders\"\n\n"; } print "\n"; exit; sub process() { if (-d) { process_dir($File::Find::dir); } else { process_file($File::Find::name); } } sub process_dir() { my $direc = shift(); $DEBUG && print "\nDIR $direc"; if ($direc !~ m/^drafts$/ && $direc !~ m/^outbox$/ && $direc !~ m/^trash$/ && $direc !~ m/^inbox$/) { my $tmpdir = $direc; $tmpdir =~ s/^$MAIL_dir//; $tmpdir =~ s/\/sent-mail$/sent/; $tmpdir =~ s/\/cur$//; $tmpdir =~ s/\/new$//; $tmpdir =~ s/^\///; $tmpdir =~ s/\.directory//g; $tmpdir =~ s/\.//g; my $newdir = "$claws_tmpdir/$tmpdir"; $DEBUG && print qq{\n>>> -e "$newdir" || mkdir("$newdir")}; $PRETEND || -e "$newdir" || mkdir("$newdir"); } } sub process_file { my $file = shift; $DEBUG && print "\nFILE $file"; my $nfile; my $tmpfile = $file; $tmpfile =~ s|^$kmaildir||; if ($tmpfile =~ m/\/cur\// || $tmpfile =~ m/\/new\//) { $tmpfile =~ s/\/new//; $tmpfile =~ s/\/cur//; my @spl_str = split("/", $tmpfile); pop(@spl_str); push(@spl_str, "$count"); foreach my $spl_str (@spl_str) { $spl_str =~ s/\.directory$//; $spl_str =~ s/^\.//; $spl_str =~ s/^sent-mail$/sent/; } $nfile = join("/", @spl_str); $nfile = $claws_tmpdir.$nfile; } if (-e "$file" && $nfile ne "") { $DEBUG && print qq{\n+++ cp "$file" "$nfile"}; $PRETEND || system("cp \"$file\" \"$nfile\""); $count++; } }

    cp: cannot create regular file '/home/********/claws_tmp/*******/Misc. (PO,NRMA,etc)/711': No such file or directory

    Is this simply because the file is attempted to be copied before the path exists ? How do I fix that please

    Also this error ...

    Use of uninitialized value $nfile in string ne at line 149.

    It is defined at libe 125, but not initialised; is that all that needs doing there ?

Add your question
Your question:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others chilling in the Monastery: (3)
    As of 2017-04-30 05:27 GMT
    Find Nodes?
      Voting Booth?
      I'm a fool:

      Results (534 votes). Check out past polls.