Steve Litt via plug on 6 May 2023 21:05:42 -0700 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: [PLUG] take-your-bash-scripting-seriously |
Walt Mankowski via plug said on Sat, 06 May 2023 09:35:48 -0400 >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: > > > >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! `perl -pe ‘s(b/c)(x/y)’` Xactly! SteveT Steve Litt Autumn 2022 featured book: Thriving in Tough Times http://www.troubleshooters.com/bookstore/thrive.htm ___________________________________________________________________________ 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