Less example data would have been better, less scrolling to do ;-)
Also please use 'use warnings' and 'use strict'
One error I can see is in this line: @storage = $second_num; In short, the line does nothing sensible, even prevents the array from getting filled and should be removed completely.
Another problem: my ($first, $second) = split(/^\s{1}/, $organized); Using '^' in a split would only make sense if you wanted to split a file into separate lines (you also would need the regex-modifier m). But since you want to split one line, '^' makes this line simply a no-op. Also "\s{1}" is identical to "\s". So you could just write "split(/\s/, ..."
@final_storage seems superfluous, but in case you need it, copying the array would be as easy as @final_storage= @storage;
Finally, all this stuff you are doing step by step could be done by a simple regex if it is guaranteed that all elements except the first one have a space before them:
while (my $organized = <DATA2>) { $organized=~s/(\s)\w+/$1z/g; print $organized; }
UPDATE: Thanks to jwkrahn for noticing that \s in the replacement isn't really working. Changed to use parentheses and $1
In reply to Re: regular expessions question: (replacing words)
by jethro
in thread regular expessions question: (replacing words)
by $new_guy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |