Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6364331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:09:01+00:00 2026-05-25T00:09:01+00:00

sub parse { my ($self,$raw_cookie) = @_; my %results; my @pairs = split([;,] ?,$raw_cookie);

  • 0
sub parse {
  my ($self,$raw_cookie) = @_;
  my %results;

  my @pairs = split("[;,] ?",$raw_cookie);
  foreach (@pairs) {
    s/\s*(.*?)\s*/$1/;
    my($key,$value) = split("=",$_,2);

    # Some foreign cookies are not in name=value format, so ignore
    # them.
    next if !defined($value);
    my @values = ();
    if ($value ne '') {
      @values = map unescape($_),split(/[&;]/,$value.'&dmy');
      pop @values;
    }
    $key = unescape($key);
    # A bug in Netscape can cause several cookies with same name to
    # appear.  The FIRST one in HTTP_COOKIE is the most recent version.
    $results{$key} ||= $self->new(-name=>$key,-value=>\@values);
  }
  return \%results unless wantarray;
  return %results;
}

Anyone knows why @values = map unescape($_),split(/[&;]/,$value.'&dmy'); is there?

Why must convert it to an array first?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:09:01+00:00Added an answer on May 25, 2026 at 12:09 am

    Converted? First? Your question doesn’t make much sense. I’m going to assume you want to know what the code that populates @values does.

    The code in question takes a string containing a series of values, and separates it into a list of values. This list is stored in an array because it’s the only type of variable that would hold that.

    I’m not clear on why &dmy is added and then removed. I suspect it’s to prevent empty trailing arguments from being removed by split, but a third argument of -1 would do that more clearly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to parse url-encoded strings that are made up of key=value pairs
I would like to parse text and separate it into tasks and subtasks: 'Asubsubsubtask:Bsubtask:Ctask:D'.split(/((sub)*task)\:/i)
I have: An XML with some elements. A sub-element that may or may not
I’m trying to parse some JSON from the twitter API and extract the value
I'd like to be able to use ruby's OptionParser to parse sub-commands of the
I am trying to parse some C# code to Python. There are several regular
If I pass a hash to a sub: parse(\%data); Should I use a variable
I need to parse text lists: 1 List name 1 item 2 item 3
I am trying to get the key, value attributes of the xml using the
I'm trying to parse JSON in android but am having trouble with accessing sub

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.