Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I am trying to write a simple script that I could use while editting files with vi. One of the things I like about vi is that you can do things like :1,$ !program. Here's a demostration of what I want to be able to do ...
bash-2.05b$ vi junk NOTES doc backup notes scripts cpio_out bashrc ~ ~ ~ :1,$ !sort backup bashrc cpio_out doc notes NOTES scripts :wq
In the above example I used sort to modify my file. I want to be able to do this with this script ...
bash-2.05b$ cat twc #!/usr/bin/perl -w use strict; my $file = shift; if ( !defined( $file ) ) { print "usage: $0 <dir|file>\n"; exit 0; } if ( ! -e $file ) { print "#$file\n"; } else { print "$file\n"; }
... but when I do something like this ...
bash-2.05b$ vi junk backup bashrc cpio_out doc notes NOTES scripts ~ ~ ~ :1,$ !./twc
... I get this ...
usage: ./twc <dir|file>
How should I be handling the input in my Perl script?

Plankton: 1% Evil, 99% Hot Gas.

In reply to making my script work with vi by Plankton

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2024-04-19 15:22 GMT
Find Nodes?
    Voting Booth?

    No recent polls found