LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 05-04-2011, 04:04 PM   #1
fusion1275
Member
 
Registered: Jul 2007
Location: Portsmouth, Hants
Distribution: Mint 13
Posts: 265

Rep: Reputation: 35
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.
 
Old 05-04-2011, 04:37 PM   #2
corp769
Guru
 
Registered: Apr 2005
Posts: 5,807

Rep: Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996
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
 
Old 05-04-2011, 04:42 PM   #3
fusion1275
Member
 
Registered: Jul 2007
Location: Portsmouth, Hants
Distribution: Mint 13
Posts: 265

Original Poster
Rep: Reputation: 35
Thanks I will check that out.
 
Old 05-04-2011, 04:45 PM   #4
corp769
Guru
 
Registered: Apr 2005
Posts: 5,807

Rep: Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996
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
 
Old 05-04-2011, 06:01 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,972
Blog Entries: 11

Rep: Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876
Quote:
Originally Posted by corp769 View Post
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
 
Old 05-04-2011, 06:21 PM   #6
corp769
Guru
 
Registered: Apr 2005
Posts: 5,807

Rep: Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996
Quote:
Originally Posted by Tinkster View Post
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
perl script get enviromnet varible LINES= for current session zerobane Programming 6 04-02-2009 05:23 PM
Perl Script to select common lines in two files. perluser59 Programming 12 05-26-2008 02:19 AM
bash script to remove the blank lines in the file naveensankineni Programming 7 03-25-2008 08:34 PM
NEED HELP IN comment lines PERL Perl script adam_blackice Programming 17 11-07-2007 08:01 AM
Perl: testing for blank lines Garda Programming 4 11-16-2006 07:39 PM


All times are GMT -5. The time now is 09:32 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration