in reply to Re: Need help protecting the user - detecting and redirecting browsers the ADVANCED way...
in thread Need help protecting the user - detecting and redirecting browsers the ADVANCED way...

Say a user attempts to view a page and the browser is detected to have not passed. I would like to be able to list (for ( keys %passed )) the passed browsers along with formal browser names, versions, and URL info.

I am seeing something like this forming:

my %passed = { # MSIE 5.0 on MS NT 4.0 1 = ( HTTP_USER_AGENT => "Mozil +la/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)", NAME => "MS Internet + Explorer" VERSION => "5.0" PLATFORM => "NT" MANUFACTURER => "Microsoft" URL => "http://w +ww.microsoft.com"

Does this seem like the correct way to go with this idea? How would I structure the line to display the info like:

Here is a list of browsers that have passed testing:

   + MS Internet Explorer 5.0 / NT (http://www.microsoft.com)
...

being that the info is a hash in a hash in a hash?

======================
Sean Shrum
http://www.shrum.net

  • Comment on Re: Re: Need help protecting the user - detecting and redirecting browsers the ADVANCED way...
  • Download Code

Replies are listed 'Best First'.
Re: Re: Re: Need help protecting the user - detecting and redirecting browsers the ADVANCED way...
by particle (Vicar) on Mar 02, 2002 at 12:54 UTC
    since you're building this data structure manually, you have the ability to keep it in a config file, and do or eval it when neccessary. if you have unique values, for instance HTTP_USER_AGENT, you can use this as the key to the hash. i have an example below.

    if you don't have unique values, or require some combination of values for a unique key, you'll have to modify the data structure a little bit, to make sure your keys are unique.

    in any case, a read through perldsc will give you insight on working with complex data structures like hashes of hashes.

    my %passed = { "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)"=> { NAME => "MS Internet Explorer", VERSION => "5.0", PLATFORM => "NT", # more specialized info here }, # more HTTP_USER_AGENT strings here... URI_REDIRECT => 'http://passaddress/', }; # if $test_key is the unique browser identifier you're looking for # you may print like... my $message = join( ' ', $passed{$test_key}->{NAME}, $passed{$test_key}->{VERSION}, '/', $passed{$test_key}->{PLATFORM), # etc. );

    ~Particle ;Þ

      Ahhhh! I didn't know you could have key names with spaces in them. I learned something new. In that case, you're right.

      Moo-Chess-Grass-e-ous!

      ======================
      Sean Shrum
      http://www.shrum.net