Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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
Iterate multiple arrays with added text
3 direct replies — Read more / Contribute
by Bman70
on May 23, 2017 at 15:44
    Hi, I'm looking at another ten hours of troubleshooting (sucks to not know much Perl!), so I thought I would ask. I have several arrays, @title, @author, @date, each of which have multiple elements. I need to output all the elements (several hundred) organized as:
    Title: "title from array" Author: "author from array" Date: "Date from array"
    In my searching the closest I got was another perlmonks thread:
    while (@title, @author, @date) { print join ': ', map shift @$_ // 'NULL', \@title, \@author, \@dat +e; print "\n"; }
    This gets all the information out, but not formatted right. Would I be able to add the text and newlines to this code, or should I use something entirely different? I realize it could probably be done with hashes but currently it's in arrays so hoping that can work. Thanks!
sending to multiple addressess
2 direct replies — Read more / Contribute
by bigup401
on May 23, 2017 at 12:56

    how can i send message to multiple addresses without showing cc, bcc emails to recipients. i want something like php mailer.

    any idea

    $msg = MIME::Lite->new( To => ,
Capturing output from a long-running pipeline
1 direct reply — Read more / Contribute
by wanna_code_perl
on May 23, 2017 at 12:56

    Hello monks,

    I've mostly written a Perl program that runs several external backup and file transfer programs, such as duplicity, scp, rsync, etc. Everything's fine except I'm not sure of the best way to actually execute the commands. I'll show you the relevant subroutine, then I'll get into specifics:

    # Run executable @system command, reporting name as $name If there # is an upload limit, we run through trickle(1) to limit bandwidth. sub _ext_cmd { my ($name, @system) = @_; if ($o{general}{upload}) { @system = ($o{general}{trickle}, $o{general}{trickled} ? () : '-s', -u => $o{general}{upload}, '|', @system); } say "Running name=$name, @system"; # system { $system[0] } @system[1..$#system]; # Obviously nope. say "\$?=$?"; }
match a word and delete last line
3 direct replies — Read more / Contribute
by ArifS
on May 23, 2017 at 09:26
    Hi, I am trying to match the word (sample-text) and delete previous line if has a single word that might include (digit,_,-).
    use strict; use warnings; my $filename = 'test1.txt'; open(my $fh, '<:encoding(UTF-8)', $filename) or die "Could not open file '$filename' $!"; my $line; my $flag=1; while($line=<$fh>) { if($flag == 0) { print $line; next; } if($line=~/sample-text/) { $flag=0; print $line; } }
    Content of the test1.txt
    Text_1 sample-text file Text_1 matching the 1st line matching the last line Text text_1 text-2 sample-text file text-2 matching the 1st line matching the last line
    Expected output
    sample-text file Text_1 matching the 1st line matching the last line text text_1 sample-text file text-2 matching the 1st line matching the last line
    But it only removes the 1st line, and doesn't look for other lines. Please let me know.
Authorization Negotiate Wep-Programming
3 direct replies — Read more / Contribute
by amitsq
on May 23, 2017 at 08:51
    hi,

    so i am totally new and over challenged with proxies and all that web programming, so pls bear with me. I am currently trying to access with the LWP-Modul a (https-)webpage, to fill in its form, submit it and getting the result page. While I am able to get the content of the first page with the form, the response via Post is always empty. While I am trying to recreate the request-request, i see there is following line in the request-header :

    Proxy-Authorization:"Negotiate YIIGzQYGKwYBBQUCoIIGwTCCBr2gMDAuBgkqhkiC9xIBAgIGCSqGSIb3EgECAgYKKwYBBAGCNwICHgYKKwYBBAGCNwICCqKCBoc [shorted] "  

    There is no need to log in to the website, so I got no password or username. I tried my best to find out about it, but I got no clue how i could get the Negotiate key. So i use Active perl on Windows and the LWP-Authen-Negotiate Modul is not available for Windows. Are there any other solutions?

    $param ='simpleSearchSearchForm=simpleSearchSearchForm&simpleSearchSea +rchForm%3Aj_idt379=ALLTXT&simpleSearchSearchForm%3AfpSearch=brushless ++motor&simpleSearchSearchForm%3AcommandSimpleFPSearch=Search&simpleSe +archSearchForm%3Aj_idt447=workaround&$viewState'; $request = HTTP::Request->new('POST', 'https://patentscope.wipo.int/se +arch/en/search.jsf'); $request->header('Content-Type' => 'application/x-www-form-urlencoded' +); $request->header('Referer' => "https://patentscope.wipo.int/search/en/ +search.jsf"); $request->header('Accept' => 'text/html,application/xhtml+xml,applicat +ion/xml;q=0.9,*/*;q=0.8'); $request->header('Connection' => 'keep-alive'); $request->header('Cookie' => uc $jsessionID.'; ABIW=balancer.cms41; wi +po_language=en; BSWA=balancer.bswa2'); $request->content($param); #Proxy-Authorization: Negotiate ? $response = $ua->request($request); $page = $response->decoded_content(); #empty print $page;
Wildcards for a wide array of strings?
7 direct replies — Read more / Contribute
by zarath
on May 23, 2017 at 04:01
    Heyhey!

    Perl-virgin here, be gentle, pretty please with sugar on top. + English is not my native tongue, but i pride myself in my capabilities (in written English anyways, I sound a bit like a mix of a Frenchman and a German trying to speak American).

    I have a question about the very first script I'm trying to write.

    I'm sure this will be resolved in a jiffy by the first person who bothers to read this whole thing. Will you be that person?

Backtracking in perl
3 direct replies — Read more / Contribute
by pdahal
on May 23, 2017 at 03:56
    hello monks! I was seeking for help about backtracking algorithm in perl. How can I backtrack the PubMed Abstract? Any helps are appreciated.
Hash Multiple values for a key-Filtering unique values for a key in hash
6 direct replies — Read more / Contribute
by rahulme81
on May 22, 2017 at 23:11

    Hi, Below is the output of hash. I get multipe values for my keys and values appeared more than one, I need to have only unique values for a key.

    $HASH1 = { 'Alabama' => ['Andalusia', 'Anniston', 'Clanton', 'Eufaula', 'Auburn', + 'Bessemer', 'Eufaula', 'Auburn', 'Bessemer' ], 'California' => ['Barstow','Barstow'], 'Georgia' => ['Darien'], 'New York' => ['Amsterdam','Coney Island','Coney Island','Beacon','Bec +on'] };

    for e.g. for key "California" I get values 'Barstow','Barstow' (same value two times), I need to retain the only one value 'Barstow'

    what is a good way to check the existence for a key that has multiple values? and keep the value unique so my output looks

    $HASH1 = { 'Alabama' => ['Andalusia', 'Anniston', 'Clanton', 'Eufaula', 'Auburn', + 'Bessemer'], 'California' => ['Barstow'], 'Georgia' => ['Darien'], 'New York' => ['Amsterdam','Coney Island','Becon'] };

    Thanks

CGI hangs unless print
4 direct replies — Read more / Contribute
by janedoh
on May 22, 2017 at 18:21
    Dear all,

    I have a CGI script which does a lot of things such as logging in to our large company database to get information.
    There is a foreach loop that goes through a list and foreach item contacts the db, gets info, etc etc. This hangs unless I
    put a print "." in the foreach loop. I'm unclear why this would happen. Could it be buffering? When I flush the output
    it doesn't help. It needs a print statement or it will hang.
    Any ideas?

    Thanks for your help.
Imager::File::TIFF Dependencies
3 direct replies — Read more / Contribute
by BrentD
on May 22, 2017 at 17:31
    I have written a program that allows me to input some info, then calls Imager to output the info as Group4 Fax encoded TIF files. I am running this under Windows 10 64-Bit. The program runs fine if I use the .pl file, but if I use pp to build an .exe file and copy to another system, the file will not run. This is my current pp command call:
    pp -M Imager::Font::W32 -M Imager::File::TIFF -M -a cbxarrow.xbm -a ar +rowdownwin.xbm -u -o Program.exe Program.pl
    This is what happens when I run the .exe file:
    E:\>Program.exe Can't load 'C:\Users\generic\AppData\Local\Temp\par-67656e65726963\cac +he-1fbb3c46710e1a62d9823bf27f4a9fe7a961c4bb\c6dc6748.xs.dll' for modu +le Imager::File::TIFF: load_file:The specified module could not be fo +und at C:/Strawberry/perl/lib/DynaLoader.pm line 193. at C:/Strawberry/perl/lib/DynaLoader.pm line 95. DynaLoader::croak("Can't load 'C:\\Users\\generic\\AppData\\Lo +cal\\Temp\\par-67656e657"...) called at C:/Strawberry/perl/lib/DynaLo +ader.pm line 193 DynaLoader::bootstrap("Imager::File::TIFF", 0.89) called at C: +/Strawberry/perl/vendor/lib/PAR/Heavy.pm line 120 PAR::Heavy::_bootstrap("Imager::File::TIFF", 0.89) called at C +:/Strawberry/perl/lib/DynaLoader.pm line 102 DynaLoader::bootstrap_inherit("Imager::File::TIFF", 0.89) call +ed at Imager/File/TIFF.pm line 10 Imager::File::TIFF::BEGIN() called at Imager/File/TIFF.pm line + 11 eval {...} called at Imager/File/TIFF.pm line 11 require Imager/File/TIFF.pm called at TCTC/Dockets.pm line 6 require TCTC/Dockets.pm called at script/Program.pl line 32 main::BEGIN() called at Imager/File/TIFF.pm line 11 eval {...} called at Imager/File/TIFF.pm line 11 require main called at C:/Strawberry/perl/vendor/lib/PAR.pm li +ne 636 PAR::_run_member(Archive::Zip::ZipFileMember=HASH(0x37e33b0), +1) called at script/main.pl line 26 require main called at C:/Strawberry/perl/vendor/lib/PAR.pm li +ne 636 PAR::_run_member(Archive::Zip::ZipFileMember=HASH(0x37e3698)) +called at C:/Strawberry/perl/vendor/lib/PAR.pm line 428 PAR::import("PAR") called at -e line 631 eval {...} called at -e line 41 __par_pl::BEGIN() called at Imager/File/TIFF.pm line 11 eval {...} called at Imager/File/TIFF.pm line 11 BEGIN failed--compilation aborted at Imager/File/TIFF.pm line 11. Compilation failed in require at TCTC/Dockets.pm line 6. Compilation failed in require at script/Program.pl line 32. BEGIN failed--compilation aborted at script/Program.pl line 32. E:\>
    Seems obvious that I have some sort of missing dependency, but I can't seem to find what that might be. Any ideas?

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 all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others wandering the Monastery: (5)
    As of 2017-05-25 04:25 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?