Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I avoid this error produced while using 'strict'?
    primarykey
    data
    text
    <p>I have a couple of lines of code that work if <code>use strict;</code> is commented out. However, I don't want to have it disabled for the entire script just because of one small section.</p> <p>I need to either recode it, or somehow disable <code>use strict;</code> temporarily and then re-enable it. The first option is more realistic, but I don't know how to change the code to work in strict mode.</p> <pre><code>my ($ctc_rec_ref) = get_expected_contacts($ctc,$fy); my @expected_ctc_rec = @$ctc_rec_ref; print $expected_ctc_rec[0][0]."\n"; print $expected_ctc_rec[0][1]."\n"; print $expected_ctc_rec[0][2]."\n"; sub get_expected_contacts { my (@ctc_rec,$i) = ((),0); $STMT = "SELECT DISTINCT field1, field2, field3 FROM table WHERE field4 = ? AND field5 = ? AND field6 = 'E'"; $sth = $db1-&gt;prepare($STMT); $sth-&gt;execute(@_); while(@results = $sth-&gt;fetchrow_array()) { push @{ $ctc_rec[$i] }, $results[0]; push @{ $ctc_rec[$i] }, $results[1]; push @{ $ctc_rec[$i] }, $results[2]; $i++; } return (\@ctc_rec); } </code></pre> <p><hr> With <code>use strict;</code> enabled:<br></p> <blockquote> <p>Can't use string ("0") as an ARRAY ref while "strict refs" in use at ./return5.pl line 49.</p> </blockquote> <p>(line 49: <code>push @{ $ctc_rec[$i] }, $results[0];</code>)</p> <p><br> With <code>use strict;</code> disabled:<br></p> <pre><code>1468778 04/01/2011 30557 </code></pre> <hr> <p>How can I rewrite this code so that it works as if strict mode was disabled? If that is not possible, can <code>use strict;</code> be temporarily disabled and then re-enabled for this short piece of code within the script?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload