Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
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
Issue with regex
1 direct reply — Read more / Contribute
by shounak mukherjee
on Jun 23, 2017 at 11:47
    Hello Experts, I am new to perl programming and facing a few issues related to perl regular expressions. I need to apply a condition logic only if my $filename is something like: $filename =._foo.xml #Any file that starts with ._" For such files,I need to overlook the content of the file. while( ($fileName = readdir(DIR))) { next if ($fileName eq "^\._.*"); However I think this regular expresion is not able to filter the filenames based on the criteria. I shall be highly obliged if anyone can please help.
Architecture design for full stack development.
2 direct replies — Read more / Contribute
by SimonClinch
on Jun 23, 2017 at 10:42
    Hi Monks, I am developing a website from scratch which will hopefully have plenty of activity some time in the future after it goes live. Although I am still developing it on Windows, I will migrate it to Linux/Apache, with Perl and Postgres completing the rest of the picture before and after migration. I am inclined to avoid PHP for performance reasons.

    While loading the database with some initial reference data (about 1GB), using one-off code that got fixed as I went along, I somehow managed to "lose" some PK values, because sequences do not roll back if accessed with nextval.

    But it occurred to me that when the system goes live, it will need to manage deleted values. Although I was careful to use bigint for PK values where necessary, I don't want to have the situation where the PK values stay fragmented and increase fragmentation over time.

    It was at this point that I realised I needed DBIx::Class, otherwise I would have layers of raw SQL hiding in any homegrown DBMS/Perl framework and that had to be avoided at all costs.

    So I am at the point where I have installed DBIx class and feel obliged to determine the rest of the architecture (MVC perhaps) and at the same level of detail, before writing any methods to dynamically defrag my keys (probably through use of an idpool table/class where inserters will look before calling nextval if nothing is in the pool for the table).

    It becomes clear that the defrag code belongs in the "Controller" part of the framework. But having never built a Controller before, I am hoping for advice on what the classes should look like in there, e.g. should I have a dbController class that uses methods in DBIx. Should it inherit from the Schema and/or should I have some kind of parent-of-all utility class? I am keen to make a good choice now rather than have to make fundamental architecture mods later. Many thanks in advance,

    Simon

    One world, one people

strings to json
4 direct replies — Read more / Contribute
by bigup401
on Jun 23, 2017 at 09:26

    how can i read string into json output

    $name = 'mike'; $age = "20"; $email = "johndeo@/test.com"; $pass = "test"; $resp = '{ "$name": $age, "$email": $pass }'; print $resp;
get specific value of element using xpath in perl
1 direct reply — Read more / Contribute
by snehit.ar
on Jun 23, 2017 at 08:48
    <?xml version="1.0"?> <playlist> <movie id="tt0112384"> <title>Apollo 13</title> <director>Ron Howard</director> <release-date>1995-06-30</release-date> </movie> <movie id="tt0307479"> <title>Solaris</title> <director>Steven Soderbergh</director> <release-date>2002-11-27</release-date> </movie> <movie id="tt1731141"> <title>Ender's Game</title> <director>Gavin Hood</director> <release-date>2013-11-01</release-date> </movie> </playlist>
    I want to retrieve value of <release-date> element where <title> having value 'Solaris' and not other title elements.
    use warnings; use strict; use XML::XPath; use Data::Dumper; my $xml = '../events.xml'; my $xp = XML::XPath->new(filename => $xml); my $nodeset = $xp->findnodes('//playlist'); my $records = []; foreach my $node ($nodeset->get_nodelist) { my $title = $xp->find('./title', $node); push @$records, { title => $title->string_value, }; } print Dumper($records);
    I tired XPath something like  my $title= $xp->find("/playlist/movie[title='Solaris']/release-date", $node); But result is not as expected OutPut ::2002-11-27 Please do help !
post url with 2 input
4 direct replies — Read more / Contribute
by bigup401
on Jun 23, 2017 at 05:34

    how can i make url post with input choices

    how can i make it in url to either take input1 or input2

    post => http://link/take input $1 or input $2
Memory needed for perl process
4 direct replies — Read more / Contribute
by bsshetty17
on Jun 23, 2017 at 02:26

    Hi Monks, 2 quick questions. 1) What is the minimum memory required to start a perl process? 2)I need to install following cpan modules in HP_UX: \t Text::CSV_XS; \t SOAP::Lite; \t XML::Twig; \t Config::IniFiles; \t Parallel::ForkManager; Informatica is also installed in the same server. Informatica administrator is not agreeing to install the modules saying, It causes the informatica performance degradation. Can any one help to defend this? Thanks,

mod_perl best practices to increment XML payload
1 direct reply — Read more / Contribute
by glasswalk3r
on Jun 22, 2017 at 17:23

    Hello monks,

    I've being studying mod_perl in the past to implement a project that uses Apache as a reverse proxy, receives a SOAP request, modifies the payload (XML), handles it to the real web application, and returns back the response to the requester.

    What is the best practice in this case? I checked out Apache::ReverseProxy, but it defines a full handler and I'm guessing that using a Input or Output filter handler would be a better option (based on my readings of mod_perl2 User Guide book) combined with the standard Apache modules proxy and proxy_http to avoid reinventing the wheel.

    PS: I know mod_perl2 is not the "sexiest" framework at the moment, but I want to take advantage of already having it available on particular web servers by default.

    Thanks!

    Alceu Rodrigues de Freitas Junior
    ---------------------------------
    "You have enemies? Good. That means you've stood up for something, sometime in your life." - Sir Winston Churchill
Not able Login into webpage which use javascript while load
4 direct replies — Read more / Contribute
by trahulprajapati
on Jun 22, 2017 at 11:17

    Hi Monks I'm trying to login to a website which is using javascipt while loading. I have tried with WWW:Machanize but it is not working as WWW:Machanize not support javascript. Webpage is dynamically creating the login form as we have different option for login by selecting radio button. By simple view code it is not showing form form ,that means while loading the page it is calling javascript function and from in function form is loading. WWW:Machanize is not support javascript so is there any way by which i can login to site? I we cannot use WWW:Machanize::Firefox ,WWW::Scripter etc.. is there any way through which we can login by WWW:Machanize or somthing else? I have tried the following code:

    use strict; use warnings; use LWP::UserAgent; use WWW::Mechanize; my $login_url = 'abc.xyz.com'; my $username = "abc"; my $password = "xyz123"; my $mech = WWW::Mechanize->new(); $mech -> cookie_jar(HTTP::Cookies->new()); $mech -> get($login_url); $mech->submit_form( with_fields => { "userid" => $username, "authmethod" => 'on', "username" => $username, "login-form-type" => 'pwd', "password" => $$password }, button => "btnSubmit", ); $mech->save_content('out1.txt');
Pattern match and splitting of that
5 direct replies — Read more / Contribute
by Nansh
on Jun 22, 2017 at 09:29
    Hi My string looks like below

    RABBIT 45 -126.06686

    my output should be like 1)RABBIT 2)45 3)-126.06686

    #!usr/bin/perl use strict; use warnings; my $string="RABBIT 45 -126.06686"; (my $temp1)=$string=~ /^(\w+)\s+/; (my $temp2)=$string=~ /^\s+/(\d+)/; (my $temp3)=$string=~ /^(.*)\s+(\d+)\s+$/;
    I am not able to get -126.06686. Thank you.
Pulling from a list and inserting into XML documents
3 direct replies — Read more / Contribute
by gng4life
on Jun 22, 2017 at 09:25
    Hello All, First post so go easy on me. I'm getting back into Perl after not touching it for years so I am like a noob. This is what I need to do. I have text file A that three fields, for example IP address, MAC, hostname, and there about 200 of them, comma separated (I can change this to a csv or whatever if easier). I have about 200 XML documents that I need to search for tags and enter those three fields above into that section, save it, open the next document and enter the same three fields, save, repeat for all docs. Here is an example:
    File A hosta,1.1.1.1,00000C123456, hostb,2.2.2.2,00000C123457, hostc,3.3.3.3,00000C123458, hostd,4.4.4.4,00000C123459, etc...(about 200 items, will have more later) File 1 . <HOST_NAME></HOST_NAME> <HOST_IP></HOST_IP> <HOST_MAC></HOST_MAC> . . File 2 . <HOST_NAME></HOST_NAME> <HOST_IP></HOST_IP> <HOST_MAC></HOST_MAC> . . File 3 . <HOST_NAME></HOST_NAME> <HOST_IP></HOST_IP> <HOST_MAC></HOST_MAC> . . After all the docs are done, they will look like this... File 1 . <HOST_NAME>hosta</HOST_NAME> <HOST_IP>,1.1.1.1</HOST_IP> <HOST_MAC>00000C123456</HOST_MAC> . . File 2 . <HOST_NAME>hostb</HOST_NAME> <HOST_IP>,2.2.2.2</HOST_IP> <HOST_MAC>00000C123457</HOST_MAC> . . etc.
    I have portable strawberry Perl right now on my work computer. If it would be easier to do it in ActivePerl or in Strawberry Perl installed version, let me know and I can spin it up on another workstation. So what is the best way to do this? Thanks for any help!

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?
    [Discipulus]: :=(
    [perldigious]: I watched some video on YT awhile back with auto-subtitle on and the speaker had a very thick cockney sort of English accent... hillarity ensued in the subtitles.
    [Discipulus]: IHAA=I hate acronyms anyway
    LanX LOLs
    [perldigious]: If you want a linguistic adventure...
    [perldigious]: No offense to any Scotsman, I love Scots. Well actually, I love Scotch, but I'm sure the people are great too. :-P

    How do I use this? | Other CB clients
    Other Users?
    Others avoiding work at the Monastery: (9)
    As of 2017-06-23 16:44 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      How many monitors do you use while coding?















      Results (552 votes). Check out past polls.