In the code below I started testing my options of allowing for a
maintenance window for specific days/hours to be specified and then
attempted to calculate if a specific day/time fell within that defined
window. I'm open to suggestions and would like to know if there is a
better approach altog
#!/usr/bin/perl -w
use strict;
use warnings;
#the problem started with using split with the space delimeter
#this code only demonstrates my attempts to respect quoted strings
#while a user enters space separated commands and parameters
#command usage: adduser userid password fullname location acce
ue, 30 May 2006, listmail wrote:
Untested, off-the-cuff suggestion...
This looks suspiciously like a homework assignment. ;)
#!/usr/local/bin/perl -w
use strict;
my @data = ('NUMBERS: ONE TWO THREE',
'WORDS: CAT MOUSE DOG');
my (@numlist, @wordlist);
foreach my
#!/usr/local/bin/perl -w
use strict;
my @data = ('NUMBERS: ONE TWO THREE',
'WORDS: CAT MOUSE DOG');
my (@numlist, @wordlist);
foreach my $line (@data) {
print "$line\n";
if ($line =~ /^NUMBERS:/) {
#
#Need to shift $line so $line becomes onl
I need to tee STDOUT to both STDOUT and a variable. For tee'ing to
STDOUT and a LOGFILE, I've used the older package described at
http://jenda.krynicky.cz/perl/TeeOutput.pm.html for some time and this
works wonderfully. I'm not getting a variable to work and
perhaps its because of a misunders
If it doesn't have to be perl: cat t.txt | awk '{ print $1 }' | sort |
uniq -c
Sharp, Craig wrote:
I have a file that contains many li˜es. Here is an example:
evaluate eaprod 7844 2 15688 0 2
evaluate agncyis 7347 2 14694 0 1
agncyis compstr 1117 2 0 0 0
evaluate highcost 7036 4 28144 0 0
eval
#!/usr/bin/perl -w
use strict;
use warnings;
my %hash = ( "acc12", 1,
"acc2", 0,
"acc3", '',
"una1", 1 );
$hash{acc3} = ();
my $valid="acc1|acc2|acc3";
while (my ($key, $value) = each (%hash)) {
if ($key !~ $valid) {
print
sorry listers, I didn't notice that RR's webmail html app. was adding
conversation attachments when I hit reply and then changed the email
around for my needs.
Second, thanks for another great response $Bill. I'll investigate the
Getopt module as well.
- Original Message -
From: $Bi
Before I roll my own ARGV parse code I wanted to know if someone had
some sample code to get me started. I just want to be able to pass
simple switches that contain one parameter each to my perl app. I have
looked to the list first for I plan to accept the switches in any
order, but only allo
I have compiled a perl script of using perlapp and it will run
successfully in a regular shell, but things get ugly when trying to
run it from cron. My first approach is to try and set the
environment inside the perl script itself. I'd like to try it this way
as opposed to calling some other s
Is there a way that I can work around the "Grayed Out" appearance of a
BrowseEntry widget in readonly mode? I thought I could use colorstate
to override the colors used in that mode.
use Tk;
use Tk::BrowseEntry;
my $top=MainWindow->new();
my $var="opt1";
my $b = $top->BrowseEntry(-label => "La
Well I considered the wrapper version Net-SSH-Perl for the UNIX portion
of my program. It does
not use a password and relies on rsa keys. I really didn't want to have
to set all that up for several
boxes and would rather stick to the old username password setup, alot
less maintenance I do beli
Has anyone successfully built Net-SSH-Perl on solaris 8? I tried
version 1.29 but it appears the crypt packages I needed are either
missing or dont install from the default PPM repositories. I skipped
ahead a moment and try to compile the latest Math-Pari from CPAN and it
failed. I wanted t
Thanks for the varied suggestions. I'm still dealing with a few things
I cannot explain. I have provided below a very simple program that
produces errors in two scenarios, each case is resolved by reverting
back to the regular use statement.
#EXAMPLE1:
#!/usr/bin/perl -w
use strict;
my $GUI =
How can you get perl to not check for modules that are loaded
conditionaly? In the example below perl would still error on the Tk
module(s) if they are not installed. I'm basically coding to support
both a GUI and command line mode, eventually across a couple of
platforms.
~snip~
$runmode
My problem is that arrays are being printed all on one line (as much as
it can) instead of one line per element. What do I need to do with the
data?
use Printer;
my @data = ('This is line one','This line two');
$prn = new Printer();
$prn->use_default;
$prn->print(@data);
#---
#perl 5
#!/usr/bin/perl -w
use strict;
use warnings;
my @values = ('1','12','123','1,2','12,34',',123','123,');
foreach my $value (@values) {
# check that value is number and it can be comma seperated list
of
# numbers but doesn't have to be. the last two values in
@values
#
for lack of a better perl vocab ill do the best I can. I'm trying to
use a hash key call inside another one. Basically getting a key from
one hash and using that value in another call to get a key from another
hash. so something i'm doing in the syntax is incorrect. at the end
of the progr
I want to retrieve data from the HList itself based on the current
selection ($grid->info("selection")). This would be what I'd call an
equivalent of $listbox->get($index). So in otherwords something like
$grid->get(0,1) or be able to retrieve an array of the entire row and
work from there.
(the ptk list seems dead so if anyone here can help that'd be great)
--- Begin Message ---
I need to be able to return the item text but haven't been able to
figure it out.
#!/usr/bin/perl
use strict;
use Tk;
use Tk::HList;
use Tk::BrowseEntry;
my $mw = MainWindow->new;
# Mainwindow: sizex/y,
I must be breaking some rules since I dont understand why comparison 2 is NOT
equal and comparision 2 is equal...
#!/usr/bin/perl -w
use strict;
use warnings;
my $num1='2.80';
my $num2='2.8';
my $num3='2.80';
#comparison 1
if ($num1 == $num2) {
print "The values are equal\n";
} else {
p
It appears that $widget->cget('-height') returns the original number of
character lines set for the widget and $widget->Height returns the number of
pixels.
Do I need to do some math or is there a better way to retrieve the current
number or character lines for a widget that has been resized?
With this new structure, how would I dereference the hash to return the text
value instead of the hash reference?
use strict;
my %INST= (
DEV => {
fullname=> "DEVELOPMENT",
dbhost => { "erpd3" => {
sshcon => "",
Martin, thanks for the response. Yes there are multiple servers and I tried to
simplify the code since I wasn't providing a full script. This can also help
me minimize hard coding throughout the script.
- Original Message -
From: Martin Moss <[EMAIL PROTECTED]>
Date: Monday, April 4, 2
my %INST= (
PROD => {
fullname=> "PRODUCTION",
dbhost => "proddb",
dbsshcon=> "",
webhost1=> "prodapp",
websshcon1 => "",
version => "8.1.7",
},
DEV => {
fullname=> "DEVELOPMENT",
dbhost => "devdb",
I'll have a look at the package, thanks for the tip. What I wanted overall was
to have perl cause a system beep, repeatedly, until you came and hit a key
after a hardcoded process related to the nohup file had exited.
My code follows, not sure if perl would allow me to ween from ps and awk or
I use the following to tail a growing file and exist on key hit. This code is
pretty much straight from the Perl CD Bookshelf. I'd like to know how I could
possibly seek to the last line of the file ~at the time of execution~ so as to
not have to print the whole file each time this program is r
It appears that if I build an anonymous array with the following:
# DBI/DBD
while ($ary = $sth->fetchrow_arrayref) {
push @myarray, [ @{$rowdata} ];
}
then when using the following:
foreach my $line (@myarray) {
...
}
$line will iterate through
This is a code snippet from my program the prints a fixed set of column headings and
seperators for an array retrieved from a database. The final output for this example
should be:
USER SID,SERIAL LOGON TIME MODULE ACTION
~~ ~~ ~
below is a password entry dialog example. I'd like to know if it is possible to only
have to press tab once (after typing the username) in order to have focus on the
password field ??
~~
#! /usr/bin/perl -w
use strict;
use Tk;
my ($username, $password);
my $top = MainW
while ($ary = $sth->fetchrow_arrayref) {
push @newary, @{$ary};
}
$sth->finish;
if ($debugmode eq "on") {
$output->insert('end', $newary[0][0]); # (1) this will cause
"Cannot use string as an ARRAY ref."
foreach my $line (@newary) {
Here is a code snippet that I wrote for this procedure but for some reason the source
file seems to disappear on files with 4000+ lines. Just trying to isolate the
problem. Does anyone recommend a better way for this procedure?
open(SOURCE, "< $SOURCEFILE")
or die "\n* Could not ope
How can I undefine/flush $digit variables ($1,$2,$3) within the same block?
___
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
How can I work with extracting only the matched pattern in text in PERL just as with
UNIX sed below:
sed -n -e /\Starting_text.*/s/.*\(Starting_text.*Ending_text\).*/\1/p
example from UNIX piping file contents to the above sed:
blah blah Starting_text blah Ending_text blah blah
~~would return
34 matches
Mail list logo