#!/usr/bin/perl #Url2Link v0.1 coded by Miguel D Velez <migueldvelez@msn.com> use Tk; my $mw = new MainWindow; my $f = $mw->Frame->pack(-fill=>'x'); $mw->title( "Url2Link v0.1" ); $mw->geometry('+100+300'); $f->Label(-text=>'Url2Link v0.1') ->pack(); $f->Label(-text=>'by Miguel D Velez') ->pack(); my $report_variable = "Type in a list of URLs and press \"Process\" bu +tton to beging."; my $l = $mw->Frame->pack(-side=>bottom, -fill=>x, -ipadx=>10, -ipady=> +3); $l->Label(-textvariable=>\$report_variable, -relief=>groove) ->pack(-f +ill=>both, -ipady=>3); my $b = $mw->Frame->pack(-side=>bottom, -fill=>'x', -pady=>5); $b->Button( -text=>"Exit", -relief=>groove, -command=> sub { exit } ) ->pack(-side=>bottom, -fill=>x, -ipadx=>10, +-ipady=>3); $b->Button( -text=>"Process", -relief=>groove, -command=> sub { &process } ) ->pack(-side=>bottom, -fill=>x, -ipadx=> +10, -ipady=>3); my $t = $mw->Frame->pack(-padx=>5); my $txt_body = $t->Scrolled(Text, -scrollbars=>e, -background=>white, -relief=>groove, -width=>50, -height=>15, -wrap=>'word') ->pack(); MainLoop; sub process { my @url_list = split /\s+/, $txt_body->get("1.0", "end"); my $count = 0; if (@url_list) { my $mkdir = mkdir "Links"; if (! $mkdir) { $report_variable = "Could not create \"Links\" folder in current direc +tory. $!."; } else { $report_variable = "\"Links\" folder created."; } my $chdir = chdir "Links"; if (! $chdir) { $report_variable = "Could not access \"Links\" folder in current direc +tory. $!."; } foreach(@url_list) { if ($_ =~ /^(http|https|ftp|ftps|w).+\.([a-zA-Z0-9_-]+)\..+/) { open FILEOUT, "> \u$2.url"; print FILEOUT '[DEFAULT]'."\n"; print FILEOUT "BASEURL=$_"."\n"; print FILEOUT '[InternetShortcut]'."\n"; print FILEOUT "URL=$_"."\n"; print FILEOUT 'Modified=0'."\n"; close(FILEOUT); ++$count } } chdir ".."; $txt_body->delete( "1.0", "end" ); $report_variable = "Converted $count URLs to link files. Please check +the \"Link\" folder."; } else { $report_variable = "User input is empty. Please type at least one URL +in textbox."; } }

In reply to Url2Link 0.1 GUI/TK by m_dv

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.