I have to prepare a GUI , where the Perl/Tk should invoke a batch command (a local one with path hardcoded) and passing argument (which is the .csv file selected by the user) -When user presses the GENERATE button-here simplified as just opening the .csv file in notepad . Can someone help me ?

use Tk; my $my_MW=MainWindow->new(); $my_MW->title("Sample application"); $my_MW->geometry("350x180-500+500"); $my_MW->resizable( 'no', 'no' ); my $my_Button=$my_MW->Button(-text=>"Select CSV Input File",-command=> + \&get_file); $my_Button->pack(-side=>"top",-expand=>1,-anchor=>"w",-padx => 20,-pad +y => 20); my $filepath=" .... "; my $my_Entry=$my_MW->Entry(-textvariable=> \$filepath); $my_Entry->pack(-side=>"top",-expand=>1,-anchor=>"w",-padx => 20,-pady + => 0,-fill=>"x"); my $my_Button1=$my_MW->Button(-text=>"GENERATE",-width => 12,-command= +>sub{\&gen_rslt()}); $my_Button1->pack(-side=>"left",-expand=>1,,-pady => 20); $my_Button1->configure(-state => 'disabled'); my $my_Button2=$my_MW->Button(-text=>"RESET",-width => 12,-command=>su +b{\&clear_field()}); $my_Button2->pack(-side=>"left",-expand=>1,,-pady => 20); my $my_Button3=$my_MW->Button(-text=>"EXIT",-width => 12,-command=>sub +{exit()}); $my_Button3->pack(-side=>"left",-expand=>1,,-pady => 20); MainLoop(); sub gen_rslt{ #Call the batch file and pass the file path as an argument! #batch file to open the file in notepad } sub clear_field{ $my_Entry->delete(0,'end'); $my_Entry->insert(0," .... "); $my_Button1->configure(-state => 'disabled'); } sub get_file { $my_Entry->delete(0,'end'); my @types = (["comma seperated files", [qw/.csv/]], ["All files", '*'], ); $filepath = $my_MW->getOpenFile(-filetypes => \@types) or return(); $my_Button1->configure(-state => 'normal'); }

In reply to Perl/Tk invoking a batch command and passing argument by vipinm2007

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.