in reply to Re: Bugfixing Old Code
in thread Bugfixing Old Code

Thank you, after making your changes "Can't use string ("StartFerrite") as an ARRAY ref while "strict refs" in use at ../../plot_TTTDIA.pl line 58" this is a reference to temp_and_starts in the following block:

# Read the file's per-temperature data while(<$in>) { # Split on multiple spaces using regex captured matches my @temp_and_starts = @{$_} =~ /[ +^\s]+/g; my @last_AT_fracs = <$in> =~ /[^\s +]+/g; my @twenty_SFs = (<$in> . <$in> . <$in> . <$in>) =~ /[^\s +]+/g; my $max_SF = max @twenty_SFs; # Build the @TTTPLOT row $TTTPLOT[$index]->[0] = $temp_and_starts[0]; $TTTPLOT[$index]->[1] = $temp_and_starts[1]; $TTTPLOT[$index]->[2] = $temp_and_starts[2]; $TTTPLOT[$index]->[3] = $temp_and_starts[3]; $TTTPLOT[$index]->[4] = $max_SF; push @{ $TTTPLOT[$index] }, @twenty_SFs; $index++; }

Is this a simple fix or does it require an overhaul?

Replies are listed 'Best First'.
Re^3: Bugfixing Old Code
by choroba (Cardinal) on Jul 22, 2021 at 15:56 UTC
    Are you sure this has ever worked? This line makes no sense:
    my @temp_and_starts = @{$_} =~ /[^\s]+/g;

    Under warnings, it even warns:

    Applying pattern match (m//) to @array will act on scalar(@array)

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
Re^3: Bugfixing Old Code
by NetWallah (Canon) on Jul 23, 2021 at 00:50 UTC
    Without knowing what the data looks like, here is my guess at what "should" work:
    my @temp_and_starts = $_=~/(\S+)/g; my @last_AT_fracs = scalar(<$in>) =~/(\S+)/g; my @twenty_SFs = (<$in> . <$in> . <$in> . <$in>) =~/(\S+) +/sg;

                    "The difficult we do today; the impossible takes a little longer."

      I thought that required brackets as in my @temp_and_starts = ($_=~/(\S+)/g); but it does not.

        Also note that $_=~ can be shortened to . Moreover, you don't need a capture if you capture the whole pattern.
        my @temp_and_starts = /\S+/g;
        map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]