There is no CSS Selector for :first
.
The following uses :nth-child(1)
to isolate the first column and then removes the cells:
Could also have used :first-child
, :first-of-type
, etc. Be sure to check out all the different selectors available to be sure which ones will serve your purpose best.
use strict;
use warnings;
use Mojo::DOM;
my $dom = Mojo::DOM->new(do {local $/; <DATA>});
$dom->find('tr > td:nth-child(1)')->each( sub {$_->remove} );
print $dom;
__DATA__
<html>
<head>
<title>Hello Tables</title>
</head>
<body>
<h1>Hello world</h1>
<table>
<tr><td>Row 1 Col 1</td><td>Row 1 Col 2</td><td>Row 1 Col 3</td></tr>
<tr><td>Row 2 Col 1</td><td>Row 2 Col 2</td><td>Row 2 Col 3</td></tr>
<tr><td>Row 3 Col 1</td><td>Row 3 Col 2</td><td>Row 3 Col 3</td></tr>
<tr><td>Row 4 Col 1</td><td>Row 4 Col 2</td><td>Row 4 Col 3</td></tr>
</table>
</body>
</html>
Outputs:
<html>
<head>
<title>Hello Tables</title>
</head>
<body>
<h1>Hello world</h1>
<table>
<tr><td>Row 1 Col 2</td><td>Row 1 Col 3</td></tr>
<tr><td>Row 2 Col 2</td><td>Row 2 Col 3</td></tr>
<tr><td>Row 3 Col 2</td><td>Row 3 Col 3</td></tr>
<tr><td>Row 4 Col 2</td><td>Row 4 Col 3</td></tr>
</table>
</body>
</html>