Beefy Boxes and Bandwidth Generously Provided by pair Networks kudra
The stupid question is the question not asked
 
PerlMonks  

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
how to unpack a C struct with length array preceding data array
1 direct reply — Read more / Contribute
by johnlumby
on May 22, 2013 at 15:28

    my perl app receives a buffer containing this format

    { short lengths[2]; char data[???]; } where there are two items in data, of length lengths[0] and lengths[1] respectively.

    I have tried and tried to unpack this into 4 perl variables in a single unpack() call and failed. I had to resort to two unpack()'s, the first to extract the lengths followed by something like

    eval('($junk1 , $junk2, $data0, $data1) = unpack "ssA' . $data0_length + . "A" . $data1_length . '",$rcvd_buf;');

    which works fine, but can some kind Monk tell me how to do this in one unpack.

Mac Space in Path
2 direct replies — Read more / Contribute
by Anonymous Monk
on May 22, 2013 at 14:26

    I've not been able to solve the problem of space bands in paths on Mac.

    chomp (my $metadata_file = <>); $metadata_file =~ s/\s$//; open FILE, "$metadata_file"; $metadata = join '', <FILE>;

    It currently produces a "readline() on closed filehandle FILE" if there is a space in the path. I've done a lot of research and the answer is quoting the path. I think I've done that. I'm running perl5.10.0 on MacOS 10.6.8.

    Any help would be greatly appreciated.

Question about inheritance of WWW::Mechanize
2 direct replies — Read more / Contribute
by ryo0ka
on May 22, 2013 at 13:25
    Hi monks, I just registered. Thanks in advance! I want to use WWW::Mechanize::get in an inherited class's "get" subroutine, but it does not export any error (like "GETting...") even while the Internet access is out. See my code:
    package MyMech; use base qw(WWW::Mechanize); sub new { my $class = shift or die $!; my $self = $class->SUPER::new; return bless $self, $class; } sub get { my $self = shift; $self->SUPER::get(@_); }
    I think the get routine should work just like the base class' one, but it never die when it fails GETting. When I call the class and use the get subroutine while the Internet access is out, it just pass through the GETting error without saying anything and $mech->title produces "Uninitialized..." error. It works perfectly when the access is not out. Does anybody know why it happens? Thank you so much!
pdftotext pass options
1 direct reply — Read more / Contribute
by welle
on May 22, 2013 at 13:02

    Hi monks

    On a Windows machine I am using pdftotext to bunch convert pdf files into plain text. Using the following, I get no problems:

    system("$path/pdftotext","-nopgbrk","$path_my_pdf","$path_my_pdf.txt") +;

    I now want to add the encoding option "-enc UTF-8", so I try

    system("$path/pdftotext","-enc UTF-8 -nopgbrk","$path_my_pdf","$path_m +y_pdf.txt"); or simply system("$path/pdftotext","-enc UTF-8","$path_my_pdf","$path_my_pdf.txt +");

    but it doesn't work. What am I missing? Thanks

    SOLVED

    system("$path/pdftotext","-enc", "UTF-8","$path_my_pdf","$path_my_pdf. +txt");
system perl api fails with exit code 65280 on Win 2003
2 direct replies — Read more / Contribute
by Prakash Babu
on May 22, 2013 at 10:02

    I have perl script that is executed from a Application server using java on Windows 2003.

    my $zipExec='C:/zip.exe'; my @cmd = ($zipExec, "-rq", $destinationPath, "."); print "Executing command @cmd\n"; $syscode = system(@cmd); my $error = $!; print "Return code = $syscode \n"; print "Error = $error\n";

    It fails with the following error message.

    Return code = 65280
    Error = No such file or directory

    I have ensured that C:/zip.exe files exists and is executable. I tried executing other system binaries like cmd.exe but ran into the same issue.
    My question is what could be causing this issue like
    i. some environment setting is wrong and interfering with the system api and hence it is not able to load the binary.
    ii. The $PATH variable in this environment is greater than 1024 characters. Is the length of this variable a concern or some paths set in this variable is causing this issue


    thanks,
    Prakash
object creation
2 direct replies — Read more / Contribute
by *alexandre*
on May 22, 2013 at 09:52
    Hi, I rewrite some perl code and I found a problem creating a new object here is my package

    And into another module I'm trying to create a DB object like this way
    my $db = DB->new(); but I'm getting the following exception
    Can't locate object method "new" via package "DB" at LoadProperties.pm line 8.
perl in a container (lxc or other)
No replies — Read more | Post response
by djzort
on May 22, 2013 at 07:03
    Im curious if someone would be so kind as to share their experiences setting up a minimal perl container in lxc, openvz, bsd jails, linux-vserver or even chroots.

    App::Staticperl (http://software.schmorp.de/pkg/App-Staticperl.html) looks like it might be a good starting point - if i wanted to avoid a stripped down installed of <favourite distro or bsd>

    The ideal outcome would provide a container with mcpan and a given version of perl. Possibly some fusion of perlbrew and some dark magic to cook up the perl version then drop it in the container.

    Use case is to wrap up apps and put resource limits on them. PAAS like really. I know uwsgi can use namespaces and what not, if someone has used that - please share!
performance of counting keys in a big hash
2 direct replies — Read more / Contribute
by xufengnju
on May 22, 2013 at 04:58
    when we use scalar keys %MyHash to get count of keys in a hash, does perl actually go through every key? I mean if it is a big hash having more than 100,000 keys, does it slow down?
eval point in hash ref
3 direct replies — Read more / Contribute
by ag4ve
on May 22, 2013 at 02:50
    I'd like to be able to do:
    ./dat_query '{seek}'
    or
    ./dat_query '{seek}{messages}'

    and have code do:
    print Dumper($nethist->{seek});
    or
    print Dumper($nethist->{seek}{messages});

    I've been trying:
    my $in = $ARGV[0]; my $val = eval '$nethist->$in'; print Dumper($val);
    and the like with no luck
read a mail from outlook from a sub folder
1 direct reply — Read more / Contribute
by katsomo
on May 22, 2013 at 01:49

    I am able to read a mail from the inbox. My actual requirement is to fetch a mail from a subfolder in Outlook by comparing the subject of the mail in the Sub-Folder with a predefined text.

    use Mail::Outlook; use Win32::OLE::Const 'Microsoft Outlook'; my $outlook = new Mail::Outlook(); my $folder = $outlook->folder('Inbox'); my $message = $folder->last(); my $text = $message->Subject(); my $text1 = $message->From(); print "From : $text1\n"; print "Subject : $text\n";

    Using the code above I can read the subject and from address of the mail in the inbox. But I'd like to read a mail from the sub-folder. Please provide some tips.


Add your question
Title:
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!
  • 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
  • Outside of code tags, you may need to use entities for some characters:
            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?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others avoiding work at the Monastery: (9)
    As of 2013-05-22 20:56 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The best material for plates (tableware) is:









      Results (470 votes), past polls