[Perl-unix-users] allowing for a custom time window specification and then calculating if a date/time is within its range

2007-06-12 Thread listmail
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

[Perl-unix-users] parsing user command & parameter text: using split with space as the delimeter

2006-12-05 Thread listmail
#!/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

Re: [Perl-unix-users] manipulating/parsing string data

2006-05-31 Thread listmail
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

[Perl-unix-users] manipulating/parsing string data

2006-05-30 Thread listmail
#!/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

[Perl-unix-users] tee STDOUT to STDOUT and a Variable

2006-04-28 Thread listmail
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

Re: [Perl-unix-users] Counting words

2006-04-26 Thread listmail
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

[Perl-unix-users] validating (restricting) hash values and keys

2006-03-01 Thread listmail
#!/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

Re: [Perl-unix-users] parsing ARGV

2005-11-03 Thread listmail
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

[Perl-unix-users] parsing ARGV

2005-11-03 Thread listmail
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

[Perl-unix-users] DBI perl script, perlapp compiled, executed from cron gives errors

2005-11-02 Thread listmail
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

[Perl-unix-users] Tk::BrowseEntry -colorstate

2005-10-31 Thread listmail
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

Re: [Perl-unix-users] Net-SSH-Perl on Solaris 8, ActivePerl 5.8.7

2005-10-20 Thread listmail
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

[Perl-unix-users] Net-SSH-Perl on Solaris 8, ActivePerl 5.8.7

2005-10-20 Thread listmail
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

Re: [Perl-unix-users] ignoring conditional use module statements

2005-10-20 Thread listmail
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 =

[Perl-unix-users] ignoring conditional use module statements

2005-10-19 Thread listmail
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

[Perl-unix-users] Printer perl module printing on same line

2005-09-06 Thread listmail
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

[Perl-unix-users] regex numerical matching w/comma seperated list support

2005-06-10 Thread listmail
#!/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 #

[Perl-unix-users] embedding hash syntax

2005-05-12 Thread listmail
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

Re: [Perl-unix-users] Fwd: HList item values

2005-04-28 Thread listmail
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.

[Perl-unix-users] Fwd: HList item values

2005-04-28 Thread listmail
(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,

[Perl-unix-users] numeric comparisions containing trailing 0 in decimal place

2005-04-13 Thread listmail
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

[Perl-unix-users] [ptk list down?] text widget height

2005-04-07 Thread listmail
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?

[Perl-unix-users] dereferencing hash of hashes

2005-04-04 Thread listmail
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 => "",

Re: [Perl-unix-users] hash of hashes

2005-04-04 Thread listmail
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

[Perl-unix-users] hash of hashes

2005-04-04 Thread listmail
my %INST= ( PROD => { fullname=> "PRODUCTION", dbhost => "proddb", dbsshcon=> "", webhost1=> "prodapp", websshcon1 => "", version => "8.1.7", }, DEV => { fullname=> "DEVELOPMENT", dbhost => "devdb",

[Perl-unix-users] Re: RE: tail a file [was: subscriber]

2005-02-22 Thread listmail
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

Re: [Perl-unix-users] subscriber

2005-02-22 Thread listmail
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

[Perl-unix-users] determine array type

2004-07-28 Thread listmail
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

[Perl-unix-users] passing array references: to normal and anonymous array's, between functions

2004-07-23 Thread listmail
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 ~~ ~~ ~

[Perl-unix-users] dialog tab navigation issue

2004-07-13 Thread listmail
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

[Perl-unix-users] help needed with array references

2004-07-08 Thread listmail
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) {

[Perl-unix-users] remove line 1 from text file

2004-05-27 Thread listmail
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

[Perl-unix-users] flush matched $digit vars

2004-05-18 Thread listmail
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

[Perl-unix-users] matched pattern extraction

2004-05-17 Thread listmail
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