Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 224149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:17:23+00:00 2026-05-11T19:17:23+00:00

I asked a question earlier today regarding using Perl to search in a CSS

  • 0

I asked a question earlier today regarding using Perl to search in a CSS document. I have since refined my requirements a little bit, and have a better idea of what I am trying to do.

The document I am searching through is actually an .html doc with CSS as a style in the <head>, if that makes sense.

Basically, what I need to do though is find all the CSS elements that have a color or background color attribute, and record them. Here’s my thought process.

  1. open the file and set it as an array
  2. read the array line-by-line until it comes to a “{“
  3. make everything into a scalar variable or array until I get to the “}”
  4. search the secondary variable or string for instances of “color” blah blah blah.

The issue I am having is finding a way to scour the document and turn everything between { and } into a variable of some sort. Any one have any ideas?

Cheers!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T19:17:23+00:00Added an answer on May 11, 2026 at 7:17 pm

    No matter what, I wouldn’t recommend writing your own code from the ground up for this. You should use a parser. A quick search on CPAN suggests this family of modules. On the other hand, if your css is in an html file rather than a separate css file (shame on you), then you might end up needing a different type of parser.

    Either way, it’s generally not a good idea to try to hand-roll your own quasi-parser out of regular expressions. Use a proper parser, and leverage someone else’s work.

    On a slightly different tack, if you only want to extract some of the information from a file of any kind, then in many cases you don’t want to put the whole file into an array first. (It can be memory intensive if the file is very large, and it’s unnecessary.) It’s easy to open the file and the process the items as you work through it line by line.

    #!/usr/bin/env perl
    use strict;
    use warnings;
    
    open my $fh, '<', 'file-of-interest'
      or die "Couldn't open 'file-of-interest': $!";
    
    my @saved_items;
    
    while (my $line = <$fh>) {
      # process $line
      # push @saved_items, $something
    }
    
    # Do more fun stuff with @saved_items
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 104k
  • Answers 104k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Different architectures have different rules, but in general, memory loads… May 11, 2026 at 8:33 pm
  • Editorial Team
    Editorial Team added an answer Interesting... In my Server 2008 I have it listed right… May 11, 2026 at 8:33 pm
  • Editorial Team
    Editorial Team added an answer You could always use the Enum with Visitor pattern: enum… May 11, 2026 at 8:33 pm

Related Questions

Earlier today I asked a question about environ , and one of the more
Earlier today I asked wether it would be a good idea to develop websites
This stems out of How can one number paragraphs in LaTeX? , which I
I asked a question earlier about which language to use for an AI prototype.
I asked a question earlier , and got an excellent response, but, being a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.