1. Toby Inkster
  2. p5-web-magic

Commits

Toby Inkster  committed 2e334a3

Magic one-liners

  • Participants
  • Parent commits 5610853
  • Branches default

Comments (0)

Files changed (1)

File lib/Web/Magic.pm

View file
  • Ignore whitespace
 {
 	my ($class, %args) = @_;
 	
+	if ($0 eq q<-e> and caller eq 'main')
+	{
+		$args{-quotelike} ||= ['web'];
+	}
+	
 	my $caller = caller;
 	
 	unless (exists $args{-util} and not $args{-util})
 
 No shortcut is provided for C<new_from_data>.
 
+In Perl one-liners (that is, using the "-e" or "-E" command-line options),
+C<< use Web::Magic -quotelike => 'web' >> is automatically exported into
+C<main>. So this works:
+
+ perl -MWeb::Magic -E'web <http://example.com/> \
+   -> make_absolute_urls \
+   -> findnodes("~links") \
+   -> foreach(sub { say $_->{href} })'
+
 =head2 Pre-Request Methods
 
 Constructing a Web::Magic object doesn't actually perform a request