Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
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
Segmentation fault with threads and binmode utf-8
3 direct replies — Read more / Contribute
by Anonymous Monk
on May 05, 2016 at 04:32

    The following program produces a segmentation fault with perl 5.10.1, 5.20.3, and 5.22.2:

    #!/usr/bin/perl use strict; use warnings; use threads; binmode STDOUT, ':encoding(utf-8)'; for my $i (1..4) { threads->create(sub {})->join(); }

    Is this a known bug?

Help with loops
3 direct replies — Read more / Contribute
by htmanning
on May 05, 2016 at 04:06
    Monks, I have a situation where I'm looping through a list to send an email out. There are 9 possible email addresses, even though 99% of the time only the $email variable exists. My logs show errors every time an email is sent. It's as if this loop is trying to send to the other 8 $pscemail vars even though they are empty.
    @email = ($email,$pscemail1,$pscemail2,$pscemail3,$pscemail4,$pscemail +5,$pscemail6,$pscemail7,$pscemail8); foreach $address (@email) { open (HTMLMAIL, "|$sendmail $address") || die "Can't o +pen $sendmail!\n"; print HTMLMAIL "From: $name <$adminemail>\n"; #print HTMLMAIL "Reply-to: $fromname <$fromemail>\n"; print HTMLMAIL "To: $address\n"; print HTMLMAIL "Subject: $subject\n"; print HTMLMAIL "Content-type: text/html\n"; Print HTMLMAIL "blah blah blah"; close (HTMLMAIL); }
    I'm not sure how to solve this. I assumed it simply wouldn't send if the vars were empty. This is the error I'm getting 7x: sendmail.postfix: fatal: Recipient addresses must be specified on the command line or via the -t option:
Grep the first occurrence of a string above a reference string
2 direct replies — Read more / Contribute
by venkat1312
on May 05, 2016 at 02:58
    Hi, I would like to know how to grep the first occurrence of a string above(upwards) a reference string. for (e.x.)in the below set, I would like to get the first occurrence of "AAA" above "XXX". AAA BBB AAA CCC XXX Thanks, Venkat
Accessing 2 multidimensional arrays simultaneously
4 direct replies — Read more / Contribute
by Ppeoc
on May 04, 2016 at 13:17
    Dear Monks, I have 2 multi dimensional arrays @array1 and @array2. @array1 and @array2 have elements in the form,
    $VAR1 = ['1,v,3,4']; $VAR2 = ['3,v,4,t']; ... ... $VARn = ['3,8,0,7']; $VAR1 = ['7,po,0'];
    @array1 and @array2 have the same number of rows but different columns. How can I access each row of both the arrays simultaneously. I want to print $VAR1 of @array1 and $VAR1 of @array2 on the same line. display as eg. 1,v,3,4,7,po,0. This is how I have saved my data into @array1
    while (<$fh>){ last if /^\s*$/; my @data= split(/\s+/,$_); @data = join (",",@data); push @array1, [@data]; }
    This is how I have been accessing elements of 1 2D array
    foreach my $x (@array1) { foreach my $y (@$x) { print $fout1 $y,"\n"; } }
    Any help would be appreciated. Thanks!
Print &
4 direct replies — Read more / Contribute
by meechl
on May 04, 2016 at 13:07

    Hi monks,

    I would simply like to print out the character "&". All my attempts thus far have been futile, including use of "\&" or ascii codes. Thanks for the help!

    Edit: Thanks for the replies! I am running perl on the command line and printing to a file. Here is the code for the out file generation and print statement:

    my $outFile = $outbase . "_temp_stems_RNAcofold.txt"; open(OUT, ">$outFile") or die "Could not open $outFile.\n"; print OUT ">$name\t$compName\n$seq" . "&" . "$compSeq\n";

    Edit 2: Wow, I'm an idiot. Was looking at the wrong output.

Perl6 Threads
1 direct reply — Read more / Contribute
by Anonymous Monk
on May 04, 2016 at 13:03
    I saved "my $thread = Thread.start({ for 1 .. 10 -> $v { say $v }});" from https://docs.perl6.org/language/concurrency#Threads into a file and ran "perl6 file.pl" but get error "Undeclared name: Thread used ..." Any ideas how to fix the problem? (The document doesn't mention using any packages.)
Multiple condition IF statement using grep and eq
1 direct reply — Read more / Contribute
by Anonymous Monk
on May 04, 2016 at 12:53

    I have a IF statement in this form:

    if (grep $_ == $F[1],73,89,121,101,117,69,77,67,115,81,97,65,113) {

    That compares values held within $F1 to those listed. I wish to add an additional condition that checks another variable other than $F1 but i'm struggling somewhat with the syntax and how this will work with the grep. For example:

    if (grep $_ == $F[1],73,89,121,101,117,69,77,67,115,81,97,65,113 && $inext eq "Global.SAM")

    Each condition works individually, but the latter condition testing $inext is ignored when written in this form. Why is this happening and what could be a solution to the problem?

Cleaning up cpantesters
1 direct reply — Read more / Contribute
by SBECK
on May 04, 2016 at 11:53

    This isn't really the best place to ask this, but I've submitted this to various contact addresses on cpantesters over the past year or so, and never received an answer, so I'll ask here in the hopes that someone can answer.

    Over the years, I've contributed a number of modules to CPAN that needed to be renamed. In 2007, I renamed a bunch to fit the accepted naming standards such as:

       DateManip renamed to Date-Manip
    

    and I've renamed a couple based on recommendations from the perl-module list, or for various other reasons such as:

       Locale-Messages renamed to Locale-VersionedMessages
       cpantorpm renamed to App-CPANtoRPM
    

    Unfortunately, if you go to my cpantesters.org page, all of the old distribution names appear in the "Distribution Summary" box. Is there anything that I can do to clean up whatever data is used to create that list? I'd like to have the list reflect only modules that currently exist if possible?

One-on-one Perl tutorial
7 direct replies — Read more / Contribute
by dominick_t
on May 04, 2016 at 10:43
    Hello-- I've recently posted a specific question and received some much appreciated input towards a solution. I am interested in learning more about Perl & regular expressions, and I'd really benefit from having some one-on-one lessons in person. I live in New York City. Any suggestions as to how to find someone in the area who could offer, say, a few hours of instruction one day? Open to bartering arrangements or doing it the old-fashioned way (cash). Thanks very much in advance.
FTP or scp or SFTP from Windows to server
1 direct reply — Read more / Contribute
by ravi45722
on May 04, 2016 at 09:32

    I am trying to get a file from windows to Linux. But my script has to run in Linux. I am Trying Net::SSH File::Remote but not succeed. Any modules to do this?? thanks in Advance


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!
  • 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?
    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 examining the Monastery: (8)
    As of 2016-05-05 12:40 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?