david wrote:

>the chop(EXP) function always remove the last character (or byte if you are 
>dealing with ASCII test only) from the applied EXP or $_ if EXP is omitted.
>it doesn't care what that character is. it's true that if you happen to have 
>a single space at the end of your string, chop will remove it for you, but 
>if you have many spaces at the end, only one will be removed.
>
>the chomp(EXP) function remove the last character from EXP(or $_) only if 
>that character is a newline for your OS. chomp() knows what newline your OS 
>uses so you don't have to worry about it. again, chomp doesn't remove 
>spaces(unless you happen to treat newline and space is the same).
>
>to trim spaces, try:
>
>$line ="\t\t    abcd\t  \t\n";
>$line =~ /^\s+//;
>$line =~ /\s+$//; #-- also remove \n
>print "|$line|"; #-- prints |abcd| without leading or tailing spaces
>
>__END__
>  
>
Humm... Ok, I see. It looks like I have to get a better understanding of 
using regular expressions.

>also, i notice that you use 'outfile' as one of your open file handle. using 
>all lower case is not recommanded because Perl names all of it's functions 
>using lower case. what happen if later version of Perl happen to have a 
>function call 'outfile'? what will the following do then:
>
>print outfile "hi";
>
>prints hi to file handle outfile?
>or
>prints whatever outfile() return to STDOUT?
>
>if you have warning enable like '-w' (which i think you should), Perl will 
>warn you about using all lower case for file handle.
>
>david
>
Ok Noted and will do

Thanks to everyone who responded.
 
It looks like Ill do something like this in the future

from perldoc -q strip blank space

            # trim whitespace in the scalar, the array,
                # and all the values in the hash
                foreach ($scalar, @array, @hash{keys %hash}) {
                    s/^\s+//;
                    s/\s+$//;
                }

I just diddnt think it would/should be this... exotic
Im used to TRIM LTRIM RTRIM....
<sigh>

Thanks again to everyone for their explanations
rob

-- 
   You will find it a distinct help if you know and look as if you know what you are 
doing. -- IRS Training Manual for tax auditors




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

Reply via email to