Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Extracting a list of selectors from a css file

by un-chomp (Scribe)
on Jul 14, 2007 at 23:02 UTC ( [id://626669]=note: print w/replies, xml ) Need Help??


in reply to Extracting a list of selectors from a css file

You could simply loop through the object's data structure (usual caveats apply):
#!/usr/bin/perl use strict; use warnings; use CSS; my $css_data = do{ local $/; <DATA> }; my $css = CSS->new(); $css->read_string( $css_data ); foreach my $style ( @{ $css->{ styles } } ) { foreach my $selector ( @{ $style->{ selectors } } ) { print $selector->{ name } . "\n"; } } __DATA__ .selector_one { margin-left: 1em; } .selector_two, .selector_three { margin-left: 1em; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-03-29 09:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found