Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Answer: How do I strip lines prefixed by a

by runrig (Abbot)
on Oct 25, 2000 at 07:32 UTC ( #38281=categorized answer: print w/replies, xml ) Need Help??

Q&A > regular expressions > How do I strip lines prefixed by a "#" - Answer contributed by runrig

Simplest is to:
while (<INFILE>) { next if /^#/; # or next if substr($_,0,1) eq '#'; $content .= $_; };

Replies are listed 'Best First'.
RE: Answer: How do I strip lines prefixed by a
by Coplan (Pilgrim) on Oct 25, 2000 at 07:37 UTC
    Ok....that works great!

    But I am (unfortunately) a beginner Perl Hacker. So could you (or someone) please explain what exactly you did?

    I think it's the ^ that confuses me a bit.

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
[james28909]: it would be to much work just to get around renaming three subs lol
[james28909]: but you could put it all in one sub and return the same data type that was inputted. i could write a small example maybe
[Lady_Aleena]: Their uses are also vastly different.
[Lady_Aleena]: The first two make hashes and arrays from a file, the third returns data from a pre-existing hash.
[Lady_Aleena]: Well, HoH and AoH respectively.

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2017-05-24 05:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?