in reply to Sorting and subsituting a data file, one pass

my %seen; while (<>) { if (s/\\\n\z/ /) { my $next = <>; if (defined($next)) { if ($next =~ /^\s*-end\s/) { $_ .= $next; } elsif ($next =~ /(\\\n)\z/) { $_ .= "\\\n"; } else { $_ .= "\n"; } redo; } } print if /^data\s/ && !$seen{$_}++; }

Replies are listed 'Best First'.
Re^2: Sorting and subsituting a data file, one pass
by tsk1979 (Scribe) on Jun 21, 2010 at 09:38 UTC
    This should be the solution. But I am stumped at <>. Won't this stop for user input at every stage?
      Only if you don't pass filenames, or redirect a file
      $ perl myprogram.pl file1 file2 file3 $ myprogram.pl < file4