I'm stuck :-( And it's driving me crazy.

I have some perl experience and have created a good few perl CLI scripts in the past. I'm now trying my hand at creating a GUI for one of these scripts. I've decided to use the Tcl::Tk module from CPAN. In fact, I've also tried to use Perl/Tk and struck the same problem.

I want the user to select a file to be moved to a new directory. However, while the file seems to be selected correctly, attempting to move it results in an error.

Here's an excerpt from the code:

#!/usr/local/bin/perl use Tcl::Tk; # Main Window my $int = new Tcl::Tk; my $mw = $int->mainwindow; $mw->title("Move File"); my $frame_border_top = $mw -> Frame(-relief => flat); my $welcome_label = $frame_border_top -> Label(-text => "Welcome\n"); my $select_input_file_label = $mw -> Label(-text=>"Select initial file + to move:"); my $select_input_file_button = $mw -> Button(-text => "Browse", -command => \&open_file ); my $move_button = $mw -> Button(-text => "Move File", -command => \&push_button ); # Geometry Management $frame_border_top -> grid(-row=>1,-column=>1,-columnspan=>2); $welcome_label -> grid(-row=>1,-column=>1,-columnspan=>2); $select_input_file_label -> grid(-row=>2,-column=>1); $select_input_file_button -> grid(-row=>2,-column=>2); $move_button -> grid(-row=>10,-column=>1,-columnspan=>2); $int->MainLoop; # All sub-routines below this point. # Open File Dialogue sub open_file { my $select_input_file = $mw-> getOpenFile(-title=>"Select File +"); # These lines just to see what's going on print "Got: $select_input_file\n"; print "My current directory is: $ENV{PWD}\n"; print "Thinking of doing: mv ${select_input_file} -t /home/phillc\n"; } # Move File sub push_button { system("mv ${select_input_file} -t /home/phillc"); }

Whenever the button is pushed, I get the following error in my terminal:

mv: missing file operand
Try `mv --help' for more information.

I'm sure that I am missing something very obvious but don't know what. Any pointers most appreciated.


In reply to Tcl::Tk getOpenFile Not Working - Missing File Operand by phillc

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.