Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Head comments parsing

by ChOas (Curate)
on May 18, 2001 at 14:00 UTC ( [id://81459]=note: print w/replies, xml ) Need Help??


in reply to Head comments parsing

Hey ;))

Something like this ?:
while (<INPUTFILE>) { last if $HeaderLines==$.; ProcessHeader($_); };

If you know how many lines there are in the header
you can just set $HeaderLines to that...($. will be set to the current
line number during each read (I`m assuming you`re using \n as a delimiter))

Since you didn`t mention any other header-delimeter or tags, and said `top of the file`...
that would be my guess

GreetZ!,
    ChOas

print "profeth still\n" if /bird|devil/;

Replies are listed 'Best First'.
Re: Re: Head comments parsing
by toadi (Chaplain) on May 18, 2001 at 15:11 UTC
    Ok... See i know how to parse te header... But i only want the top of the file being parsed!!!

    eg for perl:
    #!/usr/bin/perl -w # # Comment's about the file ... # ########################################### # Need this ... use strict;
    IMHO opninion it can't be safely done because there is now way every comment structure is the same...



    --
    My opinions may have changed,
    but not the fact that I am right

      # Assume that the header is all the first block of commented # lines and that the first non-comment line ends the # header block while (<OLDFILE>) { last unless is_comment($filetype, $_); } # Print new header to new file print NEWFILE new_header($filetype); # Print the rest of the file while (<OLDFILE>) { print NEWFILE $_; }
      --
      <http://www.dave.org.uk>

      "Perl makes the fun jobs fun
      and the boring jobs bearable" - me

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://81459]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-23 23:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found