Dear Monks

I have TK window with two drop down fields. The Idea is that if users specify parameters for thoes drop down fields, or else the script will pick up the data specified in __DATA__. the script works ok the first time its run. Problem is, the seek (DATA ,0 ,0);seems to do a strange thing! I get a bit of the code dumped on the screen too when its called for the second time! instead of the seek()command rewinding to the top of the __DATA__! its rewinding half way up the actual code instead!!!

I have never came across this kind of behaviour where chunks of the actual code gets dumped on the screen!!

Can somewone please enlighten me why is this happening? And the way around it?

Thanks.
#!c:/perl/bin/perl.exe -w use strict; use vars qw /%data %tk/; use Win32; use Tk; use Tk::HistEntry; $data{analyst}=Win32::LoginName(); $data{sysadmin}='c$\program files\sysadmin\log'; $tk{main} = MainWindow->new; $tk{main}->geometry('400x130'); $tk{top_frame}=$tk{main}->Frame->pack(qw/-side top -fill x/); $tk{top_box} = $tk{top_frame}->Label(-text=>"Hosts : ", )->pack(qw/-side left -padx 10 -pady 10/); $tk{top_entry}=$tk{top_frame}->HistEntry (-width=>40, -background =>'white', -textvariable => \ $data{source}, )->pack(qw/-side right -fill both -padx 10 -pady 10 -expand 1/); $tk{middle_frame} = $tk{main}->Frame->pack(qw/-side top -fill x/); $tk{middle_box}=$tk{middle_frame}->Label(-text=>"Path : " )->pack(qw/-side left -padx 10 -pady 10/); $tk{middle_entry}=$tk{middle_frame}->HistEntry (-width=>40, -background =>'white', -textvariable => \ $data{xls}, )->pack(qw/-side right -fill both -padx 10 -pady 10 -expand 1/); $tk{bottom_frame}=$tk{main}->Frame->pack(qw/-side top -fill x/); $tk{go_buttn}=$tk{bottom_frame}->Button ( -text=>'GO!', -borderwidth=>5, -width=>60, -command=>sub{ &check_process, $tk{top_entry}->invoke; $tk{middle_entry}->invoke;}, )->pack(qw/-side bottom -padx 10 -pady 10/); sub check_process { my @DB_info; my @work_file; if ($data{source} ne "") { open (LST, "$data{source}") || &error_display($data{source}); chomp (@work_file=<LST>); close (LST); } else { chomp ( @work_file=<DATA>); seek (DATA ,0 ,0); } for (@work_file) { next if ($_ =~ /^\s*$/); my $data = {}; ($data->{bu}, $data->{group}, $data->{function}, $data->{source_id}, $data->{source_pc}, $data->{target_pc},) = split (/,/,$_); push (@DB_info, $data); print "$_\n"; undef $data; } } sub error_display { my (@input) = @_; Win32::MsgBox("$!\n\n@input\n",MB_ICONSTOP,"$0 : Operation Failed"); } MainLoop; exit 0; __DATA__ IED,AMM,,manjeet,cw036348,SN02RDS03a IED,AMM,,manjeet,cw036348,SN02RDS04a IED,Cash Sales,Specialist European Global Japanese Far East Global & W +hitephone,maxwill,cw036647,SN02BDW05a IED,Cash Sales,US Sales,breugelw,cw035660,SN02BDZ05a IED,Cash Sales,US Sales,breugelw,cw035660,SN02BDZ06a IED,Cash Sales,US Sales,breugelw,cw035660,SN02BDZ07a
Blackadder

In reply to BoSelecta __DATA__ and rewind. by blackadder

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.