TTC Equivalent to Perl `One-Liner'

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
Jun 6, 2009
14
0
#1
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
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
 
Jun 6, 2009
14
0
#3
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
Sorry.

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

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

samintz

Scott Mintz
May 20, 2008
1,203
11
Solon, OH, USA
#4
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:


> 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
>
>
>
>