Loading ...
Sorry, an error occurred while loading the content.

ltrim & rtrim

Expand Messages
  • Chris Brown
    i ve only been using perl for a few days, so this may seem a simple question - well, good! that means one of you at least might be able to help... is there an
    Message 1 of 2 , Mar 1 4:54 PM
    • 0 Attachment
      i've only been using perl for a few days, so this may seem a simple question - well, good! that means one of you at least might be able to help...
       
      is there an easy equivalent in perl to the old basic 'ltrim' and 'rtrim', ie. chop off the first character / last character of a variable?
       
      i've got it down to
       
      $year         "1999
      $cost        4000"
       
      and want to get rid of the " signs!
       
      cheers
      chris
    • Damien Carbery
      To change: 4000 to 4000 use chop(). It chops off the last character of a string and returns the character chopped. To change: 1999 to 1999 use substr(
      Message 2 of 2 , Mar 1 5:33 PM
      • 0 Attachment
        To change: 4000" to 4000
        use chop(). It "chops off the last character of a string and returns
        the character chopped."

        To change: "1999 to 1999
        use substr( $year, 1 ).

        It is probably possible to incorporate this trimming into the
        algorithm that resulted in these values. This may be worth looking
        into though I can't comment on that as you've not included info about
        this.

        --- In perl-beginner@y..., "Chris Brown" <chris.brown@w...> wrote:
        > i've only been using perl for a few days, so this may seem a simple
        question - well, good! that means one of you at least might be able to
        help...
        >
        > is there an easy equivalent in perl to the old basic 'ltrim' and
        'rtrim', ie. chop off the first character / last character of a
        variable?
        >
        > i've got it down to
        >
        > $year "1999
        > $cost 4000"
        >
        > and want to get rid of the " signs!
        >
        > cheers
        > chris
      Your message has been successfully submitted and would be delivered to recipients shortly.