Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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.

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.

Post a new question!

User Questions
Defining directory/Datas the perl script should work with
3 direct replies — Read more / Contribute
by perlnewbie
on Oct 21, 2021 at 09:20

    Hi all, I want to write a script which should use extern programms for MRI-preprocessing, doing several processing commands to a bunch of data. For example: running brain extraction from the command line in linux I would write bet <inputimage> <nameforoutputimage> -m Then the programm bet in fsl would be opened and skull stripping would be performed, the output image would be saved in the same folder of the inputimage. In my script I want the outputimage to be saved in an other folder. Could anyone help me with this? I think there a lot of syntax errors ...

    #!/usr/bin/perl use strict; use warnings; use diagnostics; my $dir = "usr/bin/Test_Protokoll" my $001= "prob_001"; my $002= "prob_002"; my $003= "prob_003"; @filter: ("001", "002", "003"); #Brainextraction foreach ("001", "002", "003") { system ("bet SYNT_MPRAGE_T1_PD_B0corr YNT_MPRAGE_T1_PD_B0corr_brain + -m"); }
regex in perl
2 direct replies — Read more / Contribute
by noviceuser
on Oct 21, 2021 at 05:41

    suppose i have multiple lines like below and i want to grep lines having "code" only after fixed pattern "/dir1/dir2/100.10/dir3/100.20/" . i have tried using grep "/code/",but it is giving all the lines containing the match elsewhere. please help

    /dir1/dir2/100.10/dir3/100.20/code/abc/def.txt /dir1/dir2/100.10/dir3/100.20/code/def/ghi.txt . .
Angle operator
5 direct replies — Read more / Contribute
by jerryhone
on Oct 20, 2021 at 10:19
    Hi brethren,
    I have encountered a very strange issue, and I'm looking for advice on how to start finding the root cause... I have a VERY old script with line 1 which says
    #!/opt/bin/perl5.004
    To support its update to use Oracle 19c, I've changed that to
    #!/opt/oraClient/11.2.0.4/perl/bin/perl
    However, I now find that the behaviour has changed, and when I drill into it with the debugger I find the problem seems to be with the diamond file handle The code says
    while( <> ) { &assert ( (substr($_,0,4) eq "573\r") , "blah, blah...
    What I'm seeing is that in the original Perl, I am not going into the while loop, but with the new version, I am! Command line is identical for each version, environment is identical for each version - the only change is line 1! Any thoughts on how I can get to the bottom of this...?
AWS EC2 and Perl
3 direct replies — Read more / Contribute
by Bod
on Oct 20, 2021 at 09:00

    Many will know that I need to upgrade from the current shared webhosting...it is overdue!

    A dedicated server would, of course, be ideal but I'm not sure I can justify the cost - I'm not totally convinced that I can't either! Plus, there is the server admin that I certainly don't have the time for or the skills for. The latter is solvable but not the time issue in the short-term.

    So, I thought about an AWS EC2 instance for all our webs services. This seems an ideal solution for a number of reasons:

    1. Once setup, take an image to restore if I mess things up
    2. Whatever version of Perl we want, we can install
    3. For testing, we take an image of production, spin up another EC2 instance and use that for testing/developing thus avoiding having a test setup and potential security holes
    4. No need to guess about the specs we need - AWS automagically scales as needed
    5. If one part of the business grows significantly, its easy to spin up another EC2 instance just for that
    6. Not as much server admin needed as a dedicated server but still some

    In some ways this seems too good to be true...
    Is this a plan worth looking further into or have a overlooked a flaw somewhere?

    We have databases of significant size - the biggest has 138 tables but only takes up 285Mb storage space. Plus we use Perl for everything! The shared hosting runs Apache but I have nothing to do with that other than some simple additions to the webroot .htaccess file.

Problems for installing Perl-Tk on MAC (OS version BigSur).
3 direct replies — Read more / Contribute
by asspat2021
on Oct 20, 2021 at 05:47

    I am trying to install Tk402.001 for Perl version 5.34.0
    on my MAC (with OS version BigSur). Running "perl Makefile.PL",
    I obtain a lot of errors ; after that, "make" will end with
    'Sorry no HTML building yet' and "make test" will fail.

    Before upgrading Perl 5.34.0 and BigSur, Perl-Tk was working
    very well and I used it for my own word processor. I need it
    since I don't know another way to obtain text widgets (in fact
    Curses would work, but without Unicode ; and unfortunately
    CamelBones is no longer maintained).

    How could I install Tk for Perl 5.34.0 on MAC (with BigSur) ?

Assign multiple items into an array containing the range operator from a file
5 direct replies — Read more / Contribute
by george59
on Oct 19, 2021 at 11:26

    Is it possible to read a set of values that include the range operator into an array for further processing or is this disallowed - if so can anyone suggest a workaround as the array set and number of ranges is dynamic and cannot be set directly

    Directly writing the ranges into an array works

    !/usr/bin/perl use strict; use warnings; my @list = ([0..1], [2..4], [5..8]); my @sets = []; for my $eacharray (@list) { @sets = map { my @prev = @$_; map [ @prev, $_ ], @$eacharray } @sets +; } use Data::Dump 'dd'; dd @sets;

    Writing the ranges into an array from a file doesn't

    !/usr/bin/perl use strict; use warnings; open my $handle, 'input.txt'; open my $handle, '<', 'input.txt'; chomp(my @list = <$handle>); close $handle; my @sets = []; for my $eacharray (@list) { @sets = map { my @prev = @$_; map [ @prev, $_ ], @$eacharray } @sets +; } use Data::Dump 'dd'; dd @sets; The input.txt file is: [0..1] [2..4] [5..8]
Perl tutorial building on Python skills?
9 direct replies — Read more / Contribute
by LanX
on Oct 19, 2021 at 10:16
Assigning printf to a variable
4 direct replies — Read more / Contribute
by viffer
on Oct 19, 2021 at 09:53
    <grovel>Hi wonderful smart people </end grovel>

    Hopefully this makes sense
    I am processing an afp file
    I want to see the value of a certain string so I can use

    printf "Triplet_Values = <hex: %*v2.2X>\n", ' ', $data;
    The problem is this writes it to stdout

    What I want to do is assign it to a variable and write that variable to a log file, or pass that variable back to the calling routine
    eg something like

    my $variable=printf "--INSIDE Get_Triplet_Values = <hex: %*v2.2X>\n", +' ', $data; print LOG $variable
    But all the apostrophes are making it beyond my capabilities.

    Any help gratefully received.

dumper hash incorrect?
4 direct replies — Read more / Contribute
by wolfie7873
on Oct 19, 2021 at 09:52
    It seems my hash has gone wonky. It's affecting key matching downstream. Any guesses as where to look first?
    foreach my $line ( @name_lines ) { #$/ = '\n' ; chomp($line) ; my @data = split '\|' , $line ; #map { $_ =~ s/[^a-zA-Z0-9_\@\. ]//g } @data ; #print Dumper @data ; my ( $name , $email , $wishlist , $address , $spouse_name ) = +@data ; $people{$name}{email} = $email ; $people{$name}{wishlist} = $wishlist ; $people{$name}{address} = $address ; $people{$name}{spouse} = $spouse_name ; if ( $spouse_name ne '' ) { $spouses{$name} = $spouse_name ; } } print Dumper %spouses ; $VAR1 = 'Jay'; ';AR2 = 'Shirley $VAR3 = 'Travis'; ';AR4 = 'Emmy $VAR5 = 'Trisha'; ';AR6 = 'Eddie $VAR7 = 'Eddie'; ';AR8 = 'Trisha $VAR9 = 'Shirley'; ';AR10 = 'Jay
How do we set debug to our suit
3 direct replies — Read more / Contribute
by abdan
on Oct 19, 2021 at 09:09
    How do we set the Perl's debug configuration in the terminal when doing perl -d -e "1;" on that so that it can perform moving the cursor left if LEFT key is pressed and moving the cursor right if RIGHT key is pressed, and retrieve the previous commands have been typed if the UP key is pressed and so on.

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":


  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2021-10-22 23:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (86 votes). Check out past polls.

    Notices?