File I/O Manipulation....

Discussion in 'Perl Misc' started by RodFGWA, Oct 5, 2005.

  1. RodFGWA

    RodFGWA Guest

    Thank you all for your replies. I appreciate the time you have spent on
    my problem.

    Suppose I use the following solution:

    #!/usr/bin/perl
    use warnings;
    use strict;


    open FILE, '<', 'text_file' or die "Cannot open 'text_file' $!";


    chomp( @ARGV = <FILE> );


    close FILE;


    open OUT, '>>', 'OUTPUT_FILE' or die "Cannot open 'OUTPUT_FILE' $!";


    my $lines = 10;


    while ( <> ) {


    $. == 1 && print OUT "*****\n";


    $. <= $lines && print OUT $_;


    $. > $lines || eof and close ARGV;


    }


    __END__


    I chose this one because it seems the likely candidate to extend for
    what I would ideally like to do. However, Perl is so obscure to me now
    that I may be wrong about that.

    I would like to print the lines of each file that begin with an open
    parenthesis '('. These are the comment lines in the beginning of each
    file.

    I originally chose the top ten lines because I thought that would
    suffice, but upon reflection, I need only the lines that begin with
    '('. Sometimes there are more than 10 comment lines.

    Once the comment lines have stopped there are additional lines, but I
    do not care about these, so I can go on to the next file.

    Ideally, I would like to print the lines that begin with certain
    headers beginning with a '(', such as '(CUSTOMER', or '(MATERIAL'.

    So, read each line
    Does it begin with '(' OR Does it begin with '(CUSTOMER'
    If it Does Print the line to the Output File
     
    RodFGWA, Oct 5, 2005
    #1
    1. Advertising

  2. RodFGWA

    Ian Wilson Guest

    <Additional newsgroup removed>

    RodFGWA wrote:
    > Thank you all for your replies. I appreciate the time you have spent on
    > my problem.
    >
    > Suppose I use the following solution:
    >


    <snip: repeat of earlier post with different subject & thread>

    Since you appear to be using Google groups, you may be unaware that most
    readers of the comp.lang.perl.misc newsgroup do not use google groups
    and that therefore it is helpful to follow long established conventions
    that predate the existence of Google.

    See http://groups.google.com/googlegroups/posting_style.html

    in particular:
    http://groups.google.com/googlegroups/posting_style.html#summarize

    Since you posted a new posting rather than replying to an existing one,
    your posting is detached from the related thread. Since you didn't quote
    any context, many people will have a hard time working out what you are
    talking about.

    I can't remember if you've been pointed to
    http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
    but its well worth reading too.
     
    Ian Wilson, Oct 5, 2005
    #2
    1. Advertising

  3. "RodFGWA" <> wrote in news:1128516951.194779.11140
    @o13g2000cwo.googlegroups.com:

    > Thank you all for your replies. I appreciate the time you have spent
    > on my problem.


    Why do you keep posting the same message. How is this any different than

    http://groups.google.com/group/comp.lang.perl.misc/msg/3bc2bd64f3cc2ad0

    Sinan

    --
    A. Sinan Unur <>
    (reverse each component and remove .invalid for email address)

    comp.lang.perl.misc guidelines on the WWW:
    http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
     
    A. Sinan Unur, Oct 5, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JezB

    Resource File Manipulation

    JezB, Feb 25, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    323
  2. Roedy Green

    Zip file manipulation

    Roedy Green, Aug 17, 2003, in forum: Java
    Replies:
    2
    Views:
    864
    Roedy Green
    Aug 17, 2003
  3. John Harrison

    Re: file overwrite data manipulation

    John Harrison, Jun 26, 2003, in forum: C++
    Replies:
    2
    Views:
    5,958
    John Harrison
    Jun 27, 2003
  4. Chris Theis
    Replies:
    0
    Views:
    810
    Chris Theis
    Jun 26, 2003
  5. Darren

    File Manipulation

    Darren, Oct 25, 2003, in forum: C++
    Replies:
    1
    Views:
    337
    Jon Bell
    Oct 25, 2003
Loading...

Share This Page