Perl - Add and Modify HTML with pQuery

General Tech Learning Aids/Tools 2 years ago

0 1 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Learning Aids/Tools related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

I'm just a hobbyist Perl programmer learning pQuery and using a local HTML file to aid the process. Here is what I have so far:

        use strict;
        use warnings;

        use pQuery;

        my $filename = 'learn.html';
        my $file = pQuery($filename);

        my $metadesc = pQuery("meta", $file)->eq(2);
        my $title = $file->find('title');
        my $h1 = $file->find('h1')->find('a');
        my $h2 = $file->find('h2')->eq(0);

        $title->html('New Title');
        $h1->html('New Heading');
        $h2->html('New Sub-Heading');

However, I've hit a bit of a wall and can't quite work out what to do next. What I'd like to do:

  1. Modify the "Content" attribute of $metadesc;
  2. Add a p inside a div immediately after $h2;

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.