Wildcarding in a Perl @ARGV Context?

Hello folks!

While "sedding" about again, I ran into this little conundrum du jour:

#!/usr/bin/perl

use strict;
use warnings;
use diagnostics;

@ARGV = ('./afile.dat', './*.txt');

$^I = '';
while (<>)
{
    s/Twinkies/Dinner/g;
    print;
}

When run, perl complains,

...but, of course, "afile.dat" gets its dinner in good fashion.

So, how would one reform the @ARGV line to process the collected textfiles scattered about on this dir as well?

Thanks a bunch :wink:

Try

@ARGV=glob('./*.txt');
unshift(@ARGV, "./afile.dat");
1 Like

@Corona688:

Done; and thank you kindly :wink: