What you want to do seems unusual to me: in my experience, one normally reads a file into a string or an array. Most problems can be fully solved with either a string representation or an array one -- which representation is more appropriate depends on the problem. Also, it is easy to slurp the whole file into a string, then convert into an array of lines; for example:
open(my $fh, '<', 'input') or die "open input: $!"; # Slurp file contents into a string. my $contents = do { local $/; <$fh> }; # Convert into an array. my @lines = split /^/, $contents;
Can you describe what you are trying to achieve? Then we might be able to suggest solutions using either a string or an array (rather than both).
In reply to Re: Input to String OR Array
by eyepopslikeamosquito
in thread Input to String OR Array
by jriggs420
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |