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

RE: [PBML] Question on strings

Expand Messages
  • Balakrishna BK
    You can you Use Split Unpack This is nicely explained in Perl CookBook 1st Chapter ==================== Thanks & Regards, Balakrishna BK PH : +91 80 5196 1000
    Message 1 of 8 , Jun 8, 2005
    • 0 Attachment
      You can you Use
      Split
      Unpack
      This is nicely explained in Perl CookBook 1st Chapter


      ====================
      Thanks & Regards,
      Balakrishna BK
      PH : +91 80 5196 1000
      Ext: 2091

      -----Original Message-----
      From: perl-beginner@yahoogroups.com [mailto:perl-beginner@yahoogroups.com]
      On Behalf Of Sreeram B S
      Sent: Wednesday, June 08, 2005 6:15 PM
      To: perl-beginner@yahoogroups.com
      Subject: [PBML] Question on strings

      HI,
      I have one question on strings.

      Suppose, I have:
      $check = "abcde";

      Now, is there a way to access each character of the string $check, ie I
      want to get only the letter 'a', only letter 'b' etc. How can I achieve
      this??

      Kindly help.

      Thanks,
      Sreeram


      __________________________________________________
      Do You Yahoo!?
      Tired of spam? Yahoo! Mail has the best spam protection around
      http://mail.yahoo.com

      [Non-text portions of this message have been removed]



      Unsubscribing info is here:
      http://help.yahoo.com/help/us/groups/groups-32.html
      Yahoo! Groups Links
    • Madani, Srikanth, VF-DE
      Sreeram B S wrote on Mittwoch, 8. Juni 2005 14:45 ... ie I want to get only the letter a , only letter b etc. How can I achieve this?? Use the function
      Message 2 of 8 , Jun 8, 2005
      • 0 Attachment
        Sreeram B S wrote on Mittwoch, 8. Juni 2005 14:45
        > Suppose, I have:
        > $check = "abcde";

        > Now, is there a way to access each character of the string $check,
        ie I want to get only the letter 'a', only letter 'b' etc. How can I
        achieve this??


        Use the function split; use a pattern matching a null string.

        my $sample_string = "abcde";
        my @sample_string = split / */,$sample_string;
        print "\nthe third char (for instance) is ", $sample_string[2], "\n";


        Cheers,
        Srikanth Madani

        Hummingbirds never remember the words to songs.
      • steve.stamper@foremost.com
        HI, I have one question on strings. Suppose, I have: $check = abcde ; Now, is there a way to access each character of the string $check, ie I want to get only
        Message 3 of 8 , Jun 8, 2005
        • 0 Attachment
          HI,
          I have one question on strings.

          Suppose, I have:
          $check = "abcde";

          Now, is there a way to access each character of the string $check, ie I
          want to get only the letter 'a', only letter 'b' etc. How can I achieve
          this??

          Kindly help.

          Thanks,
          Sreeram

          ==============================================
          15 ways to do everything...

          go check out perldoc -f substr
        • merlyn@stonehenge.com
          ... Sreeram HI, Sreeram I have one question on strings. Sreeram Suppose, I have: Sreeram $check = abcde ; Sreeram Now, is there a way
          Message 4 of 8 , Jun 8, 2005
          • 0 Attachment
            >>>>> "Sreeram" == Sreeram B S <sreeramabsc@...> writes:

            Sreeram> HI,
            Sreeram> I have one question on strings.

            Sreeram> Suppose, I have:
            Sreeram> $check = "abcde";

            Sreeram> Now, is there a way to access each character of the string $check, ie I want to get only the letter 'a', only letter 'b' etc. How can I achieve this??

            To see them "in place":

            substr($check, 0, 1) is "a"
            substr($check, 1, 1) is "b"
            substr($check, 2, 1) is "c"

            To get them as an array:

            @chars = split //, $check;

            --
            Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
            <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
            Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
            See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
          • Sreeram B S
            Hi, I thank one and all for the support you have provided in solving the below issue. I am pleased to say that I have achieved this task purely because of your
            Message 5 of 8 , Jun 8, 2005
            • 0 Attachment
              Hi,

              I thank one and all for the support you have provided in solving the below issue. I am pleased to say that I have achieved this task purely because of your support.

              Thanks for the co-operation.
              Sreeram


              Sreeram B S <sreeramabsc@...> wrote:
              HI,
              I have one question on strings.

              Suppose, I have:
              $check = "abcde";

              Now, is there a way to access each character of the string $check, ie I want to get only the letter 'a', only letter 'b' etc. How can I achieve this??

              Kindly help.

              Thanks,
              Sreeram


              __________________________________________________
              Do You Yahoo!?
              Tired of spam? Yahoo! Mail has the best spam protection around
              http://mail.yahoo.com

              [Non-text portions of this message have been removed]



              Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.html



              ---------------------------------
              Yahoo! Groups Links

              To visit your group on the web, go to:
              http://groups.yahoo.com/group/perl-beginner/

              To unsubscribe from this group, send an email to:
              perl-beginner-unsubscribe@yahoogroups.com

              Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


              __________________________________________________
              Do You Yahoo!?
              Tired of spam? Yahoo! Mail has the best spam protection around
              http://mail.yahoo.com

              [Non-text portions of this message have been removed]
            • Charles K. Clarkson
              ... You may not need to split the string into separate characters. Can you show us how you are using this solution? There may be a more perlish way to
              Message 6 of 8 , Jun 8, 2005
              • 0 Attachment
                Sreeram B S <> wrote:
                : Hi,
                :
                : I thank one and all for the support you have provided in solving
                : the below issue. I am pleased to say that I have achieved this
                : task purely because of your support.

                You may not need to split the string into separate characters.
                Can you show us how you are using this solution? There may be a
                more "perlish" way to accomplish your task.

                HTH,

                Charles K. Clarkson
                --
                Mobile Homes Specialist
                254 968-8328
              Your message has been successfully submitted and would be delivered to recipients shortly.