How to modify complex argument strings in Perl
        Posted  
        
            by mmccoo
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by mmccoo
        
        
        
        Published on 2010-03-25T20:44:21Z
        Indexed on 
            2010/03/25
            20:53 UTC
        
        
        Read the original article
        Hit count: 194
        
I have a cmdline that I'm trying to modify to remove some of the arguments. What makes this complex is that I can have nested arguments.
Say that I have this:
$cmdline = "-a -xyz -a- -b -xyz -b- -a -xyz -a-"
I have three different -xyz flags that are to be interpreted in two different contexts. One is the -a context and the other is the -b context.
I want to remove the "a" -xyz's but leave the ones in the "b" -xyz.
How can I most effectively do this in Perl?
© Stack Overflow or respective owner