fasoli has asked for the wisdom of the Perl Monks concerning the following question:
Hello wise monks,
Can somebody help me match this filename? 1M01_F00121.npt.groWhat I'm doing, first for testing on one file, is
And then, if this succeeded, I wanted to use the variable $i in the matching, as in#/bin/perl/ use strict; #test only for file 1M01_F00121.npt.gro my $file = /(1M01)(\_)(F)(\0+)(121)/; print $file; # for testing `grompp -f input.mdp -c "$file".npt.gro -p topol.top -o "$file".md.tpr +`;
#/bin/perl/ use strict; my $i; #now loop through all the files in the directory for ($i=121; $i<=150; $i++) { my $file = /(1M01)(\_)(F)(\0+)($i)/; print $file; # for testing `grompp -f input.mdp -c "$file".npt.gro -p topol.top -o "$file".md.tpr +`; }
Or do these two code attempts make no sense? I am kind of confused especially about the ending (.npt.gro). Because I want to use the file further on with Gromacs to do some simulations, I'm wondering, does it make sense to also match the .npt.gro or not? What confuses me is the fact that then I'll have to change the file extension each time depending on the simulation step and what kind of output my file becomes, so that's why I decided I shouldn't match the ending.
edit: I forgot to say that all my filenames follow the pattern 1M01_F and then a number of zeros and the index number of my file. The total number of digits after the "F" is always 5. So the files range from 1M01_F00001 to 1M01_F00150, in this directory. That's why I'm trying to match for "one or more zeros".
I'd be grateful if you could provide me with some feedback/corrections as to how I can fix this :)
Thank you very much!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: matching characters in filename
by shmem (Chancellor) on Aug 11, 2015 at 13:14 UTC | |
|
Re: matching characters in filename
by Anonymous Monk on Aug 11, 2015 at 13:13 UTC | |
by Anonymous Monk on Aug 11, 2015 at 13:34 UTC |