1 2 3 4 5 6 7 8 9 10 11 12 13 14
#! /usr/bin/perl use strict; use warnings; use Tie::File; my $file = 'data.txt'; tie my @file, 'Tie::File', $file or die "tie '$file' failed.\n"; while ( defined $file[-1] && $file[-1] !~ m/\{$/ ) { pop @file; } untie @file;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#!/usr/bin/perl use strict; use warnings; my @data = reverse <DATA>; my $notfound = 1; while ($notfound) { $data[0] =~ /\{/ and $notfound = 0 and last; shift @data if $notfound; } @data = reverse @data; __DATA__ 12 i0 { xo 46 { 28 98
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
use strict; use warnings; my @data = <DATA>; my $cutpos = (map {$data[$_] eq "{\n" ? $_ : ()} 0 .. $#data)[-1]; defined $cutpos or die "Keine Klammer in der Datei\n"; $#data = $cutpos - 1; print @data; __DATA__ 12 i0 { xo 46 { 28 98