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

Re: [PBML] file help needed

Expand Messages
  • Emen Zhao
    Here is a simple one liner # perl -wnl -e /reg/ and print file_name note: customize reg part to fit your needs ... [Non-text portions of this message have
    Message 1 of 20 , Oct 10, 2007
      Here is a simple one liner

      # perl -wnl -e '/reg/ and print' file_name

      note: customize reg part to fit your needs

      On 10/10/07, Lou Hernsen <lhernsen1015@...> wrote:
      >
      > I have a 200 x 200 charecter file. Thats 200 lines, each having 200
      > charecters.
      > Currently I have to read the whole file and then pick out the 7 lines, 7
      > charecters from each line.
      > I know how to "seek" but "getc" only get one charecter at a time. is there
      > a
      > way to get the whole line of 200 charecters? Can getc get more than one
      > charecter?
      >
      > Help would be welcomed
      > Thanks Lou
      >
      >
      >


      [Non-text portions of this message have been removed]
    • Lou Hernsen
      Thank you.. but I have no clue what you just wrote. Is that a perl command? something that goes to a module? or something to look up on line? I admit to not
      Message 2 of 20 , Oct 10, 2007
        Thank you.. but I have no clue what you just wrote.
        Is that a perl command? something that goes to a module?
        or something to look up on line?
        I admit to not knowing alot.....
        Thanks
        Lou

        ----- Original Message -----
        From: "Emen Zhao" <emenzhaowork@...>
        To: <perl-beginner@yahoogroups.com>
        Sent: Wednesday, October 10, 2007 11:06 AM
        Subject: Re: [PBML] file help needed


        > Here is a simple one liner
        >
        > # perl -wnl -e '/reg/ and print' file_name
        >
        > note: customize reg part to fit your needs
        >
        > On 10/10/07, Lou Hernsen <lhernsen1015@...> wrote:
        > >
        > > I have a 200 x 200 charecter file. Thats 200 lines, each having 200
        > > charecters.
        > > Currently I have to read the whole file and then pick out the 7 lines, 7
        > > charecters from each line.
        > > I know how to "seek" but "getc" only get one charecter at a time. is
        there
        > > a
        > > way to get the whole line of 200 charecters? Can getc get more than one
        > > charecter?
        > >
        > > Help would be welcomed
        > > Thanks Lou
        > >
        > >
        > >
        >
        >
        > [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
        >
        >
        >
        >
        >
        >
        > --
        > No virus found in this incoming message.
        > Checked by AVG Free Edition.
        > Version: 7.5.472 / Virus Database: 269.14.6/1061 - Release Date: 10/10/07
        8:43 AM
        >
        >
      • merlyn@stonehenge.com
        ... Lou Is that a perl command? something that goes to a module? Lou or something to look up on line? Lou I admit to not knowing alot..... Perhaps you
        Message 3 of 20 , Oct 10, 2007
          >>>>> "Lou" == Lou Hernsen <lhernsen1015@...> writes:

          Lou> Is that a perl command? something that goes to a module?
          Lou> or something to look up on line?

          Lou> I admit to not knowing alot.....

          Perhaps you should start by saying why you chose Perl for this task, and
          where you are on your learning cycle. You might want to look at the
          resources at learn.perl.org to begin your quest.

          Or, if you're just trying to get a quick handout (someone else doing
          your work for you) or a homework assignment, you should be honest and
          declare that.

          --
          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!
        • Lou Hernsen
          I have reviewed how to use SEEK, TELL, GETC and I am able to use them quite well. I was hoping that GETC might have a command like $VAR = GETC(FILE, position,
          Message 4 of 20 , Oct 10, 2007
            I have reviewed how to use SEEK, TELL, GETC and I am able to use them quite
            well.
            I was hoping that GETC might have a command like $VAR = GETC(FILE, position,
            length);
            I was hoping for a command closer to how substr(string, position, length)
            works...

            So I would not have to
            $StartHere=20; #some number
            open (READ, "Test.txt");
            seek READ,$StartHere,0;
            for ($y=0;$y<200;$y++)
            {
            $POS.=getc READ;
            }

            As you can see, I have a clue as to what I am doing.
            I simply can't find any info on a better GETC command.

            So now I am going to test which is faster.. reading the whole file into an
            array
            or seeking 7 times and GETCing 200 times .... but I think I know which will
            be faster.
            will let you know.
          • merlyn@stonehenge.com
            ... Lou As you can see, I have a clue as to what I am doing. Lou I simply can t find any info on a better GETC command. That s because nobody uses getc().
            Message 5 of 20 , Oct 10, 2007
              >>>>> "Lou" == Lou Hernsen <lhernsen1015@...> writes:

              Lou> As you can see, I have a clue as to what I am doing.
              Lou> I simply can't find any info on a better GETC command.

              That's because nobody uses getc(). It's crazy-slow. Read the whole
              thing into memory, and perform operations on the list of elements.
              That'll be very fast.

              --
              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!
            • Jenda Krynicky
              From: Lou Hernsen ... 300*300 is not that much, if you know how to do it using substr(), read the whole file and use the
              Message 6 of 20 , Oct 10, 2007
                From: "Lou Hernsen" <lhernsen1015@...>
                > I have reviewed how to use SEEK, TELL, GETC and I am able to use them quite
                > well.
                > I was hoping that GETC might have a command like $VAR = GETC(FILE, position,
                > length);
                > I was hoping for a command closer to how substr(string, position, length)
                > works...

                300*300 is not that much, if you know how to do it using substr(),
                read the whole file and use the substr() :-)

                Jenda
                ===== Jenda@... === http://Jenda.Krynicky.cz =====
                When it comes to wine, women and song, wizards are allowed
                to get drunk and croon as much as they like.
                -- Terry Pratchett in Sourcery
              • Lou Hernsen
                OK thanks.. thats what I am doing. ... From: To: Lou Hernsen Cc: Sent:
                Message 7 of 20 , Oct 10, 2007
                  OK thanks.. thats what I am doing.

                  ----- Original Message -----
                  From: <merlyn@...>
                  To: "Lou Hernsen" <lhernsen1015@...>
                  Cc: <perl-beginner@yahoogroups.com>
                  Sent: Wednesday, October 10, 2007 12:01 PM
                  Subject: Re: [PBML] file help needed


                  > >>>>> "Lou" == Lou Hernsen <lhernsen1015@...> writes:
                  >
                  > Lou> As you can see, I have a clue as to what I am doing.
                  > Lou> I simply can't find any info on a better GETC command.
                  >
                  > That's because nobody uses getc(). It's crazy-slow. Read the whole
                  > thing into memory, and perform operations on the list of elements.
                  > That'll be very fast.
                • Lou Hernsen
                  OK thanks What size file is considered large? I am writing an online game.. still... after 3 years and several rewrites as I learn more.. If nothing else its
                  Message 8 of 20 , Oct 10, 2007
                    OK thanks
                    What size file is considered large?
                    I am writing an online game.. still... after 3 years
                    and several rewrites as I learn more..
                    If nothing else its been fun and keeps my brain sharp.



                    ----- Original Message -----
                    From: "Jenda Krynicky" <Jenda@...>
                    To: <perl-beginner@yahoogroups.com>
                    Sent: Wednesday, October 10, 2007 12:07 PM
                    Subject: Re: [PBML] file help needed


                    > From: "Lou Hernsen" <lhernsen1015@...>
                    > > I have reviewed how to use SEEK, TELL, GETC and I am able to use them
                    quite
                    > > well.
                    > > I was hoping that GETC might have a command like $VAR = GETC(FILE,
                    position,
                    > > length);
                    > > I was hoping for a command closer to how substr(string, position,
                    length)
                    > > works...
                    >
                    > 300*300 is not that much, if you know how to do it using substr(),
                    > read the whole file and use the substr() :-)
                    >
                    > Jenda
                    > ===== Jenda@... === http://Jenda.Krynicky.cz =====
                    > When it comes to wine, women and song, wizards are allowed
                    > to get drunk and croon as much as they like.
                    > -- Terry Pratchett in Sourcery
                    >
                    >
                    >
                    > Unsubscribing info is here:
                    http://help.yahoo.com/help/us/groups/groups-32.html
                    > Yahoo! Groups Links
                    >
                    >
                    >
                    >
                    >
                    >
                    > --
                    > No virus found in this incoming message.
                    > Checked by AVG Free Edition.
                    > Version: 7.5.472 / Virus Database: 269.14.6/1061 - Release Date: 10/10/07
                    8:43 AM
                    >
                    >
                  • aditi gupta
                    Hello All, I wrote a code to read the contents of a directory and then do something to the .txt files in it. The problem is that the code is not recognizing
                    Message 9 of 20 , Oct 10, 2007
                      Hello All,

                      I wrote a code to read the contents of a directory and then do something to the .txt files in it. The problem is that the code is not recognizing the files present in the directory.

                      ==== CODE BEGINS ====
                      1 #!/usr/bin/perl -w
                      2
                      3 use strict;
                      4
                      5 print "enter dir name:";
                      6 my $dirname = <STDIN>;
                      7 chomp $dirname;
                      8
                      9 opendir (DIR, "$dirname") or die "couldn't open $dirname: $!\n";
                      10
                      11 my @list = readdir(DIR);
                      12 closedir(DIR);
                      13 print "Files present are: @list\n";
                      14 foreach my $file (@list) {
                      15 if ($file =~ /\.txt$/) {
                      16 print "file name is $file";
                      17 open (FH, "$file") or die "couldn't open file:$file : $!\n";
                      18 open (OUT, ">$file.random") or die "couldn't open outfile\n";
                      19
                      20 while (<FH>) {
                      21 $_ =~ s/^>.*/\n/;
                      22 $_ =~ s/\n\n/-/;
                      23 $_ =~ s/\n//;
                      24 $_ =~ s/-/\n/;
                      25 print OUT $_;
                      26 }
                      27 }
                      28 }

                      ==== CODE ENDS ====

                      When I run it, I see the following:

                      >pre.pl
                      enter dir name:5S_ribosomal_seq
                      Files present are: . .. A.txt B.txt C.txt
                      couldn't open file:A.txt : No such file or directory
                      file name is A.txt
                      ---------------------------
                      I don't understand why it is not recognizing A.txt.
                      Also, the program should have died after printing the error message "No such file or directory", but it prints line 16. Is the flow of the program not right? The code doesn't return any errors or warnings.

                      When I tried to debug the code, I get:

                      main::(pre.pl:5): print "enter dir name:";
                      DB<1> 5S_ribosomal_seq
                      Bareword found where operator expected at (eval 25)
                      ---------------------------------------------------------------------------

                      Again, I didn't understand why is an operator expected, when all I'm doing is entering the directory name.

                      I'd be obliged if anyone can identify what I;m doing wrong.

                      Thank You!
                      Aditi




                      ---------------------------------
                      Get the freedom to save as many mails as you wish. Click here to know how.

                      [Non-text portions of this message have been removed]
                    • Jeff Pinyan
                      ... Right here is your problem. The variable $file only holds the NAME of the file, not the PATH to it. You re not in the directory where $file exists, you
                      Message 10 of 20 , Oct 10, 2007
                        On 10/10/07, aditi gupta <aditi9783@...> wrote:
                        > I wrote a code to read the contents of a directory and then do something to the .txt files in it. The problem is that the code is not recognizing the files present in the directory.
                        >
                        > ==== CODE BEGINS ====
                        > 1 #!/usr/bin/perl -w
                        > 2
                        > 3 use strict;
                        > 4
                        > 5 print "enter dir name:";
                        > 6 my $dirname = <STDIN>;
                        > 7 chomp $dirname;
                        > 8
                        > 9 opendir (DIR, "$dirname") or die "couldn't open $dirname: $!\n";
                        > 10
                        > 11 my @list = readdir(DIR);
                        > 12 closedir(DIR);
                        > 13 print "Files present are: @list\n";
                        > 14 foreach my $file (@list) {
                        > 15 if ($file =~ /\.txt$/) {
                        > 16 print "file name is $file";
                        > 17 open (FH, "$file") or die "couldn't open file:$file : $!\n";

                        Right here is your problem. The variable $file only holds the NAME of
                        the file, not the PATH to it. You're not in the directory where $file
                        exists, you need to use "$dirname/$file" to get the file.

                        opendir my $dh, $dirname or die "can't readdir $dirname: $!";
                        my @files = readdir $dh;
                        closedir $dh;

                        for my $file (@files) {
                        if ($file =~ /\.txt$/) {
                        open my $in_fh, "<", "$dirname/$file" or die "can't read
                        $dirname/$file: $!";
                        open my $out_fh, ">", "$dirname/$file.random" or die "can't
                        write $dirname/$file.random: $!";
                        ...
                        }
                        }

                        --
                        [Mary said,] "Do whatever he tells you." ~ John 2:5
                      • Jenda Krynicky
                        From: Lou Hernsen ... Depends. Depends on the type of file, what you do with it, how much physical memory do you have,
                        Message 11 of 20 , Oct 10, 2007
                          From: "Lou Hernsen" <lhernsen1015@...>
                          > OK thanks
                          > What size file is considered large?

                          Depends. Depends on the type of file, what you do with it, how much
                          physical memory do you have, etc. etc. etc. There is no definite
                          answer.

                          When it comes to the viability of slurping a file, I'd think slurping
                          a single 1MB file is quite OK if processing it in chunks would be
                          tedious.

                          Jenda
                          ===== Jenda@... === http://Jenda.Krynicky.cz =====
                          When it comes to wine, women and song, wizards are allowed
                          to get drunk and croon as much as they like.
                          -- Terry Pratchett in Sourcery
                        • Janice Williams
                          Since this is a beginner thread, may I please ask what slurp means? I looked on perl doc and google, but the meaning still escapes me. thanks, Jan ... From:
                          Message 12 of 20 , Oct 10, 2007
                            Since this is a beginner thread, may I please ask what slurp means?
                            I looked on perl doc and google, but the meaning still escapes me.
                            thanks,
                            Jan



                            ----- Original Message ----
                            From: Jenda Krynicky <Jenda@...>
                            To: perl-beginner@yahoogroups.com
                            Sent: Wednesday, October 10, 2007 5:15:45 PM
                            Subject: Re: [PBML] file help needed













                            From: "Lou Hernsen" <lhernsen1015@ wowway.com>

                            > OK thanks

                            > What size file is considered large?



                            Depends. Depends on the type of file, what you do with it, how much

                            physical memory do you have, etc. etc. etc. There is no definite

                            answer.



                            When it comes to the viability of slurping a file, I'd think slurping

                            a single 1MB file is quite OK if processing it in chunks would be

                            tedious.



                            Jenda

                            ===== Jenda@Krynicky. cz === http://Jenda. Krynicky. cz =====

                            When it comes to wine, women and song, wizards are allowed

                            to get drunk and croon as much as they like.

                            -- Terry Pratchett in Sourcery














                            <!--



                            #ygrp-mkp{
                            border:1px solid #d8d8d8;font-family:Arial;margin:14px 0px;padding:0px 14px;}
                            #ygrp-mkp hr{
                            border:1px solid #d8d8d8;}
                            #ygrp-mkp #hd{
                            color:#628c2a;font-size:85%;font-weight:bold;line-height:122%;margin:10px 0px;}
                            #ygrp-mkp #ads{
                            margin-bottom:10px;}
                            #ygrp-mkp .ad{
                            padding:0 0;}
                            #ygrp-mkp .ad a{
                            color:#0000ff;text-decoration:none;}
                            -->



                            <!--



                            #ygrp-sponsor #ygrp-lc{
                            font-family:Arial;}
                            #ygrp-sponsor #ygrp-lc #hd{
                            margin:10px 0px;font-weight:bold;font-size:78%;line-height:122%;}
                            #ygrp-sponsor #ygrp-lc .ad{
                            margin-bottom:10px;padding:0 0;}
                            -->



                            <!--



                            #ygrp-mlmsg {font-size:13px;font-family:arial, helvetica, clean, sans-serif;}
                            #ygrp-mlmsg table {font-size:inherit;font:100%;}
                            #ygrp-mlmsg select, input, textarea {font:99% arial, helvetica, clean, sans-serif;}
                            #ygrp-mlmsg pre, code {font:115% monospace;}
                            #ygrp-mlmsg * {line-height:1.22em;}
                            #ygrp-text{
                            font-family:Georgia;}
                            #ygrp-text p{
                            margin:0 0 1em 0;}
                            #ygrp-tpmsgs{
                            font-family:Arial;clear:both;}
                            #ygrp-vitnav{
                            padding-top:10px;font-family:Verdana;font-size:77%;margin:0;}
                            #ygrp-vitnav a{
                            padding:0 1px;}
                            #ygrp-actbar{
                            clear:both;margin:25px 0;white-space:nowrap;color:#666;text-align:right;}
                            #ygrp-actbar .left{
                            float:left;white-space:nowrap;}
                            .bld{font-weight:bold;}
                            #ygrp-grft{
                            font-family:Verdana;font-size:77%;padding:15px 0;}
                            #ygrp-ft{
                            font-family:verdana;font-size:77%;border-top:1px solid #666;padding:5px 0;}
                            #ygrp-mlmsg #logo{
                            padding-bottom:10px;}

                            #ygrp-vital{
                            background-color:#e0ecee;margin-bottom:20px;padding:2px 0 8px 8px;}
                            #ygrp-vital #vithd{
                            font-size:77%;font-family:Verdana;font-weight:bold;color:#333;text-transform:uppercase;}
                            #ygrp-vital ul{
                            padding:0;margin:2px 0;}
                            #ygrp-vital ul li{
                            list-style-type:none;clear:both;border:1px solid #e0ecee;}
                            #ygrp-vital ul li .ct{
                            font-weight:bold;color:#ff7900;float:right;width:2em;text-align:right;padding-right:.5em;}
                            #ygrp-vital ul li .cat{
                            font-weight:bold;}
                            #ygrp-vital a{
                            text-decoration:none;}

                            #ygrp-vital a:hover{
                            text-decoration:underline;}

                            #ygrp-sponsor #hd{
                            color:#999;font-size:77%;}
                            #ygrp-sponsor #ov{
                            padding:6px 13px;background-color:#e0ecee;margin-bottom:20px;}
                            #ygrp-sponsor #ov ul{
                            padding:0 0 0 8px;margin:0;}
                            #ygrp-sponsor #ov li{
                            list-style-type:square;padding:6px 0;font-size:77%;}
                            #ygrp-sponsor #ov li a{
                            text-decoration:none;font-size:130%;}
                            #ygrp-sponsor #nc{
                            background-color:#eee;margin-bottom:20px;padding:0 8px;}
                            #ygrp-sponsor .ad{
                            padding:8px 0;}
                            #ygrp-sponsor .ad #hd1{
                            font-family:Arial;font-weight:bold;color:#628c2a;font-size:100%;line-height:122%;}
                            #ygrp-sponsor .ad a{
                            text-decoration:none;}
                            #ygrp-sponsor .ad a:hover{
                            text-decoration:underline;}
                            #ygrp-sponsor .ad p{
                            margin:0;}
                            o{font-size:0;}
                            .MsoNormal{
                            margin:0 0 0 0;}
                            #ygrp-text tt{
                            font-size:120%;}
                            blockquote{margin:0 0 0 4px;}
                            .replbq{margin:4;}
                            -->








                            [Non-text portions of this message have been removed]
                          • merlyn@stonehenge.com
                            ... Janice Since this is a beginner thread, may I please ask what slurp means? It s an english word, which is why it s not on perldoc. Have you never heard of
                            Message 13 of 20 , Oct 10, 2007
                              >>>>> "Janice" == Janice Williams <janicew3@...> writes:

                              Janice> Since this is a beginner thread, may I please ask what slurp means?

                              It's an english word, which is why it's not on perldoc.

                              Have you never heard of slurping?

                              --
                              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!
                            • Lou Hernsen
                              Slurping is basically to suck all the data into a var or array ....Like a vampire draining the life force... as opposed to using a selective tool like MySQL
                              Message 14 of 20 , Oct 10, 2007
                                Slurping is basically to suck all the data into a var or array
                                ....Like a vampire draining the life force...
                                as opposed to using a selective tool like MySQL
                                which dances daintily around a file selectively tickling its bits.. and
                                bites.....
                                sorry.. saw a Monty Python movie tonight....
                                cheers


                                ----- Original Message -----
                                From: <merlyn@...>
                                To: "Janice Williams" <janicew3@...>
                                Cc: <perl-beginner@yahoogroups.com>
                                Sent: Wednesday, October 10, 2007 10:53 PM
                                Subject: Re: [PBML] file help needed


                                > >>>>> "Janice" == Janice Williams <janicew3@...> writes:
                                >
                                > Janice> Since this is a beginner thread, may I please ask what slurp
                                means?
                                >
                                > It's an english word, which is why it's not on perldoc.
                                >
                                > Have you never heard of slurping?
                                >
                                > --
                                > 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!
                                >
                                >
                                > Unsubscribing info is here:
                                http://help.yahoo.com/help/us/groups/groups-32.html
                                > Yahoo! Groups Links
                                >
                                >
                                >
                                >
                                >
                                >
                                > --
                                > No virus found in this incoming message.
                                > Checked by AVG Free Edition.
                                > Version: 7.5.472 / Virus Database: 269.14.6/1061 - Release Date: 10/10/07
                                8:43 AM
                                >
                                >
                              • Jenda Krynicky
                                From: Janice Williams ... Sorry. To slurp a file means to read all its contents in one go, store them in a scalar or array and only then
                                Message 15 of 20 , Oct 11, 2007
                                  From: Janice Williams <janicew3@...>
                                  > Since this is a beginner thread, may I please ask what slurp means?
                                  > I looked on perl doc and google, but the meaning still escapes me.
                                  > thanks,
                                  > Jan

                                  Sorry. To slurp a file means to read all its contents in one go,
                                  store them in a scalar or array and only then start to process the
                                  data.

                                  The other basic option is to loop reading individual lines or records
                                  (often called chunks), processing them and then throwing away.

                                  The later generally uses less memory, but sometimes there is no good
                                  definition of lines/records or you need to search over the
                                  line/record boundary so it makes the code more complex. Because you
                                  have to make sure you find even the occurences that start in one
                                  record and end in another.

                                  So sometimes "slurping" the whole file and working with a single
                                  scalar is easier. And if the file is not too big, it's a good
                                  solution.

                                  HTH, Jenda
                                  ===== Jenda@... === http://Jenda.Krynicky.cz =====
                                  When it comes to wine, women and song, wizards are allowed
                                  to get drunk and croon as much as they like.
                                  -- Terry Pratchett in Sourcery
                                • Jeff Pinyan
                                  ... The only problem is that none of the standard definitions for the word slurp (that is, before it was hijacked by hackers) is similar to the definition it
                                  Message 16 of 20 , Oct 11, 2007
                                    On 10/10/07, merlyn@... <merlyn@...> wrote:
                                    >
                                    > >>>>> "Janice" == Janice Williams <janicew3@...> writes:
                                    >
                                    > Janice> Since this is a beginner thread, may I please ask what slurp means?
                                    >
                                    > It's an english word, which is why it's not on perldoc.
                                    >
                                    > Have you never heard of slurping?

                                    The only problem is that none of the standard definitions for the word
                                    "slurp" (that is, before it was hijacked by hackers) is similar to the
                                    definition it has in a programming context.

                                    slurp (slûrp)
                                    v., slurped, slurp·ing, slurps.
                                    v.tr.
                                    To eat or drink noisily.
                                    v.intr.
                                    To eat or drink something noisily.
                                    n.
                                    1. A loud sucking noise made in eating or drinking.
                                    2. Slang. A mouthful of a liquid: took a slurp of grape juice.

                                    It doesn't mean "to consume an entire food or drink all at once, in
                                    one gulp". Contrast that with the hacker definition:

                                    To read a large data file entirely into core before working on it.
                                    This may be contrasted with the strategy of reading a small piece at a
                                    time, processing it, and then reading the next piece. "This program
                                    slurps in a 1K-by-1K matrix and does an FFT."

                                    --
                                    [Mary said,] "Do whatever he tells you." ~ John 2:5
                                  • Janice Williams
                                    Randall, To answer your question. No. Thanks everyone else for the nice and helpful answers. Jan ... From: merlyn@stonehenge.com To:
                                    Message 17 of 20 , Oct 11, 2007
                                      Randall,

                                      To answer your question.

                                      No.

                                      Thanks everyone else for the nice and helpful answers.

                                      Jan



                                      ----- Original Message ----
                                      From: "merlyn@..." <merlyn@...>
                                      To: Janice Williams <janicew3@...>
                                      Cc:
                                      perl-beginner@yahoogroups.com
                                      Sent: Wednesday, October 10, 2007 7:53:09 PM
                                      Subject: Re: [PBML] file help needed













                                      >>>>> "Janice" == Janice Williams <janicew3@yahoo. com> writes:



                                      Janice> Since this is a beginner thread, may I please ask what slurp means?



                                      It's an english word, which is why it's not on perldoc.



                                      Have you never heard of slurping?



                                      --

                                      Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095

                                      <merlyn@stonehenge. com> <URL:http://www.stonehen ge.com/merlyn/>

                                      Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.

                                      See PerlTraining. Stonehenge. com for onsite and open-enrollment Perl training!












                                      <!--



                                      #ygrp-mkp{
                                      border:1px solid #d8d8d8;font-family:Arial;margin:14px 0px;padding:0px 14px;}
                                      #ygrp-mkp hr{
                                      border:1px solid #d8d8d8;}
                                      #ygrp-mkp #hd{
                                      color:#628c2a;font-size:85%;font-weight:bold;line-height:122%;margin:10px 0px;}
                                      #ygrp-mkp #ads{
                                      margin-bottom:10px;}
                                      #ygrp-mkp .ad{
                                      padding:0 0;}
                                      #ygrp-mkp .ad a{
                                      color:#0000ff;text-decoration:none;}
                                      -->



                                      <!--



                                      #ygrp-sponsor #ygrp-lc{
                                      font-family:Arial;}
                                      #ygrp-sponsor #ygrp-lc #hd{
                                      margin:10px 0px;font-weight:bold;font-size:78%;line-height:122%;}
                                      #ygrp-sponsor #ygrp-lc .ad{
                                      margin-bottom:10px;padding:0 0;}
                                      -->



                                      <!--



                                      #ygrp-mlmsg {font-size:13px;font-family:arial, helvetica, clean, sans-serif;}
                                      #ygrp-mlmsg table {font-size:inherit;font:100%;}
                                      #ygrp-mlmsg select, input, textarea {font:99% arial, helvetica, clean, sans-serif;}
                                      #ygrp-mlmsg pre, code {font:115% monospace;}
                                      #ygrp-mlmsg * {line-height:1.22em;}
                                      #ygrp-text{
                                      font-family:Georgia;}
                                      #ygrp-text p{
                                      margin:0 0 1em 0;}
                                      #ygrp-tpmsgs{
                                      font-family:Arial;clear:both;}
                                      #ygrp-vitnav{
                                      padding-top:10px;font-family:Verdana;font-size:77%;margin:0;}
                                      #ygrp-vitnav a{
                                      padding:0 1px;}
                                      #ygrp-actbar{
                                      clear:both;margin:25px 0;white-space:nowrap;color:#666;text-align:right;}
                                      #ygrp-actbar .left{
                                      float:left;white-space:nowrap;}
                                      .bld{font-weight:bold;}
                                      #ygrp-grft{
                                      font-family:Verdana;font-size:77%;padding:15px 0;}
                                      #ygrp-ft{
                                      font-family:verdana;font-size:77%;border-top:1px solid #666;padding:5px 0;}
                                      #ygrp-mlmsg #logo{
                                      padding-bottom:10px;}

                                      #ygrp-vital{
                                      background-color:#e0ecee;margin-bottom:20px;padding:2px 0 8px 8px;}
                                      #ygrp-vital #vithd{
                                      font-size:77%;font-family:Verdana;font-weight:bold;color:#333;text-transform:uppercase;}
                                      #ygrp-vital ul{
                                      padding:0;margin:2px 0;}
                                      #ygrp-vital ul li{
                                      list-style-type:none;clear:both;border:1px solid #e0ecee;}
                                      #ygrp-vital ul li .ct{
                                      font-weight:bold;color:#ff7900;float:right;width:2em;text-align:right;padding-right:.5em;}
                                      #ygrp-vital ul li .cat{
                                      font-weight:bold;}
                                      #ygrp-vital a{
                                      text-decoration:none;}

                                      #ygrp-vital a:hover{
                                      text-decoration:underline;}

                                      #ygrp-sponsor #hd{
                                      color:#999;font-size:77%;}
                                      #ygrp-sponsor #ov{
                                      padding:6px 13px;background-color:#e0ecee;margin-bottom:20px;}
                                      #ygrp-sponsor #ov ul{
                                      padding:0 0 0 8px;margin:0;}
                                      #ygrp-sponsor #ov li{
                                      list-style-type:square;padding:6px 0;font-size:77%;}
                                      #ygrp-sponsor #ov li a{
                                      text-decoration:none;font-size:130%;}
                                      #ygrp-sponsor #nc{
                                      background-color:#eee;margin-bottom:20px;padding:0 8px;}
                                      #ygrp-sponsor .ad{
                                      padding:8px 0;}
                                      #ygrp-sponsor .ad #hd1{
                                      font-family:Arial;font-weight:bold;color:#628c2a;font-size:100%;line-height:122%;}
                                      #ygrp-sponsor .ad a{
                                      text-decoration:none;}
                                      #ygrp-sponsor .ad a:hover{
                                      text-decoration:underline;}
                                      #ygrp-sponsor .ad p{
                                      margin:0;}
                                      o{font-size:0;}
                                      .MsoNormal{
                                      margin:0 0 0 0;}
                                      #ygrp-text tt{
                                      font-size:120%;}
                                      blockquote{margin:0 0 0 4px;}
                                      .replbq{margin:4;}
                                      -->








                                      [Non-text portions of this message have been removed]
                                    • aditi gupta
                                      That Worked! Thank You! :) ... Right here is your problem. The variable $file only holds the NAME of the file, not the PATH to it. You re not in the
                                      Message 18 of 20 , Oct 11, 2007
                                        That Worked! Thank You! :)

                                        Jeff Pinyan <japhy.734@...> wrote: On 10/10/07, aditi gupta <aditi9783@...> wrote:
                                        > I wrote a code to read the contents of a directory and then do something to the .txt files in it. The problem is that the code is not recognizing the files present in the directory.
                                        >
                                        > ==== CODE BEGINS ====
                                        > 1 #!/usr/bin/perl -w
                                        > 2
                                        > 3 use strict;
                                        > 4
                                        > 5 print "enter dir name:";
                                        > 6 my $dirname = <STDIN>;
                                        > 7 chomp $dirname;
                                        > 8
                                        > 9 opendir (DIR, "$dirname") or die "couldn't open $dirname: $!\n";
                                        > 10
                                        > 11 my @list = readdir(DIR);
                                        > 12 closedir(DIR);
                                        > 13 print "Files present are: @list\n";
                                        > 14 foreach my $file (@list) {
                                        > 15 if ($file =~ /\.txt$/) {
                                        > 16 print "file name is $file";
                                        > 17 open (FH, "$file") or die "couldn't open file:$file : $!\n";

                                        Right here is your problem. The variable $file only holds the NAME of
                                        the file, not the PATH to it. You're not in the directory where $file
                                        exists, you need to use "$dirname/$file" to get the file.

                                        opendir my $dh, $dirname or die "can't readdir $dirname: $!";
                                        my @files = readdir $dh;
                                        closedir $dh;

                                        for my $file (@files) {
                                        if ($file =~ /\.txt$/) {
                                        open my $in_fh, "<", "$dirname/$file" or die "can't read
                                        $dirname/$file: $!";
                                        open my $out_fh, ">", "$dirname/$file.random" or die "can't
                                        write $dirname/$file.random: $!";
                                        ...
                                        }
                                        }

                                        --
                                        [Mary said,] "Do whatever he tells you." ~ John 2:5





                                        ---------------------------------
                                        Chat on a cool, new interface. No download required. Click here.

                                        [Non-text portions of this message have been removed]
                                      • Syamanthaka Balakrishnan
                                        Hello friends, I was planning to buy some reference books for perl based system programming. Thought I would mail you all to get some suggestions on
                                        Message 19 of 20 , Oct 15, 2007
                                          Hello friends,

                                          I was planning to buy some reference books for perl based system programming. Thought I would mail you all to get some suggestions on titles/authors which would help ppl like me, with more examples, more real time scenarios etc. More to do with servers, networks etc, in relavance with perl. Any help, guidance would be grately appriciated. Online tutorial links would also help me widen my study. I have done a basic search on google and i found few links, which were slides of a classroom based lesson. It was really nice slide, listing jists, imp points etc. If any of you hav come across such good links, it would be really nice if you could put them up for reference :).
                                          Thank you in advance
                                          Regards,
                                          Syama


                                          ---------------------------------
                                          Building a website is a piece of cake.
                                          Yahoo! Small Business gives you all the tools to get online.

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