The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Sirc::URL - view URLs with an external browser

SYNOPSIS

  From sirc:

    /eval use Sirc::URL

    /url                        # load most recent URL
    /url 27                     # load URL marked as number 27
    /url www.argon.org          # load named URL

    /urls -5                    # list 5 most recent URLs
    /urls 23                    # list url marked as number 23
    /urls                       # list all URLs

    /set url_browser openvt lynx %s &
    /set url_mark off           # disable URL marking
    /set url_mark_format %s[%d] # less verbose marking style
    /set url_max 234            # cycle back to 0 after 234

  From Perl:

    use Sirc::URL qw(browse_url urls);

    browse_url $url;            # load named URL
    ($index, @url) = urls;      # index of most recent, and full list

DESCRIPTION

This module provides an easy way to view URLs which you see on IRC. Each URL printed to the screen (as told by the URI::Find module) is numbered. For example, you might see

    <Morgaine> It was either at http://www.memepool.com (/url 23)
        or http://www.argon.org/~roderick/books.html (/url 24), I'm
        not sure which.

The (/url 23) and (/url 24) tags were added by Sirc::URL.

COMMANDS

/url [number]
/url URL

You can load one of the marked URLs into your web browser by typing

    /url 23     # load http://www.memepool.com
    /url 24     # load http://www.argon.org/~roderick/books.html
    /url        # same, no number means load the most recent one

You can also use the machinery to load an URL you type yourself

    /url www.leisuretown.com
/urls [number]

This command lists the noted URLs.

    /urls -5                    # list 5 most recent URLs
    /urls 23                    # list URL marked as number 23
    /urls                       # list them all

SETTABLE OPTIONS

You can set these variables with sirc's /set command.

url_browser format|code ref

This sets the command which will be used to load URLs. It can be either an sprintf() format or a code reference. The default value is

    netscape -remote openURL\(%s", new-window)" &

If the value is a string it's passed through sprintf() with a single argument (the URL to be viewed, but already shell-escaped, so you shouldn't quote it yourself). The command is interpred with /bin/sh.

If the value is a code reference it's called with the URL and it can do what it likes. You have to use doset() to set this up.

     doset 'url_browser', \&mysub;

I'd originally thought to make a number of pre-canned settings for this, such as combinations of netscape, netscape -remote, and netscape-remote with and without new-window, and text-mode browsers launched with a settable X terminal emulation program or in a new screen window, or the like, but I came to believe that was a bad idea. No matter which method you like to use, you'd do well to have a simple shell script which you can pass URLs to in order to load them, and if you have one of those you can just specify it for this.

url_debug on|off|toggle

This controls debugging messages. You can use them to see what command is actually being run to load an URL.

url_mark on|off|toggle

This turns URL marking on and off. It defaults to on, if the URI::Find module is available.

url_mark_format format|code ref

url_mark_format dictates how URLs are marked up on the screen. It can be either an sprintf() format or a code reference. The default value is

    %s (/url %d)

If it's a string it's given to sprintf() with 3 arguments, the original text, the URL number, and the cleaned-up URL.

This doesn't give you much flexibility, though, since Perl's sprintf() doesn't support position specifiers (eg, %2$s to print the second argument as a string). You can set url_mark_format to a code reference if you need to do something more fancy. Your sub is called with the same 3 args, it returns the text which will replace the original URL. You have to use doset() to set this up.

     doset 'url_mark_format', \&mysub;
url_max number

URL numbers cycle back around to 0 once they pass the url_max, the default is 99. If you set this to -1 the list will just keep growing (and your free memory will just keep shrinking).

PROGRAMMING

Sirc::URL optionally exports some functions and variables.

browse_url url

This is the internal machinery which is used to view an URL. You can use it, too, to piggy-back on the user's existing browser configuration. It doesn't return anything meaningful.

urls

This returns the index of the current URL followed by the full list. If no URLs have been noted nothing is returned

$Sirc::URL::Inhibit

If this is set to true then URL marking is inhibited. You might want this if you're going to print the existing URL list out to the screen, for example. You could also use doset 'url_enabled', 'off' for that purpose, but I provide this variable so you can conveniently localize it.

AVAILABILITY

Check CPAN or http://www.argon.org/~roderick/ for the latest version.

AUTHOR

Roderick Schertler <roderick@argon.org>

SEE ALSO

sirc(1), perl(1).

1 POD Error

The following errors were encountered while parsing the POD:

Around line 120:

You forgot a '=back' before '=head1'