Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Remove whitespace between lines

by sundialsvc4 (Abbot)
on Feb 03, 2015 at 17:31 UTC ( [id://1115417]=note: print w/replies, xml ) Need Help??


in reply to Remove whitespace between lines

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^2: Remove whitespace between lines
by Laurent_R (Canon) on Feb 03, 2015 at 22:36 UTC
    Hmm, sorry, but your answer is off-topic. The OP is writing a Perl script for achieving a given result, and your answer is: "Don't do it! Use grep!" But the code presented by the OP is not just trying to grep one file. It is looking for files in a directory, modifying these files and writing output in other files in another directory. It seems a bit difficult to do all this with a simple grep or even a awk one-liner. Of course, you could wrap the grep or the awk one-liner in a bash or sh or ksh script, but then the "no programming argument" is gone, you might as well do it in Perl, and it is likely to be more efficient in Perl.

    But there is an even more important factor: a Perl script, if well designed, is portable across different platforms. Even though the script shown by the OP has an (admittedly strange) "#! /usr/bin/perl -w" shebang line, the rest of the script seems to strongly indicate the OP is running her or his script under MS Windows, probably with Strawberry Perl. I pray you: how are you going to run a grep or a awk one-liner script under Windows (unless you are using Cygwin, but the OP does not seem to be doing that)? (Well, awk may probably have been ported under Windows, I do not know, but by far most Windows users don't have it.)

    Je suis Charlie.

      FYI, FWIW, several versions of awk have been ported to MS Windows. Until a few years ago, I used a version that was packaged along with make and a few other Unix tools as part of code generation application we use with many of our projects. We used the make and the awk from that package in our build scripts because everyone in the SW department had the package installed. Now we use Perl instead of awk (but still use make).

        Yes, thank you for the information, RonW. As I said in my previous post, I suspected that awk had been ported to Windows, but it is probably not commonly available (in the sense that it is not natively there on a fresh Windows install, so that most users probably don't have it). OTOH, the OP has Perl installed, and Perl is able to do just about everything that awk can do (and much more), so that recommending awk did not make much sense in that specific case.

        Je suis Charlie.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (9)
As of 2024-04-18 07:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found