Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
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
Redirecting Output to shell command from within perl
4 direct replies — Read more / Contribute
by dracut
on Feb 16, 2018 at 19:32
    Hey guys, not sure if this has been answered here before, but I was looking to feed less a string stored within a variable $output.
    Essentially I'm trying to do the following from within the script:

              script.pl|less

    Any help would be greatly appreciated!
Writing to File based on condition
4 direct replies — Read more / Contribute
by cbtshare
on Feb 16, 2018 at 16:57

    Hello All, I have the script below that is suppose to run against a file with a list of ip addresses, check if they are up or not .If they are up just print, if they are not write to a file after it determines if its empty or not, but I also want that file to have no duplicates, so I have the following, seems like over kill to do a simple task.It runs, but when I get to if the host is not up, that section doesn't even run (I know this because I put dead ip addresses in the list.Can you please assist

    #!/usr/bin/perl use warnings; use strict; my $awsGone = "/ansible/awsGone"; my $awsLists = "/ansible/awsLists"; my @ips; open(FILE, '<', $awsLists) || die("Could not open file, $!"); @ips = <FILE>; close FILE; foreach my $addy(@ips) { chomp($addy); #Test if up my $retreval=system qq{nc -w 1 $addy 22 > /dev/null 2>&1}; if($retreval==0) { print "This up -> $addy\n"; } else { ##check if the file is empty, dont bother searching for +duplicates if(-z "$awsGone") { print "Host not up\n"; open(WRITE,'+>>',"$awsGone") || die("canot open $awsGone,$ +!"); print WRITE "$addy\n"; close WRITE; #remove dead ip from file system qq{perl -p -i -e "/$addy/" $awsLists}; } else { ##ip is dead, so open file for writing, then check if d +ead ip is already there open(WR,'+>>',"$awsGone") || die("canot open $awsGone,$!") +; while(my $line = <WR>) { if($line =~ /$addy/) { print "already exists\n"; } else { ##Append dead ip to the file print "Host not up now\n"; print WR "$addy\n"; close WR; system qq{perl -p -i -e "/$addy/" $awsLists}; } } } } }
    My test file looks like below, all are good except the 3rd and 4th
    ip-10-1-0-152.us-west-2.compute.internal ip-10-1-0-239.us-west-2.compute.internal ip-10-55-55-55.us-west-2.compute.internal ip-10-122-122-122.us-west-2.compute.internal ip-10-1-1-143.us-west-2.compute.internal ip-10-1-1-149.us-west-2.compute.internal ip-10-1-1-150.us-west-2.compute.internal ip-10-1-1-167.us-west-2.compute.internal
    my results are
    This up -> ip-10-1-0-152.us-west-2.compute.internal This up -> ip-10-1-0-239.us-west-2.compute.internal This up -> ip-10-1-1-143.us-west-2.compute.internal This up -> ip-10-1-1-149.us-west-2.compute.internal This up -> ip-10-1-1-150.us-west-2.compute.internal This up -> ip-10-1-1-167.us-west-2.compute.internal
Convert string to variable
4 direct replies — Read more / Contribute
by ShermW0829
on Feb 16, 2018 at 15:27

    Name: Sherman 71 years old retired and creating my own poker visits database

    Platform: HP Compaq 6710b

    Operating System: Ubuntu 17.10

    PERL Version: 5.26

    postgresql Version: 9.6

    Problem: Need to assign a string to act as a variable

    I am building a front end for postgresql entries. I have fourteen entries that I need to query the user and set the user's value into a variable. I am using IO::Prompt.

    If I straight-line the code everything works. e.g:

    my ($date_in, $date_out); $date_in - prompt("Start Date: "); $date_in =~ s/^\s+|\s+$//g; $date_out = prompt("$End Date: "); $date_out =~ s/^\s+|\s+$//g;

    And 12 more user inputs to get along with the no space check equals 24 more lines of code. Lots of code so I tried the following:

    my ($k, $date_in, $date_out); my %var_list = ('date_in'=>'Start Date', 'date_out'=>'End Date'); foreach $k (keys(%var_list)) { ## $k prints date_out and then date_in print( "\$k: \"$k\"\n" ); ## $var_list prints End Date and then Start Date print( "\$var_list{k}: \"$var_list{$k}\"\n" ); ## Below is where I want to go: ## $k = prompt($var_list{k}); ## and have $date_out = user's entry ## ## Now how do I assign a beginning $ ## to change date_out to $date_out? ## The below does not work ## ${$k} = prompt(${$var_list{k}}); ## ## I've tried $$k, $($k), and ${$k} ## An example error is the following: ## Can't use string ("date_out") as a SCALAR ## ref while "strict refs" in use at ## ./build_sql_entries line 25 }

    Thank you;

    Sherman

Appending downlad file LWP
1 direct reply — Read more / Contribute
by Anonymous Monk
on Feb 16, 2018 at 13:52

    Hello

    I am trying to improve some code. Basically, I want to build a downloader with progress bar. I know how to download file, how to build a progress bar (for example in Tk). What I cannot solve is appending the portion of file I have downloaded to the main (final) file. Here it is what I got (stripped of the GUI part. The code is based on a solution I found on the web.

    use strict; use warnings; use LWP::Simple; use LWP::UserAgent; my $url='www.myurl.com'; my $ttlDown = 0; my $resp = LWP::UserAgent->new()->get($url, ':content_cb' => sub { my ($data, $response) = @_; my $size = $response->content_length; $ttlDown += length $data; printf("%7.1f KB of %7.1f (%5.1f%%)$/", $ttlDown / 1024.0, $size / 1024.0, $ttlDown * 100.0 / $size ); #Here I need to append the bit of file downloaded, but I am down +loaded the entire file over and over... my $file = 'myfile.exe'; getstore($url, $file); });
Compilation failed in require, but how to get the actual compilation error?
1 direct reply — Read more / Contribute
by Anonymous Monk
on Feb 16, 2018 at 12:13

    Hi everyone, I have a script called switchscan.pl which is turned into an executable called switchscan through the use of Par Packer. When I run the switchscan, it tries to load the module SwitchScan::Service::local::mlnx, but I end up with this error:

    Attempt to reload SwitchScan/Service/local/mlnx.pm aborted (#1) (F) You tried to load a file with use or require that failed to compile once already. Perl will not try to compile this file agai +n unless you delete its entry from %INC. See "require" in perlfunc +and "%INC" in perlvar. Compilation failed in require at script/switchscan.pl line 42 (#2) (F) Perl could not compile a file specified in a require statement +. Perl uses this generic message when none of the errors that it encountered were severe enough to halt compilation immediately. BEGIN failed--compilation aborted at script/switchscan.pl line 42 (#3) (F) An untrapped exception was raised while executing a BEGIN subroutine. Compilation stops immediately and the interpreter is exited. Uncaught exception from user code: Attempt to reload SwitchScan/Service/local/mlnx.pm aborted. Compilation failed in require at script/switchscan.pl line 42. BEGIN failed--compilation aborted at script/switchscan.pl line 42.

    How do I get the actual error that caused the compilation failure? When I run perl -c on mlnx.pm before packing everything with Par Packer, I get "syntax OK". Something in the packing process is causing the failure, but I'm at a loss for how to further troubleshoot.

    Much appreciated.

including variables
6 direct replies — Read more / Contribute
by LloydRice
on Feb 16, 2018 at 11:32

    I have a short bit of Perl variable definitions that I would like to use in two different scripts. The simple plan is that I would not need to maintain 2 copies of that fragment. I have tried do, exec, use, module, a few more things. It all seems designed to defeat my simple goal by imposing all of the module structure. As I read the new Camel book, "do" should do what I want. But the variables do not get into the calling script. What am I missing?

HASH Hierarchy
3 direct replies — Read more / Contribute
by dirtdog
on Feb 16, 2018 at 10:40

    Hi Monks, I've got a working snippet of code that will take parameters and stuff them into a hash to be used later in the program to only keep the highest ranked value only (0 is top ranked) if it exists.

    hierarchy.pl POPE PATRIARCH ARCHBISHOP CARDINAL
    #!/usr/bin/env perl use strict; my @hierarchy; my %hierarchy; my $order =0; while ($#ARGV >= 0) { push @hierarchy,shift; } for (@hierarchy) { $hierarchy{$_} = $order; $order++; } while( my( $key, $value ) = each %hierarchy ){ print "$key: $value\n"; }

    The code appears to work, but I thought there might be a better way to do it so thought I'd check with the Monks.

    Much appreciated!

why does par packer cause incorrect Perl-Tk server() output?
5 direct replies — Read more / Contribute
by perltux
on Feb 16, 2018 at 05:38
    Given the following script:

    use strict; use warnings; use Tk; my $mw=MainWindow->new(); print STDOUT "PerlTk server: [". $mw->server() ."]\n";

    If I run the above script on Windows 10 using StrawberryPerl I get the following output which is as expected:

    PerlTk server: [Windows 10.0 10586 Win32]

    but if I create an exe of the above script with Par::Packer on the same system I get the following wrong output when running the exe:

    PerlTk server: [Windows 6.2 9200 Win32]

    Why does Par::Packer change the output of the Tk 'server()' command making it incorrect and what do I have to do to get the correct output when using an exe created by Par::Packer?
pearl script working but is changing to attachment
6 direct replies — Read more / Contribute
by cwebber1
on Feb 16, 2018 at 01:32
    I have a perl script which is working on most email servers, but my client has a gmail address and it is converting the text email to an non openable attachment on chrome, what needs to be changed? script attached 2 part. I am no expert just dangerous enough to get it to work. It works fine on safari. Part one
    #!/usr/local/bin/perl #### # # Program: question1.pl # Cimmaron Design # 702 448-4927 # #### #### # # Image Uploading Routine # #### #### # # The libraries to use... CGI for the CGI functions used in print sta +tements. # Use 'perldoc CGI' to find out more about the CGI functions. # #### use CGI qw/:all/; #### # # Begin of the main code # #### #### # # The param function will determine if there was a CGI submission. # #### if (param) { #### # # This is where we want to be, print out a nice HTML header # and start to process the stuff that the server will send in # email to the user and the guys who are going to actually # fill the order. # #### print STDOUT header; print STDOUT start_html('View Sovereign Questionnaire'); #### # # Okay - next we will verify *all* the fields on the order # form are listed properly, and verify their correctness. # If those conditions are met, then we'll print out what the # email will look like, and save it off to a variable that we # can pipe to the email program. # #### $your_email_address = param('your_email_address'); $your_name = param('your_name'); $email_subject_line = param('email_subject_line'); $required_fields = param('required_fields'); $thank_you_title = param('thank_you_title'); $return_link_url = param('return_link_url'); $return_link_name = param('return_link_name'); $client_email = param('client_email'); $client_name = param('client_name'); $client_phone = param('client_phone'); $tell = param('tell'); $owned = param('owned'); $lookingfor = param('lookingfor'); $how = param('how'); $fenced = param('fenced'); $time = param('time'); $sex = param('sex'); $house = param('house'); $out = param('out'); $comp = param('comp'); $comments = param('comments'); #### # # Now - to verify each of the *required* entries... the # undefined ones weren't used in what the user listed... # We'll go through all the errors, and then print out what # we find, instead of breaking if there's just one and not # showing any others we might find as well, to make it more # usable. # #### $err_no = 0; if ( ! defined($your_email_address) ) { $err[$err_no++]="Invalid hidden fields 'your_email_address'\n" +; } if ( ! defined($your_name) ) { $err[$err_no++]="Invalid hidden fields 'your_name'\n"; } if ( ! defined($email_subject_line) ) { $err[$err_no++]="Invalid hidden fields 'email_subject_line'\n" +; } if ( ! defined($thank_you_title) ) { $err[$err_no++]="Invalid hidden fields 'thank_you_title'\n"; } if ( ! defined($return_link_url) ) { $err[$err_no++]="Invalid hidden fields 'return_link_url'\n"; } if ( ! defined($return_link_name) ) { $err[$err_no++]="Invalid hidden fields 'return_link_name'\n"; } #### # # User information next... # #### if ( ! defined($client_email) ) { $err[$err_no++]="You must enter an email address\n"; } else { if ( $client_email eq "" ) { $err[$err_no++]="You must enter an email address\n"; } } if ( ! defined($client_name) ) { $err[$err_no++]="You must enter a name\n"; } else { if ( $client_name eq "" ) { $err[$err_no++]="You must enter a name\n"; } } if ( ! defined($client_phone) ) { $err[$err_no++]="You must enter a phone number\n"; } else { if ( $client_name eq "" ) { $err[$err_no++]="You must enter a phone number\n"; } } #### # # Verifications complete. Next we check if there were # any errors. If there were, print them, and exit, if not, # then print out what we're here after - the order form. # #### if ( $err_no > 0 ) { print STDOUT h2({-align=>'center'}, font( {-color=>"#AF0000"}, "Submitted Questionnaire - Sovereign +Brittanys - errors" ) ), "\n"; print STDOUT hr( {-noshade} ), "\n"; print STDOUT "<UL>\n"; for ( $i = 0 ; $i < $err_no; $i++ ) { print STDOUT li($err[$i]), "\n"; } print STDOUT "</UL>\n"; print STDOUT end_html, "\n"; exit; } #### # # So - lets print out some HTML to show them what they ordered, # and get verification that it's all good. # #### print STDOUT h2({-align=>'center'}, font( {-color=>"#AF0000"}, "Submitted Sovereign Questionnaire" ) ), +"\n"; print STDOUT hr( {-noshade} ), "\n"; print STDOUT "<pre>\n"; if ($imageError) { my @vars = sort(keys(%ENV)); #foreach(@vars) { # $ENV{$_} ||= qq~›~; #print qq~ # # $of\$ENV{$_}$cf # $of$ENV{$_}$cf # #~; #} print STDOUT " Upload Error: $returned\n"; } print STDOUT "Email Address: $client_email\n"; print STDOUT "Your Name: $client_name\n"; print STDOUT "Your Phone: $client_phone\n"; print STDOUT "____________________________________________________ +_______________________\n"; if ( length($tell) > 1 ) { print STDOUT "Please tell us a little about your home and fami +ly (including number of children and ages at home). \n"; print STDOUT "$tell\n"; print STDOUT "____________________________________________________ +_______________________\n"; } if ( length($owned) > 1 ) { print STDOUT "Have you owned a dog/Brittany (raised a puppy)? +\n"; print STDOUT "$owned\n"; print STDOUT "____________________________________________________ +_______________________\n"; } if ( length($lookingfor) > 1 ) { print STDOUT "What are you looking for in a Brittany? \n"; print STDOUT "$lookingfor\n"; print STDOUT "____________________________________________________ +_______________________\n"; } if ( length($how) > 1 ) { print STDOUT "If you are looking for a hunting dog, how often +do you hunt? Will you be using a professional trainer? \n"; print STDOUT "$how\n"; print STDOUT "____________________________________________________ +_______________________\n"; } if ( length($fenced) > 1 ) { print STDOUT "Do you have a fenced in yard? \n"; print STDOUT "$fenced\n"; print STDOUT "____________________________________________________ +_______________________\n"; } if ( length($sex) > 1 ) { print STDOUT "Are you looking for a male or female, or open to + either? \n"; print STDOUT "$sex\n"; print STDOUT "____________________________________________________ +_______________________\n"; } if ( length($house) > 1 ) { print STDOUT "Where will this puppy/dog live? Where will it st +ay when you are not home? \n"; print STDOUT "$house\n"; print STDOUT "____________________________________________________ +_______________________\n"; } if ( length($out) > 1 ) { print STDOUT "Will there be someone home during the day to tak +e the puppy out? \n"; print STDOUT "$out\n"; print STDOUT "____________________________________________________ +_______________________\n"; } if ( length($comp) > 1 ) { print STDOUT "Do you have any interest in competing with your +dog (ie. conformation shows, hunt tests, field trials, agility, obedience, rally, lure coursing, barn hunt, etc)? \n"; print STDOUT "$comp\n"; print STDOUT "____________________________________________________ +_______________________\n"; } if ( length($comments) > 1 ) { print STDOUT "Additional Comments:\n"; print STDOUT "$comments\n"; } print STDOUT "</pre>\n"; print STDOUT "<form action=\"question2.pl\" method=\"POST\">\n"; ##### # # Now, for the next cgi in line, we'll need ALL # the elements of the last page, to print out on the # email that's going to the address specified in the # html file, and the one specified on the form (the client) # #### if (!$imageError) { print STDOUT "<input type=\"hidden\" name=\"upload_name\" valu +e=\"$returned\">\n"; print STDOUT "<input type=\"hidden\" name=\"upload_type\" valu +e=\"$fileType\">\n"; } print STDOUT "<input type=\"hidden\" name=\"your_email_address\" v +alue=\"$your_email_address\">\n"; print STDOUT "<input type=\"hidden\" name=\"your_name\" value=\"$y +our_name\">\n"; print STDOUT "<input type=\"hidden\" name=\"email_subject_line\" v +alue=\"$email_subject_line\">\n"; print STDOUT "<input type=\"hidden\" name=\"required_fields\" valu +e=\"$required_fields\">\n"; print STDOUT "<input type=\"hidden\" name=\"thank_you_title\" valu +e=\"$thank_you_title\">\n"; print STDOUT "<input type=\"hidden\" name=\"return_link_url\" valu +e=\"$return_link_url\">\n"; print STDOUT "<input type=\"hidden\" name=\"return_link_name\" val +ue=\"$return_link_name\">\n"; print STDOUT "<input type=\"hidden\" name=\"client_email\" value=\ +"$client_email\">\n"; print STDOUT "<input type=\"hidden\" name=\"client_name\" value=\" +$client_name\">\n"; print STDOUT "<input type=\"hidden\" name=\"client_phone\" value=\ +"$client_phone\">\n"; print STDOUT "<input type=\"hidden\" name=\"client_phone\" value=\ +"$client_phone\">\n"; print STDOUT "<input type=\"hidden\" name=\"tell\" value=\"$tell\" +>\n"; print STDOUT "<input type=\"hidden\" name=\"owned\" value=\"$owned +\">\n"; print STDOUT "<input type=\"hidden\" name=\"lookingfor\" value=\"$ +lookingfor\">\n"; print STDOUT "<input type=\"hidden\" name=\"how\" value=\"$how\">\ +n"; print STDOUT "<input type=\"hidden\" name=\"fenced\" value=\"$fenc +ed\">\n"; print STDOUT "<input type=\"hidden\" name=\"time\" value=\"$time\" +>\n"; print STDOUT "<input type=\"hidden\" name=\"sex\" value=\"$sex\">\ +n"; print STDOUT "<input type=\"hidden\" name=\"house\" value=\"$house +\">\n"; print STDOUT "<input type=\"hidden\" name=\"out\" value=\"$out\">\ +n"; print STDOUT "<input type=\"hidden\" name=\"comp\" value=\"$comp\" +>\n"; print STDOUT "<input type=\"hidden\" name=\"comments\" value=\"$co +mments\">\n"; print STDOUT "<hr><div align=\"center\">\n"; print STDOUT "<input type=\"submit\" name=\"submit\" value=\"OK\"> +\n"; print STDOUT "<input type=\"button\" name=\"back\" value=\"Back\" +onclick=\"history.back()\">\n"; print STDOUT "</div>\n"; } else { #### # # Somehow they got here without going to the order form html # page... so lets just print out an error and tell them to hit # a link to the submissionform.html page # #### print STDOUT header; print STDOUT start_html('Error'); print STDOUT h1( {-align=>'center'}, font( {-color=>'#AF0000'}, "Error") ), "\n"; print STDOUT hr( {-noshade} ), "\n"; print STDOUT div( {-align=>'center'}, "Please return to the ", a({-href=>'questionnaire18.html'}, "Questionnaire") , "\n", "instead of calling this CGI directly\n"), "\n"; } #### # # That's all folks :-) # #### print STDOUT end_html, "\n";
    Part 2
    #!/usr/local/bin/perl #### # # Program: svetime2.pl # Cimmaron Design 7/2017 # 720 448-4927 # #### #### # # The libraries to use... CGI for the CGI functions used in print sta +tements. # Use 'perldoc CGI' to find out more about the CGI functions. # #### use CGI qw/:all/; #### # # The param function will determine if there was a CGI submission. # #### if (param) { #### # # This is where we want to be, print out a nice HTML header # and start to process the stuff that the server will send in # email to the user and the guys who are going to actually # fill the inquiry . # #### print STDOUT header; print STDOUT start_html('Sovereign Brittany Questionnaire'); #### # # Okay - next we will verify *all* the fields on the order # form are listed properly, and verify their correctness. # If those conditions are met, then we'll print out what the # email will look like, and save it off to a variable that we # can pipe to the email program. # #### $your_email_address = param('your_email_address'); $your_name = param('your_name'); $email_subject_line = param('email_subject_line'); $required_fields = param('required_fields'); $thank_you_title = param('thank_you_title'); $return_link_url = param('return_link_url'); $return_link_name = param('return_link_name'); $client_email = param('client_email'); $client_name = param('client_name'); $client_phone = param('client_phone'); $tell = param('tell'); $owned = param('owned'); $lookingfor = param('lookingfor'); $how = param('how'); $fenced = param('fenced'); $time = param('time'); $sex = param('sex'); $house = param('house'); $out = param('out'); $comp = param('comp'); $comments = param('comments'); #### # # So - lets print out some HTML to show them what they ordered, # and get verification that it's all good. # #### $inquiry = ""; $inquiry .= " Email: $client_email\n"; $inquiry .= " Name: $client_name\n"; $inquiry .= " Phone: $client_phone\n"; $inquiry .= " ---------------------------------------- +------------------\n"; if ( length($tell) > 1 ) { $inquiry .= "Please tell us a little about your home and famil +y (including number of children and ages at home). \n"; $inquiry .= "$tell\n"; $inquiry .= "_____________________________________________________ +______________________\n"; } if ( length($owned) > 1 ) { $inquiry .= "Have you owned a dog/Brittany (raised a puppy)? \ +n"; $inquiry .= "$owned\n"; $inquiry .= "_____________________________________________________ +______________________\n"; } if ( length($lookingfor) > 1 ) { $inquiry .= "What are you looking for in a Brittany? \n"; $inquiry .= "$lookingfor\n"; $inquiry .= "_____________________________________________________ +______________________\n"; } if ( length($how) > 1 ) { $inquiry .= "If you are looking for a hunting dog, how often d +o you hunt? Will you be using a professional trainer? \n"; $inquiry .= "$how\n"; $inquiry .= "_____________________________________________________ +______________________\n"; } if ( length($fenced) > 1 ) { $inquiry .= "Do you have a fenced in yard? \n"; $inquiry .= "$fenced\n"; $inquiry .= "_____________________________________________________ +______________________\n"; } if ( length($sex) > 1 ) { $inquiry .= "Are you looking for a male or female, or open to +either? \n"; $inquiry .= "$sex\n"; $inquiry .= "_____________________________________________________ +______________________\n"; } if ( length($house) > 1 ) { $inquiry .= "Where will this puppy/dog live? Where will it stay when you are not home? \n"; $inquiry .= "$house\n"; $inquiry .= "_____________________________________________________ +______________________\n"; } if ( length($out) > 1 ) { $inquiry .= "Will there be someone home during the day to take + the puppy out? \n"; $inquiry .= "$out\n"; $inquiry .= "_____________________________________________________ +______________________\n"; } if ( length($comp) > 1 ) { $inquiry .= "Do you have any interest in competing with your d +og (ie. conformation shows, hunt tests, field trials, agility, obedience, rally, lure coursing, barn hunt, etc)? \n"; $inquiry .= "$comp\n"; $inquiry .= "_____________________________________________________ +______________________\n"; } if ( length($comments) > 1 ) { $inquiry .= "Additional Comments:\n"; $inquiry .= "$comments\n"; $inquiry .= "_____________________________________________________ +______________________\n"; } #### # # Now we've got the order as it was displayed to the user # in the last script stuck inside a variable. We can send # that out in an email to the required email addresses, *and* # print it on the screen for the user again to make sure its # perfect, but there's no going back now... # #### print STDOUT h3({-align=>'center'}, font( {-color=>"#AF0000"}, "Sovereign Brittany Questionnaire" ) ), " +\n"; print STDOUT hr( {-noshade} ), "\n"; print STDOUT "<pre>\n"; print STDOUT $inquiry; print STDOUT "</pre>\n"; print STDOUT "<hr><div align=\"center\">\n"; print STDOUT "<h2 align=\"center\">$thank_you_for_your_filling_out +_our_questionnaire</h2>\n"; #### # # On a windows system, the mail command may need to change # I don't have one to test with, but the lines that say # "open ( MAILx" are the ones that you'll need to fuss with... # #### if ( open (MAIL1, "| mail -s \"$email_subject_line\" $client_email +") != 0 ) { print MAIL1 $inquiry; close MAIL1; } else { print STDOUT "<p>Mail failed to $client_email</p>\n"; } if ( open (MAIL2, "| mail -s \"$email_subject_line\" $your_email_a +ddress") != 0 ) { print MAIL2 $inquiry; close MAIL2; print STDOUT "<p>Mail sent to $your_email_address (to process +this inquiry)</p>\n"; } else { print STDOUT "<p>Mail FAILED to $your_email_address (Will NOT +process this inquiry)</p>\n"; } print STDOUT "<p>click <a href=\"$return_link_url\">$return_link_n +ame</a> to return.</p>\n"; print STDOUT "</div>\n"; } else { #### # # Somehow they got here without going to the order form html # page... so lets just print out an error and tell them to hit # a link to the contact.html page # #### print STDOUT header; print STDOUT start_html('Error'); print STDOUT h1( {-align=>'center'}, font( {-color=>'#AF0000'}, "Error") ), "\n"; print STDOUT hr( {-noshade} ), "\n"; print STDOUT div( {-align=>'center'}, "Please return to the ", a({-href=>'index.html'}, "Sovereign Brittanys.") , "\n", "instead of calling this CGI directly\n"), "\n"; } #### # # That's all folks :-) # #### print STDOUT end_html, "\n";
outputs followed by each other
5 direct replies — Read more / Contribute
by busyvish
on Feb 15, 2018 at 19:18
    hello guys before i start i am a complete newbie to perl. i have a code that runs just about fine. the problem is with the output. this is the code
    #! /usr/bin/perl -l print "please enter a number: "; $n1 = <STDIN>; print "please enter a number"; $n2 = <STDIN>; if ($n1 < $n2) { print "$n1" , "$n2" ; } else { print "$n2" , "$n1" ; }
    i need the output in a specific format $n1 followed by $n2 or vice versa this code gives me values in format $n1 newline $n2 what can i do to solve my problem

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

    How do I use this? | Other CB clients
    Other Users?
    Others musing on the Monastery: (3)
    As of 2018-02-18 03:31 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      When it is dark outside I am happiest to see ...














      Results (250 votes). Check out past polls.

      Notices?