Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Bugfixing Old Code

by choroba (Cardinal)
on Jul 22, 2021 at 15:38 UTC ( [id://11135304]=note: print w/replies, xml ) Need Help??


in reply to Bugfixing Old Code

For some time, it was possible to use
push $scalar, @values;

It's not possible anymore. You have to dereference the scalar. In this particular case, use

push @{ $TTTPLOT[$index] }, @twenty_SFs;

BTW, this is not a valid syntax and has never been:

push /@TTTPLOT, /@header;

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^2: Bugfixing Old Code
by cluelessPerlMan (Initiate) on Jul 22, 2021 at 15:43 UTC

    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?

      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]
      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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11135304]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-23 23:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found