wfsp has asked for the wisdom of the Perl Monks concerning the following question:
I want to iterate over each selector in the CSS object and get its name. Dumping the object shows that everything is there but I can't work out which assessor to use never mind how to use it.
My current attempts have proven woefully inadequate. Any pointers appreciated.
#!/usr/bin/perl use strict; use warnings; use CSS; use Data::Dumper; $Data::Dumper::Indent = 1; my $css_data = do{$/ = undef; <DATA>}; #print qq{$css_data\n}; my $css = CSS->new(); $css->read_string($css_data); #print Dumper $css; # fails #my $style = $css->get_style_by_selector('selector_name') # or die qq{could't get style\n}; #my @styles = $css->styles; #my $selectors = $css->selectors; # works print $css->output(); # [id://208695|Simplifying CSS] __DATA__ .selector_name { margin-left: 1em; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Extracting a list of selectors from a css file
by shmem (Chancellor) on Jul 14, 2007 at 14:55 UTC | |
|
Re: Extracting a list of selectors from a css file
by un-chomp (Scribe) on Jul 14, 2007 at 23:02 UTC |