#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    74
    Rep Power
    11

    Reading __DATA__ section


    Hi guys:
    I was just wondering how do I read the inline __DATA__ section in perl, without using SelfLoader

    I tried using <main:ATA> which worked on another program on another server, but when i use it on this one it gives me "readline() on unopened filehandle DATA". Help! I think this should be just a syntax thing that I don't know about....

    Thanks guys!
  2. #2
  3. Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Oct 2004
    Location
    Sunny Southern California
    Posts
    2,687
    Rep Power
    861
    Code:
    #!perl
    #one way
    while(<DATA>){
       print;
    }
    
    #another way
    @array = <DATA>;
    print "@array";
    
    
    __DATA__
    this is the data
    this is the data
    this is the data
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    74
    Rep Power
    11
    Thanks for the reply!!! Unfortuantely using <DATA> gave me a no such file handle error....

    Originally Posted by KevinADC
    Code:
    #!perl
    #one way
    while(<DATA>){
       print;
    }
    
    #another way
    @array = <DATA>;
    print "@array";
    
    
    __DATA__
    this is the data
    this is the data
    this is the data
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    74
    Rep Power
    11
    Ah... it seems like I couldn't read from __DATA__ is because I included the Switch class.......

IMN logo majestic logo threadwatch logo seochat tools logo