Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

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
sourcing the csh script issue
3 direct replies — Read more / Contribute
by lpl
on Feb 17, 2017 at 10:35
    hi, i have sourcing script source.csh,in perl i sourced by using the system("csh source.csh")but when sourcing is done it was not setting any required variables, but wen i ran a script in exterm using source source.csh the required vairables are available but in perl source is not supporting how to solve this issue plaz help.....
How to read the value of a variable (read from a Excel file converted Into text file) and put then back into Excel column
1 direct reply — Read more / Contribute
by rockyurock
on Feb 17, 2017 at 08:51
    I am able to read the variables from excel and print them in the above program but I want to read these variables(from Variables to read from Excel sheet :) value from Input data (from My input data to search from:) and put them back into excel sheet which I am not able to do. can some one pls help on the same ?
    Variables to read from Excel sheet : isim = usim = sim_invalid = pcscf_discovery_flag signaling_flag ran_type emergency_ind rat pcscf_v4 pcscf_v6 plmn is_ems_support ipv4 ipv6
    My input data to search from: 8077 8116 D type hexa usim = 1, isim = 1 8077 8116 D type hexa usim = 1, isim = 1 pcscf_v4 : num = 2, protocol_type = 0x21, port_num = 0, addr = 10.56.5 +.85 8088 1223 D temp sim_invalid = 0 8099 1223 XX is_ems_support = 1 #88 8099 1224 XX pdn_act_ind->pcscf_discovery_flag = 1 ind->signaling_flag = 1 some text here plmn = 405872 DefaultStatusBarPlmnPlugin: into updateCarrierLabel ipv6 = get_ipv6_prefix,temp ipv4 = _send_ipv4_notify
    MY program:
    #use strict; #use 5.010; use Spreadsheet::Read qw(ReadData); my $book = ReadData ('UE_NW_Parameters.xlsx'); #my @files = grep { -f } (<*.txt>,<*main_log>,<*Project>,<*properties> +); my @files = grep { -f } (<*main_log>); my @rows = Spreadsheet::Read::rows($book->[1]); foreach my $i (1 .. scalar @rows) { foreach my $j (1 .. scalar @{$rows[$i-1]}) { my $temp = "\n$rows[$i-1][$j-1]"; my @keywords = "$temp"; print @keywords; } foreach my $file (@files){ open(my $fh, '<', $file) or die $!; my @content = <$fh>; close($fh); my $l = 0; foreach my $kw (@keywords) { foreach (@content){ $l++; my $search = $kw; if ($search =~ /(\ d+)/) { printf 'Found keyword %s in file %s, line %d:% +s'.$/, $search, $file, $l, $_; last; } } } } }
How to detect non printable characters and non white space characters? [RESOLVED]
3 direct replies — Read more / Contribute
by thanos1983
on Feb 17, 2017 at 04:49

    Hello again Monks,

    Lately I have been bombing the forum with questions but no matter how much I experiment with my code I can not figure out the solution(s) to my problems this is why I keep asking questions over and over.

    To the question, I have a hash of hashes with hundreds values on each hash. I want to use a negative condition on both detecting white space character or non printable character. In such a case I want to delete the element from the hash (if does not contain white space character or non printable character).

    I tried the conditions separately and they work just fine, at least based on my experimentation examples. I need to combine them in a nested if because a value with no spaces it does not mean that it does not contain special characters.

    Based on my research in order to detect non printable characters you can use either this /[^[:print:]]/g or this /[^[:ascii:]]/ regex expression found here (Finding out non ASCII Characters in the text)

    Sample of code:

    #!/usr/bin/env perl use strict; use warnings; use Data::Dumper; my $str = 'a[bdy]dfjaPÑsdafÜ'; my $str_2 = 'WAP'; my $hoh_ref = { hash_1 => { a => 'a[bdy]dfjaPÑsdafÜ', b => 'WAP' }, hash_2 => { c => 'Te st' } }; print Dumper $hoh_ref; foreach my $key (sort keys %{$hoh_ref}) { foreach my $value (keys %{$$hoh_ref{$key}}) { # If not white space character or non printable character remove e +lement if ($$hoh_ref{$key}{$value} !~ /[^[:print:]]/g || $$hoh_ref{$key}{$value} !~ /\s/) { delete $$hoh_ref{$key}{$value}; } elsif ($$hoh_ref{$key}{$value} =~ /[^[:print:]]/g) { while ($$hoh_ref{$key}{$value} =~ /[^[:print:]]/g) { print "Non Printable Characater:\t$&\n"; } } } } print Dumper $hoh_ref; __END__ $VAR1 = { 'hash_2' => { 'c' => 'Te st' }, 'hash_1' => { 'b' => 'WAP', 'a' => 'a[bdy]dfjaPÑsdafÜ' } }; $VAR1 = { 'hash_2' => {}, 'hash_1' => {} };

    Desired output would be:

    $VAR1 = { 'hash_2' => { 'c' => 'Te st' }, 'hash_1' => { 'a' => 'a[bdy]dfjaPÑsdafÜ' } };

    Thanks in advance for your time and effort.

    Seeking for Perl wisdom...on the process of learning...not there...yet!
Parse for a name after a keyword search in all the files, given directory as input
7 direct replies — Read more / Contribute
by prash_sri
on Feb 17, 2017 at 02:19
    #!/usr/local/bin/perl $dir = $ARGV[0]; open(HANDLE,$dir) || die "ERROR in opening file"; @allfiles = readdir HANDLE; close(HANDLE); foreach $files (@allfiles) { open(FH,"<",$files)|| die "ERROR in opening file"; foreach $line (<FH>) { $line =~ m/ \^module\ /g ; @next = split(/\s+/,$line); } close(FH); } print "$next[0]\n"

    Trying to write a perl code which browses all the files recursively under a given input directory and do the following: - Parse all the list of module names. - Parse all the instance names inside each of the modules. Kindly let me know where am I going wrong!! And guide me for obtaining the correct output. Thanks

PDF::PDFUnit notContaining
No replies — Read more | Post response
by andreas1234567
on Feb 16, 2017 at 16:51
    Dear Monks

    PDF::PDFUnit let's us verify PDF documents using perl. It seems to do a good job, except for the notContaining function. It seems to always return true (here a rewritten version of 01-load.t). The basic idea is to detect presence of unwanted words, such as the name of the former CEO:

    $ cat t/01-test-mod.t use strict; use utf8; use warnings; use FindBin; use File::Spec; use Test::More; use Test::Exception; use PDF::PDFUnit qw(:skip_on_error); my $resources_dir = File::Spec->catfile($FindBin::Bin, 'resources'); my $pdfReference = "$resources_dir/reference.pdf"; lives_ok { AssertThat ->document($pdfReference) ->hasText() ->containing("Hello") } "containing Hello"; lives_ok { AssertThat ->document($pdfReference) ->hasText() ->notContaining("Hello") } "notContaining Hello"; diag $@->getMessage() if $@; done_testing(); __END__ $ perl t/01-test-mod.t ok 1 - containing Hello ok 2 - notContaining Hello 1..2 $
    Do anyone have experience with this module?

    openjdk-8-jre:amd64 + Ubuntu 16.04.1 LTS + perl v5.22.1


    No matter how great and destructive your problems may seem now, remember, you've probably only seen the tip of them. [1]
Critical sections; In the Perl interpreter
3 direct replies — Read more / Contribute
by Wiggins
on Feb 16, 2017 at 13:45
    My interest is in critical sections in the Perl interpreter itself.
    I was asked by a friend, why after starting 150 web spider threads, his system would bog down until it seem to stop, but was still running?

    I proposed that each of those threads was a separate process, with each having a full Perl interpreter. But they were all sharing the same .so libraries, and the number of critical sections(CS) that the interpreter had to go through would create single file bottle-neck after bottle-neck.

    Are there CS in the interpreter? Are there certain functional areas that have significantly more CS than others

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

Can't find a module that is installed
1 direct reply — Read more / Contribute
by Weebo
on Feb 16, 2017 at 13:24 is giving me problems with MAKER again, you'd think I would become a Perl coder instead of jsut a Perl user by now...

    I tried running MAKER on a new cluster I installed it on and got the following response for every MPI process I created

    Can't locate in @INC (you may need to install the forks modul +e) (@INC contains: /Data/Apps/maker/bin/../perl/lib /Data/Apps/maker/ +bin/../lib /Data/Apps/maker/bin/../src/inc/perl/lib /Data/Apps/CEGMA_ +v2.5/lib /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.22.1 /usr/l +ocal/share/perl/5.22.1 /usr/lib/x86_64-linux-gnu/perl5/5.22 /usr/shar +e/perl5 /usr/lib/x86_64-linux-gnu/perl/5.22 /usr/share/perl/5.22 /usr +/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base .) at /Data/ +Apps/maker/bin/maker line 42.

    So I went looking

    locate /home/seth/.cpan/build/forks-0.36-0/blib/lib/ /home/seth/.cpan/build/forks-0.36-0/lib/ /usr/local/lib/x86_64-linux-gnu/perl/5.22.1/
    Now, I might be crazy, but /usr/local/lib/x86_64-linux-gnu/perl/5.22.1 seems to be in both. Why can't it find
What does chdir ?
2 direct replies — Read more / Contribute
by pcouderc
on Feb 16, 2017 at 02:26
    This script fails :
    #!/usr/bin/perl # # chdir 'core/efl'; `./`;
    But if I key :
    cd core/efl ./
    my configuration is ok. What do I miss ? What is the difference ?

    Update: added . in front of / in second code snippet

PERL Oracle wallet Error
1 direct reply — Read more / Contribute
by Ajoy
on Feb 16, 2017 at 01:07
    when i am trying to connect to oracle using oracle wallet it ends with below error ORA-12534:TNS:Operation not supproted (DBD Error:OCISessionBegin). but in sqlplus i am able to connect via connection string using wallet. DBD-Oracle version --- 1.21 Oracle 11.2 can some guide on this to get it resolved
Horizontal Line By OODoc
1 direct reply — Read more / Contribute
by sachss
on Feb 15, 2017 at 21:32
    I have the following test code:
    #!/usr/bin/perl -w use strict; use OpenOffice::OODoc; use constant FALSE => 0; use constant TRUE => 1; my $doc = odfDocument( file => "MyDocument.odt", create => 'text' ); my $rightStyle = $doc->createStyle( "RightStyle", family => 'paragraph', parent => 'Standard', properties => { '-area' => 'paragraph', 'fo:text-align' => 'right', 'style:font-name' => 'Times New Roman' } ); my $leftStyle = $doc->createStyle( "LeftStyle", family => 'paragraph', parent => 'Standard', properties => { '-area' => 'paragraph', 'fo:text-align' => 'left', 'style:font-name' => 'Times New Roman' } ); $doc->appendParagraph( text => "RightStyle-Applied", style => "RightStyle" ); $doc->appendParagraph( text => "LeftStyle-Applied", style => "LeftStyle" ); $doc->appendParagraph( text => "\n\nThis is a test\n------\n", style => "LeftStyle" ); $doc->save; exit 0; ### End of Main ### ### -- Begin of Subroutines --- ### ### -- End of Subroutines --- ### ###--- End of File ---###

    The \n------\n is what I manually to do create a horizontal line within OpenOffice Writer. But when I run the above code, I just get the "------" on its own line and not a horizontal line.

    Anyone have any ideas?

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

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (5)
    As of 2017-02-19 14:28 GMT
    Find Nodes?
      Voting Booth?
      Before electricity was invented, what was the Electric Eel called?

      Results (292 votes). Check out past polls.