RE: regexp help

2002-06-03 Thread David . Wagner
You can use a module File::Basename or I use for my scripts a simple one to extract the filename of my scripts to use in displays(Basic assumption is a valid filename being searched): my $MyFilename ; if ( /^.+[\\\/](.+)/ ) { # assuming full or partial filename is in $_

RE: Parsing a path environment...

2002-06-05 Thread David . Wagner
split on the ; and you now have array with all the elements of your environment. Wags ;) -Original Message- From: James Kelty [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 04, 2002 14:58 To: [EMAIL PROTECTED] Subject: Parsing a path environment... Hello. I am writing a quick

RE: Parsing a path environment...

2002-06-05 Thread David . Wagner
Sorry, but should have been split on : as stated by drieux. Wags ;) -Original Message- From: Wagner, David --- Senior Programmer Analyst --- WGO Sent: Tuesday, June 04, 2002 15:13 To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: Parsing a path environment... split

RE: Regex Problem - please help

2002-06-05 Thread David . Wagner
With the solutions presented, I used rindex since what about the title: 'Perl by example by New Author' . Doing a split and you will not have what you expected. Here is a shot: while ( ) { chomp; next if ( /^\s*$/ ); my $MyPtr = rindex($_," by "); if ( $MyPtr < 0 )

RE: probably a simple question

2002-06-05 Thread David . Wagner
Each number in @your_list becomes $_ one at a time. It does the modulo if true does the first operation after ? or if false then after the :. Short and sweet, and you will get there. Wags ;) -Original Message- From: Bryan R Harris [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June

RE: parse file into hash

2002-06-05 Thread David . Wagner
Uncertain if this is as big as it gets or what, but I tried this: where %Myusgs is keyed from $USGS_QD_ID [0] points to Quad name [1] points to element of array holding input data %Myquad is keyed from $QUAD_NAME

RE: lvalues

2002-06-06 Thread David . Wagner
It is the left side of an an equation(ie, lvalue operator rvalue) lvalue is for left value and rvalue would be for the right value. substr($name, 4) = 'dy'; substr($name,4) is an lvalue. Wags ;) -Original Message- From: Mark Anderson [mailto:[EMAIL PROTECTED]] S

RE: Killing Idle Users

2002-06-11 Thread David . Wagner
Here is the site for Dave Roth and his sys admin via Perl: http://www.roth.net/ Wags ;) -Original Message- From: Akens, Anthony [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 11, 2002 10:14 To: [EMAIL PROTECTED] Subject: RE: Killing Idle Users Here's the shell script,

RE: filter list of files from directory into array

2002-06-20 Thread David . Wagner
Could add the: grep m/^\d\d\d(\d|\d\d)\d$/ && ! -e "c:\\prod\\rej" . $_ , readdir DIR; You need to have the directory location because the readdir returns only the file or directory name read. Wags ;) ps Did test and put out files only. -Original Message- From: Auernhei

RE: filter list of files from directory into array

2002-06-20 Thread David . Wagner
But unless you have done a chdir it will only pass the file name or directory name and not do what you want. Wags ;) -Original Message- From: Felix Geerinckx [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 20, 2002 15:31 To: [EMAIL PROTECTED] Subject: Re: filter list of files fro

RE: filter list of files from directory into array

2002-06-20 Thread David . Wagner
2 3:40 PM To: [EMAIL PROTECTED] Subject: RE: filter list of files from directory into array on Thu, 20 Jun 2002 22:29:45 GMT, David Wagner wrote: > But unless you have done a chdir it will only pass the file name or > directory name and not do what you want. You are absolutely right. Th

RE: Formatting

2002-06-20 Thread David . Wagner
You can build the format string: my $myVar = 'ABCD'; #(Left Aligned, padded with spaces) #$newVar = sprintf("%-10s,$myVar); #$newVar should have 'ABCD '; # Works while ( 1 ) { printf "eft or ight: "; chomp(my $MyInput = ); last if ( $MyInput =~ /^ex/i ); my $MySign = '-'

RE: Regex Help Please!?

2002-06-27 Thread David . Wagner
You will need to escape the | as \| otherwise won't do what you think. I checked to make sure. Wags ;) -Original Message- From: Tom Stewart [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 27, 2002 11:18 To: Balint, Jess; [EMAIL PROTECTED] Subject: RE: Regex Help Please!? Why no

RE: Regex help!

2002-07-02 Thread David . Wagner
if ( $plup =~ /\.(gif|jpg)$/i ) { # # This is success(ie, name ends with a . and either gif or jpg) Ignore case # }else { # not a gif or jpg } Wags ;) -Original Message- From: Troy May [mailto:[EMAIL PROTECTED]] Sent:

RE: How to pass the value of $@ to a subroutine

2002-07-03 Thread David . Wagner
Basically with the @_ and not having parens is like $var = scalar(@_); # which is one since @_ is to subs what @ARGV is to incoming Arguments passed to a module. So by doing the parens, you are populating the variables on the left with values being passed into the

RE: How to change "20020706" to "July 6, 2002"?

2002-07-06 Thread David . Wagner
There is nothing in concrete in Perl, so up to the individual. To me for this type of action, you create your own. You can posibbly use Date::Manip or one of the other Date routines, but alot of times this add a lot of extra overhead for piece of data you want to work with. You

RE: Windows NT / 2000 Services

2002-07-15 Thread David . Wagner
Not sure from what list this was received ( on a number of them ), but here is one using Win32::Service. Change the 'x' within GetServices for the computer you are running on or want to get at. use Win32::Service; #set up a hash of known service states my %statcodeHash = ( '

RE: Pattern Matching

2002-07-17 Thread David . Wagner
Here is one way: /(n=[^']*)/; which says find a n= and then everything up to the next ' You probably want to wrap in if statement so if not a hit, then can do something. Wags -Original Message- From: Dan Finch [mailto:[EMAIL PROTECTED]] Sent: We

RE: sorting %hash entries

2002-07-22 Thread David . Wagner
Here is one shot: %usernum = ( "server.one.com", "15", "server.two.com", "5", "server.three.com", "14", "server.four.com", "9" ); foreach my $MyId (sort {$a->[1] <=>$b->[1]} map{[$_,$usernum{$_}]} keys %usernum) { printf "%-s\n", $My

RE: sorting %hash entries

2002-07-23 Thread David . Wagner
Subject: Re: sorting %hash entries ok.. that worked, now how about if i wanted it to go the other way.. from most to least? dan "David Wagner" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Here is one shot: > > > %usernum =

RE: another sort question (flame away)

2002-07-24 Thread David . Wagner
If you want ascending numeric then <=> vs cmp ( ascii ) and you have it. Wags ;) -Original Message- From: nkuipers [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 24, 2002 10:39 To: [EMAIL PROTECTED] Subject: another sort question (flame away) Hello all, My hash keys look som

RE: another sort question (flame away)

2002-07-24 Thread David . Wagner
This should not matter what the size is but would expect a number at the beginning: foreach my $MyKey (sort {$a->[1] <=> $b->[1]} map{[ $_, /^(\d+)/ ]} keys %final_list) { printf "%-s\n", $MyKey->[0]; } Wags ;) -Original Message- From: Jo

RE: another sort question (flame away)

2002-07-25 Thread David . Wagner
Depends on what the user is really after. To me it is a starting point for the developer to continue from there. With minor changes, it should be able to handle all that the developer wants, but it was stated that this was a Key into a hash. Wags ;) -Original Message- From: Bob

RE: string extraction

2002-07-26 Thread David . Wagner
Could do something like: my($Month,$Date,$Time,$Year,$Zone)= split(/\s+/,$notAfter); On the split, it shows one space, but I always use the + so if an extra space gets added along the way, it will not break. A start. Wags ;) -Original Message- From: lz

RE: Perl Menu Script

2002-07-26 Thread David . Wagner
Made minor changes: #!perl -w my $date = localtime(time); while ( 1 ) { print "\nCOMMAND MENU\n"; print "\n a. Current date and time\n"; print "\n b. Users currently logged in\n"; print "\n c. Name of the working directory\n"; print "\n d. Con

RE: Print data in sequential order

2002-07-29 Thread David . Wagner
What constitutes a set of data? Set 1:54, 7 thru 9 Set 2:54,19 thru 23 or Set 1:54, 7 thru 23 Wags ;) -Original Message- From: Kevin Old [mailto:[EMAIL PROTECTED]] Sent: Monday, July 29, 2002 15:19 To: [EMAIL PROTE

RE: How to write a Regex to modify numbers in the particular context within a file?

2002-08-11 Thread David . Wagner
Unclear what you are really trying to do. Before compiling, you need to insure that the Network has a starting number and then after that, it should increment by 1. Can code be sucked into an array and worked with from there? Or should the script find the first entry which matche

RE: deprewhat?

2002-08-12 Thread David . Wagner
When doing a split and no array present to the left of = then would go to @_ when wanted to see what you had just split. It is saying you should not do that, but provide an array reference for the split. Wags ;) ps I believe that it is what it is saying. -Original Message- From:

RE: RegEx question

2002-08-12 Thread David . Wagner
You might try a indexr looking for the 1st and 2nd comma from the right. What is between those columns would be your number. As to being easier, unsure of that. Though you could possible do something like: /,\s*(\d+\.\d+),\s*\d+\.\d+$/ which would have

RE: Passing Hashes into a function

2002-08-19 Thread David . Wagner
A code snippet would be very helpful. To pass a hash and update it, then func(\%hash); sub func { my ( $hash ) = @_; $hash->{key} = 1; # this should be reflected back in the calling program when you return } Wags ;) -Original Message- From: John Ros

RE: Regexp

2002-08-26 Thread David . Wagner
Something along the line of: my $uuid ; if ( ! /\[uuid\s+([^\]]+)/ ) { # if no hit then do something # warn or die depending on what you expect } $uuid = $1; If you want $_ then you can do $_ = $uuid; Wags ;) -Original Messag

RE: sorting logs

2002-08-27 Thread David . Wagner
Here is the output I got: "2002-08-28","Tape 1", "staff", "315825" "2002-08-28","Tape 2", "www.cs", "102860" "2002-08-28","Tape 2", "staff_homepages", "103142" "2002-08-28","Tape 2", "ftp.cs", "103204" "2002-08-28","Tape 2", "local", "103216" "2002-08-28","Tape 2", "Hyper-G", "103236" "2

RE: Interpolation problem

2002-08-28 Thread David . Wagner
You are using single quotes which tell Perl to NOT interpret what is between the single quotes. SO '$2 $1' becomes $2 $1 in the new variable while "$2 $1" would become the values of $2 and $1. Wags ;) -Original Message- From: Beau E. Cox [mailto:[EMAIL PROTECTED]] Sent: Wednesda

RE: Need help

2002-08-29 Thread David . Wagner
I changed your hash to h, so no conflict with sort values: my %h = (); $h {"1"} = [ "some string","other string",3 ] ; $h {"2"} = [ "some string","other string",2 ] ; $h {"3"} = [ "some string","other string",1 ] ; foreach my $MyKey (sort { $a->[1]<=>$b->[1] } map{[$_,$h{$_}[2]]} keys %

RE: uniq elements of an array

2002-08-30 Thread David . Wagner
The one sent in by david which was @uniq{@a} = () was even faster by a significant margin where you have sub using_array { @uniq{@a} = (); } Need to define my %uniq above as you do my @uniq. Wags ;) -Original Message- From: NYIMI Jose (BMB) [mailto:[EMAIL PROTE

RE: sorting of arrays

2002-09-04 Thread David . Wagner
As default it assumes ascii (alphanumeric data). So if you have only numeric data then you need to change to @sorted = sort {$a <=> $b} @list; which would sort numerically if needed otherwise will sort as you want. Wags ;) -Original Message- From: Quincy Ntuli [mailto:[