Help for this page

Select Code to Download


  1. or download this
    sub countLeadingTabSpaces {
        my($data) = @_;
    ...
    }
    
    countLeadingTabSpaces("\t\t!\tfoo"); # prints "3" but only has two lea
    +ding tabs!
    
  2. or download this
    my $numberofLeadingTabs = 0;
    if ($data =~ /^(\t+)/) {
        my $tabs = $1;
        $numberofLeadingTabs = length $tabs;
    };