ejdpop has asked for the wisdom of the Perl Monks concerning the following question:

I want to read some lines of text into a Perl array, directly from the source, and then spit it out as user help. There is a way to do this, but I've forgotten it. Something like


read down to /xxx ... /xxx

PS: HTML, like a newborn baby gorilla, sucks and is truly ugly!

Replies are listed 'Best First'.
Re: Input from source
by kcott (Archbishop) on Jul 05, 2013 at 05:02 UTC

    G'day ejdpop,

    Welcome to the monastery.

    That's the range (aka flip-flop) operator. See perlop - Range Operators. Note the two forms: .. and ...

    -- Ken

Re: Input from source
by CountZero (Bishop) on Jul 05, 2013 at 05:47 UTC
    Perhaps you mean something like:
    my @array = <$FILEHANDLE>;
    It will slurp the whole sourcefile directly into the array.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

    My blog: Imperial Deltronics
Re: Input from source
by hdb (Monsignor) on Jul 05, 2013 at 07:08 UTC
Re: Input from source
by sahil2588 (Novice) on Jul 05, 2013 at 08:06 UTC

    you can directly open the file using some filehandler and parse it accordingly. below is the snippet

    open (IN,"file.txt") or die ("Blah Blah"); while (<IN>){ Blah Blah Blah }
    Thats it!!! :)