Video-Dumper-QuickTime

 view release on metacpan or  search on metacpan

samples/DumpQuickTime.pl  view on Meta::CPAN

my $currIndent    = '';
my $indentStr     = $file->IndentStr ();

push @pathStack, 0;

for my $line ( split "\n", $str ) {
    chomp $line;
    next if length($line) == 0;    # Skip blank lines

    my ( $newIndent, $nodeText ) = $line =~ /^((?:\Q$indentStr\E)*)(.*)/;

    while ( length($newIndent) > length($currIndent) ) {
        # new project
        push @pathStack, 0;
        $currIndent .= $indentStr;
    }

    while ( length($newIndent) < length($currIndent) ) {
        # new project
        pop @pathStack;
        substr $currIndent, 0, length $indentStr, '';
    }

    $pathStack[-1]++;
    $maxNesting = @pathStack if $maxNesting < @pathStack;
    my $currPath = join "/", @pathStack;
    $tree->add( $currPath, -text => $nodeText, -state => 'normal' );

    ++$totalLines;
    $maxLineLenght = length($nodeText)
      if length($nodeText) > $maxLineLenght;
}

$totalLines    = 40  if $totalLines > 40;
$totalLines    = 10  if $totalLines < 10;
$maxLineLenght = 120 if $maxLineLenght > 130;
$maxLineLenght = 80  if $maxLineLenght < 80;
$main->geometry( ( $maxLineLenght + $maxNesting * 4 ) * 5 . 'x'
      . ( 40 + $totalLines * 20 ) );
closeTree( $tree, '' );

MainLoop;

sub showProgress {
    my ( $pos, $total ) = @_;
    my $progress = 100 * $pos / $total;

    $progressBar->value($progress);
    $main->update();
}

sub copyItemText {
    my $path = shift;
    my $text = $tree->itemCget( $path, 0, '-text' );

    $tree->Busy( -recurse => 1 );
    if ( $tree->info( children => $path ) ) {
        openTree( $tree, $path, 1 );
    }
    else {
        $tree->clipboardClear ();
        $tree->clipboardAppend ($text);
    }

    $tree->Unbusy();
}

sub openTree {
    my $tree = shift;
    my ( $entryPath, $openChildren ) = @_;
    my @children = $tree->info( children => $entryPath );

    return if !@children;

    for (@children) {
        openTree( $tree, $_, 1 );
        $tree->show( 'entry' => $_ ) if $openChildren;
    }
    $tree->setmode( $entryPath, 'close' ) if length $entryPath;
}

sub closeTree {
    my $tree = shift;
    my ( $entryPath, $hideChildren ) = @_;
    my @children = $tree->info( children => $entryPath );

    return if !@children;

    for (@children) {
        closeTree( $tree, $_, 1 );
        $tree->hide( 'entry' => $_ ) if $hideChildren;
    }
    $tree->setmode( $entryPath, 'open' ) if length $entryPath;
}



( run in 4.531 seconds using v1.01-cache-2.11-cpan-84e82930d8c )