Hi,

Please tell me how to grab the leading spaces from a given line of text.

I tried this :

my $text = "       this is a test" ;

# Test 1
my $leading_spaces = ($text =~ m/^(\s+)/) ; # This doesn't work
print $leading_spaces ;                     # Prints 1

# Test 2
print ($text =~ m/^(\s+)/) ;                # this prints the spaces

Why does the 2nd case work, when the 1st case doesn't ?

pv.

-- 
Prahlad Vaidyanathan <[EMAIL PROTECTED]>

You may get an opportunity for advancement today.  Watch it!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to