#!/usr/bin/perl # # Summary: prints all the filenames which are imported from the main css file # Parameters: base_dir: Specifies the base directory where all the css files are located # maincss_file: The main css file from where the lookup should be started use File::Basename; if ($#ARGV != 0) { print usage(); exit 1; } sub usage { print "Usage:\n"; print "perl mergecss.pl base_dir maincss_file \n"; print "where base_dir: Specifies the base directory where all the css files are located \n"; print "\tmaincss_file: The main css file from where the lookup should be started"; } my $css_file = $ARGV[0]; #"C:\\projects\\iwc1_dojo_port\\commssuite\\iwc\\static\\layout\\css\\Default.css"; my @allcss; #uncomment this for windows #fileparse_set_fstype('MSWin32'); sub listImports($) { my $filename = shift; my @list; my $base_dir = dirname($filename); open CSSFILE, "$filename" or die "Cannot open $filename: $!"; while ( ) { if (m/^\s*\@import url\([\"\'](.*)[\"\']\);/) { push @list, "$base_dir/$1"; } } return @list; } sub listFiles($) { $f = shift; my @temp = listImports($f); push @allcss, $f; foreach(@temp) { listFiles($_); } } listFiles($css_file); print "$_\n" foreach(@allcss);