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

Re: [PBML] 0..99 operator

Expand Messages
  • Jenda Krynicky
    From: eventualdeath ... While you could use the .. operator like this : if (grep {$a eq $_} ( a .. z ) ) { ... it s
    Message 1 of 8 , Nov 1, 2001
    • 0 Attachment
      From: "eventualdeath" <eventualdeath@...>
      > Indeed a good programmer must not have a one track mind like me. I
      > must admit that I am still far away. Anyway I ask about the range
      > operator because sometimes we may even want to do things like this :-
      >
      > if ($a eq a or $a eq b or $a eq c .... all the way up to $a eq z){ };
      > it would be great if I could use the range operator or an easier way.
      > Please advice.

      While you could use the .. operator like this :

      if (grep {$a eq $_} ('a' .. 'z') ) { ...

      it's usualy not the best way to do it. In the case with the letters I'd
      use

      if ($a =~ /^[a-z]$/) { ...

      but that's me ... I see regexps everywhere.

      Jenda

      =========== Jenda@... == http://Jenda.Krynicky.cz ==========
      There is a reason for living. There must be. I've seen it somewhere.
      It's just that in the mess on my table ... and in my brain.
      I can't find it.
      --- me
    • eventualdeath
      ... _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com
      Message 2 of 8 , Nov 8, 2001
      • 0 Attachment
        ----- Original Message -----
        From: "Jenda Krynicky" <Jenda@...>

        > it's usualy not the best way to do it. In the case with the letters I'd
        > use
        > if ($a =~ /^[a-z]$/) { ...

        I've just completed studying some basics of regexp and now here I am. I've
        confirmed that without the ^ and $ sign, $a is still being tested against
        (a..z). such as this:- if ($a=~/[a-z]/){ print "true" } else {print
        "false"};

        Since we are comparing $a against a..z , why do you put the carret ^
        (signifying beginning ) and the dollar sign $ (last). Is there some safety
        catch.

        Thanks



        _________________________________________________________
        Do You Yahoo!?
        Get your free @... address at http://mail.yahoo.com
      • Frank J. Schmuck
        I think I understand how SendMail works but I d like to retrieve e-mail remotely. Is there a perl module that does this? Thanks Frank [Non-text portions of
        Message 3 of 8 , Nov 9, 2001
        • 0 Attachment
          I think I understand how SendMail works but I'd like to retrieve e-mail
          remotely. Is there a perl module that does this?

          Thanks
          Frank



          [Non-text portions of this message have been removed]
        • Jenda Krynicky
          From: eventualdeath ... This depends on what exactly do you want to match. If you only want to match one letter strings
          Message 4 of 8 , Nov 9, 2001
          • 0 Attachment
            From: "eventualdeath" <eventualdeath@...>

            > ----- Original Message -----
            > From: "Jenda Krynicky" <Jenda@...>
            >
            > > it's usualy not the best way to do it. In the case with the letters
            > > I'd use if ($a =~ /^[a-z]$/) { ...
            >
            > I've just completed studying some basics of regexp and now here I am.
            > I've confirmed that without the ^ and $ sign, $a is still being tested
            > against (a..z). such as this:- if ($a=~/[a-z]/){ print "true" } else
            > {print "false"};
            >
            > Since we are comparing $a against a..z , why do you put the carret ^
            > (signifying beginning ) and the dollar sign $ (last). Is there some
            > safety catch.

            This depends on what exactly do you want to match.

            If you only want to match one letter strings containing a lower case
            letter than /^[a-z]$/ is the right one.

            If on the other hand you want to match any string that contains a
            lowercase letter (so that even "12545a6878" would match) then you
            want /[a-z]/.

            If you want the lowercase at the beginning you'll use /^[a-z]/ and
            and if you want it at the end you'll have /[a-z]$/.

            Now ... if it's guaranteed that the string always only contains just
            one character, than all those give the same result. If it's not ... they
            are very different.

            Jenda

            =========== Jenda@... == http://Jenda.Krynicky.cz ==========
            There is a reason for living. There must be. I've seen it somewhere.
            It's just that in the mess on my table ... and in my brain.
            I can't find it.
            --- me
          • Greg
            ... mail ... Yes. If its a POP3 account, then you need POP3Client. For SMTP you need something else. Greg
            Message 5 of 8 , Nov 9, 2001
            • 0 Attachment
              --- In perl-beginner@y..., "Frank J. Schmuck" <fschmuck@c...> wrote:
              > I think I understand how SendMail works but I'd like to retrieve e-
              mail
              > remotely. Is there a perl module that does this?
              >
              > Thanks
              > Frank

              Yes. If its a POP3 account, then you need POP3Client.
              For SMTP you need something else.

              Greg
            Your message has been successfully submitted and would be delivered to recipients shortly.