Convert string to integer?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • skyy
    New Member
    • May 2007
    • 109

    Convert string to integer?

    Hi...

    How do i convert from a string to an integer??
  • miller
    Recognized Expert Top Contributor
    • Oct 2006
    • 1086

    #2
    Your question reveals your ignorance concerning how perl treats scalars. What exactly are you trying to do? What "string" do you have that you're wanting to convert to an integer?

    State exactly what you have and what you want.

    - Miller

    Comment

    • skyy
      New Member
      • May 2007
      • 109

      #3
      Hi...

      I want to convert

      my $my_string="123 ";

      into

      my $my_int=123;

      for some calculation...

      Comment

      • skyy
        New Member
        • May 2007
        • 109

        #4
        Thanks..

        i managed to do it with casting...

        Comment

        • miller
          Recognized Expert Top Contributor
          • Oct 2006
          • 1086

          #5
          [CODE=perl]
          my $var = "123";
          print $var + 3;
          # Outputs 126
          [/CODE]

          - Miller

          Comment

          Working...