Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: How can I get the last element of an array inside of fetchall_arrayref?

by hippo (Bishop)
on Mar 23, 2021 at 18:45 UTC ( [id://11130229]=note: print w/replies, xml ) Need Help??


in reply to Re^2: How can I get the last element of an array inside of fetchall_arrayref?
in thread How can I get the last element of an array inside of fetchall_arrayref?

Your variables (scalars and arrays in this case) which are declared outside the loop will continue to hold their values once the loop is finished - just like they do in your second example. Try it and see!

Scoping is an important topic in programming generally, not just in Perl. It will be worth your time to read and learn more about it. The usual reference given is Coping with scoping which covers lots more than you will need for this particular question - but it is all good stuff.


🦛

  • Comment on Re^3: How can I get the last element of an array inside of fetchall_arrayref?

Replies are listed 'Best First'.
Re^4: How can I get the last element of an array inside of fetchall_arrayref?
by Lewisa (Novice) on Mar 23, 2021 at 20:09 UTC
    Thanks a lot! I will read that top to bottom as I thought I understood scope but I'm clearly missing a few key points.
Re^4: How can I get the last element of an array inside of fetchall_arrayref?
by Lewisa (Novice) on Mar 24, 2021 at 01:20 UTC
    Hey Hippo. I thought that I responded to your comment. Thank you! I thought I had a great understand of scope but I see that I'm missing a few key points. I will be reading that link you posted.

Log In?
Username:
Password:

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

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

    No recent polls found