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

  • Home
  • SEARCH
  • 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 6071023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:00:00+00:00 2026-05-23T10:00:00+00:00

How do I copy/clone an object ref that has been blessed? For example, I

  • 0

How do I copy/clone an object ref that has been “blessed”? For example, I have

my $html = HTML::PullParser->new(file => $file, text => 'text');

then I want to iterate over that $html object multiple times via

$html->get_token();

So what I tried to do is to copy the object first:

use Clone qw(clone);
my $html1 = clone($html);
my $html2 = clone($html);

Then I tried to iterate over the new objects:

while ($html1->get_token()) {
    # do something
}
while ($html2->get_token()) {
    # do something else
}

But clearly the object is NOT copied over (or at least not copied over in the right way) so that I do not get any iteration in either loop.

What is the right way to copy this object?

Thx!!

  • 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-23T10:00:00+00:00Added an answer on May 23, 2026 at 10:00 am

    In general, cloning an object requires knowledge of its internal structure. Clone just copies the internal structure, which works on plain data structures and many objects, but fails on more complex objects in unpredictable ways.

    In this case, the HTML::PullParser object is reading from a filehandle. The cloned copy gets a reference to the same filehandle, so they are not independent.

    Some objects have a clone method, but HTML::PullParser does not. You can create multiple objects:

    my $html1 = HTML::PullParser->new(file => $file, text => 'text');
    my $html2 = HTML::PullParser->new(file => $file, text => 'text');
    

    and they will be independent. Or are you trying to clone the object in the middle of parsing? Perhaps you can explain why you think you need to clone the parser and we can suggest a better approach.

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

Sidebar

Related Questions

I have some code that performs a deep copy using Object.clone, but I'm trying
If I have a clone of a git repository as a cached copy on
I need to copy the newest file in a directory to a new location.
I have this code: Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application(); object nullobj = System.Reflection.Missing.Value; object
I would like to ask about PHP clone / copy object to $this variable.
The Object.clone() method in Java is pretty special, as instead of returning a copy
I am trying to automatically clone an object without having to instantiate a new
I have an object which has many bufferedimages in it, I want to create
I have a function that returns a user-defined object. First I want to know
I have a pre-made Word Template that has a table. I would like to

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.