Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Starting a New Script

by shmem (Chancellor)
on Sep 16, 2016 at 21:55 UTC ( [id://1171967]=note: print w/replies, xml ) Need Help??


in reply to Starting a New Script

Would this be of interest to anybody? If so, I will make it freely available.

Of course yes, people might learn, the tool might spawn discussions which probably will generate further enlightenment. I guess the appropriate place to publish such a thing would be Cool Uses for Perl.

How do I start a new script? Well, depends. If it is a straight forward task, I start with a blank page and type along. If the thing at hand requires new modules I'm not familiar with, I usually fire up my own enhanced version of perlsh included in Term::ReadLine::Gnu which writes a history file, fool around with that upon the modules in question until the bits are in place, and then I'll copy the good parts from the history into my new script editors buffer. No, not cut&paste. Two terminals aligned side by side, the left one holding the new script in vi, the right one paging the perlsh history with line numbers (less -N on Linux/Cygwin). Copying from right to left is done with

:r ! l 42-64,96,14 .perlsh_history

and $HOME/bin/l reads as follows:

#!/usr/bin/perl -n BEGIN { $spec=shift; @l=split/,/,$spec; for(@l){ ($s,$e)=split/-/; $e||=$s; $_=[$s,$e]; } } CHECK { unless(@ARGV) { push @ARGV, <DATA>; chomp @ARGV; } die "usage: $0 linespec file\n" unless @ARGV; $file = $ARGV[0]; } # === loop ==== for $l(@l){ print if $.>=$l->[0] and $.<=$l->[1] } # === end === # END { if ($file) { open $fh,'<', $0; @lines = <$fh>; close $fh; open $fh,'>',$0; for(@lines){ print $fh $_; last if /^__DATA__$/; } print $fh $file,"\n"; } } __DATA__

which code isn't posted to Cool Uses for Perl yet...

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

Replies are listed 'Best First'.
Re^2: Starting a New Script
by stevieb (Canon) on Sep 17, 2016 at 00:05 UTC
    "which code isn't posted to Cool Uses for Perl yet... "

    Perhaps it should be ;)

    ++ OP, for bringing up a conversation about tips and tricks that isn't necessarily editor specific. Although there are use-cases for editors, I like that this is general.

    I think anyone should post their Perl quick-tips here for instantiation of a new file/project. Most of us likely have many, that are hidden away somewhere.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2024-04-24 09:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found