Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: .vimrc for perl programmers

by tinita (Parson)
on Mar 30, 2006 at 14:24 UTC ( [id://540175]=note: print w/replies, xml ) Need Help??


in reply to .vimrc for perl programmers

  • :imap dumper <ESC>^iwarn Data::Dumper->Dump([\<ESC>llyw$a], ['<ESC>pa']);<ESC>
    lets you type '@myarraydumper' and you'll get 'warn Data::Dumper->Dump([\@myarray], ['myarray']);
  • map ß O#!/usr/local/bin/perl<CR><ESC>iuse strict;<CR><ESC>iuse warnings;<CR>
  • (un)comment: (update: this also works in visual mode. just select the block and type §1)
    map §1 :s/^/# /<CR> map §2 :s/^# //<CR>

Replies are listed 'Best First'.
Re^2: .vimrc for perl programmers
by demerphq (Chancellor) on Mar 30, 2006 at 17:58 UTC

    Youll get more accurate results on self referential structures by using

    warn Data::Dumper->Dump(sub{\@_}->(\@myarray), ['myarray'])

    it doesnt make that much difference when the example is an array, but when its a scalar it does make a lot of difference.

    Alternatively install Data::Dump::Streamer and get prettier, easier to read and more accurate dumps outright.

    Yes, this is a shameless plug. :-)

    ---
    $world=~s/war/peace/g

      can you provide an example where this (undocumented?) syntax makes a difference?

        Looks like its been superficially improved so there is no difference anymore, which is good. But the output is still wrong, which is bad. For $x=\$y; $y=\$x; the raw call to Data::Dumper->Dump([$x,$y]) used to produce:

        $VAR1 = [ \\$VAR1->[0], ${$VAR1->[0]} ];

        But now it produces what Data::Dumper::Dumper (and what the sub{\@_} trick does) produce:

        $VAR1 = \\$VAR1; $VAR2 = ${$VAR1};

        Wheras Data::Dump::Streamer::Dump produces the correct output:

        $REF1 = \$REF2; $REF2 = \$REF1;

        Hope that explains things.

        ---
        $world=~s/war/peace/g

Re^2: .vimrc for perl programmers
by cees (Curate) on Mar 30, 2006 at 21:53 UTC

    For commenting and uncommenting code (in perl and many other languages) have a look at the BlockComment plugin.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://540175]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-12-09 03:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which IDE have you been most impressed by?













    Results (53 votes). Check out past polls.