in reply to very new to perl; suggestions for porting this shell script to perl?
@Files=readdir(DIR);
It could be better stated:
my @Files = grep /\.desktop$/, readdir DIR;
grep will only pass *.desktop files to @Files
If you plan on writing Perl scripts, it would be advisable to declare your variables, (usually with 'my'), and to include the lines (at the beginning of your script):
#!/usr/bin/perl use strict; use warnings;
These will tell you of errors in your code syntax, spelling mistakes, etc. You will find nearly all the code on this site follow that method.
Update: It would also be helpful to see some of the input files, in paticular, lines that match Categories and Name and Exec.
One last thing - it would be nice to enclose these sample inputs and outputs in <readmore>. . .</readmore> tags so your post doesn't take so much space. :-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: very new to perl; suggestions for porting this shell script to perl?
by sinusoid (Initiate) on May 29, 2011 at 00:51 UTC | |
by Cristoforo (Curate) on May 29, 2011 at 20:35 UTC | |
by Anonymous Monk on May 30, 2011 at 23:53 UTC | |
by sinusoid (Initiate) on May 31, 2011 at 00:01 UTC | |
by Cristoforo (Curate) on May 31, 2011 at 00:08 UTC |