Suppose you have this input:
line1 line2 line3 line4 line5
And the following code:
#!/usr/bin/perl my $file = shift; local( $/, *INPUT ); open(INPUT, $file); $input = <INPUT>; print $input;
Is there a way to transform that $input scalar into an array? I realize that local( $/, *INPUT ); gets rid of the new lines. I also don't have any special separators in my actual input (my "real" input is a lot like this "fake" input, except that its MIME encoded, and I decode it using MIME::QuotedPrint::Perl. Which by the way, is why I'm doing local( $/, *INPUT ); in the first place.. I have to read the whole MIME-encoded file into a scalar to decode it. Can't read it in line by line because of that. :/ )
I just want to iterate through $input line by line and do something with each..so, somehow, I need to turn it into an array :)
Any thoughts/suggestions/solutions welcome!
In reply to Transforming a scalar to an array by vxp
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |