[NTLUG:Discuss] Perl help
Stuart Johnston
saj at thecommune.net
Wed Feb 6 14:05:57 CST 2008
oops, typo:
my $path = '/path/to/files';
for $n ( 31000 .. 31500 ) { if ( ! -e "$path/$n.wav" ) ...
Stuart Johnston wrote:
> You can use Eric's solution by simply prepending the path:
>
> my $path = '/path/to/files';
> for $n ( 31000 .. 31500 ) { if ( ! -e "$page/$n.wav" ) ...
>
>
> Michael Barnes wrote:
>> Thanks, Eric. This works fine run from command line in the folder
>> containing the desired files.
>> However, I need to include it into a script along with a bunch of
>> other things. It will not be in the folder containing the files.
>>
>> I have tried
>>
>> $n = glob "/path/to/files/*";
>>
>> which, of course does not work.
>>
>> I guess I need to get a
>>
>> foreach $n (@files) {
>>
>> type of thing in there, but I can't get it to work.
>>
>> Thanks for your kind assistance.
>>
>> Michael
>>
>> On Feb 5, 2008 4:33 PM, Eric Waguespack <ewaguespack at gmail.com> wrote:
>>> perl -e 'for $n ( 31000 .. 31500 ) { if ( ! -e "$n.wav" ) { print
>>> "$n.wav\n"; exit }}; done'
>>>
>>> ./e
>>>
>>>
>>> On Feb 5, 2008 4:10 PM, Michael Barnes <barnmichael at gmail.com> wrote:
>>>> I'm looking for a quick perl script and my brain just isn't
>>>> functioning right now.
>>>>
>>>> I have a folder full of audio files. Each file is a five digit
>>>> number.wav, i.e. 12345.wav.
>>>>
>>>> Files are entered in this folder into particular groups of numbers, so
>>>> there are lots of gaps.
>>>>
>>>> I need to search a range of these files from 31000.wav to 31500.wav
>>>> (ignoring everything below 31000 and above 31500) and find the largest
>>>> available file number to use. There may be files 31000.wav-31057.wav
>>>> in use, (There would be no files 31058-31500) making 31058 the next
>>>> available file.
>>>>
>>>> All I need to do is get the next number (31058 in this case) into a
>>>> variable to be used elsewhere.
>>>>
>>>> I know this should be quite easy, but I sure can't get my head around
>>>> it right now.
>>>>
>>>> Thanks for any help you can come up with.
>>>>
>>>> Michael
>>>>
>> _______________________________________________
>> http://www.ntlug.org/mailman/listinfo/discuss
>
>
> _______________________________________________
> http://www.ntlug.org/mailman/listinfo/discuss
More information about the Discuss
mailing list