in reply to perlapp, die, and __DATA__

I wanted to let you know that __DATA__ doesn't work in Tinyperl either. Your code isn't broke... You can create a data file and load it into your app, or just roll your own array to simulate __DATA__ like so...
my @DATA; my @data = q( testing 1 testing 2 testing 3 ); for (@data) { push @DATA, split /\n/; } $DATA[$_].="\n" for 0..$#DATA; for(@DATA){ chomp; print; }

it's all about preference :) Lot of ways to do the same thing.. James

Replies are listed 'Best First'.
Re: Re: perlapp, die, and __DATA__
by integral (Hermit) on Apr 25, 2003 at 10:47 UTC

    Or since @DATA isn't needed as an array this would be sufficient:

    my $data = q{ line 1 line 2 line 3 }; # OR $data = <<'END'; line 1 line 2 line 3 END # to ensure a terminating newline # chomp $data; $data .= $/ print "$data";

    This is as usual another way to write the first suggestion (where @data should be $data too):

    @DATA = map "$_\n", split /\n/, $data; # but why add \n when you chomp + later?

    --
    integral, resident of freenode's #perl