Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

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
Use command line argument in script
3 direct replies — Read more / Contribute
by homer4all
on Dec 18, 2014 at 18:01
    Experts, How can we use value in sub which was accepted at script run?

    DB: oracle 11gR2

    I tried using $days = $ARGV1, not sure but it doesn't work.

    Usage: ./ -days 30
    sub deleteData { $days = <how to have 10 here??>; my $sth = $dbh->prepare("DELETE FROM TEST_TABLE WHERE date = trunc(sysdate) - ?"); $sth->execute( $days ) or die $DBI::errstr; print "Number of rows deleted :" + $sth->rows; $sth->finish(); $dbh->commit or die $DBI::errstr; }
    Does above delete all days together or it will use cursor and delete one day at a time? Deleting one day at a time using bind variable will give better performance. Thanks...
Extracting data from CSV file + Extracting selected few lines through perl
2 direct replies — Read more / Contribute
by NicholasNVS
on Dec 18, 2014 at 12:00

    Hi Monks,

    I'm with the following problem:

    I have data in a CSV file:(contig name, species name)

    contig2, ponkan

    contig2, orange

    contig2, clementine

    contig2, maxima

    contig8, maxima

    contig8, orange

    contig8, clementine

    contig8, ponkan

    contig8, medica

    contig8, maxima

    contig8, ponkan

    contig9, maxima

    contig9, orange

    contig9, clementine

    contig9, ponkan

    contig9, medica

    contig9, maxima

    contig9, ponkan

    contig9, ponkan




    Excel CSV. file with more rows of data

    My output should look like:

    contig8 = maxima, orange, clementine, ponkan, medica

    contig9 = maxima, orange, clementine, ponkan, medica

    Perl script should read the first column and select entries equal (ie: lines with contig8 entry, for example) and then evaluate the second column of those selected entries and check if it have the five elements (maxima, orange, clementine, ponkan, doctors), selected will be in the output file. The entries (lines) that do not have the five elements (maxima, orange, clementine, ponkan, medical) will not be selected (ie: contig2) and not will be in the output file.

    I ask help and suggestions from you all on how to proceed in the analysis of these data. Please excuse any mistakes as English is my second language

    Thank you very much!

Loosing variable content after regular expression
2 direct replies — Read more / Contribute
by metty
on Dec 18, 2014 at 11:23


    I cannot figure out why my variable looses its content after applying a regular expression on it. The program is running in a mod_perl environment using Perl 5.14.2. The following code snippet is part of an object method. An interesting fact: sometimes its working, sometimes its not.

    if (defined($$l_Name_ref)) { print STDERR "1 $$l_Name_ref\n" if (defined($$l_Name_ref)); print STDERR "2 $l_Name_ref\n"; if ($$l_Name_ref =~ /^[a-zA-Z]\w+$/) { print STDERR "3 $l_Name_ref\n"; print STDERR "4 $$l_Name_ref\n"; ...

    Here is the output from the apache log files

    1 MMP_MODULES 2 SCALAR(0x7f80ab361968) 3 SCALAR(0x7f80ab361968) 4 MMP_MODULES 1 TMP_MODULE_HASH 2 SCALAR(0x7f80ad04ed68) 3 SCALAR(0x7f80ad04ed68)
    Use of uninitialized value in concatenation (.) or string at + line 1061.

    The error message indicates the line storing the print command with number 4.

    During the first run, referencing the value 'MMP_MODULES', the program is working fine. The debug code send to STDERR, which is passed to the Apache log files, prints the expected result. During its second run, using the value 'TMP_MODULE_HASH', the regular expression is validated fine, but the referenced value gets undefined. I printed the pointer value. Interesting enough, the pointer to the memory block does not get modified. Just the value gets lost. Any idea why?

    I can fix this by creating a local copy before applying the regular expression:

    if (defined($$l_Name_ref)) { my $l_Name = $$l_Name_ref; if ($l_Name =~ /^[a-zA-Z]\w+$/) { ...

    Using this code, it is always working. As the code is in a central part of my program, which is executed hundreds of times during a web page call, I would like to avoid copying a value without a need.

    How can a regular expression check modify the content of a variable?

Private temporal files on Windows
3 direct replies — Read more / Contribute
by salva
on Dec 18, 2014 at 08:11
    I am improving the support for Windows in Net::SSH::Any and adding backends for additional SSH clients, including one for the Tectia command line client sshg3 which has the nice feature of being fast (because it reuses connections transparently).

    Currently I am passing passwords to sshg3 on the command line, but that is quite insecure as anybody with access to the machine can see them. Fortunately, the program also accepts reading them from a file, but now the problem is that I don't really know how to create a temporary file which only the current user is allowed to access on Windows...

    Well, ok, I could invent something, but I don't like inventing things when security is involved and specially on a platform that I don't know well.

    So, can anybody illuminate me?

    And while we are at it, beta-testers for Net::SSH::Any are welcome. The development version is available from GitHub.

[OT] connectivity
3 direct replies — Read more / Contribute
by syphilis
on Dec 18, 2014 at 07:43

    For the last 2 or 3 days, whenever I try to browse to I get (almost instantly):

    The page you are looking for is temporarily unavailable.
    Please try again later.
    (port reminder 9080)

    Are others able to reproduce this ?
    Does anyone know what it means ?
    How temporary is "temporary" likely to be ? ... weeks ? ... years ? ... millennia ? ... the lifetime of the universe ?

    I tried connecting to but that just times out.
    I'm getting the same message on both IE (Windows 7) and Firefox (Ubuntu-14.04) - both of which connect through the same router.

    Anyway, I'll just have to change my IE home page from to

Blast Plus help.
1 direct reply — Read more / Contribute
by Robbih
on Dec 18, 2014 at 06:20

    Good day perl people.I have been working on some light perl projects. I have a project were i need to use the module Blast plus and i require some help.

    I have this code

    It is a very simple Blast Plus script which works as far as the blasting is concerned. My problem is that it also creates a lot of blast reports.

    $seq = "MGPTSGPSLLLLLLTHLPLALGSP"; my ($hit, $frac, $eval) = blast($seq); print "$hit\t$frac\t$eval\n"; sub blast { use strict; use Bio::Tools::Run::StandAloneBlastPlus; use Bio::Seq; use Bio::SearchIO; my $seq = $_[0]; my $seq_obj = Bio::Seq->new(-id =>"test", -seq =>$seq); my $fac = Bio::Tools::Run::StandAloneBlastPlus->new( -db_name => 'db', ); my $report = $fac->blastp( -method => 'blastp', -query => $seq_obj, ); my $hit = $report->next_hit(); my $hit_name = $hit->name(); $hit_name =~ s/\w{3}//; $hit_name; my $hsp = $hit->next_hsp(); my $frac_cons = $hsp->frac_conserved( ['query'|'hit'|'total'] ); $frac_cons = $frac_cons*100; my $evalue = $hsp->evalue(); return ($hit_name, int($frac_cons), $evalue); }

    The files which are created are "somename.fas" which gives the sequence which is being blasted and a BLASTP report "somename.file". So here comes the question: Is it possible to tell Blast Plus that i don't want anyfiles created?

    I will be doing allot of blasting and i don't want to end up with gazillion(estimation) files on the server. If you see some errors or mistakes i would also of course appreciate help.

    I have mostly been using But i did not see anything there which helped me.

    Thank you in advance.

Dynamic SNI certificates while upgrading to SSL
1 direct reply — Read more / Contribute
by gr3m1in
on Dec 18, 2014 at 05:01

    good day, monks!

    my program at my LAN host listens an IO::Socket:INET as HTTPS at port 443 and upgrades connections to IO::Socket::SSL with specified cert/key pair.

    i need to detect the SNI hostname to which a client is connecting and generate a dynamic cert/key pair according to the detected hostname.

    as the SNI documentation says, the hostname is reachable before actual handshake, but i can't figure out how to get it during upgrade to IO::Socket::SSL and dynamically supply just generated cert/key pair to upgrading object.

    thanks for any help!

    regards, gr3m1in

To check color of image using perl script
4 direct replies — Read more / Contribute
by codewalker
on Dec 18, 2014 at 04:38

    I need to check whether the given image is in color or black and white using perl.

    Is it is possible?

Transposing rows to columns
4 direct replies — Read more / Contribute
by simak29
on Dec 18, 2014 at 01:38

    Hello, Newbie here. Is there a way that I can transpose DB rows into columns? I am thinking, that I can read the rows into a hashmap and then do some processing there, but am just not sure how to go about this.

    For example: If I have the below table:

    id name dept date_joined email date_sent 1 P1 Test 12/10/14 Y 12/11/14 10:53:45 1 P1 Test2 1/1/14 Y 1/05/14 05:25:34 2 P2 Test 3/1/14 N Null 2 P2 Test 8/1/14 Y 8/05/14 11:28:28 3 P2 Test3 10/1/14 N Null

    Desired Output is: id name Test Test2 Test3 Y_email N_E +mail 1 P1 12/10/14,8/1/14 1/1/14,3/1/14 10/1/14 12/11/14 10:53:45 +,1/05/14 05:25:35,8/05/14 11:28:28 Null 2 P2 1/1/14,3/1/14 null 10/1/14 Null, Null Basically, trying to transpose and flatten it to get one row per recor +d. Any ideas how I can do this?

    Can anyone suggest how I can go about this in the simplest way possible? The data I am dealing with is huge.

    Thanks in advance

How to install perl in custom directory on solaris.
3 direct replies — Read more / Contribute
by Ankur_kuls
on Dec 18, 2014 at 00:30

    Hi, I am facing many issues while installing perl modules with the default perl which comes with sun OS 10. Now I want to install perl in any custom directory. what I know and did is as below

    downloaded the latest perl in any directory (say /home/abc) unzipped and untar it. cd /home/abc/perl-5.20.1 ln -s /usr/sfw/bin/gcc /usr/bin/gcc ln -s /usr/ccs/bin/make /usr/bin/make ./Configure prefix=/customperl/cac make make test make install

    all three make command didn't show any failure but still I didn't get my perl installed in custom /customperl/cac directory. Could any one please tell me where I am wrong or provide me the complete steps to install this...thanks.

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!
  • 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?

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

    How do I use this? | Other CB clients
    Other Users?
    Others surveying the Monastery: (8)
    As of 2014-12-19 06:30 GMT
    Find Nodes?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?

      Results (71 votes), past polls