CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Running Perl in Linux

 



PerlBeginner123
New User

Sep 15, 2016, 5:57 PM

Post #1 of 7 (3020 views)
Running Perl in Linux Can't Post

Automating a tool in linux and when I run a print it puts the text into three separate lines on the command line. I want to keep it into one. Anyone know why this happens?


Laurent_R
Veteran / Moderator

Sep 15, 2016, 11:15 PM

Post #2 of 7 (3016 views)
Re: [PerlBeginner123] Running Perl in Linux [In reply to] Can't Post

How does this relate to Perl? Does this faulty print happen in Perl? If so, please show the print statement as we as possibly the code lines where the variables used in this print statement are used.


PerlBeginner123
New User

Sep 16, 2016, 5:44 PM

Post #3 of 7 (2992 views)
Re: [PerlBeginner123] Running Perl in Linux [In reply to] Can't Post

Yes it is written in perl, the string looks something like this print "Linux command \argument1:argument2\ Linux command" ; If I remove the variables the print stays on one line but as soon as they are back in they chop to 3 separate lines


FishMonger
Veteran / Moderator

Sep 16, 2016, 5:58 PM

Post #4 of 7 (2990 views)
Re: [PerlBeginner123] Running Perl in Linux [In reply to] Can't Post

Post your real code.

Without that or least a short test script that demonstrates the problem, it's impossible for anyone to tell you what you're doing wrong other than to say your variables contain a \n line terminator.


PerlBeginner123
New User

Sep 16, 2016, 7:04 PM

Post #5 of 7 (2984 views)
Re: [PerlBeginner123] Running Perl in Linux [In reply to] Can't Post

print "Highlight and copy text --> This is your link to your webpage \"http://$argument:$argument2 \n";


Laurent_R
Veteran / Moderator

Sep 17, 2016, 12:32 AM

Post #6 of 7 (2977 views)
Re: [PerlBeginner123] Running Perl in Linux [In reply to] Can't Post

And can you show the output you get?

I suspect that your variables $argument1 and $argument2 might contain newline characters (probably at the end of it). If so, you can just chomp them (check the chomp function in the documentation). Where are these variables coming from (how are they populated)?


PerlBeginner123
New User

Sep 17, 2016, 2:42 PM

Post #7 of 7 (2957 views)
Re: [Laurent_R] Running Perl in Linux [In reply to] Can't Post

You are 100% correct, I did not use chomp below my arguments and now it works smoothly. Thank you all for your help as I am slowly figuring all of this out.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives