Perl - Add and Modify HTML with pQuery

General Tech Learning Aids/Tools 3 years ago

1.6K 1 0 0 0

User submissions are the sole responsibility of contributors, with TuteeHUB disclaiming liability for accuracy, copyrights, or consequences of use; content is for informational purposes only and not professional advice.

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 3 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;
0 views
0 shares

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.

Similar Forum