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

HELP REQUIRED

Expand Messages
  • Mirza Abdullah Jan
    Following is the scenario A text fie name data.txt and contains data like # hello phone # tango mango # bus truck 12 23 34 43 32 34 # # I write a program to
    Message 1 of 9 , Apr 9, 2007
      Following is the scenario

      A text fie name "data.txt" and contains data like
      # hello phone
      # tango mango
      # bus truck
      12 23
      34 43
      32 34
      #
      #

      I write a program to counts how many line with # is preent in array . My code is as follow

      my $datafile;
      ;
      my $u;
      my $tsize;

      $datafile = "data.txt";
      open(FILEHANDLE,"$datafile");
      my @fdata=<FILEHANDLE>;

      $tsize = (@fdata);
      for($u=0;$u<$tsize;$u++)
      {
      if($fdata[$u] eq ' # ' )
      { printf "This is line number ".$u; }
      }


      But when i executes the files is doen't show the desired result.

      Regards
      Abullah


      ---------------------------------
      Never miss an email again!
      Yahoo! Toolbar alerts you the instant new Mail arrives. Check it out.

      [Non-text portions of this message have been removed]
    • Huangj
      open(FILE, data.txt ) or die $!; while ( ) { if (/^#/) { print This is line number , $. , n } } close FILE; ÔÚ2007-04-10£¬ Mirza Abdullah Jan
      Message 2 of 9 , Apr 9, 2007
        open(FILE, 'data.txt') or die $!;
        while (<FILE>)
        { if (/^#/) { print 'This is line number ', $. , "\n" } }
        close FILE;




        ��2007-04-10��"Mirza Abdullah Jan" <jan576pk@...> ������

        Following is the scenario

        A text fie name "data.txt" and contains data like
        # hello phone
        # tango mango
        # bus truck
        12 23
        34 43
        32 34
        #
        #

        I write a program to counts how many line with # is preent in array . My code is as follow

        my $datafile;
        ;
        my $u;
        my $tsize;

        $datafile = "data.txt";
        open(FILEHANDLE,"$datafile");
        my @fdata=<FILEHANDLE>;

        $tsize = (@fdata);
        for($u=0;$u<$tsize;$u++)
        {
        if($fdata[$u] eq ' # ' )
        { printf "This is line number ".$u; }
        }


        But when i executes the files is doen't show the desired result.

        Regards
        Abullah

        ---------------------------------
        Never miss an email again!
        Yahoo! Toolbar alerts you the instant new Mail arrives. Check it out.

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




        [Non-text portions of this message have been removed]
      • yuva bala
        Hi, try this open IN, e:/test.txt || die cannot open the input file $! ; undef $/; $name= ; @grep=$name=~/^#.*$/mg; print scalar(@grep); regards,
        Message 3 of 9 , Apr 9, 2007
          Hi,

          try this


          open IN, 'e:/test.txt' || die "cannot open the input file $!";
          undef $/;
          $name=<IN>;
          @grep=$name=~/^#.*$/mg;
          print scalar(@grep);

          regards,
          yuvanbala

          Huangj <redspid@...> wrote:
          open(FILE, 'data.txt') or die $!;
          while ()
          { if (/^#/) { print 'This is line number ', $. , "\n" } }
          close FILE;




          ÔÚ2007-04-10£¬"Mirza Abdullah Jan" дµÀ£º

          Following is the scenario

          A text fie name "data.txt" and contains data like
          # hello phone
          # tango mango
          # bus truck
          12 23
          34 43
          32 34
          #
          #

          I write a program to counts how many line with # is preent in array . My code is as follow

          my $datafile;
          ;
          my $u;
          my $tsize;

          $datafile = "data.txt";
          open(FILEHANDLE,"$datafile");
          my @fdata=;

          $tsize = (@fdata);
          for($u=0;$u<$tsize;$u++)
          {
          if($fdata[$u] eq ' # ' )
          { printf "This is line number ".$u; }
          }


          But when i executes the files is doen't show the desired result.

          Regards
          Abullah

          ---------------------------------
          Never miss an email again!
          Yahoo! Toolbar alerts you the instant new Mail arrives. Check it out.

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




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



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






          ---------------------------------
          Here’s a new way to find what you're looking for - Yahoo! Answers

          [Non-text portions of this message have been removed]
        • vivek kumar
          Hello, Mirza Abdullah JanIf you are running the perl script in Windows: Try this out. $path = E: data.txt ; print `findstr /n /i $Text $path ` ; else try
          Message 4 of 9 , Apr 11, 2007
            Hello, Mirza Abdullah JanIf you are running the perl script in Windows: Try this out.

            $path = "E:\data.txt";
            print `findstr /n /i $Text "$path"` ;

            else
            try what Huangj has sent.


            ---------------------------------
            Check out what you're missing if you're not on Yahoo! Messenger

            [Non-text portions of this message have been removed]
          • Mirza Abdullah Jan
            This is my code.......... # !/usr/local/bin/perl -w use warnings; # use strict; #use diagnostics -verbose; my $datafile = data.txt ;
            Message 5 of 9 , Apr 30, 2007
              This is my code..........

              # !/usr/local/bin/perl -w

              use warnings;
              # use strict;
              #use diagnostics -verbose;

              my $datafile = "data.txt";
              open(FILEHANDLE,"$datafile");
              @fdata = <FILEHANDLE>;

              $tsize = (@fdata);
              my $v=0;
              my $u=0;


              for($u=0;$u<=$tsize;$u++)
              {

              if($fdata[$u] != '#')
              {
              $datain[$v] = $fdata[$u];

              $v = $v + 1;

              }
              else
              {
              $u = $u+1;
              }
              }



              When is execute this code , i get following error........

              Argument "72795^I230\n" isn't numeric in numeric ne (!=) at abc.pl line 206, <FILEHANDLE> line 1466.
              Argument "72850^I232\n" isn't numeric in numeric ne (!=) at abc.pl line 206, <FILEHANDLE> line 1466.
              Argument "72913^I231\n" isn't numeric in numeric ne (!=) at abc.pl line 206, <FILEHANDLE> line 1466.

              Please help me how to fiugre out this error.......my data file contain the data like this.


              12 230
              45 250
              75 250

              and so on.............


              ---------------------------------
              Ahhh...imagining that irresistible "new car" smell?
              Check outnew cars at Yahoo! Autos.

              [Non-text portions of this message have been removed]
            • Thiago Nascimento
              Clue: change the != operator in the conditional statement; use the ne operator. ... { ... -- Thiago Nascimento perl -e $_= tMM naaCt
              Message 6 of 9 , Apr 30, 2007
                Clue: change the "!=" operator in the conditional statement; use the "ne"
                operator.

                On 4/30/07, Mirza Abdullah Jan <jan576pk@...> wrote:
                >
                >
                > This is my code..........
                >
                > # !/usr/local/bin/perl -w
                >
                > use warnings;
                > # use strict;
                > #use diagnostics -verbose;
                >
                > my $datafile = "data.txt";
                > open(FILEHANDLE,"$datafile");
                > @fdata = <FILEHANDLE>;
                >
                > $tsize = (@fdata);
                > my $v=0;
                > my $u=0;
                >
                > for($u=0;$u<=$tsize;$u++)
                > {
                >
                > if($fdata[$u] != '#')
                >









                {
                > $datain[$v] = $fdata[$u];
                >
                > $v = $v + 1;
                >
                > }
                > else
                > {
                > $u = $u+1;
                > }
                > }
                >
                > When is execute this code , i get following error........
                >
                > Argument "72795^I230\n" isn't numeric in numeric ne (!=) at abc.pl line
                > 206, <FILEHANDLE> line 1466.
                > Argument "72850^I232\n" isn't numeric in numeric ne (!=) at abc.pl line
                > 206, <FILEHANDLE> line 1466.
                > Argument "72913^I231\n" isn't numeric in numeric ne (!=) at abc.pl line
                > 206, <FILEHANDLE> line 1466.
                >
                > Please help me how to fiugre out this error.......my data file contain the
                > data like this.
                >
                > 12 230
                > 45 250
                > 75 250
                >
                > and so on.............
                >
                > ---------------------------------
                > Ahhh...imagining that irresistible "new car" smell?
                > Check outnew cars at Yahoo! Autos.
                >
                > [Non-text portions of this message have been removed]
                >
                >
                >



                --
                Thiago Nascimento
                perl -e '$_="tMM naaCt Feocmama_itpUilucoGa";$_.=$1,print $2 while
                s/(..)(.)//;print substr$_,1,1;'
                "...just because I don't know the meaning of my art, does not mean it has no
                meaning..." S.D.


                [Non-text portions of this message have been removed]
              • Mirza Abdullah Jan
                when use ne gives same warning messages........ Thiago Nascimento wrote: Clue: change the !=
                Message 7 of 9 , Apr 30, 2007
                  when use "ne" gives same warning messages........

                  Thiago Nascimento <nascimenthiago@...> wrote: Clue: change the "!=" operator in the conditional statement; use the "ne"
                  operator.

                  On 4/30/07, Mirza Abdullah Jan <jan576pk@...> wrote:
                  >
                  >
                  > This is my code..........
                  >
                  > # !/usr/local/bin/perl -w
                  >
                  > use warnings;
                  > # use strict;
                  > #use diagnostics -verbose;
                  >
                  > my $datafile = "data.txt";
                  > open(FILEHANDLE,"$datafile");
                  > @fdata = <FILEHANDLE>;
                  >
                  > $tsize = (@fdata);
                  > my $v=0;
                  > my $u=0;
                  >
                  > for($u=0;$u<=$tsize;$u++)
                  > {
                  >
                  > if($fdata[$u] != '#')
                  >

                  {
                  > $datain[$v] = $fdata[$u];
                  >
                  > $v = $v + 1;
                  >
                  > }
                  > else
                  > {
                  > $u = $u+1;
                  > }
                  > }
                  >
                  > When is execute this code , i get following error........
                  >
                  > Argument "72795^I230\n" isn't numeric in numeric ne (!=) at abc.pl line
                  > 206, <FILEHANDLE> line 1466.
                  > Argument "72850^I232\n" isn't numeric in numeric ne (!=) at abc.pl line
                  > 206, <FILEHANDLE> line 1466.
                  > Argument "72913^I231\n" isn't numeric in numeric ne (!=) at abc.pl line
                  > 206, <FILEHANDLE> line 1466.
                  >
                  > Please help me how to fiugre out this error.......my data file contain the
                  > data like this.
                  >
                  > 12 230
                  > 45 250
                  > 75 250
                  >
                  > and so on.............
                  >
                  > ---------------------------------
                  > Ahhh...imagining that irresistible "new car" smell?
                  > Check outnew cars at Yahoo! Autos.
                  >
                  > [Non-text portions of this message have been removed]
                  >
                  >
                  >

                  --
                  Thiago Nascimento
                  perl -e '$_="tMM naaCt Feocmama_itpUilucoGa";$_.=$1,print $2 while
                  s/(..)(.)//;print substr$_,1,1;'
                  "...just because I don't know the meaning of my art, does not mean it has no
                  meaning..." S.D.

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






                  ---------------------------------
                  Ahhh...imagining that irresistible "new car" smell?
                  Check outnew cars at Yahoo! Autos.

                  [Non-text portions of this message have been removed]
                • merlyn@stonehenge.com
                  ... Mirza Argument 72795^I230 n isn t numeric in numeric ne (!=) at abc.pl line 206, line 1466. You haven t shown line 206. Please don t show
                  Message 8 of 9 , Apr 30, 2007
                    >>>>> "Mirza" == Mirza Abdullah Jan <jan576pk@...> writes:

                    Mirza> Argument "72795^I230\n" isn't numeric in numeric ne (!=) at abc.pl line 206, <FILEHANDLE> line 1466.

                    You haven't shown line 206. Please don't show something that results from
                    code you haven shown. First, I don't want to see 206 lines of code, EVER.
                    Second, it'd be better if you could make it standalone, rather than
                    requiring external files, just so we can also run the code.

                    --
                    Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
                    <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
                    Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
                    See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
                  • Abdul
                    change your file to unix format(I saw the ^character... Argument 72795^I230 ) Mirza Abdullah Jan wrote:
                    Message 9 of 9 , Apr 30, 2007
                      change your file to unix format(I saw the ^character... Argument "72795^I230 )


                      Mirza Abdullah Jan <jan576pk@...> wrote: when use "ne" gives same warning messages........

                      Thiago Nascimento <nascimenthiago@...> wrote: Clue: change the "!=" operator in the conditional statement; use the "ne"
                      operator.

                      On 4/30/07, Mirza Abdullah Jan <jan576pk@...> wrote:
                      >
                      >
                      > This is my code..........
                      >
                      > # !/usr/local/bin/perl -w
                      >
                      > use warnings;
                      > # use strict;
                      > #use diagnostics -verbose;
                      >
                      > my $datafile = "data.txt";
                      > open(FILEHANDLE,"$datafile");
                      > @fdata = <FILEHANDLE>;
                      >
                      > $tsize = (@fdata);
                      > my $v=0;
                      > my $u=0;
                      >
                      > for($u=0;$u<=$tsize;$u++)
                      > {
                      >
                      > if($fdata[$u] != '#')
                      >

                      {
                      > $datain[$v] = $fdata[$u];
                      >
                      > $v = $v + 1;
                      >
                      > }
                      > else
                      > {
                      > $u = $u+1;
                      > }
                      > }
                      >
                      > When is execute this code , i get following error........
                      >
                      > Argument "72795^I230\n" isn't numeric in numeric ne (!=) at abc.pl line
                      > 206, <FILEHANDLE> line 1466.
                      > Argument "72850^I232\n" isn't numeric in numeric ne (!=) at abc.pl line
                      > 206, <FILEHANDLE> line 1466.
                      > Argument "72913^I231\n" isn't numeric in numeric ne (!=) at abc.pl line
                      > 206, <FILEHANDLE> line 1466.
                      >
                      > Please help me how to fiugre out this error.......my data file contain the
                      > data like this.
                      >
                      > 12 230
                      > 45 250
                      > 75 250
                      >
                      > and so on.............
                      >
                      > ---------------------------------
                      > Ahhh...imagining that irresistible "new car" smell?
                      > Check outnew cars at Yahoo! Autos.
                      >
                      > [Non-text portions of this message have been removed]
                      >
                      >
                      >

                      --
                      Thiago Nascimento
                      perl -e '$_="tMM naaCt Feocmama_itpUilucoGa";$_.=$1,print $2 while
                      s/(..)(.)//;print substr$_,1,1;'
                      "...just because I don't know the meaning of my art, does not mean it has no
                      meaning..." S.D.

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





                      ---------------------------------
                      Ahhh...imagining that irresistible "new car" smell?
                      Check outnew cars at Yahoo! Autos.

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






                      ---------------------------------
                      Ahhh...imagining that irresistible "new car" smell?
                      Check outnew cars at Yahoo! Autos.

                      [Non-text portions of this message have been removed]
                    Your message has been successfully submitted and would be delivered to recipients shortly.