in reply to Re^10: let Makefile.PL to do the Readme file for me -- new target?
in thread let Makefile.PL to do the Readme file for me -- new target?

Interesting history lesson. Sorry I have no first-hand experience to offer (apart from .BAT being the worst (by far) programming language I've ever used ;-) ... but I've noticed that all the Windows guys at work seem to have completely abandoned .BAT for PowerShell. Anyone know if the Windows Perl world is similarly replacing .BAT with PowerShell?

  • Comment on Re^11: let Makefile.PL to do the Readme file for me -- new target?

Replies are listed 'Best First'.
Re^12: let Makefile.PL to do the Readme file for me -- new target? (Powershell)
by LanX (Saint) on Jan 21, 2021 at 19:33 UTC
    PowerShell is a very interesting and powerful language, which also borrowed many aspects from Perl and some from Haskell.
    • Interesting b/c instead of piping text, they are piping objects (in the first draft the language was named "Monad")
    • Powerfull because these object have deep access into the OS and .NET-framework.
    <update> Example:
    • if you do ls PATTERN | grep PATTERN in bash, you are piping a list of lines and you'll end in regexing relevant fields like file-size.
    • In PS you'll transport a list of objects , e.g. the file-size is just an attribute of one of the file-objects
    </update>

    But in my experience it's not an intuitive DWIM hack like bash, mainly because the syntax is lengthy with "Verb-Noun Thing -options" structure

    Example: To tail in PS you need Get-Content PATH.txt -Tail 10

    They try to compensate this "wordy" structure with aliases for common commands like:

    Standard Aliases for Get-Content: cat, type, gc

    Though it still doesn't feel like CLI scripting (to me)

    BUT: For many things PS is the only viable alternative.

    My current strategy is to write Perl wrappers shelling out to PS.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

      PowerShell is a very interesting and powerful language, which also borrowed many aspects from Perl and some from Haskell.

      I never worked with PowerShell, except for casting a few magic spells copied from Google results to make Windows behave.

      • Interesting b/c instead of piping text, they are piping objects (in the first draft the language was named "Monad")
      • Powerfull because these object have deep access into the OS and .NET-framework.

      That should allow doing interesting things WITHIN the PowerShell/.NET walled garden. As long as you can use those objects, everything should be fine (except for bugs). But what about Unix-style interactions with other programs? Piping objects arounds surely is a powerful concept, but can I stuff binary data from STDOUT of tool A into a pipe, then filter it through B, C, D, and finally have E process the result of filtering? (In other words, what's the equivalent of a bash on Unix doing A -foo -bar | B -bla bla | C --what=ever | D ./magic ./stuff  | E +gnarf)

      What about networking? I often do things like this:

      tar -C /some/where -cf - subtree | ssh root@embedded.system tar -C /else/where -xvf - > copied.txt 2> problems.txt

      (Create a tar archive of subtree in /some/where and write to STDOUT, have ssh pass that byte stream to another tar instance running as root on embedded.system as STDIN, make that second tar extract the archive to /else/where, write STDOUT of the second tar to copied.txt on the local system, and STDERR to problems.txt on the local system.)

      What about quoting? Quoting the two redirections in the previous command would write STDOUT and STDERR of the second tar to embedded.system, because ssh implicitly invokes a shell on embedded.system:

      tar -C /some/where -cf - subtree | ssh root@embedded.system tar -C /else/where -xvf - '>' copied.txt '2>' problems.txt

      How to pass things like ", ', <, >, | as arguments? On Unix:

      echo '"' "'" \< ">" "|"

      Expanding variables, and passing parameters that just look like variable expansions?

      echo '$PATH' "expands to \"$PATH\""

      Alexander

      --
      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
        Well... Tell me! :)

        With the exception of ssh all of this should be possible, Win has another approach here.

        update

        Looks like win10 comes with a ssh server. Haven't used it yet.

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery

      In PS you'll transport a list of objects , e.g. the file-size is just an attribute of one of the file-objects 

      that's interesting, I was not aware. Actually it sounds impressive but in reality is nothing more than a unix-like pipe communication passing a text-json-pojo-whatever or, as easily, binary-data to, e.g., represent serialized objects. Both can be and are achieved in unix. Text-pipes we are all aware of and for binary: an example is imagemagick's piping of binary images to its various converter-executables.

      This however poses some more interesting questions: for example are these objects allowed to have pointers to other objects? Surely there is inter-linkage. For example a file object with pointers to the object of its user-owner which in turn will have pointers to history-object and preferences-object and a myriad of other details? Often saucy and often remotely stored? Oh that's lovely, I can suck the whole M$-big-brother-brain with just an ls. and God said let there be ls. I can imagine that with just an ls I can suck each and every digital record ever existed.

      Further, when do these objects expire/die/cleared from memory? It seems that there is a gargantuan garbage collector larking at the bowels of the OS? And is very busy indeed. With each innocent find c:/*.*|grep which could potentially copy the whole hard-disk's contents into RAM and then back to disk-swap to feed back find. Here's a nice blue screen of death right there.

      Anyway, some thoughts. now, begin-trolling:

      Nah... M$ is thoughtless crap (disclaimer: If trump was voted in as USA president then I am allowed an aphorism for each of them votes).

      end-trolling

      bw, bliako

        > for example are these objects allowed to have pointers to other objects?

        yes, a little demo

        PS C:\tmp> ls tst # stringific +ation of list of objects Verzeichnis: C:\tmp Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 22.01.2021 01:23 12 tst PS C:\tmp> (ls tst).GetAccessControl().Owner # get Access + Obj and get owner COM\RolfLanX PS C:\tmp> $x=ls tst # save obj i +n var PS C:\tmp> $x.length 6 PS C:\tmp> cat tst PS C:\tmp> echo "blabla" >tst # change con +tent PS C:\tmp> $x.length # old length 6 PS C:\tmp> (ls tst).length # new length 18

        I also already found a caveat

        PS C:\tmp> (ls tst*).name # name for each list element tst tst.pl tst.txt tst_flushing.pl tst_flushing.pl~ tst_onclick.html tst_onclick.html~ tst_pde.pl tst_pde.pm tst_pde.pm~ PS C:\tmp> (ls tst*).length # length of list not list elements 10

        NB: The "cmdlet" Get-ChiltItem (aka ls) can list very different types of objects, not only filesystem.

        PS C:\tmp> ls -Path HKLM:\HARDWARE Hive: HKEY_LOCAL_MACHINE\HARDWARE Name Property ---- -------- ACPI DESCRIPTION DEVICEMAP RESOURCEMAP UEFI PS C:\tmp> cd -Path HKLM:\HARDWARE # cd into registry PS HKLM:\HARDWARE> ls -name # list names ACPI DESCRIPTION DEVICEMAP RESOURCEMAP UEFI PS HKLM:\HARDWARE>

        TIMTOWTDI, this is was all done without even piping.

        You might wanna consult a tutorial, I only scratched the surface so far. :)

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery