Walt Mankowski via plug on 6 May 2023 06:36:15 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] take-your-bash-scripting-seriously


On Sat, May 6, 2023, at 1:05 AM, Steve Litt via plug wrote:
Walt Mankowski via plug said on Fri, 5 May 2023 22:28:36 -0400

>On Fri, May 05, 2023 at 08:55:46PM -0400, Steve Litt via plug wrote:
>> On scripts vs programs. I've always maintained that if you tell a
>> computer what to do in the future, you're programming. Whether it's
>> 100K lines of C or 2 lines of /bin/sh, if it's non-interactive and
>> more than one command, it's programming. If you write a Word macro,
>> it's programming.  
>
>Wait, does this mean all my Perl one-liners aren't programs?

If I had to take a stand on this I'd say they're programs. If a
distinction needs to be made, I spoze they could be called one-liners.

Yesterday I had was working with a file that had paths to about 700 files. The files had moved, so I needed to change the paths from /a/b/c/d to a/x/y/d. This is really easy to do in a Perl one-liner:

perl -pe ‘s(b/c)(x/y)’

The only reason that’s one line is that the -p flag is wrapping a loop around it that reads from stdin and runs a regex on every line. If I had to write it all out, it would look something like this:

while (<>) {
    s(b/c)(x/y);
    print;
}

It seems like a real program to me!

>> I hear people who can work miracles with Perl claim "I'm not a
>> programmer!" Nonsense. What, if they converted their script to C all
>> of a sudden it would be a program?  
>
>I don't hear many people claim that. Of course, these days it's hard
>to find people who'll even admit that they're Perl programmers! :)

I hear a lot of people claim that. And if you'd ask them, they'd
probably say they're not Perl programmers, they just use it for admin.

I just don't see the need for the distinction at all.

That’s just a matter of semantics. I occasionally need to do system admin tasks on my Linux boxes, but I don’t consider myself an admin. On the other hand, when I was working on my dissertation I was trying to think of myself as a “writer” and not just “a programmer/researcher who writes”. I suppose it doesn’t really matter much either way.

Walt
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug