LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-11-2012, 05:22 AM   #1
zahheb
LQ Newbie
 
Registered: Aug 2012
Posts: 29

Rep: Reputation: Disabled
blank space in perl


if $line =~ /^\s*$/;

this is the code for avoiding blank lines.....can someone tel why do we have $..... i know its for matching \s means space ... and why dont we have if $line =~ m/^\s*$/;......
why match operator m is not present?


thanks
 
Old 08-11-2012, 08:16 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,133

Rep: Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273
which $? $ is used to define scalar variables, so $line is a scalar variable, see here: http://www.comp.leeds.ac.uk/Perl/scalars.html
using regexp: ^ is the beginning of the line, $ is the end of the line, \s means white space, * means any number, so ^\s*$ means any number of white space chars between the beginning and end of the line, so the whole line can contain only white space chars.
^\s* would mean some white spaces at the beginning of the line... see here: http://perldoc.perl.org/perlretut.html or there: http://perldoc.perl.org/perlre.html
why we do not need m? because the operator is =~, we do not need both. see: http://perldoc.perl.org/perlop.html#Binding-Operators
 
  


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
Blank space on screen in Suse 10.1 using KDE 3.5.1 St_Mike777 Linux - Laptop and Netbook 3 01-17-2007 01:34 PM
Getting the free space in a blank cd or dvd? Tacroy Linux - Software 2 09-02-2006 03:06 PM
Perl database blank server-solution Linux - Software 6 04-28-2006 05:11 AM
Is linux *blank* up my windows space? mimithebrain General 0 06-13-2004 09:05 PM
how do I print 'blank space' to standard out in C on same line? purpleburple Programming 7 08-19-2002 12:54 AM


All times are GMT -5. The time now is 10:44 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration