in reply to chomp any data structure recursively
Here's a non-recursive version:
sub mychomp { while (@_) { eval { chomp $_[0] }, shift, next unless ref; (push @_, @{shift @_}), next if ref $_[0] eq 'ARRAY'; (push @_, values %{shift @_}), next if ref $_[0] eq 'HASH'; shift; } }
-- Randal L. Schwartz, Perl hacker
Also, I didn't see the unusual multi-line backwards-for in the original code, so it appears to be less buggy than I thought. {sigh}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: chomp any data structure recursively
by runrig (Abbot) on Dec 21, 2001 at 01:51 UTC | |
|
Re: Re: chomp any data structure recursively
by Anonymous Monk on Dec 21, 2001 at 01:50 UTC | |
|
Re: Re: chomp any data structure recursively
by Juerd (Abbot) on Dec 21, 2001 at 01:41 UTC | |
by merlyn (Sage) on Dec 21, 2001 at 01:45 UTC | |
by Juerd (Abbot) on Dec 21, 2001 at 01:48 UTC | |
by merlyn (Sage) on Dec 21, 2001 at 01:55 UTC | |
|
Re: Re: chomp any data structure recursively
by Anonymous Monk on Dec 21, 2001 at 02:35 UTC | |
by runrig (Abbot) on Dec 21, 2001 at 03:00 UTC |