How can I remove trailing commas?

Discussion in 'Perl Misc' started by Jame Pearl, Jan 30, 2006.

  1. Jame Pearl

    axel Guest

    For single line strings it is usually a good idea to chomp them as
    soon as they have been read in from an external data source and
    then only explicitly use a separate newline when it comes to the
    output stage - it avoids all sorts of problems.

    Axel
     
    axel, Feb 2, 2006
    #21
    1. Advertisements

  2. Jame Pearl

    ced Guest

    I think you intended something a bit different :) The RHS of 's'
    is missing....

    The (\n)? can't be right either since, if present, a RHS // would then
    remove
    the \n too. So I assume you meant thiis to be something entirely
    different...


    I could shorten mine to: s{ , (\z)? \Z }{}x though which seems
    hard
    to beat.
     
    ced, Feb 3, 2006
    #22
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.