Perl code for spiltting numerical value from a input file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sundarbioinfo
    New Member
    • Feb 2008
    • 2

    Perl code for spiltting numerical value from a input file

    can any one give a code for spilitting a numerical value randomly from a input file.....
  • eWish
    Recognized Expert Contributor
    • Jul 2007
    • 973

    #2
    What have you tried? We need some effort here...

    --Kevin

    Comment

    • KevinADC
      Recognized Expert Specialist
      • Jan 2007
      • 4092

      #3
      Originally posted by eWish
      What have you tried? We need some effort here...

      --Kevin

      Yes, and an example of whatever the hell-o that vague requirement actually means would be helpful too.

      Comment

      • Kelicula
        Recognized Expert New Member
        • Jul 2007
        • 176

        #4
        Here ya go!!

        [code=perl]

        #!/usr/bin/perl -T

        my $inputfile = '/dir/file.txt';

        $input = $inputfile =~ s/\d*/$1/;
        @input = split(//,$input);

        $result = $input[int(rand($#inpu t))]

        # $result is now a random "split" number from an input file !! heheheee.... :)

        [/code]

        That's what you get.

        Sorry guys, I'm in a mood... hehehee

        Comment

        • numberwhun
          Recognized Expert Moderator Specialist
          • May 2007
          • 3467

          #5
          Really man! Can't you see that the Kevin's were trying to get the OP to provide the code that they have been trying? This is a learning forum, not a code writing service. Of course, you just gave him the answer to what could have been school work.

          Please do not do that again, it completely undermines our efforts to have the OPs learn from their questions.

          Regards,

          MODERATOR

          Comment

          • Kelicula
            Recognized Expert New Member
            • Jul 2007
            • 176

            #6
            Originally posted by numberwhun
            Really man! Can't you see that the Kevin's were trying to get the OP to provide the code that they have been trying? This is a learning forum, not a code writing service. Of course, you just gave him the answer to what could have been school work.

            Please do not do that again, it completely undermines our efforts to have the OPs learn from their questions.

            Regards,

            MODERATOR

            I apologize.
            Did you look at the code?

            All it does is see if there are any 0-9's present within the "name" of a file.
            If so it omit's everything but them.
            And splits them into an array, and returns a random one of them

            So you see it: "can any one give a code for spilitting a numerical value randomly from a input file".

            I was trying to prove to him that with such a vague question, you'll get a vague (most likely not effective) answer.

            (It probably doesn't even work)

            But I knew when I posted it, that it may be out of line.
            Making fun of OP's.

            For that I apologize.

            Won't happen again.

            Comment

            Working...