what i would like/home/units/bakery/cake.pl /home/units/bakery/pie.pl /home/units/bakery/plumcake.pl /home/units/fruitjunction/juice.pl /home/units/fruitjunction/icecream.pl /home/units/bakery/choclate.pl
it would be something like in the file i am writing...1. it should maitain the same order as listed. 2. based on the pattern (bakery|fruitjunction) it should add some patt +ern
currently my code is# BAKERY /home/units/bakery/cake.pl /home/units/bakery/pie.pl /home/units/bakery/plumcake.pl # END BAKERY # FRUITJUNCTION /home/units/fruitjunction/juice.pl /home/units/fruitjunction/icecream.pl # END FRUITJUNCTION # BAKERY /home/units/bakery/choclate.pl # END BAKERY
but i am unable to maintain the order of the files . similiar type is required for one of the modules in my project and hence i have changed the name of the files .... Thanks,my @bakery; my @fruitjunction; foreach my $file ( @filenames) { push (@bakery,$file) if($file =~ /bakery/) ; push (@fruitjunction,$file) ($file =~ /fruitjunction/); } if(scalar(@bakery)) { print WRITE "# BAKERY \n"; print WRITE @bakery; print WRITE "# END BAKERY \n"; } if(scalar(@fruitjunction)) { print WRITE "# FRUITJUNCTION \n"; print WRITE @fruitjunction; print WRITE "# END FRUITJUNCTION \n"; }
In reply to insert lines based on some pattern by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |