Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

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
Translate .net regex to Perl regex
2 direct replies — Read more / Contribute
by roho
on Sep 16, 2019 at 15:19
    I have been tasked at work to scan c# source code and extract c# method names. I have located some .net regexes on Stack Overflow that claim to extract c# method names. Unfortunately I cannot find any Perl regexes to extract c# method names. My question is, does anyone know of utilities that convert .net regexes to perl regexes? My searches have come up empty so far. TIA.

    "It's not how hard you work, it's how much you get done."

While Uploading html file ,“WebKitFormBoundary ” are added at the top of page using perl. How to prevent this?
1 direct reply — Read more / Contribute
by arvindbhardwaj2003
on Sep 16, 2019 at 00:43
    While uploading a an HTML file, ------WebKitFormBoundarywPhRMi5J1WMEAybu data------WebKitFormBoundarywPhRMi5J1WMEAybu-- get added before tag, causing to display the above when we open the HTML page. i am using LWP with perl to uplaod the file:
    my $req = POST( $url, Authorization => 'Basic ' . encode_base64('admin' . ':' . '*****') +, Content_Type => 'multipart/form-data', 'Content' => { 'file_to_upload' => ["$location"] } );
    Can someone explain how to get rid of WebKitFormBoundary in uploaded file ?
Tk bind key scrolled Text
3 direct replies — Read more / Contribute
by Takamoto
on Sep 15, 2019 at 16:45

    Dear monks

    I use the following (simplified) code to be able to decide the order of widget switching when using the TAB key. This works fine except when the cursor enters a text widget. Here the tab has its own behavior (inserting a tab in a text), which makes sense. However, in my application, I would like to overwrite this behavior and would like the tab to allow further switching. Any idea?

    use strict; use warnings; use Tk; my $mw = MainWindow->new(); my $entry1 = $mw->Entry()->pack(); my $entry2 = $mw->Entry()->pack(); my $entry3 = $mw->Entry()->pack(); my $text = $mw->Scrolled('Text')->pack(); my %after = ( $entry1 => $entry3, $entry3 => $entry2, $entry2 => $text, $text => $entry1, ); $mw -> bind('all','<Tab>',sub{ ($after{$_[0]} // $_[0])->focus; } ); $mw->MainLoop(); exit(0);
DBI trace and Apache
1 direct reply — Read more / Contribute
by Anonymous Monk
on Sep 14, 2019 at 02:55
    I'm redirecting DBI trace to a file from within a CGI script.
    The script contains some info but not the sql query.
    There has to be something wrong with the environment becuase in other servers I can see the sql output
    Any htoughts?
Change Namespace of Package
5 direct replies — Read more / Contribute
by elliott9
on Sep 14, 2019 at 00:55

    I'll start by saying I am new to Perl.

    Short Story: How can I rename the namespace of a Perl package? Either doing this on an already installed package OR do this on a new package before I compile it?

    Long Story (if you are interested):

    I have an existing Perl script that runs a package imported from a vendor named Infoblox that we use to automate changes to records on a server. The Perl packages are custom to Infoblox AND the version of their OS that happens to be on that server. We'll call this package version 7.

    I need a way to, without disturbing existing functionality, run scripts from the same Linux machine that interact with a different Infoblox server that runs a newer version of the Infoblox operating system. Since they have released a newer version of their OS (version 8) they also have a newer version of their Perl package. After testing I am unable to make API calls to the version 7 server using the version 8 perl package. Likewise I am not able to make API calls to the version 8 server using the version 7 perl package. I tried installing them at the same time but since they use the same namespace of "Infoblox" that did not work out at all.

    I have no experience creating perl packages but it seems that I should be able to alter something in the new package before I compile and install it which would give it a unique namespace. Any tips on where that would be? ALternatively I thought I could use CPAN or package or some kind to rename the existing (version 7) already installed package to something unique which would mean installing version 8 package would work okay. I found Package::Rename on but have been unable to figure out how to make it work.

    Any help would be appreciated.

Soap::Lite set charset
3 direct replies — Read more / Contribute
by Anonymous Monk
on Sep 13, 2019 at 14:21
    Simple question but I can't figure it out.
    I want to send iso-8858-5 to a Soap service, but Soap::Lite client defaults to utf8.
    How do I change that?
How to update tk label value embedded in textarea.
2 direct replies — Read more / Contribute
by Anonymous Monk
on Sep 13, 2019 at 14:14

    Hi Monks,
    I have list of labels embedded in textarea.
    After deleting/removing label from textarea, I want to update the value of remaining labels in textarea all the time.
    Any help on this would be appreciated.


get() from website hangs
4 direct replies — Read more / Contribute
by jeffw_00
on Sep 13, 2019 at 08:42

    Hi - the relevant lines of my script are

    ------- use LWP::Simple; $pass=1; my $doc = get(' +ry&state=MA&site=BOX&lat=42.3667&lon=-71.4') || die {$pass=0}; -------

    This is part of a script that runs every 15 minutes that gets this webpage, parses some specific info from it (like temperature), and writes the info to a file so my home control program can later open the file and act on the data. My problem is that a few times a day, the get never returns, and the script hangs. I have another script running that detects the hang, and kills and restarts the script. But that's clunky. I'd like to either eliminate the hang, or detect the hang -within- the script. But that is a level of Perl that I haven't dealt with before so I'm wondering if anyone can point me to a recipe. Thanks!

    Further background - using ActivePerl on a W7 machine this code never hung. Switched to W10 and ActivePerl stopped supporting the get properly so I switched to Strawberry Perl (which i like better overall) but where I am having this intermittent issue. (this is probably the "fanciest" thing I do with Perl on my PC so for everything else either Perl works fine).

    Many Thanks!

Extacting lines where one column matches a name from a list of names
4 direct replies — Read more / Contribute
by mr_clean
on Sep 12, 2019 at 21:07
    Hello, wise monks.

    I have some tab delimited data:

    name1 \t data \t moredata \t evenmoredata \t
    name2 \t data \t moredata \t evenmoredata \t

    And a list of names which are interesting;

    name1 name2 name3 name4

    I have been using awk to extract rows from the tab delimited file where column 0 matches my name, and looping through my list of names in order to extract all matching rows. But as my data grows, this task gets very time consuming (6 hours for 200 mb worth of data; and I want to analyse files that are 10 gb!)

    So I would like to user perl (I have no perl experience, previously worked in bash).

    My plan:

    Convert each entry in the data file to a key (the name column) and corresponding hashes (all the other data in each column).
    Do a regex match between my list of names, and my hash keys.
    Use the matching hashes to extract the keys.

    But I have no idea where to start.

    Any advice?

Running JavaScript from within Perl
5 direct replies — Read more / Contribute
by anautismobserver
on Sep 12, 2019 at 21:06

    My goal is to develop an automated means to obtain the number of followers for each of a list of WordPress blog feeds (eg, which display the number of followers in a way that is captured by a copy-and-paste but is not in the HTML page source code. In order for these pages to display properly I need to be logged into a WordPress account and have JavaScript enabled in the browser.

    So far I have the following code:

    use strict; use warnings; use LWP::UserAgent; use LWP::Simple; use HTML::TreeBuilder; print HTML::TreeBuilder->new_from_url(' +s/94271045')->as_text;

    This code produces the following output:

    > WordPress.comPlease enable JavaScript in your browser to enjoy

    Naively it seems to me that since my browser can interpret a web page using JavaScript without any a priori information, Perl should be able to as well. Is this possible? If not, why not?

    I'm a Perl novice who wants to get code running without learning Perl "from the ground up". My strategy has been to find working code samples that do pieces of what I want, then change them incrementally until they do all I want. I'm using Strawberry Perl on Windows.

    Can you offer guidance or link to somewhere that explains it for novices like me? Thank you.

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

    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 about the Monastery: (4)
    As of 2019-09-17 04:50 GMT
    Find Nodes?
      Voting Booth?
      The room is dark, and your next move is ...

      Results (199 votes). Check out past polls.