SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

Tendances

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
 

Tendances (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
 

En vedette

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
 

En vedette (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
 

Similaire à 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
 

Similaire à 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
 

Dernier

+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@
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Dernier (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
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...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
+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...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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
 
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
 

COMP2021 Final Project - LightHTML