1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

TTC Equivalent to Perl `One-Liner'

Discussion in 'Support' started by hensh, Jun 8, 2009.

  1. hensh

    Joined:
    Jun 6, 2009
    Messages:
    14
    Likes Received:
    0
    The Perl one-liner below works as expected under the TCC (v10) command shell. That is, it pretty prints the path. Is there a solution that doesn't rely on external tools, i.e., is there an equivalent TCC one-liner?
    path |! perl -pe "s/(;|=)/\n/g"

    This is more of a curiosity question.

    thanks
    rick
     
  2. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,523
    Likes Received:
    4
    hensh wrote:
    | The Perl one-liner below works as expected under the TCC (v10)
    | command shell. That is, it pretty prints the path. Is there a
    | solution that doesn't rely on external tools, i.e., is there an
    | equivalent TCC one-liner?path |! perl -pe "s/(;|=)/\n/g"

    If you gave an example of what the perl command does (I don't know anything
    about perl) rather than saying "it pretty prints the path" (an extremely
    ambiguous statement) we might be able to help. Trying to interpret the perl
    command as if it were a vi "substitute" command, it looks as if it replaced
    every occurrenceof the characters ":", "|" and "=" with newlines, i.e., it
    splits the path into one line per element. If that is correct, try the
    command below:

    @for /l %w in (0,1,%@dec[%@words[";|=",%path]]) echo %@word[";|=",%w,%path]
    --
    HTH, Steve
     
  3. hensh

    Joined:
    Jun 6, 2009
    Messages:
    14
    Likes Received:
    0
    Sorry.

    The output should be:
    c:\path1
    c:\path2
    ...

    which is exactly what your ``one-liner'' does. Thanks!
     
  4. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,178
    Likes Received:
    11
    While this doesn't catch all three characters, it is quite simple. Since
    the semicolon is the actual path separater (I don't know why you're
    including the other chars) this works quite well.

    It means replace all occurances of semicolon with a newline in the path
    variable and echo the result.

    echo %@replace[;,^n,%path]

    -Scott


    Steve F$BaC(Bi$BaO(B <> wrote on 06/08/2009 08:06:22 AM:


    anything


    perl

    replaced

    it

    %@word[";|=",%w,%path]

     

Share This Page