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

Re: [PBML] a simple question...

Expand Messages
  • Octavian Rasnita
    Why isn t substr() function good enough? Teddy, Teddy s Center: http://teddy.fcc.ro/ Email: orasnita@home.ro ... From: Jadi, SoftHome
    Message 1 of 4 , Feb 2, 2003
    • 0 Attachment
      Why isn't "substr()" function good enough?

      Teddy,
      Teddy's Center: http://teddy.fcc.ro/
      Email: orasnita@...

      ----- Original Message -----
      From: "Jadi, SoftHome" <jadi@...>
      To: "Perl Beginner" <perl-beginner@yahoogroups.com>
      Sent: Sunday, February 02, 2003 1:21 PM
      Subject: [PBML] a simple question...


      hI, Can real beginners ask questions ? :)
      I want to browse a String char by char. I've used to
      do in C this way :

      for (int i, i<length(str), i++)
      str[i]='A';

      how can I access to the n'th char in a string ? I'm using

      substr $str, $n, 1;

      but there must be a better way.

      Jadi


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


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

      Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    • Nathan.Jeffrey@dhs.vic.gov.au
      That s probably the way I d do it.... my $str = foobarbaz ; my $i; for ( $i = 0, $i
      Message 2 of 4 , Feb 2, 2003
      • 0 Attachment
        That's probably the way I'd do it....

        my $str = "foobarbaz";
        my $i;
        for ( $i = 0, $i < length($str), $i++ ) {
        # NB, brackets added for clarity
        print( substr($str, $i, 1), "\n" );
        }

        N





        "Jadi, SoftHome" <jadi@...>
        02/02/2003 10:21 PM
        Please respond to perl-beginner


        To: "Perl Beginner" <perl-beginner@yahoogroups.com>
        cc:
        Subject: [PBML] a simple question...


        hI, Can real beginners ask questions ? :)
        I want to browse a String char by char. I've used to
        do in C this way :

        for (int i, i<length(str), i++)
        str[i]='A';

        how can I access to the n'th char in a string ? I'm using

        substr $str, $n, 1;

        but there must be a better way.

        Jadi


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


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

        Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/







        _________________________________________________________________________________

        This email contains confidential information intended only for the person named above and may be subject to legal privilege. If you are not the intended recipient, any disclosure, copying or use of this information is prohibited. The Department provides no guarantee that this communication is free of virus or that it has not been intercepted or interfered with. If you have received this email in error or have any other concerns regarding its transmission, please notify Postmaster@...
        _________________________________________________________________________________
      • Jadi, SoftHome
        how can I change the 3th character of the string to A ? $str = jadi ; and I want to change it to : $str = jaAi ; how ? I used to write in c just like
        Message 3 of 4 , Feb 3, 2003
        • 0 Attachment
          how can I change the 3th character of the string to A ?

          $str = "jadi";

          and I want to change it to :

          $str = "jaAi";

          how ? I used to write in c just like " str[2]='A'; "... what's the translation(!) in Perl ?

          Jadi
          Why isn't "substr()" function good enough?

          Teddy,
          Teddy's Center: http://teddy.fcc.ro/
          Email: orasnita@...

          ----- Original Message -----
          From: "Jadi, SoftHome" <jadi@...>
          To: "Perl Beginner" <perl-beginner@yahoogroups.com>
          Sent: Sunday, February 02, 2003 1:21 PM
          Subject: [PBML] a simple question...


          hI, Can real beginners ask questions ? :)
          I want to browse a String char by char. I've used to
          do in C this way :

          for (int i, i<length(str), i++)
          str[i]='A';

          how can I access to the n'th char in a string ? I'm using

          substr $str, $n, 1;

          but there must be a better way.

          Jadi


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


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

          Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/





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

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



          [Non-text portions of this message have been removed]
        • Jeff 'japhy' Pinyan
          ... substr($str, 2, 1, A ); # or substr($str, 2, 1) = A ; Don t think of a string as an array of characters. It s not like that in Perl. It s a string. --
          Message 4 of 4 , Feb 4, 2003
          • 0 Attachment
            On Feb 4, Jadi, SoftHome said:

            >how can I change the 3th character of the string to A ?
            >
            >$str = "jadi";
            >
            >and I want to change it to :
            >
            >$str = "jaAi";

            substr($str, 2, 1, "A");
            # or
            substr($str, 2, 1) = "A";

            Don't think of a string as an array of characters. It's not like that in
            Perl. It's a string.

            --
            Jeff "japhy" Pinyan japhy@... http://www.pobox.com/~japhy/
            RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
            <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
            [ I'm looking for programming work. If you like my work, let me know. ]
          Your message has been successfully submitted and would be delivered to recipients shortly.