The DATA Filehandle: get the data from the same script : DATA « String « Perl






The DATA Filehandle: get the data from the same script

    

#while(<DATA>){
#    Do something with the data here
#}
#__DATA__
#    The actual data


#Or you could use the $_ explicitly

#while($_=<DATA>){
#    Do something with the data here
#}
#__DATA__
#    The actual data


#Or use another variable instead of $_ as follows:

#while($inputline=<DATA>){
#    Do something with the data here
#}
#__DATA__
#    The actual data

while(<DATA>){
     print if /A/;     # Print the line if it matches A
}
__DATA__
    A
    B
    I
    N
    J
    K

   
    
    
    
  








Related examples in the same category