how can I create this program more concise. I'm new to PEARL so I'm still learning the tricks. Any assistance would be really appreciated. The code works, I just want to make it more neat and short. I feel like I'm writing too much code for what it does. I keep experimenting with regex but I can't seem to make it work using regex.
#!/usr/bin/perl opendir(CURRENT,"."); @list = readdir(CURRENT); closedir(CURRENT); my $string = "messages"; my $x = 0; foreach $item(@list){ if($item =~ /^$string\.*\d*/){ open(FILE,"$string"); open(FILE1,"$string.1"); open(FILE2,"$string.2"); open(FILE3,"$string.3"); open(FILE4,"$string.4"); $content = <FILE>; $content1 = <FILE1>; $content2 = <FILE2>; $content3 = <FILE3>; $content4 = <FILE4>; while($content == $x){ print ($content, $content1, $content2, $content3, $content4); $x++; close(/FILE\d*/); } } }
In reply to Perl: Directoriesand files by craziestfire73
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |