Re: File transfer over socket connection

2006-07-19 Thread Peter Cornelius
ke a crack at writing some code and then post back with some more specific problems if you encounter them. Peter Cornelius Sr. Software Engineer LiveOps (http://liveops.com) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>

Re: Help with Stupid question

2006-07-17 Thread Peter Cornelius
hrough the math modules. Peter Cornelius Sr. Software Engineer LiveOps (http://liveops.com) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>

Re: Newbie Perl Question

2006-07-17 Thread Peter Cornelius
truct again (\d+)(.+) #This is the same as above except instead of the non- greedy thing #it captures the description string with the 'one or more of anything' #construct. /x #I added the 'x' on here because it lets you put comment

Re: puzzling '.{1,4}'

2006-06-26 Thread Peter Cornelius
On Jun 26, 2006, at 11:42 AM, tom arnall wrote: On Monday 26 June 2006 10:49 am, Peter Cornelius wrote: ... x|a #followed by an 'x' or an 'a' aren't the alternates (1) everything to the left of '|' and (2) 'a'? th

Re: puzzling '.{1,4}'

2006-06-26 Thread Peter Cornelius
er from looking at your test data. On Jun 26, 2006, at 10:28 AM, tom arnall wrote: 11 #with '.{1,4}' 12 $re1 = qr/x.{1,4}\d\dx|a/; 13 $re2 = qr/($re1\s)?$re1/; 14 ($f) = /($re2)/; 15 print "f:$f\n"; HTH, Peter Cornelius Sr. Applications Engineer LiveOps Inc. (http://www.liveops.com)

Re: Create array of references

2006-06-09 Thread Peter Cornelius
onto the hash. } I'm using the $day-$dom key but that's probably not unique enough. You probably want the full date as the key. Hope this helps, Peter Cornelius Sr. Software Engineer and Supreme Commander of the Western Forces LiveOps (http://www.liveops.com/careers) -- To

Re: accessor problem in OO

2006-05-28 Thread Peter Cornelius
On May 27, 2006, at 3:56 PM, chen li wrote: Based on what I learn the regular method to defer a hash reference to get specific value takes this format: $ref_hash->{key1} but in this line $_[0]->{_name}= $_[1] if defined $_[1] the format is array element->{_name} Yes, the contents of the a

Re: accessor problem in OO

2006-05-27 Thread Peter Cornelius
This might be a little more clear if you break down the way arguments are being passed in and what they actually are. It sounds like you're aware that the arguments are passed in as a list name @_, it looks like the arguments are something like this: @_ = ( #< A list { _name =>

Re: Hide password on console

2006-05-12 Thread Peter Cornelius
Have you looked at Term::ReadPassword? PC On May 12, 2006, at 8:50 AM, SkyBlueshoes wrote: I've googled it over and over, but I can't find the way to hide the input of a password on the console screen. I know it can be done... -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional comm

Re: Regex Help

2006-04-18 Thread Peter Cornelius
This will match a ! followed by 0 or more not ! chars, I suppose it's matching the 0 part of that. Try a '+' instead of a '*' $str =~ /\![^!]*/; PC -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Perl regular exp

2006-04-11 Thread Peter Cornelius
But I'll bet you don't have @LINES containing all 3 words separated by 2 '&' symbols. You need to break this up into: if($line =~ /$pattern1/ && $line =~ /$pattern2/) { ... } or something similar. On Apr 11, 2006, at 4:15 PM, Sonika Sachdeva wrote: my $querystring="$str1 && $str2 && $str

Re: Perl regular exp

2006-04-11 Thread Peter Cornelius
This matches: my $test_string = 'This is my test string'; my $pattern1 = 'This is'; print "Passed test 1 $/" if ($test_string =~ /$pattern1/); I think that at least part of your problem is the '&&' characters. I'm guessing that you don't mean to match a literal '&&' but that is what your

Re: Perl regular exp

2006-04-11 Thread Peter Cornelius
What do you mean by 'works'? It looks to me like this will print the line if the string 'pattern1 && pattern2 && pattern3' is in the line. Not if pattern1 is in the line and pattern2 is in the line and pattern3 is in the line. Is that what you mean? I think some more detail would help me

Re: purpose of /? at the end of a link

2006-02-17 Thread Peter Cornelius
The slash is the beginning of the file portion of the request, in this case it's asking for the web root default which is usually index.html but can be specified through server configuration. The '?' signals the beginning of the GET parameter list, which is empty in this case. If you do a

Re: Regex puzzler!

2006-02-08 Thread Peter Cornelius
The first thing that jumps out at me is that the '.*' pattern is going to be a greedy match. This means it will match everything, swallowing the '" BORDER=0> part of the string too. You can make the * non-greedy by putting a '?' after it. $imageURL =~ !!; but you might be better off with

Re: please help find logic error in home-brewed brute force anagram solver/creator script

2005-12-30 Thread Peter Cornelius
Jupiter host has a good point about not reinventing the wheel but it might still be educational to fix this code. There's an interesting warning if you run this with '-w': word=NERO |NERO| |ENRO| |RNEO| |ONER| Use of uninitialized value in join or string at ./anagram.pl line 33. |NERO| Use o

RE: time function

2002-01-16 Thread Peter Cornelius
Ooo. I've never used this. It sure looks better than parsing the date out yourself. Peter C. -Original Message- From: Hanson, Robert [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 16, 2002 10:21 AM To: Roy Peters Cc: [EMAIL PROTECTED] Subject: RE: time function You could also us

RE: time function

2002-01-16 Thread Peter Cornelius
To convert *to* seconds since the epoch you want the timelocal() function. It's part of the Time::Local standard module and takes input in the form of localtime's output. From 'perldoc Time::Local' use Time::Local; $time = timelocal($sec,$min,$hours,$mday,$mon,$year); so a comp

RE: running commands in bkgd

2002-01-15 Thread Peter Cornelius
The Perl program will continue on the next line of code. But the reason to use back ticks is to easily make the output accessible to the script. So the interpreter *has* to wait for the program to finish so that it knows it has all the out put for the script. If you don't care about output you

RE: 2 simple questions - update:

2002-01-15 Thread Peter Cornelius
Why not use '.' print "WHOOT" if -e "./ThisDir" and -d _; the -d _ uses the cached results from the last stat, in this case the -e "./ThisDir". Peter C. -Original Message- From: Chris [mailto:[EMAIL PROTECTED]] Sent: Monday, January 14, 2002 8:46 PM To: [EMAIL PROTECTED] Subject: 2 sim

RE: UNIQUE KEY

2002-01-15 Thread Peter Cornelius
Is there a reason for doing it this way? The main problem that might come up here is if more than one instance of this script could run at close to the same time. If this gets kicked of by some random(ish) event, like a user signing in or something, then you can have several scripts read the num

RE: 2 simple questions...

2002-01-14 Thread Peter Cornelius
A portable solution would be to use the Cwd module. Try this use Cwd; print cwd(); On a windows machine with cygwin this is different from $ENV{PWD}. cwd() gives me c:\cygwin\home\peterc while $ENV{PWD} is /home/peterc. As for the wget thing, you should look into the LWP modules. I think LW

RE: why am I getting syntax errors ?

2002-01-08 Thread Peter Cornelius
This sort of question is a lot easier if we could see the syntax errors. Here's my guess though. #foreach $i (@section_headers) Has $i been declared? Try 'foreach my $i (@section_headers)' #die "config error - no valid section header\n" if ($config_current_section ne $config_section &&

RE: Password ---- cgi-perl-html

2002-01-08 Thread Peter Cornelius
The way that I have done this in the past is to set a cookie after the initial authentication. On all pages that require authentication you check for the cookie and validate that it hasn't been tampered with. If this check fails you redirect the user to the login page. To prevent tampering you

Re: Left side variable interpolation during associative array assignment?

2001-12-31 Thread Peter Cornelius
Before I point to the problem here, let me point out that you are trying to use symbolic references which will severely decrease the readability of your code. I personally believe that symbolic references are one of the many forms of evil perl which, while appearing elegant, merely lure you

RE: Would anybody tell me what is the meaning of "foo" ?

2001-12-30 Thread Peter Cornelius
When writing sample code one often finds themselves thinking "what should I name this meaningless variable?" Since often the variable names are incidental to the point of the sample code it's become a convention to reuse the names foo and bar to save time and effort. These names are permutations

RE: How to create an object with perl ?

2001-12-30 Thread Peter Cornelius
There's some great documentation on this. Check out 'perldoc perltoot' on your local command line or http://www.perldoc.com/perl5.6.1/pod/perltoot.html if you're into that "web" thing. Here's my hello world class package Hello; #A package declaration starts a class #A method to create a new in

RE: Would anybody tell me what is the meaning of "foo" ?

2001-12-30 Thread Peter Cornelius
It's a deliberate misspelling of fubar which means... Well, check this out. http://whatis.techtarget.com/definition/0,,sid9_gci748437,00.html -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

RE: help on how to split a string

2001-12-29 Thread Peter Cornelius
To get the output you want from the input you listed, you probably don't want to use split(). Take a look at the m// construct. use strict; #Always use strict and warnings use warnings; my @val; #declare myself an array. while () { # DATA is a special file handle that reads from t

RE: Good CS Literature

2001-12-29 Thread Peter Cornelius
I just wanted to put in a shout for one of my favorite, and unmentioned, Perl books. "Effective Perl Programming" is by Joseph Hall and Randal Schwartz. It addresses many of 'am I doing it right' questions. The "Perl Cook Book' that others have mentioned is also a good reference for this. I've

Re: cancatenate

2001-12-23 Thread Peter Cornelius
cat phr*.txt >> newfile RNOORY wrote: > Hello, > I would like to concatenate several text files that all begin phr*.txt to create one >text file. > > Thanks > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

RE: Calling a shell from a perl script.

2001-12-23 Thread Peter Cornelius
There are several methods for executing external commands from Perl. The 2 most common would be 'system()' and backticks '``'. You should probably read the 'perldoc -f system' for detailed info. The main difference between backticks and system is where the commands output goes and where the ret

Re: Learning Perl, chapter 8: pattern_test

2001-12-20 Thread Peter Cornelius
Like Michael Fowler wrote, the angle operators, when used like this, glob file names. But since you don't have any special patterns it's just returning the list of filenames from inside the '<' and '>'. If you do a print "$_\n"; inside the while loop you'll see that the strings hitting the

RE: testing input/loops

2001-12-18 Thread Peter Cornelius
This doesn't do what you think it does. unless ($response eq '1' || '2' || '3') It says, unless the response was eq to 1, or if 2 is true, or if 3 is true. 2 and 3 are true by definition so this will always be true. I think you want unless ($response eq '1' or $r

RE: Last line of file...

2001-12-18 Thread Peter Cornelius
If you know the size of the last line you can use 'seek' to get there, but this operates on bytes, not chars. If the records are of a fixed size this would be the most efficient way to do it. use POSIX; #This gives us the SEEK_END constant seek (FH, -$recsize, SEEK_END) or die "Could not seek: $

RE: Should I use Perl?

2001-12-18 Thread Peter Cornelius
While there are some things Perl doesn't do as well as other languages you would be hard pressed to find something it couldn't do at all. While I haven't written anything like what you describe, it sounds like a Perl job to me. You might want to take a look at the CPAN archive to see if anyone h

RE: Last line of file...

2001-12-18 Thread Peter Cornelius
You are probably thinking of associative arrays. They are declared with the '%' character in the lead and do not have any intelligible order. With a normal array the order is guaranteed. If your files aren't to big I've found this idiom useful when I just want the last line. open (FH, "smallfi

RE: List of Associative Arrays

2001-12-18 Thread Peter Cornelius
>I initiatize the list with: > @MainList = (); Looks good. >To add elements, I am doing: > push(@MainList, [%ElementAssocArray]); Not quite right. Loose the square brackets and take a reference to the hash. push (@MainList, \%ElementAssocArray); >To access each element (for example the

RE: Scalar Localtime

2001-12-16 Thread Peter Cornelius
I can think of lots of times the output of 'time()' has been just what I needed. For example, anytime you want to compare times, like my $timeout = time() + $sec_to_alarm; do { #stuff } until (time() > $timeout); Or to compare dates $date = timelocal(@user_supplied_date); $now = time(); if ($

RE: Question about using an IF statement in searching a sub string

2001-12-14 Thread Peter Cornelius
It's not clear from your post if you should expect $line to have a value when it encounters the if statement. You might find a 'print "<$line>\n";' right before the if statement really informative. The angle brackets are just in case $line is undef and you don't have warnings turned on. Peter C

RE: command-line way to search contents of files

2001-12-14 Thread Peter Cornelius
You might want to check for the '-r' option in your system's grep command. On my Linux system and under Cygwin I can do something like grep -r 'search string' ./* or the '-d recurse' option should do the same thing. Good luck, Peter C. -Original Message- From: Thomas S. Dixon [mailto:[

RE: Problems with ^M

2001-07-16 Thread Peter Cornelius
Are you transferring these files via ftp? If so it sounds like you are using bin mode when you want ascii (ascii translates the line termination chars for you). Just 2 bits. Peter C. > This is for newbies, right? Can anyone tell me why a s/^M//g > won't get rid of the annoying ^M on the end of

RE: This Guy Wants help

2001-07-03 Thread Peter Cornelius
Mark-Jason Dominus sent your message to the beginners perl group, which is probably the right place for this kind of question. You can subscribe to the group through lear.perl.org. As for your question, you should look into the Perl DBI set of packages available from CPAN. You can get the docum

RE: Finding @INC

2001-06-26 Thread Peter Cornelius
> My difficulty is that I don't understand how to modify @INC to > include the non-standard locations, so that I don't have to > have the user > supply commandline arguments each time the script is needed. You want the 'use lib "/non/statdard/lib";' directive. You can get more in

RE: array slice question

2001-06-26 Thread Peter Cornelius
I don't think so. I do (split)[-1] regularly and it works fine. If you left out the parens however it would think this was a pattern to match. I was told by someone on perlmonks that the failure of [3 .. -1] with split is something that should be fixed in subsequent versions of Perl. > > [

RE: removing white space

2001-06-26 Thread Peter Cornelius
> Is the following regrex the correct way to remove leading or > trailing white space > from a string? > > $data = "[EMAIL PROTECTED] (mike smith)" > > $data =~ s/(^\s+)|(\s+$)//g; This looks like it works to me. > or would it be more efficient to it thus: > > # two passes > $data =

RE: Autovivification/$key++ (was RE: $hash{$_}++)

2001-06-18 Thread Peter Cornelius
> At 04:36 PM 6/18/01 -0700, Peter Cornelius wrote: > >use Data::Dumper; > > > >%hash = ( > > 1 => "I exist...", > > 2 => "This is academic", > > 3 => "I should be using an array" > >

Autovivification/$key++ (was RE: $hash{$_}++)

2001-06-18 Thread Peter Cornelius
I'm sorry to drag this thread on for something that's completely academic, but I can't help myself. I think it's been established that if you find yourself doing this $key++ thing you are probably using the wrong data structure (i.e. a hash when you want an array), but let me just throw up some t

RE: $hash{$_}++

2001-06-18 Thread Peter Cornelius
> > The value. If you wanted to increment the key, you would say > > "$hash{$key++}". > > Wait a sec, brain cramp > Wouldn't that: > 1) just access $hash{$key} > 2) increment $key > 3) add $hash{$key + 1} > I realize this is getting away from the original post, but I'm confused by #3

RE: Re[4]: When to use "my"?

2001-06-15 Thread Peter Cornelius
Hi Tim, So, all this stuff just has to do with how Perl resolves what a name refers to. If you have script that looks like... $var1 = 1; my $var1 = 3; print $var1; you, of course get 3. But probably not for the reason you think. The first declaration and initialization of $var1 creates a sy

RE: Re[2]: Reformating text

2001-06-15 Thread Peter Cornelius
> Also, I had not thought of converting to Palm DOC format using perl > (silly me, it would save a mousing set of steps). I use QEX - a > companion to QED (that lets you edit DOC's on the Palm). If anyone > knows of a Perl module to do this, I would love to hear about it (or > any module that w

RE: Re[4]: When to use "my"?

2001-06-15 Thread Peter Cornelius
>It's also worth mentioning that if you 'use strict;' you can't declare >you're own symbol table variables so all of your user defined variables will >be lexically scoped. I need to correct myself. I said you can't declare symbol table variables if you 'use strict', that's wrong. 'my' declares

RE: Stuck in the Perl Beginners Panic-Zone!

2001-06-15 Thread Peter Cornelius
> > When I open (launch) my PERL interpreter (location > > C:\Perl\bin\perl.exe) I > > get a black screen with a blinking white line. > > Whoa! Don't open the Perl interpreter. Well, he could launch the Perl interpreter. From your reaction I guess you think he was opening it in notepad or somet

RE: Update: Where to begin??!!??

2001-06-15 Thread Peter Cornelius
Gorp meant /\|/ as per Dave Cross's reply. > I would guess you really want #!/usr/bin/perl, spaces are > meaningful. And a > -w at the end can tell you a lot. > > #! usr/bin/perl > > use strict; > > > > open (FILE_IN, "pslbingocard.dat")|| die "failed to open file\n"; > You really want an

RE: Update: Where to begin??!!??

2001-06-15 Thread Peter Cornelius
I would guess you really want #!/usr/bin/perl, spaces are meaningful. And a -w at the end can tell you a lot. > #! usr/bin/perl > use strict; > > open (FILE_IN, "pslbingocard.dat")|| die "failed to open file\n"; You really want an 'or' here ---^^ not '||'. The operator precedence can bite y

RE: html formatting in perl script

2001-06-15 Thread Peter Cornelius
You might search around on perldoc.org, but I found this in the perlfaq4... http://language.perl.com/newdocs/pod/perlfaq4.html#Why_don_t_my_E_lt_E_lt_HE RE_docu As far as template systems go you should look into HTML::Template and HTML::Mason on CPAN. http://search.cpan.org/search?module=HTML::Te

RE: testing on email characters

2001-06-13 Thread Peter Cornelius
> Subject: testing on email characters I just wanted to expand on Jeff Yoaks comment that the regexes discussed in this thread don't actually validate syntax on _all_ e-mail addresses. I think this is a common problem. I remember looking this up in 'Mastering Regular Expressions' (though I don

RE: RE: Unexplainable behavior

2001-06-13 Thread Peter Cornelius
So wouldn't you expect the more clingy '||' to work here? It doesn't, I checked. If operator precedence was the problem then using the higher precedence operator should work. I think this is a logic flaw. Charles really meant if (exists ... and this and that) { ... } not i

Re: non-greedy *

2001-06-13 Thread Peter Cornelius
You might want to check out Japhy's modules YAPE::Regex and YAPE::Regex::Explain. You can pass in regular expressions and have it spit out an explanation of what the parser is doing. An example of (non) greedy matching would be something like: $string = "here"; #you want to pull out the tags an

RE: ensuring that there *is* an \@ symbol

2001-06-12 Thread Peter Cornelius
> i am trying: > > } elsif ( $add_destination !=~ /\@/ ) { > > which is not working. i am hoping that this reads "if $add_destination > does NOT contain \@ then" > > however, it apparently does not read this way :) > is my error in perl syntax or the regex? I think the syntax you want is '!~

RE: Installing new Modules problem

2001-06-11 Thread Peter Cornelius
> > > I download a > > module from activestate but when I try to install it I get > the following > > error. > > > G:\Perl\bin>>ppm install win32-gui.ppd > > Why not to visit the CPAN, take the tar.gz distribution, open > it and run > perl makefile.pl > make > make test > make install ? > >

RE: if then else

2001-06-08 Thread Peter Cornelius
Aside from all the valid comments you've already received, '==' is a numeric comparison and I believe you want string comparison. For that use 'eq'. Just to let you know another way: my $previous = "an unknown site"; $previous = $ENV{'HTTP_REFERER'} if $ENV{'HTTP_REFERER'}; or the even more ter

RE: directory listing to array

2001-06-07 Thread Peter Cornelius
> I got > > Benchmark: timing 5 iterations of Randals, variations... >Randals: 79 wallclock secs (28.94 usr + 49.99 sys = 78.93 > CPU) @ 633.46/s > (n=5) > variations: 0 wallclock secs ( 0.03 usr + 0.00 sys = 0.03 CPU) @ > 166.67/s (n=5) > (warning: too few it

RE: directory listing to array

2001-06-07 Thread Peter Cornelius
> which is faster? > > Randal's suggestion: > > my @result = <*.jpg>; > > or variations on: > > @files = grep /jpg/i, readdir DIR; > Try this... use Benchmark; opendir (DH, ".") or die; timethese(5, { 'Randals' => q{my @result = <*.jpg>}, 'variations' => q{my @result =

RE: directory listing to array

2001-06-07 Thread Peter Cornelius
Looking at the other posting to this I realize I should have included the open and close in the test block. That makes the results... Benchmark: timing 1 iterations of Randals, variations... Randals: 16 wallclock secs ( 6.00 usr + 10.05 sys = 16.05 CPU) @ 622.98/s (n=1) variations: 3 w

RE: double quotes around a variable

2001-06-07 Thread Peter Cornelius
> print "$username"; > > Why are double quotes around $username a "bad" thing in the > print statement? They are? I do print "your username is $username\n"; all the time. I know that doesn't mean it's right but I've never had a problem with it. If all you're printing in print "$username"; th

RE: one last attempt?

2001-06-05 Thread Peter Cornelius
Umm. Don't you need an http header? print "content type: text/html\n\n"; before printing anything else out. CGI.pm would allow you to just say 'print header();' btw. > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, June 05, 2001 6:41 PM > To:

splitting strings with quoted white space

2001-06-05 Thread Peter Cornelius
I have this script that reads in lines from a configuration file, processes them, and then stores them in a hash. Everything is working (mostly) but I really don't like the snippet below and wanted to see if anyone could suggest a better solution. I would call better a syntactically shorter, les

RE: did i do this correctly?

2001-06-04 Thread Peter Cornelius
> #!/usr/bin/perl -w > use strict; > > > # Setup begin > $hompage = "/home/thx-1138/"; > I'm think you mean "$homepage/counter.txt" > $counterfile = "$homepage counter.txt"; #Full file path of counter.txt > and "$homepage/$i.gif" > $imagefile{'0'}="$home

RE: did i do this correctly?

2001-06-04 Thread Peter Cornelius
[Add a -w to this] > #!/usr/bin/perl -w > > # Setup begin > [and a strict pragma] use strict; > $homepage = "/home/yourdomain/counter/"; > > $counterfile = "$homepage counter.txt"; #Full file path of counter.txt > [I don't think you really want a hash he

RE: using fork

2001-06-04 Thread Peter Cornelius
> I can't use system because , a nested command in my program is not > allowed, so i try the fork. > I try with waitpid($pid, ) but i didn't know how to tell > the waitpid > that waits for the child and don't continue > > waitpid($pid,&WNOHANG) > continues execution without > waiting f

RE: Speaking of flock......

2001-06-04 Thread Peter Cornelius
> > open(FILE,">$datafile"); > flock(FILE, LOCK_EX); > print FILE "$input\n"; > close(FILE); > > Notice that I do not use flock(FILE, LOCK_UN); before I close > the file. I > don't use it because I was told not to by the server administrator. The file is implicitly unlocked when you close the

RE: using fork

2001-06-04 Thread Peter Cornelius
I see a posting suggesting using system() which does sound like a good solution. If for some reason you need to fork explicitly look at waitpid() I think it will do what you want. Peter C. > -Original Message- > From: Ulises Vega [mailto:[EMAIL PROTECTED]] > Sent: Monday, June 04, 2001

Re: flock

2001-06-04 Thread Peter Cornelius
to lock a log file wheneber a new visitor enters the page and > also when we run scripts to traverse the log file looking for specific info. > > On Mon, Jun 04, 2001 at 07:42:38AM -0700, Peter Cornelius wrote: > > According to the docs flock is just an 'advisory' lock. So

recursion and memory use... a lot of memory use.

2001-06-01 Thread Peter Cornelius
I have this program that recurses through a directory structure building Default.htm files. The idea here was to quickly generate a bunch of these things to replace the default index listing you normally see. The part that's giving me trouble is the navbar that should have a nested structure lik

Re: Comparing time

2001-06-01 Thread Peter Cornelius
I'll be interested in any other solutions people have because I've got this going in a couple of programs now... Check out Time::timelocal(). It allows you to pass inthe results of localtime and bet back the seconds since the epoch. Since the results of localtime are things that you can actuall

Why 'and' not '&&' ? (was Cleaning up 'uninitialized value')

2001-05-30 Thread Peter Cornelius
> Use: > > if (@ARGV and -T $ARGV[0]) { ... } Just wondering if there is a reason for using the lower precedence 'and' here instead of '&&'? I haven't been finding many uses for 'and' which tells me I might not fully understand it. Thanks, Peter C.

RE: How do I....

2001-05-29 Thread Peter Cornelius
You might start by reading some of the docs that come with ActiveState. They have some details in there about things like adding Perl to your path and creating an association to Perl for files with a .pl extension. This makes things easier than having to type c:/path/to/Perl before every script c

RE: Simple question

2001-05-29 Thread Peter Cornelius
> I am working on the following output. > > * /ebppvobstore/vobs/Core /ebppvobstore/vobs/aci.vbs public > * /ebppvobstore/vobs/UCMCQ /ebppvobstore/vobs/UCMCQ.vbs > public (ucmvob) > /ebppvobstore/vobs/Comp_Care > /ebppvobstore/vobs/Comp_Care.vbs/ public The above is what comes out of `

RE: error on system command

2001-05-25 Thread Peter Cornelius
It might help to know what the error is saying and maybe some surrounding code but my first reaction is that $user has a \n in it that need to be chomped. Also, don't you want @PIDS? Peter C. > Hi, I'm getting a syntax error on the following > command > > $PIDS=`ps -ef | grep $user | grep -v g

RE: Unusual Sort question

2001-05-24 Thread Peter Cornelius
>I would like to sort the same using > the last field (ie. lward, ohara, dray) starting with > the 2nd character (ie from ward , hara and ray) : Check out perldoc sort and perldoc substr. I think this will do what you want @sorted = sort { $aname = (split /\s+/, $a)[-1]; $bname

RE: script that runs all the time to monitor log file

2001-05-24 Thread Peter Cornelius
Is there another way I should be approaching this task? How about not using tail? I'm just ripping this off from the 'Perl Cookbook' but: for (;;) { #ever and ever while () # Do your thing } sleep $awhile;

RE: Is there an alternative to #!/usr/bin/perl

2001-05-24 Thread Peter Cornelius
The camel book suggests the following: #!/bin/sh -- eval 'exec /usr/bin/perl -S $0 ${1+"$@"}' if 0; Is this the best alternative and are there situations in which it might not work? I haven't tried to script it but what about 'which perl' ?

RE: Why can't $I = chop $array[1]

2001-05-23 Thread Peter Cornelius
>I just get tired of looking everything up in my Perl book. Try perldoc ;) $> perldoc chop chop VARIABLE chop LIST chopChops off the last character of a string and returns the character chopped. It's used primarily to remove the newline from the end of an input

RE: $! after using backticks

2001-05-23 Thread Peter Cornelius
>I want to check that a backtick command has executed OK. I thought I could >do that by looking at the $! variable. Check $? This is Child exit status which is what you get when you spawn another process with back ticks. The $! is the ERRNO (or Error string depending on context) for the last sy

RE: Multiple submit buttons CGI question

2001-05-22 Thread Peter Cornelius
>I believe multiple submit buttons only send off the information for the >form they are a part of. If you have multiple forms, clicking one submit >button will only get you that form sent off. But you can have more than one submit button per form. This is useful when you want something like,

RE: Multiple submit buttons CGI question

2001-05-22 Thread Peter Cornelius
In the html: the 'value' attribute just set's up what the button text is, not a unique identifier for the button, so like tdk wrote, you need a name attribute to get the behavior you want.

RE: script review

2001-05-18 Thread Peter Cornelius
>Do you mind if I post a script I have been hacking away at for a week or so >now? Cool.

RE: Win32::OLE SaveAs functions problem

2001-05-17 Thread Peter Cornelius
I haven't worked with the OLE modules at all but I'll put in my 2 cents. It's not clear to me that $filename is open from this snippet. It looks like $filename gets defined and then you delete it if it's there and is a regular file. I don't know what the SaveAs method does but I'm guessing it sa

RE: help with arrays

2001-05-17 Thread Peter Cornelius
>is it possible to read in this file and what ever is before the : would >become the name of >the array? > >IE: >I add this to the config file >full:apple grape chestnut What you're describing sounds like a symbolic reference which would give you something like... ($arrayName, $stuff) = (split

RE: help with arrays

2001-05-17 Thread Peter Cornelius
just an offhand guess but when I've run into this it's been an unsuspected new line. Try adding a chomp $line to the top of the while loop. Peter C.

String concatenation in ?: structure.

2001-05-17 Thread Peter Cornelius
I use the tertiary conditional all the time but I just got some inexplicable behavior and wanted to see what the group had to say. I have a bit of code... my $subject = "Status"; my $returnCode = "o.k."; print "$subject\n"; $returnCode eq "o.k." ? $subject .= " -OK-" : $subject .= " -FAILED-";

RE: serching system for certain file sizes then e-mail.

2001-05-16 Thread Peter Cornelius
>I am trying to writ a script that would search a system for certain file >sizes and if so e-mail me. check out File::Find on cpan. You can do something like... use File::Find; sub checkSize { push @files, $_ if (-s == $specialSize); } find (\&checkSize, @dirs); if (defined @files

RE: Another puzzle......??

2001-05-15 Thread Peter Cornelius
With minimal quoting >I have a line that looks like this: > > TOXFY-1 LENDER: DISBURSEMENT DATE: RUN DATE: 05/01/2001 > >I want to pull off the 1st field and the date. How about ($first, $last) = (split /\s+/, $_)[0,-1]; This will give you the first and last entries

RE: Perplexing problem.........probably beginners luck??

2001-05-15 Thread Peter Cornelius
The doesn't read into $_. You can add a 'print $_;' in there to verify it. I think you're getting confused by the while(){...} structure. This puts the result of the readline into $_ for you if the is the only thing in the '()'. Otherwise, I believe just calling on a line by itself sends th

RE: negative matching?

2001-05-14 Thread Peter Cornelius
This seems to work for me as log as I leave out the 'undef $/;' Why do you want to slurp everything into $_ at once? -Original Message- From: Noah Sussman [mailto:[EMAIL PROTECTED]] Sent: Monday, May 14, 2001 4:29 PM To: [EMAIL PROTECTED] Subject: negative matching? I am trying to writ

RE: Array Size Question(s)

2001-05-14 Thread Peter Cornelius
A cool control structure in perl is the for or foreac loop. With it you don't need to know the size of the array you can just for my $thing (@A) { #do stuff with $thing } If you're familiar with shell syntax this is kinda like the 'for i in list' construct. Books - You might check

RE: Help With Matching

2001-05-11 Thread Peter Cornelius
$test1 = " the is a test"; $test1 = s/<>//g I'm not going to re-state all of the other valid comments to this problem but I would like to add... assuming you want all whitespace replaced with "" I think this should work. $test1 =~ s#\s+##g ^ ^^^ || ||-> \s

RE: Sorting

2001-05-10 Thread Peter Cornelius
I don't know if this is "correct" but I would use sort and pass in a custom compare function. @sortedArray = sort { compareDomains() } @unsortedArray; sub compareDomains { my ($userA, $domainA) = split /@/, $a; my ($userB, $domainB) = split /@/, $a; return ($domainA cmp