Gerryjun has asked for the wisdom of the Perl Monks concerning the following question:

Lost soul, needs help!

Q1. How to easily sort a scalar not by its key, but by two of its fields alphabetically?
example: $SCALAR{‘key’}[0] -- as last name $SCALAR{‘key’}[1] -- as first name

Q2. Is it possible to detect if a request came from a browser refresh? Because in my program by pressing the browser back button until just before the login form, a user that has been sign out, can sign in just by pressing the refresh, it would seem that the user name and password from the sign in form are being resent.

Thank you!!

Replies are listed 'Best First'.
Re: About %SCALAR & browser refresh
by suaveant (Parson) on Sep 24, 2001 at 23:10 UTC
    Q1 code like this...
    @sorted = sort { "$SCALAR{$a}[0] $SCALAR{$a}[1]" cmp "$SCALAR{$b}[0] $ +SCALAR{$b}[1]" } keys %SCALAR;
    Q2 yes, there are ways... the way I commonly do it is put something in the url, like a link count, so if a page's link count is 5, all of your links will contain 6... if you see a number less than 6, then they have reloaded or gone back or bookmarked or something. There are other ways, but this may give you an idea :)

                    - Ant
                    - Some of my best work - Fish Dinner