Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

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
Perl Cryptography - Seeking Resources
No replies — Read more | Post response
by ljamison
on Jul 24, 2016 at 10:46
    Greetings, Monks!

    Starting August 1st I'll be teaching a 2-week programming camp to high school students (9th, 10th, and 11th graders) which consists of two parts -- Mathematics and Programming. Another person is teaching the Math side but this year I am teaching the programming side. The topic of the camp this year is Cryptography.

    Are there any resources available which aid in teaching Perl-based Cryptography?

Apache Kafka prior use
No replies — Read more | Post response
by Wiggins
on Jul 23, 2016 at 14:52
    I am looking for advice from someone who has sailed a possibly mythical sea named 'Apache Kafka' in a Perl boat.

    Due to a thinness of published guidance for the Perl interface, I would like to know if a different Producer is needed for each 'different topic'? I have the producer and consumer each on separate threads. But now have to publish to 3 different topics. I know consumers a 1:1 with topics. Are publishers the same?

    It is always better to have seen your target for yourself, rather than depend upon someone else's description.

Linux::Inotify2 remove single watch
1 direct reply — Read more / Contribute
by agarrubio
on Jul 22, 2016 at 19:57
    What is the right way to remove a single watch. This doesn't work. After "canceling" only one watch, the the poll loop stops blocking.
    use strict; use warnings; use Linux::Inotify2; my $inotify=new Linux::Inotify2 or die "Unable to create new inotify object: $!"; my $watch_one= $inotify->watch("/var/tmp/one", IN_MODIFY , sub {print "one modified\n"} ) or die "one $!\n"; my $watch_two= $inotify->watch("/var/tmp/two", IN_MODIFY, sub {print "two modified\n"} ) or die "two $!\n"; $watch_one->cancel; # Canceling a single watch stops all activity 1 while $inotify->poll; print STDERR "loop stoped blocking\n";
remove last column of tab-delimited file
2 direct replies — Read more / Contribute
by mika6891
on Jul 22, 2016 at 13:29

    I'm loading and printing tab-delimited files in my perl script. However the last column of my input file ($table1) is empty and I don't want to print this in my output file ($table3). How and where should I do this? After the 'open' or at the end in the 'print $table3'? This is part of my script (... denotes code not important for this question)

    #! /usr/bin/perl use strict; use warnings; use Data::Dumper; local $Data::Dumper::Useqq = 1; use Getopt::Long qw(GetOptions);; ... open(my $table1,'<', $input) or die "$! - [$input]"; #input file open(my $table3, '+>', $output) || die ("Can't write new file: $!"); # +output file ... chomp( my @header_for_table1 = split /\t/, <$table1> ); print $table3 join "\t", @header_for_table1, "name1", "name2", "\n"; { no warnings 'uninitialized'; while(<$table1>){ chomp; my %row; @row{@header_for_table1} = split /\t/; print $table3 join ( "\t", @row{@header_for_table1}, @{ $lookup{ ... } // [ "", "" ] }), "\n"; } }
Modifying .hwp (Hangul Word Processor) files without conversion
1 direct reply — Read more / Contribute
by Phenomanan
on Jul 22, 2016 at 12:26
    I have been trying to do search & replace in different file types, and am running into trouble with .hwp files. I cannot use a converter, because it is too big to incorporate in our project. This is particularly sad because I was easily able to modify .hwp when I converted it to .odt, but that is out of the question now. How does one go about searching and replacing in an .hwp file in PERL?
removing the need for tmp files from script
3 direct replies — Read more / Contribute
by novice2015
on Jul 22, 2016 at 12:09
    I have this script in which I am trying to clean up the tmp file output and use only arrays and variables. It does work, I created it a while back.
    open my $bpl_fh, '<', '/tmp/bpl.txt' or die $!; chomp(my @words = <$bpl_fh>); close $bplist_fh; my $pattern = join '|', @words; my @lines; open my $fh, '<', '/tmp/lst.txt' or die "unable to open file '$file' f +or reading : $!"; open my $fh2, '>', '/tmp/lst2a.txt' or die "unable to open file '$file +' for reading : $!"; while (<$fh>) { push @lines, $_ if /$pattern/; } print $fh2 "$_\n" foreach @lines; close $fh2;
    So I have made bpl and bpout into an arrays but I am unsure of how to write the while statement. I want it to perform the same task as the above script but without using the /tmp/files to read from and output
    chomp(my @words = @bpl); my $pattern = join '|', @words; #my @lines; my $item; while (@bpout) { my $item = (@bpout); push $item, $_ if /$pattern/; } print "$_\n" foreach $item;
    Does anyone have suggestions?
Decoding an email body, into utf8
1 direct reply — Read more / Contribute
by ultranerds
on Jul 22, 2016 at 08:55

    I'm trying to decode an email body, with stuff like:

    =C2=A0 *Email:*=C2=A0 =C2=A0=C2=A0

    I'm trying to use this module:

    But it doesn't seem to want to work for me :(

    my $message = q|testing a reply *Do it as *html=C2= =A0I guess Andy Newby=C2=A0 *Email:*=C2=A0 =C2=A0=C2=A0 +k =C2=A0 * WWW: =C2=A0 =C2=A0=C2=A0 * uk =C2=A0 Mobile:=C2=A0* = =C2=A002269 201 576 =C2=A0=C2=A0 |; use MIME::Words qw(:all); my $test = decode_mimewords($message); print "FOO: $test \n";

    All I get outputted, is the exact same input. Could someone please advise on how I can do this? (I've never really dabbled with reading emails before, so this is a bit new to me)


Install perl packages using yum
2 direct replies — Read more / Contribute
by ravi45722
on Jul 22, 2016 at 06:56

    I want to install perl modules in the CentOS using yum. I tried yum install perl-Search-Elasticsearch. Its saying no such module. I tried

    yum install perl-Excel-Writer-XLSX Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: * epel: * extras: * rpmforge: * updates: Package perl-Excel-Writer-XLSX-0.84-1.el7.noarch already installed and + latest version Nothing to do

    But it is an older version. For this I updated my yum also. Still the problem is same. I need to update my perl library for this??? Then how to update the library ????

    perl -v This is perl 5, version 16, subversion 3 (v5.16.3) built for x86_64-li +nux-thread-multi
Net::Google::WebmasterTools: GWMT error: 404 Not Found
1 direct reply — Read more / Contribute
by Frosch
on Jul 22, 2016 at 06:09


    when trying to use Net::Google::WebmasterTools I am getting the following error: +searchAnalytics/query GWMT error: 404 Not Found Not Found at ./ +line 43, <DATA> line 2231.
    Here the used script (the credentials in this example like $client_id, $client_secret and $refresh_token have been certainly substituted by my own credentials).
    #!/usr/bin/perl use strict; use warnings; use Data::Dumper; use Net::Google::WebmasterTools; use Net::Google::WebmasterTools::OAuth2; # Insert your website URL here. my $site_url = ""; # See GETTING STARTED for how to get a client id, client secret, and # refresh token my $client_id = ""; my $client_secret = "rAnDoMsEcReTrAnDoMsEcReT"; my $refresh_token = "RaNdOmSeCrEtRaNdOmSeCrEt"; my $wmt = Net::Google::WebmasterTools->new; # Authenticate my $oauth = Net::Google::WebmasterTools::OAuth2->new( client_id => $client_id, client_secret => $client_secret, ); my $token = $oauth->refresh_access_token($refresh_token); $wmt->token($token); # Build request my $req = $wmt->new_request( site_url => "$site_url", report_name => "searchAnalytics", method => "query", dimensions => ['country','device'], search_type => 'web', start_date => "2016-07-01", end_date => "2016-07-20", row_limit => 1000, ); # Send request my $res = $wmt->retrieve($req); die("GWMT error: " . $res->error_message) if !$res->is_success; # Print results print "Results: 1 - ", $res->items_per_page, " of ", $res->total_results, "\n\n"; for my $row (@{ $res->rows }) { print $row->get_source, ": ", $row->get_visits, " visits, ", $row->get_bounces, " bounces\n"; } print "\nTotal: ", $res->totals("visits"), " visits, ", $res->totals("bounces"), " bounces\n";

    Any ideas what might be wrong?

    Best regards, Frosch
Parse cmd line args in this file
4 direct replies — Read more / Contribute
by pawarr
on Jul 22, 2016 at 05:07

    Wanted to parse the script's command line with "Cadence". Please Help. Sorry for the previous post.

    #!/usr/bin/perl use strict; use warnings; open(my $fh,'data4.txt'); while(my $row = <$fh>){ chomp $row; print "$row \n"; }

    Subject: Cadence rivals openly laugh at 2nd secret CDNS management reorg SHHHH! IT'S SECRET!: Starting on Monday of this week, I got emails and phone calls citing a secret weekend Cadence management reorg that Cadence Corporate Marketing was hoping the world wouldn't notice... Note how the CDNS e-staff web page "mysteriously" changed from Friday to Monday: Chi-Ping Hsu Anirudh Devgan Friday, SVP of the Cadence not seen anywhere on Nov 8th Digital & Signoff Group CDNS e-staff page! ??? \ then (*poof!*) \ Monday, Chief of Staff ----> SVP of the Cadence Nov 11th to Cadence CEO ??? Digital & Signoff Group No press release. Nothing on their home page. No announcement. Just POOF! The change secretly "happens". I wouldn't have noticed it at all -- except that Cadence's many rivals monitor and they looove to gossip... ---- ---- ---- ---- ---- ---- ---- Hey, John, Look at today's Cadence e-staff page. Anirudh took digital inplementation from Chi-Ping. - An Anon EDA Vendor ---- ---- ---- ---- ---- ---- ---- The other shoe dropped. After losing Virtuoso to Beckley back in August, Chi-Ping has now lost EDI to Devgan. No press release, but check their Executive Team web page. - An Anon EDA Vendor ---- ---- ---- ---- ---- ---- ---- Looks like Chi-Ping's second wing has been clipped. He's no longer SVP of Digital Implementation. - An Anon EDA Vendor ---- ---- ---- ---- ---- ---- ---- Anonymous please. Chip-Ping has been demoted on the page. - An Anon EDA Vendor ---- ---- ---- ---- ---- ---- ---- Another stealth mgmt shuffle at CDNS. Anirudh is now in Chip's old job. Chip's now on Special Projects. - An Anon EDA Vendor ---- ---- ---- ---- ---- ---- ---- Hi, John, Anirudh should have been made head of EDI two years ago. CDNS is missing too many big PNR renewals. It'll take too long to repair the damage organically with EDI revs. Writing is on the wall. Wished I owned ATOP shares. - An Anon EDA Vendor ---- ---- ---- ---- ---- ---- ---- This is a good move. Anirudh is revitalizing fresh blood which will bring Cadence back into PNR. Mark my words. - An Anon EDA Vendor ---- ---- ---- ---- ---- ---- ---- If they didn't empower Anirudh soon, they might have lost him along with Cadence's chance at taking Synopsys back on. - An Anon EDA Vendor ---- ---- ---- ---- ---- ---- ---- Re: Chi-Ping Hsu & John Chilton Cadence is matching Synopsys. Aart moved John Chilton out of Corp Marketing so he could become GM of SNPS Strategy. Lip-bu needs Chi-Ping as Chief of CDNS Strategy to keep up. - An Anon EDA Vendor ---- ---- ---- ---- ---- ---- ---- Q: How many months did the prior Cadence Chief of Staff last? ---- ---- ---- ---- ---- ---- ---- Internally inside Cadence, most of the employees see this as a positive move. It ensures that Lip-bu gets tight guidance from Chi-Ping as an EDA veteran who really knows the business. The CDNS sales force is excited about Anirudh taking over because they think he's the only viable executive who could lead a total R&D turnaround at Cadence. The only people afraid inside CDNS are the employees who've worked on products that haven't improved in years. He will be a day of reckoning for this dead wood. Best case is Anirudh will turn CDNS digital around in 9 to 12 months. I hear TSMC's top customers approve of this change. - An Anon EDA Vendor ---- ---- ---- ---- ---- ---- ---- And if this story sounds familiar to you -- it should. CDNS did a similar unannounced stealth reorg of its Palladium and Virtuoso senior management 14 weeks ago. See ESNUG 531 #4. Shhhh! It's secret! :) - John Cooley Holliston, MA

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 studying the Monastery: (5)
    As of 2016-07-24 19:29 GMT
    Find Nodes?
      Voting Booth?
      What is your favorite alternate name for a (specific) keyboard key?

      Results (221 votes). Check out past polls.