Are you running the main process from a command window or a Perl/Tk widget? Anyways I have used "wPerl" with Perl/Tk to eliminate the command window for the main process. The "wPerl" file is available in ActiveState Perl package. To use it, just associate the shortcut for your Perl/Tk...
Here's another way:
sub VerifyInt($);
$a = '88.0.5';
$R = VerifyInt($a);
if ($R == 0) {
print "$a is not a valid number \n";
} elsif ($R == 1) {
print "$a is an integer\n";
} else {
print "$a has a decimal point\n";
}
sub VerifyInt($) {
$Number = "@_";
$NumDecPoint++ while...
No need to know the sizes of the array. You can just use a foreach loop like this:
@list1 = ("one", "two", "three");
@list2 = ("myList2");
@fooList = ([@list2], [@list1]);
foreach $refarray (@fooList) {
foreach $item (@{$refarray}) {
print "$item\n";
}
}
The problem is that widget are normally just updating during idle times. To force the update, run $widget->update. Here is your code modified to add the updates.
use strict;
use warnings;
use Tk;
my $main = MainWindow->new;
my $message = "Some text";
my $frame = $main->Frame;
my $Label =...
Don't have time to lookup what "TelnetMode => 0" does, but I suspect that may be part of the problem or your prompt doesn't match the default prompt. Here is a portion of a program I have that works for a Solaris machine.
use Net::Telnet;
my $host = "myhost";
my $user =...
The following should do the trick. Comments added for clarification.
$file = "temp.txt";
$RecSep = $/; # Save input record separator
undef($/); # Undefine input record separator
open(F, $file) or die "Can't open $file: $!\n";
$contents = <F>; # Read all of file into a...
By default the input record separator is a new line. So each time you read from a file, it reads one line at a time. But since you want to read data between 'DESCRIPTION' strings, you should redefine the input record separator to DESCRIPTION like this:
my $filename =...
One way is to split the string into characters and count how many of each one. Here's an example:
@strings = ("abcabc", "abcdabcd", "abcabcc", "abcabcb", "abc", "aaa", "abbccbcaaacc");
foreach $string (@strings) {
@chars...
This is easy enough to do with sort. See the example below:
@list = ("01/22/2000", "01/21/2001", "08/08/2000", "12/12/2000", "09/09/1999");
sub mysort() {
@data1 = split ("/",$a);
@data2 = split ("/",$b)...
One thing I noticed was that the top one includes the directory name in the mv, but the bottom one doesn't. See change in red:
$line = "vcx@xxx.xxx.xxx.xxx@01.09.04-14.02.50";
@comb = split(/\@/,$line);
$a1 = $comb[0];
$a2 = $comb[1];
$a3 = $comb[2];
$b = "/tmp/tmpdir/";
$c...
The problem is that you need the full pathname to the file. Here's the code with changes in red
my $start_point=".";
&Traverse($start_point);
sub Traverse{
my ($workdir) = shift;
opendir(DIR, $workdir) or die "Unable to open $workdir:$!\n";
my @dirarray =...
You can try just reading until you get what you want like this:
system("stty raw");
print "Press y or n: ";
do {
$buffer = getc(STDIN);
$answer = $answer . $buffer;
} until ($answer =~ m/\w/); # Adjust condition to your liking
system("stty cooked");
Mike is right, 'stty raw' will do it. Here's an example:
system("stty raw");
print "Press y or n: ";
$answer = getc(STDIN);
system("stty cooked");
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.