SlideShare ist ein Scribd-Unternehmen logo
1 von 20
Light</HTML>
list - ls [options] elements
clean - cl elements
delete - de [options] elements
delete - de [options] elements
DEMO
Dispatch Table
hash of references to executable code
Dispatch Table
my $dispatchTable = {
! a => &func_a,
! b => &func_b,
! q => sub { exit(0) },
};
while ( 1 ) {
! print "Press a key!n";
! chomp (my $input = <STDIN>);
! if (defined $dispatchTable->($input)) {
! ! $dispatchTable->{$input}->();
! }
}
Hash table
Get user input
reference to function argvs
Dispatch Table
my $myFunc = {
! s => &saveFile,
! de => &deletTag,
! cl => &cleanUp,
! ls => &listTags,
! q => sub { $root = $root->delete; exit(0) },
! DEFAULT => sub {print ("Command not found.n")}
};
HTML::TreeBuilder
Parser that builds a HTML syntax tree
http://search.cpan.org/~cjm/HTML-Tree-5.03/lib/HTML/TreeBuilder.pm
HTML::Tree
make parse trees out of
HTML source
HTML::TreeBuilder
builds the parse trees
HTML::Element
parse trees are made up of
element class objects
create tree object
HTML::TreeBuilder
#!/usr/bin/perl -w
use warnings FATAL => 'all';
use strict;
use HTML::TreeBuilder;
use Term::ANSIColor;
(@ARGV == 1) || exit print "Usage: [HTML file].n";
(-e $ARGV[0]) || exit print "Input file does not exist.n";
my $root = HTML::TreeBuilder->new;
$root->parse_file($ARGV[0]) || die "$!";
include module
html
head
title meta
body
p
h1,h2...div
p p
Perl & LWP
by Sean M. Burke
"Fetching web pages, Parsing HTML,
Writing Spiders, & More"
http://lwp.interglacial.com/index.html
Chapter 9
HTML Processing with Trees
Chapter 10
Modifying HTML with Trees
Light</HTML>
GitHub : LightHTML
https://github.com/Conrad-Lo/LightHTML

Weitere ähnliche Inhalte

Was ist angesagt?

Nette framework (WebElement #27 lightning talk)
Nette framework (WebElement #27 lightning talk)Nette framework (WebElement #27 lightning talk)
Nette framework (WebElement #27 lightning talk)
Adam Štipák
 
Tips for using Firebird system tables
Tips for using Firebird system tablesTips for using Firebird system tables
Tips for using Firebird system tables
Mind The Firebird
 

Was ist angesagt? (20)

week-14x
week-14xweek-14x
week-14x
 
Nette framework (WebElement #27 lightning talk)
Nette framework (WebElement #27 lightning talk)Nette framework (WebElement #27 lightning talk)
Nette framework (WebElement #27 lightning talk)
 
wget.pl
wget.plwget.pl
wget.pl
 
Array menu
Array menuArray menu
Array menu
 
Tips for using Firebird system tables
Tips for using Firebird system tablesTips for using Firebird system tables
Tips for using Firebird system tables
 
PL/SQL Blocks
PL/SQL BlocksPL/SQL Blocks
PL/SQL Blocks
 
An Elephant of a Different Colour: Hack
An Elephant of a Different Colour: HackAn Elephant of a Different Colour: Hack
An Elephant of a Different Colour: Hack
 
PHP object calisthenics
PHP object calisthenicsPHP object calisthenics
PHP object calisthenics
 
Perl Fitxers i Directoris
Perl Fitxers i DirectorisPerl Fitxers i Directoris
Perl Fitxers i Directoris
 
array implementation
 array implementation array implementation
array implementation
 
Final ds record
Final ds recordFinal ds record
Final ds record
 
Migrare da symfony 1 a Symfony2
 Migrare da symfony 1 a Symfony2  Migrare da symfony 1 a Symfony2
Migrare da symfony 1 a Symfony2
 
Password.php
Password.phpPassword.php
Password.php
 
Node.js - Demnächst auf einem Server in Ihrer Nähe
Node.js - Demnächst auf einem Server in Ihrer NäheNode.js - Demnächst auf einem Server in Ihrer Nähe
Node.js - Demnächst auf einem Server in Ihrer Nähe
 
C program to implement linked list using array abstract data type
C program to implement linked list using array abstract data typeC program to implement linked list using array abstract data type
C program to implement linked list using array abstract data type
 
Codigos
CodigosCodigos
Codigos
 
20191116 custom operators in swift
20191116 custom operators in swift20191116 custom operators in swift
20191116 custom operators in swift
 
8.1
8.18.1
8.1
 
Data structure output 1
Data structure output 1Data structure output 1
Data structure output 1
 
Array imp of list
Array imp of listArray imp of list
Array imp of list
 

Andere mochten auch

210140010 강민지 12주차 수시과제
210140010 강민지 12주차 수시과제210140010 강민지 12주차 수시과제
210140010 강민지 12주차 수시과제
Minji Kang
 
소셜매니저 3차미션(130602)
소셜매니저  3차미션(130602)소셜매니저  3차미션(130602)
소셜매니저 3차미션(130602)
Hwa Yeon Park
 
Asio4 all v2 instruction manual
Asio4 all v2 instruction manualAsio4 all v2 instruction manual
Asio4 all v2 instruction manual
Jonas Souza
 
76157598 pr-mihai-andrei-aldea-despre-colinde-și-colindat
76157598 pr-mihai-andrei-aldea-despre-colinde-și-colindat76157598 pr-mihai-andrei-aldea-despre-colinde-și-colindat
76157598 pr-mihai-andrei-aldea-despre-colinde-și-colindat
Raluca Mihaela
 
A language for learning (thinking maps)
A language for learning (thinking maps)A language for learning (thinking maps)
A language for learning (thinking maps)
Sandra Herrera
 
Powerpoint taylor swift
Powerpoint taylor swiftPowerpoint taylor swift
Powerpoint taylor swift
Denissepaz13
 
Parenteral controlled release drug delivery system -by varsha phirke
Parenteral controlled release drug delivery system -by varsha phirkeParenteral controlled release drug delivery system -by varsha phirke
Parenteral controlled release drug delivery system -by varsha phirke
Varsha Phirke
 

Andere mochten auch (15)

210140010 강민지 12주차 수시과제
210140010 강민지 12주차 수시과제210140010 강민지 12주차 수시과제
210140010 강민지 12주차 수시과제
 
소셜매니저 3차미션(130602)
소셜매니저  3차미션(130602)소셜매니저  3차미션(130602)
소셜매니저 3차미션(130602)
 
Clothes
ClothesClothes
Clothes
 
School Laws Protecting Students with Food Allergies
School Laws Protecting Students with Food AllergiesSchool Laws Protecting Students with Food Allergies
School Laws Protecting Students with Food Allergies
 
Asio4 all v2 instruction manual
Asio4 all v2 instruction manualAsio4 all v2 instruction manual
Asio4 all v2 instruction manual
 
76157598 pr-mihai-andrei-aldea-despre-colinde-și-colindat
76157598 pr-mihai-andrei-aldea-despre-colinde-și-colindat76157598 pr-mihai-andrei-aldea-despre-colinde-și-colindat
76157598 pr-mihai-andrei-aldea-despre-colinde-și-colindat
 
Alex
AlexAlex
Alex
 
Slideshare
SlideshareSlideshare
Slideshare
 
Alex (2)
Alex (2)Alex (2)
Alex (2)
 
Hipertension portal
Hipertension portalHipertension portal
Hipertension portal
 
都道府県の記念日等の一覧(第1版)
都道府県の記念日等の一覧(第1版)都道府県の記念日等の一覧(第1版)
都道府県の記念日等の一覧(第1版)
 
A language for learning (thinking maps)
A language for learning (thinking maps)A language for learning (thinking maps)
A language for learning (thinking maps)
 
Powerpoint taylor swift
Powerpoint taylor swiftPowerpoint taylor swift
Powerpoint taylor swift
 
Parenteral controlled release drug delivery system -by varsha phirke
Parenteral controlled release drug delivery system -by varsha phirkeParenteral controlled release drug delivery system -by varsha phirke
Parenteral controlled release drug delivery system -by varsha phirke
 
Parenteral controlled release drug delivery system - by varsha phirke
Parenteral controlled release drug delivery system - by varsha phirkeParenteral controlled release drug delivery system - by varsha phirke
Parenteral controlled release drug delivery system - by varsha phirke
 

Ähnlich wie COMP2021 Final Project - LightHTML

2014 database - course 2 - php
2014 database - course 2 - php2014 database - course 2 - php
2014 database - course 2 - php
Hung-yu Lin
 
Php tips-and-tricks4128
Php tips-and-tricks4128Php tips-and-tricks4128
Php tips-and-tricks4128
PrinceGuru MS
 
ภาษาซี
ภาษาซีภาษาซี
ภาษาซี
kramsri
 
perl usage at database applications
perl usage at database applicationsperl usage at database applications
perl usage at database applications
Joe Jiang
 

Ähnlich wie COMP2021 Final Project - LightHTML (20)

2014 database - course 2 - php
2014 database - course 2 - php2014 database - course 2 - php
2014 database - course 2 - php
 
My First Ruby
My First RubyMy First Ruby
My First Ruby
 
Refactor like a boss
Refactor like a bossRefactor like a boss
Refactor like a boss
 
PHP POWERPOINT SLIDES
PHP POWERPOINT SLIDESPHP POWERPOINT SLIDES
PHP POWERPOINT SLIDES
 
Data Structure in C Programming Language
Data Structure in C Programming LanguageData Structure in C Programming Language
Data Structure in C Programming Language
 
Crafting Custom Interfaces with Sub::Exporter
Crafting Custom Interfaces with Sub::ExporterCrafting Custom Interfaces with Sub::Exporter
Crafting Custom Interfaces with Sub::Exporter
 
Php 101: PDO
Php 101: PDOPhp 101: PDO
Php 101: PDO
 
Introduzione JQuery
Introduzione JQueryIntroduzione JQuery
Introduzione JQuery
 
C programming array & shorting
C  programming array & shortingC  programming array & shorting
C programming array & shorting
 
Single linked list
Single linked listSingle linked list
Single linked list
 
Elixir in a nutshell - Fundamental Concepts
Elixir in a nutshell - Fundamental ConceptsElixir in a nutshell - Fundamental Concepts
Elixir in a nutshell - Fundamental Concepts
 
Php tips-and-tricks4128
Php tips-and-tricks4128Php tips-and-tricks4128
Php tips-and-tricks4128
 
ภาษาซี
ภาษาซีภาษาซี
ภาษาซี
 
FP in scalaで鍛える関数型脳
FP in scalaで鍛える関数型脳FP in scalaで鍛える関数型脳
FP in scalaで鍛える関数型脳
 
perl usage at database applications
perl usage at database applicationsperl usage at database applications
perl usage at database applications
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using C
 
PHP tips and tricks
PHP tips and tricks PHP tips and tricks
PHP tips and tricks
 
Ds
DsDs
Ds
 
Template Haskell とか
Template Haskell とかTemplate Haskell とか
Template Haskell とか
 
DBIx-DataModel v2.0 in detail
DBIx-DataModel v2.0 in detail DBIx-DataModel v2.0 in detail
DBIx-DataModel v2.0 in detail
 

Kürzlich hochgeladen

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Kürzlich hochgeladen (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

COMP2021 Final Project - LightHTML