Re: Another sub clean up

2003-10-15 Thread John W. Krahn
Sudarshan Raghavan wrote: > > Sudarshan Raghavan wrote: > > > > ($ref_to eq 'ARRAY') && do { > > foreach my $arr_elem (@{$_}) { > > $arr_elem =~ s/^\s+//; > > $arr_elem =~ s/\s+$//; > > } > > last S

Re: Another sub clean up

2003-10-15 Thread Rob Dixon
<[EMAIL PROTECTED]> wrote: > > Can someone hlpe me clean up this trim? > > Rule: remove all trailing blanks and newline/LF > > Do I need a chomp here somewhere? > > sub trim > { my $z = $_[0]; > > $z =~ s/^\s+//; > $z =~ s/\s+$//; > > return $z; > } Do you mean /leading/ and trailing, which

Re: Another sub clean up

2003-10-15 Thread perl
> On Tue, 14 Oct 2003 19:26:50 -0700, perl wrote: >> Can someone hlpe me clean up this trim? > > What do you actually mean by "clean up"? Make the code shorter and, > maybe, more obfuscated? Why? -- - more shorter - Yes - more obfuscated - hhmm... nice to know shortcut -- > >>

Re: Another sub clean up

2003-10-15 Thread Tore Aursand
On Tue, 14 Oct 2003 19:26:50 -0700, perl wrote: > Can someone hlpe me clean up this trim? What do you actually mean by "clean up"? Make the code shorter and, maybe, more obfuscated? Why? > Rule: remove all trailing blanks and newline/LF sub trim { my $string = shift; chomp( $str

Re: Another sub clean up

2003-10-14 Thread Sudarshan Raghavan
Sudarshan Raghavan wrote: > simran wrote: > > > I wrote my self this subroutine... which comes in very handy :-) > > > > ..snip > > > > sub strip { > > my $self = shift; > > my $ref = shift; > > > > if (! ref($ref)) { > > $ref =~ s/(^[\s\t]*)|([\s\t]*$)//g if (defined $ref); > > Why is

Re: Another sub clean up

2003-10-14 Thread Sudarshan Raghavan
simran wrote: > I wrote my self this subroutine... which comes in very handy :-) > > ..snip > > sub strip { > my $self = shift; > my $ref = shift; > > if (! ref($ref)) { > $ref =~ s/(^[\s\t]*)|([\s\t]*$)//g if (defined $ref); Why is it better to do this in two steps? Read through this

Re: Another sub clean up

2003-10-14 Thread simran
I wrote my self this subroutine... which comes in very handy :-) # # strip # =head2 strip =over =item Description Strips out leading and training whitespaces from references... =item Input * Reference to an array, hash or string or A string =item Return * If input was a refer

Re: Another sub clean up

2003-10-14 Thread Sudarshan Raghavan
[EMAIL PROTECTED] wrote: > Can someone hlpe me clean up this trim? > > Rule: remove all trailing blanks and newline/LF perldoc -q 'How do I strip blank space from the beginning/end of a string' > > > Do I need a chomp here somewhere? No, the \s+ will take care of that > > > sub trim > { my $

Another sub clean up

2003-10-14 Thread perl
Can someone hlpe me clean up this trim? Rule: remove all trailing blanks and newline/LF Do I need a chomp here somewhere? sub trim { my $z = $_[0]; $z =~ s/^\s+//; $z =~ s/\s+$//; return $z; } thanks, -rkl - eMail solutions by http://www.swanma