Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
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
Apache::RequestNotes in mod_perl 2.0
1 direct reply — Read more / Contribute
by ait
on Aug 29, 2014 at 10:54

    Hi

    I noticed that Apache::RequestNotes doesn't seem to be available for Apache2 so I am guessing that this functionality was incorporated in mod_perl 2.0 natively?

    If so, would someone kindly point me to an example on how to do this exact same thing with mod_perl 2?

    I need something very early in the request that parses form data and then make it avail to the rest of the request. My current solution involves a PerlTransHandler that slurps the content, parses it and saves it to notes. Then I have to re-inject the raw content back with a PerlInputFilterHandler so it's avail for the rest of the request chain.

    I hate re-inventing the wheel and I think something like Apache::RequestNotes would really be more elegant for what I'm trying to do.

    Many thanks in advance!

Rename filenames in perl using regex
3 direct replies — Read more / Contribute
by ArifS
on Aug 29, 2014 at 10:37
    I would like to replace a bunch of filenames from- "MY.switch._Org.1st.txt" "router.-2nd.Org.MY.txt" "3rd.switchmy-org.txt" to, something like as following with all uppercase- "1ST.SWITCH.MY.ORG.TXT" "2ND.ROUTER.MY.ORG.TXT" "3RD.SWITCH.MY.ORG.TXT" Any suggestion will be greatly appreciated.....
Install issue with selenium
No replies — Read more | Post response
by pdxperl
on Aug 29, 2014 at 09:33
    I'm on Windows 7, Strawbeery Perl version 5.18. I'm installing Test::WWW::Selenium and getting this error:
    t/test_default_server.t .. # Test::WWW::Selenium running open (file:// +C:\strawbe rry\cpan\build\Test-WWW-Selenium-1.36-ZkGVDi\t\files\test_click_page1. +html) # Error requesting http://localhost:4444/selenium-server/driver/: # ERROR: Command execution failure. Please search the user group at ht +tps://grou ps.google.com/forum/#!forum/selenium-users for error details from the +log window . The error message is: Access to 'file:///C:/strawberry/cpan/build/T +est-WWW-Se lenium-1.36-ZkGVDi/t/files/test_click_page1.html' from script denied # Failed test 'open, file://C:\strawberry\cpan\build\Test-WWW-Seleni +um-1.36-Zk GVDi\t\files\test_click_page1.html' t/test_default_server.t .. 1/7 # at t/test_default_server.t line 43. # Test::WWW::Selenium running get_text (link (?^:Click here for next p +age) link contains expected text) Error requesting http://localhost:4444/selenium-server/driver/: ERROR: Element link not found
    This appears to be a known install issue http://www.cpantesters.org/cpan/report/70509994-e7d1-11e2-be3b-b82b1f19502a I've run as administrator, doesn't make a difference. The file exists, and permissions are open for authenticated users. So if you're using Selenium, are you just doing a force install and ignoring failures, or is there a workaround? I did a force install, and am able to run some basic scripts, but I'm getting some odd errors that made me wonder if there was a real install/driver issue that was being flagged in the install testing.
PDFlib context pointer (nil) is invalid
1 direct reply — Read more / Contribute
by Achim
on Aug 29, 2014 at 08:39
    Hey there after i updated my gentoo (linux) and perl was updated to version 5.12.4 recompiled the pdflib and so on

    all perl depended stuff is completely updated

    i got the following Error with a Web-application
    ] *** PDFlib context pointer (nil) is invalid ***, referer: http://loc +alhost/cgi-bin/atelier/my_fin_ab_2012/kwo_fin.cgi [Fri Aug 29 13:48:26 2014] [error] [client 127.0.0.1] pdflib_pl::PDF_o +pen_file could not open file '/var/www/localhost/htdocs/projectfin/pd +f_out/2014-08-28_r_21_.pdf'., referer: http://localhost/cgi-bin/ateli +er/my_fin_ab_2012/kwo_fin.cgi [Fri Aug 29 13:48:26 2014] [error] [client 127.0.0.1] [Fri Aug 29 13:4 +8:26 2014] kwo_fin.cgi: system perl /var/www/localhost/cgi-bin/atelie +r/my_fin_ab_2012/api-test7.pl 21 r failed: 65280 at /var/www/localhos +t/cgi-bin/atelier/my_fin_ab_2012/kwo_fin.cgi line 667., referer: http +://localhost/cgi-bin/atelier/my_fin_ab_2012/kwo_fin.cgi

    so the kwo_fin.cgi line 667

    sub kunde_rechnung_print7 { $mode='kunde_rechnung_auswahl'; $rsubnr = $query->param('RSubNr') || 0; $rnr = $query->param('RNr') || 0; $knr = $query->param('knr') || 0; admin_show(); admin_show(); my @args = ("perl","/var/www/localhost/cgi-bin/atelier/my_fin_ab_2 +012/api-test7.pl", $rnr, "r"); #line667 system(@args) == 0 or die "system @args failed: $?" }
    calls a second perlscript in which i call
    use PDF::Template; my $pdf = PDF::Template->new( filename => '/var/www/localhost/cgi-bin/atelier/my_fin_ab_2012/lib +/print_rech_tmpl.xml', ); my %my_params = .... ... $pdf->param(%my_params); #print "Content/type: application/pdf\n\n", $pdf->get_buffer; my $filename='/var/www/localhost/htdocs/projectfin/pdf_out/'.$Datum.'_ +'.$rema.'_'.$RNr.'_'.$firma.'_'.$name.'.pdf'; $pdf->write_file($filename); Cleanup();

    so pdflib_pl::PDF_open_file could not open file

    has anybody a idea where i could start to solve the problem

    one more - Linux only - dance Achim
Concise foreach expression
8 direct replies — Read more / Contribute
by ram31
on Aug 29, 2014 at 08:04
    Hi, Following ( snippet ) code works fine:
    foreach my $x (@names) { if ( $x =~ /test$/) { print "$path_name\n"; } }
    Instead of above one, i want to keep it simple as follows:

    print "$path_name\n" if ( $x =~ /test$/) foreach my $x (@names) # Not working

    print "$path_name\n" if ( /test$/) foreach (@names) # Not working.

    I appreciate your suggestions to optimize it.
Parsing through Hashes
2 direct replies — Read more / Contribute
by sidsinha
on Aug 29, 2014 at 05:22

    I have an hash of keys and values as below. Each key has multiple values, but each value could reference a key. For a given input key, I need to print the values, and if the value is also a key, then print the value of that key in brackets as below:

    Usb1 Usb2,Usb3 Usb2 val1,val2,Usb4 Usb3 val3 Usb4 val4

    Input : Usb1 print Usb2[val1,val2,Usb4[val4]],Usb3[val3] Input : Usb2 print val1,val2,Usb4[val4]

    The logic I tried is to first check if the input key exists in the hash then load the values of that key into an array Now, iterate through the array, print $_ , then compare if the value matches any key in the hash, if matches, print the value. But now, I dont get how long and how I can keep doing this, because the set of keys could reference another key and so on...


    Any suggestions or examples could help. Thankyou
DES ECB mode using DES_PP
1 direct reply — Read more / Contribute
by v4169sgr
on Aug 29, 2014 at 04:21

    I use Perl 5.10 ActivePerl 5.14 on win7. I am a humble user, and don't really understand what I am doing.

    I have a requirement to connect to a remote host and send locally encrypted messages, using DES ECB mode encryption. This is not my choice, but a part of the requirement. I am trying to find out how to implement DES ECB mode encryption simply in Perl.

    I do not have access to a C compiler, and cannot be the local administrator on my machine. I don't have download rights either, but can copy / paste source from CPAN into .pm files in my C:. I have copied the source for DES_PP.pm and ECB.pm to C:\Perl 5.10\lib\Crypt\ from CPAN. I've chosen DES_PP.pm as my understanding is that I don't need a C compiler to use it.

    I need to make sure that I am using the ECB hex encryption function correctly. My code currently looks like this:

    use Crypt::ECB qw(encrypt decrypt encrypt_hex decrypt_hex); my $ascii_key = "0123456789abcdef"; my $plain_text = "Now is the time for all "; print encrypt_hex($ascii_key,"DES_PP",$plain_text,"0");

    This 'works' in that it runs without errors, but produces output:

    9a8836c3209081ed369a03f8b488a2ef3c85885f76d95430

    From the example I am using in the original DES ECB mode specification (FIPS 81), I should see:

    3fa40e8a984d48156a271787ab8883f9893d51ec4b563b53

    What am I doing wrong?

    Thanks in advance for all responses. Yes, I know there are much better ways of achieving encrypted traffic, and I know too that I should really do things the proper way via full local installation and C compilers etc, but I can't do any of that because of local policies, and still need to solve the problem.

WWW::Mechanize Webcrawler
1 direct reply — Read more / Contribute
by Thoery55
on Aug 29, 2014 at 02:43

    I'm currently new to using WWW::Mechanize and am using it to build a web scraping tool that will go onto a school website and pull course data so that the website I'm building can recognize conflicts. I currently have this code in Perl:

    #!/user/bin/perl use warnings; use strict; use WWW::Mechanize; my $browser = WWW::Mechanize->new; $browser->get( 'https://registrar.ucdavis.edu/courses/search/index.cfm +'); $browser->form_number(3); #Search Form $browser->select('subject', 'AAS'); $browser->submit(); print $browser->content();

    The way the website works, you go in, select a subject area, and then click "Search". Then a table populates based off what you selected in the forms above.

    I'm currently focused on just getting my script to select one option from the dropdown menu, click "Search" and then copy the results, but for one, I'm not sure if it's actually working (It's not giving me any errors, but I'm not sure it's doing anything) and two, I'm not sure how to view the data that pops up in the table. Any help would be appreciated!

A TableMatrix row selection question
3 direct replies — Read more / Contribute
by Anonymous Monk
on Aug 28, 2014 at 23:20
    Hello PerlMonks,

    This is a TableMatrix row selection question. I noticed that there is a four year old thread on this http://perlmonks.com/?node_id=840707. However I later felt that it is better to post it as a new question

    1. Where do I find what are all the fields that a Perl/Tk programmer can access from an XEvent object and what do those fields stand for? (Mastering Perl/Tk book by Oreilly Press doesn't give any details except Chapter 15 http://oreilly.com/catalog/mastperltk/chapter/ch15.html merely makes a mention of it when accessing 'K' and 'N' for keysym text and decimal). I also looked at Widget.pm which has following line
    sub XEvent { shift->{'_XEvent_'} }
    but I'm unable to go any further than this to understand the same.

    2. In the selectionSet and selectionIncludes methods the above specified thread used the values: '@' . $Ev->x . "," . $Ev->y what does this @ and the full expression stand for. I could not find anything in the perldocs for TableMatrix (and other widgets like TList decendants which also have these methods).

    As I'm still trying to learn Perl and Perl/Tk I had to spend few hours trying to look around but to no avail. Therefore any information would be very useful. Many Thanks
Sending Email with Dancer::Plugin::Email
No replies — Read more | Post response
by tushardave26
on Aug 28, 2014 at 23:04

    Hello Folks,

    Currently, I am developing Dancer web application. As part of my application, I would like to send email to users. I am referring Dancer::plugin::Email manual to accomplish the task. I adapted the code form the manual. But some how my code is neither working nor producing any error. Below find my code:

    use Dancer ':syntax'; use Dancer::Plugin::Email; use Try::Tiny; post '/ednContacts' => sub { try { email { from => params->{'email'}, to => 'tdave@example.edu', subject => 'Contacting for EDN Web site', body => params->{'message'} }; } catch { error "Could not send email: $_"; }; };

    FYI, I am using MAC OSX 10.9.4. And running my application on localhost:3000

    Can some one point out any problem in my code?

    Thanks.


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 making s'mores by the fire in the courtyard of the Monastery: (4)
    As of 2014-08-31 00:12 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The best computer themed movie is:











      Results (294 votes), past polls