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

need help....please!!!!

Expand Messages
  • perlscript@msn.com
    I wanted to know if there is a way to take a string and start at a specific part of the string (line) and go to a specific part and then take off the leading
    Message 1 of 7 , Jan 30 2:33 PM
      I wanted to know if there is a way to take a string and start at a
      specific part of the string (line) and go to a specific part and then
      take off the leading and trailing spaces and then compare that to a
      variable. Similar to the MID function in VB.
    • perlscript@msn.com
      I am needing help in getting specific parts of a string (line) and then take off leading and trailing spaces and then take that and compare to a variable.
      Message 2 of 7 , Jan 30 2:55 PM
        I am needing help in getting specific parts of a string (line) and
        then take off leading and trailing spaces and then take that and
        compare to a variable. This is similar to the MID function in VB; an
        example would be MID(2,3 eq somevariable). This means take the data
        from the 2nd character the three proceding character and compare that
        to some variable.

        Thanks for any help....
      • Mike Payne
        $foo = 12345 ; $bar = substr($foo,2,3); # $bar is 234 ... From: perlscript@msn.com [mailto:perlscript@msn.com] Sent: Tuesday, January 30, 2001 5:56 PM To:
        Message 3 of 7 , Jan 30 3:31 PM
          $foo = "12345";

          $bar = substr($foo,2,3);

          # $bar is "234"



          -----Original Message-----
          From: perlscript@... [mailto:perlscript@...]
          Sent: Tuesday, January 30, 2001 5:56 PM
          To: perl-beginner@yahoogroups.com
          Subject: [PBML] need help....please!!!!


          I am needing help in getting specific parts of a string (line) and
          then take off leading and trailing spaces and then take that and
          compare to a variable. This is similar to the MID function in VB; an
          example would be MID(2,3 eq somevariable). This means take the data
          from the 2nd character the three proceding character and compare that
          to some variable.

          Thanks for any help....
        • daymobrew@yahoo.com
          How about substr( EXPR, OFFSET, LENGTH ) Example: my $StringToCompare = is ; my $String = This is a simple string ; if ( $StringToCompare eq substr( $String,
          Message 4 of 7 , Jan 30 3:42 PM
            How about
            substr( EXPR, OFFSET, LENGTH )

            Example:
            my $StringToCompare = "is";
            my $String = "This is a simple string";
            if ( $StringToCompare eq substr( $String, 5, 2 ) )
            {
            print "$StringToCompare found.\n";
            }

            Note that the offset begins at 0.
            I can't remember how MID works so you'll have to adapt the code above
            for your situation.

            --- In perl-beginner@y..., perlscript@m... wrote:
            > I am needing help in getting specific parts of a string (line) and
            > then take off leading and trailing spaces and then take that and
            > compare to a variable. This is similar to the MID function in VB;
            an
            > example would be MID(2,3 eq somevariable). This means take the data
            > from the 2nd character the three proceding character and compare
            that
            > to some variable.
            >
            > Thanks for any help....
          • James Ross
            one more question; what is a nice easy way to print a formated string to a file like: stmt Locn code statement 1 0000
            Message 5 of 7 , Jan 30 5:19 PM
              one more question; what is a nice easy way to print a formated string to a file like:
              stmt          Locn          code          statement
              1              0000          0001          A      CON 0001 ;load 2 to 0 power
              2              0002          0002          B      CON 0002 ;load multiplier
              3              0004          0100          MAX  CON 0100 ;limit (256 decimal)
               
              i will prob use a foreach loop to go through a file collect items in variables, and then print to a file at the end....is there a nice way to get my info written to a disk to look like the above?  Again, thx for your help..

              ----- Original Message -----
              From: Mike Payne
              Sent: Tuesday, January 30, 2001 6:59 PM
              To: perl-beginner@yahoogroups.com
              Subject: RE: [PBML] need help....please!!!!

              $foo = "12345";

              $bar = substr($foo,2,3);

              # $bar is "234"



              -----Original Message-----
              From: perlscript@... [mailto:perlscript@...]
              Sent: Tuesday, January 30, 2001 5:56 PM
              To: perl-beginner@yahoogroups.com
              Subject: [PBML] need help....please!!!!


              I am needing help in getting specific parts of a string (line) and
              then take off leading and trailing spaces and then take that and
              compare to a variable.  This is similar to the MID function in VB; an
              example would be MID(2,3 eq somevariable).  This means take the data
              from the 2nd character the three proceding character and compare that
              to some variable.

              Thanks for any help....







              ------------------------ Yahoo! Groups Sponsor ---------------------~-~>
              eGroups is now Yahoo! Groups
              Click here for more details
              http://click.egroups.com/1/11231/0/_/12898/_/980898941/
              ---------------------------------------------------------------------_->







              Get your FREE download of MSN Explorer at http://explorer.msn.com
            • Charles K. Clarkson
              Check out sprintf and printf. HTH, Charles K. Clarkson ... From: James Ross one more question; what is a nice easy way to print a formated string to a file
              Message 6 of 7 , Feb 1, 2001
                Check out sprintf and printf.

                HTH,
                Charles K. Clarkson

                ----- Original Message -----
                From: James Ross

                one more question; what is a nice easy way to print a formated string to a
                file like:

                stmt Locn code statement
                1 0000 0001 A CON 0001 ;load 2 to 0
                power
                2 0002 0002 B CON 0002 ;load multiplier
                3 0004 0100 MAX CON 0100 ;limit (256
                decimal)

                i will prob use a foreach loop to go through a file collect items in
                variables, and then print to a file at the end....is there a nice way to get
                my info written to a disk to look like the above? Again, thx for your
                help..
              • Kul
                ... I would recommend a little talked about facility in perl that is designed specifically for this exact function, its called FORMAT. It will do EXACTLY what
                Message 7 of 7 , Feb 1, 2001
                  James Ross wrote:

                  > one more question; what is a nice easy way to print a formated string to a file like:stmt Locn code statement
                  > 1 0000 0001 A CON 0001 ;load 2 to 0 power2 0002 0002 B CON 0002 ;load multiplier3 0004 0100 MAX CON 0100 ;limit (256 decimal) i will prob use a foreach loop to go through a file collect items in variables, and then print to a file at the end....is there a nice way to get my info written to a disk to look like the above? Again, thx for your help..

                  I would recommend a little talked about facility in perl that is designed specifically for this exact function, its called FORMAT. It will do EXACTLY what your asking, and nice and tidily !
                  Regards
                  Kul
                Your message has been successfully submitted and would be delivered to recipients shortly.