in reply to Re: Re: Perl Gotchas. (if( condition) { bug })
in thread Perl Gotchas.

cat -n is where it's at.

Replies are listed 'Best First'.
Re: Re: Re: Re: Perl Gotchas. (if( condition) { bug })
by EvdB (Deacon) on Nov 20, 2003 at 19:05 UTC
    Frustrating if you want to copy and then run the code though.

    I tried tac -n to undo it but it didn't work... :-)

    --tidiness is the memory loss of environmental mnemonics

      Huh? Just run cat -n and copy the results that are printed in your terminal or redirect to a temp file: cat -n foo.pl > foo.pl.numbered

      Don't change the file itself. But for the record, i stopped using line numbers when i stopped programming in BASIC. If i need to provide line numbers as an example, i just comment the relevant lines ... not the whole darned script. ;)

      UPDATE:
      I see now ... you mean to remove the line numbers after the fact - as in i copy your code above and try to run it without having to manually remove the line numbers. How about:
      perl -pe"s/^\s+\d+\t//" foo.numbered > foo.pl
      Don'cha just love Perl. :)

      jeffa

      L-LL-L--L-LL-L--L-LL-L--
      -R--R-RR-R--R-RR-R--R-RR
      B--B--B--B--B--B--B--B--
      H---H---H---H---H---H---
      (the triplet paradiddle with high-hat)
      
        tac does the same thing as cat, just backwards - so to undo cat -n ...

        Obviously the line numbers...

        Oh, this is ridiculous, I'm going for a beer. Where's a weekend when you need one? :-)

        --tidiness is the memory loss of environmental mnemonics

Re^4: Perl Gotchas. (if( condition) { bug })
by Aristotle (Chancellor) on Nov 21, 2003 at 15:01 UTC
    Didn't even know that one. Been using nl myself.

    Makeshifts last the longest.