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
      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/
    • 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 2 of 4 , Feb 3, 2003
        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 3 of 4 , Feb 4, 2003
          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.