SPUG: Reading a whole file into a scalar.

John W. Krahn krahnj at telus.net
Wed Jul 20 20:04:16 PDT 2005

Duane Blanchard wrote:
> Hi gang,
> I'm too tired to think straight and too tired to keep looking on the
> 'Net. I want to match things like 'line\s+that' in the example file
> below.
> <file>
> this is a line
> that is a line
> </file>
> What has worn me out today is not realizing that I'll never match
> across lines of a file if I only read one line at a time. So, I either
> need a clever way to match across elements of an array or hash table,
> or (more likely) to read the whole file into a scalar. As I recall,
> I'll use the 'm' flag to hand the RE more than one line, and '\s'
> should handle '\n'.
> Someone, please give a little pointer. Thanks,

perldoc -q "How can I read in an entire file all at once"


More information about the spug-list mailing list