Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
@rem = '--*-Perl-*-- @pushd . @pushd > "%TEMP%\editd.txt" @if defined VISUAL call "%VISUAL%" "%TEMP%\editd.txt" @if not defined VISUAL notepad "%TEMP%\editd.txt" @echo - >> "%~f0" @pushd >> "%~f0" @popd @perl -x "%~f0" "%TEMP%\editd.txt" @if NOT "%OS%" == "Windows_NT" goto endofperl @if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl @if %errorlevel% == 9009 echo You do not have Perl in your PATH. @if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul @goto endofperl @rem '; #!/usr/bin/perl -w #line 17 use strict; main( @ARGV ); exit( 0 ); sub main { my( $file )= @_; my $start= tell(DATA) or die "Can't tell(DATA): $!"; open DATA, "+< $0" or die "Can't read self ($0): $!\n"; seek( DATA, $start, 0 ) or die "Can't fseek(DATA,$start,0): $!"; die "Expected :endofperl after __END__ of $0.\n" unless <DATA> =~ /^\s*:endofperl\s*$/i; $start= tell(DATA) or die "Can't tell(DATA): $!"; my @curr; while( <DATA> ) { if( /^\s*-\s*$/ ) { @curr= (); } else { chomp; unshift @curr, $_; } } open USER, "< $file" or die "Can't read $file: $!\n"; my @user= reverse <USER>; chomp @user; close USER; while( @curr && @user && $curr[0] eq $user[0] ) { shift @curr; shift @user; } seek( DATA, $start, 0 ) or die "Can't fseek(DATA,$start,0): $!"; for( @curr ) { print DATA "popd\n"; } for my $dir ( @user ) { print DATA qq{pushd "$dir"\n}; } print DATA "pushd\n"; truncate DATA, tell(DATA); } __END__ :endofperl

In reply to editd by tye

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others imbibing at the Monastery: (2)
    As of 2018-05-27 20:36 GMT
    Find Nodes?
      Voting Booth?