Solved

chomp front of line

Posted on 2007-11-21
1
674 Views
Last Modified: 2012-06-27
Experts,
Is there an easy way (in Perl) to delete the white space at the front of a line?

I have a script  that tells how many spaces something should be indented but I have to cut the white space off the front of the line.  Regular expression matching would be GREAT!

Thanks
0
Comment
Question by:dwcronin
1 Comment
 
LVL 48

Accepted Solution

by:
Tintin earned 500 total points
ID: 20331079
$line='    some text with whitespace at the beginning';
$line =~ s/^\s+//;
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Device same like our heart 12 79
Please explain: Aspect Oriented Programming 2 85
Export Variables in Perl 3 46
What are programming codes and how do they work? 7 75
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now