LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Blank Lines in a Perl Script (https://www.linuxquestions.org/questions/programming-9/blank-lines-in-a-perl-script-878846/)

fusion1275 05-04-2011 04:04 PM

Blank Lines in a Perl Script
 
Hi all,

I am a total newbie at Perl and was just asking if there is a way to add line spaces when asking for user interaction in a script.

For example:

Code:

SPACE
Hello what is your name?
SPACE
SPACE

So this is asking a question but has a space/empty line at the top of the screen and 2 spaces/empty lines below. I've seen it done in a bash script using for each line/space needed

Code:

echo ""
So what does perl use??

Sorry if its a dumb question to most of you all.

Thanks in advance.

corp769 05-04-2011 04:37 PM

Hello,

You could use a standard regular expression within your print statement, such as \n which means new line. For a list of all regular expressions used, see here: http://www.ryerson.ca/perl/manual/pod/perlre.html

Cheers,

Josh

fusion1275 05-04-2011 04:42 PM

Thanks I will check that out.

corp769 05-04-2011 04:45 PM

No problem! If you have any more questions, feel free to ask. Mark my posts helpful if you feel the need to also, thanks!

Josh

Tinkster 05-04-2011 06:01 PM

Quote:

Originally Posted by corp769 (Post 4346682)
Hello,

You could use a standard regular expression within your print statement, such as \n which means new line. For a list of all regular expressions used, see here: http://www.ryerson.ca/perl/manual/pod/perlre.html

Cheers,

Josh


Small amendment for completeness' (& correctness') sake:
"\n" in the context of print (or any string, really) is simply
an escape sequence, not a regular expression; while the escape
sequence has a meaning in REs (same meaning as in a string,
matching a newline) it is NOT an RE in this context.



Cheers,
Tink

corp769 05-04-2011 06:21 PM

Quote:

Originally Posted by Tinkster (Post 4346748)
Small amendment for completeness' (& correctness') sake:
"\n" in the context of print (or any string, really) is simply
an escape sequence, not a regular expression; while the escape
sequence has a meaning in REs (same meaning as in a string,
matching a newline) it is NOT an RE in this context.

Cheers,
Tink

I knew that man :) I refered to the regular expressions because you can also use expressions to create blank and new lines. Thanks for clarifying that though, since I forgot to.

Cheers,

Josh


All times are GMT -5. The time now is 01:18 AM.