In-place editing of multiple files in a directory using Perl's diamond and in-place edit operator
I am trying to in-place edit a bunch of text files using Perl's in-place edit operator $^I. I traverse through the directory using the diamond (<>) operator like this:

    $^I = ".bak";

    @ARGV = <*.txt>;

    while (<>)
    {
        s/((?:^|\s)-?)(0+)(?=\s|$)/$1.$2/g;
        print;
    }

This works perfectly and does the job I need it to do. But what if my @ARGV is already populated with some other data I need for the program? I tried to do the following:

    $^I = ".bak";

    my @files = <*.txt>;

    while (<@files>)
    {
        s/((?:^|\s)-?)(0+)(?=\s|$)/$1.$2/g;
        print;
    }

But it does not work. What I am I missing here? I can't use my $ARGV as it contains other data and can't mess it with file matching patterns.

Any suggestions?

Thanks!

In-place editing of multiple files in a directory using Perl's diamond and in-place edit operator
===

I am trying to in-place edit a bunch of text files using Perl's in-place edit operator $^I. I traverse through the directory using the diamond (<>) operator like this:

    $^I = ".bak";

    @ARGV = <*.txt>;

    while (<>)
    {
        s/((?:^|\s)-?)(0+)(?=\s|$)/$1.$2/g;
        print;
    }

This works perfectly and does the job I need it to do. But what if my @ARGV is already populated with some other data I need for the program? I tried to do the following:

    $^I = ".bak";

    my @files = <*.txt>;

    while (<@files>)
    {
        s/((?:^|\s)-?)(0+)(?=\s|$)/$1.$2/g;
        print;
    }

But it does not work. What I am I missing here? I can't use my $ARGV as it contains other data and can't mess it with file matching patterns.

Any suggestions?

Thanks!
