Grep question

2008-06-05 Thread David Gilden
Could someone please help me the syntax here my $Comments = param('(Comments'); &BADemail if ($Comments =~ /[virtualthirst.com|napavalleycf.org]/ig); This should go to &BADemail if $Comments contains either string, regardless else is contained in the $Comments. Thanks, Dave (kora musi

DB Conversion script issues

2007-12-09 Thread David Gilden
Greetings, Could some please tell me why this writing the data like think it should. Input data: 4,'Daniel Niederer','','Wberweg 3A','','Hersiwil',' Sample of the output: (first 4 'columns' ) 4,'Daniel Niederer','','Wberweg 3A','','Hersiwil','4558', I would think it should print to disk the f

Extra Commas in output!

2007-12-06 Thread David Gilden
This is adding to many ',' in my output and do not see why! Could some one could point where I have gone wrong. Thanks, Dave Gilden (kora musician / audiophile / webmaster @ www.coraconnection.com / Ft. Worth, TX, USA) data in: (one row of many) 35, 'Mike Hoffman', '', '2565 Davis Blvd. #1

RE: Matching a sub pattern and processing results

2006-09-25 Thread David Gilden
Dear Perl Gurus, Still struggling here... The problem is the data in the middle of the match is on multiple lines. Please reply directly and CC the list. Thanks, D.G. (kora musician / audiophile / webmaster @ www.coraconnection.com / Ft. Worth, TX, USA) >> I am having a little trouble understand

Matching a sub pattern and processing results

2006-09-25 Thread David Gilden
Greetings, I am having a little trouble understanding matching and getting the sub pattern saved to a Var. so that I can do a munge. I want to take the line returns and change them into pipe characters '|' All data records start with a date i.e. 01/01/2006 But there are fields in between t

substr question

2006-06-25 Thread David Gilden
Hello, I am not sure I have the syntax quite right here, any suggestions would be welcome. $line = "Friday, June 23, 2006 12:30 PM" ; $last_updated = substr($line, 0, (length($line) -9)); # remove the time part of time stamp # the above line is throwing an error Thx, Dave Gilden (kora

trimming white space in data

2006-03-04 Thread David Gilden
I am trying to trim white space, at the front and end of a string. The following is not working #!/usr/bin/perl $name = " Dave Gilden"; $name =~ s/^\s*([\w .-]{1,120})\s*$/$1/; print "|$name|"; # This gets the front but not the back! $name = " Dave Gilden"; ($name) = ($name =~ m/^\

if(!defined construct

2006-03-01 Thread David Gilden
I can not seem to get the following script to return the correct response. Could someone point where I am off. Thx, Dave Gilden (kora musician / audiophile / webmaster @ www.coraconnection.com / Ft. Worth, TX, USA) #!/usr/bin/perl use CGI qw/:standard/; use CGI::Carp qw(fatalsToBrowser); use

populating a Hash

2006-02-18 Thread David Gilden
cript, I have guessed at some of syntax here, and am not familiar with using 'defined'. Thanks for any guidance. Regards from Cow Town, David Gilden (kora musician / audiophile / webmaster @ www.coraconnection.com / Ft. Worth, TX, USA) -- To unsubscribe, e-mail: [EMAIL PROT

Checking a list for a value

2006-02-11 Thread David Gilden
I would like to loop through 'all' acceptable values in an array (my white list) then assign a pass or fail value. In the following code does not accomplish this, it needs to go through the entire list before assigning a value. #!/usr/bin/perl $valToTest = "ac"; @myGoodList = ("10_rater","3

Use of uninitialized value Error

2005-12-30 Thread David Gilden
Hello, In the Script below the line: last if ($num >= 35) is giving me this error: Use of uninitialized value in int How do I avoid this error? my @files contains: Gambia001.tiff through Gambia100.tiff #!/usr/bin/perl -w my @files =<*>; $tmp= 1; for (@files){ my $old = $_; $_ =~ /(\d+)/;

Re: getting a number out of a string....

2005-12-29 Thread David Gilden
Chris, Thanks and Happy New Year. Dave (kora musician / audiophile / webmaster @ www.coraconnection.com / Ft. Worth, TX, USA) > > How does one just get the number part out of a string? > > > > The script below just prints 1. > > Right. All it's doing is reporting a successful, true, match. >

getting a number out of a string....

2005-12-28 Thread David Gilden
Greetings, How does one just get the number part out of a string? The script below just prints 1. #!/usr/bin/perl @str = ('Gambia001.tiff','Gambia0021.tiff','Gambia031.tiff','Gambia035.tiff') ; foreach $str (@str) { $num = ($str =~ /\d+/); print "$str : $num\n"; } Thanks! Dave Gilden (kora

use constant

2005-12-19 Thread David Gilden
Greetings, I looked for documentation on 'use constant' but it has eluded it me. my $path = `pwd`; use constant UPLOAD_DIR => "/home/sites/site123/web/private/_data/"; I want to get the Document Root at runtime and concatenate like such... my $path = `pwd`; use constant UPLOAD_DIR

grep mystery / What happened to my @ sign ?

2005-11-22 Thread David Gilden
Greetings, #!/usr/bin/perl $SendersEmail ="[EMAIL PROTECTED]"; ($SendersEmail) = $SendersEmail =~ m/([EMAIL PROTECTED],60})/; print "$SendersEmail\n"; prints: someone.lastname.net I was expecting this: [EMAIL PROTECTED] What happened to my @ sign ? Thanks! Dave Gilden Visit my schedule

Re: grep help request -- data fields max size

2005-10-28 Thread David Gilden
Thanks Jay, For your recommendation, is there a way I can limit the size, something like: [\w\.-]{1,50} or should I do that I bring in the data for first time? Have a great weekend! Dave Ft. Worth, Tx [ www.coraconnection.com ] > It's going to be a whole lot easier, and probably just as fast

grep help request

2005-10-28 Thread David Gilden
Hello, I am stuck with this issue. How do get each substring (the names in this case) and then upper case them. This does not work just yet Possible data: mike smith john h. hamilton g. bush hendric etc.. #!/usr/bin/perl $SendersName = " dave middlename gilden "; $SendersName =~

inline GREP filter...

2005-05-17 Thread David Gilden
Hello, In the following I was thinking it would just print out: "Hello" #!/usr/bin/perl -w $S = "Hello, Perl!"; ($R) = grep {/\w+/} $S; print "$R\n"; I am trying for some sort of inline filtering so I can do the following: #!/usr/bin/perl -w use CGI qw/:standard/; use strict; my $page =

last question on the switch statement ....

2005-04-17 Thread David Gilden
Dear fellow PERL coders..., What is the "&& do" part of the code doing, i.e. I am looking to understand the syntax, the example was found in perl beginners archive, from some else's post... Thanks, Dave (kora musician / audiophile / webmaster @ www.coraconnection.com / Ft. Worth, TX, USA) f

RE: Preventing CPU spikes / was switch confusion

2005-04-13 Thread David Gilden
Dear Perl Gurus, I have some problems that I think are a result of how my Switch statement is written. This script is invoked via a web browser to upload a file, and do a few other things. However it appears that the user system / network, or my script is stalling. So the user clicks the butt

RE: Switch -- confused

2005-04-13 Thread David Gilden
Greetings, Thanks for the help so far, I am added switch... but not sure that I have syntax correct Maybe this is best written as if else logic and or: my $action = $q->param( "action" ); SWITCH ($action) { if (/Upload/) { last SWITCH; }; etc... -

Case statements

2005-04-12 Thread David Gilden
Hello, I am trying to create case statement, and I am not sure I am on the right track, any comments? Thanks, Dave Gilden SWITCH: { ## yacht form if ($whichForm eq "123") { $subject = "123 Form"; $recipient = "[EMAIL PROTECTED]"; $cc = "[EMAIL PROTECTED]"; LAST SWITCH; } ## regatta form

Testing the first line of a file

2005-01-21 Thread David Gilden
Greetings, I was looking for a way to improve the following: # Check to make sure it is an inTune File open (FH, UPLOAD_DIR . "/$file") || error( $q, "Error reading $file for test : $!" ); while(){ if ($_ !~ /\*{5} InTune/){ unlink( UPLOAD_DIR . "/$file") or error( $q, "Problem deleting

Reading the first line of a file

2005-01-17 Thread David Gilden
Greetings, The second piece of code should look for "* InTune " somewhere in the first line of the file if it does not, it should unlink the bad file and fire off the error, it seems to happen all the time regardless of the match. Two quick questions here: I can't see why I am getting thi

RE: Perl regrp 101 -- correction

2004-12-03 Thread David Gilden
Ok, > ## This Does what _not_ do what I would expect -- return the first 3 > characters of type '\w' Give this a shot! #!/usr/bin/perl -w use strict; $tmp ="Joe Smore1qazxswedcvfrtgbnhytujmkilptyot5000"; $tmp =~ s/(^\w{3})/$1/; print "$tmp\n"; This returns the whole string ... sorry ab

RE: Perl regrp 101 -- on OSX.....

2004-12-03 Thread David Gilden
To David & the group, Wags <[EMAIL PROTECTED]> wrote: > What version of Perl are running and on what OS BBedit under Panther (OSX) Mac -- Berkeley BSD Unix perl v5.8.1 > > > > ## This Does what _not_ do what I would expect -- return the first 3 > > characters of type '\w' > > > > $tmp

Perl regrp 101

2004-12-03 Thread David Gilden
Greetings, ## This Does what _not_ do what I would expect -- return the first 3 characters of type '\w' $tmp ="Joe Smore1qazxswedcvfrtgbnhytujmkilptyot5000"; $tmp =~ s/(^\w{3})(.*)/$1/; print "$tmp\n"; # is ^ better outside the '()s'? $tmp ="Joe Smore1qazxswedcvfrtgbnhytujmkilptyo

building substrings

2004-09-15 Thread David Gilden
Hello, I am building a primary key for a database, and I guess the first question would be how safe is a key made from the last 4 digits of a social security num and the first 3 letters of the last name. Now for the PERL question, I have substr. line working correctly. I wanted to try it with

Random Image script has a problem

2004-04-20 Thread David Gilden
Greetings, In the following script (see below) it should be pulling images from the directory: rand_fp_imgs The debug info looks good, but when I run the script from the URL below it pulls images that I have sitting at the root level. Does anyone have any idea why this might be? Thanks, Dave (k

running PERL from CMD line OSX

2004-03-18 Thread David Gilden
Trying to run a perl script in OSX shell, and It is not working, what am I missing? here is what I am typing: > perl -e test.pl #!/usr/bin/perl #test.pl # rename from the Terminal OSX print "hello"; __END__ Dave, (kora musician / audiophile / webmaster @ www.coraconnection.com / Ft. Worth

basic syntax s/..../..../

2004-03-18 Thread David Gilden
Greetings, I want to do the result of a substitution to $newname, but do not have it correct. #!/usr/bin/perl # rename from the Terminal OSX $orig = "tina-o1.jpg"; ($orig = $newname) =~ s/tina/quest/ig; print $newname; __END__ Then I would like to run from the command line the followi

POSIX 'strftime'

2003-04-06 Thread David Gilden
Hello, How can get the date formatted to include the day of the week (plus one) '04-07-2003-1013' Thanks, Dave ( kora musician / audiophile / web master @ cora connection / Ft. Worth, TX, USA) The following misses the day of week!! #!/usr/bin/perl -w use POSIX 'strftime'; print strftime('%m-

Re: PERL OSX --- reading a local text file

2003-03-18 Thread David Gilden
Thanks for all of the help, Here is what I am currently going with: my $prices = '../paul_s/data/prices.txt'; open (FH,$prices) || die "could not open $prices $!"; while( ) { s/^\s*(.+)\s*$/$1/; # clean the front of each line next if /^\s*$/; # skip blank lines my ( $k, $v ) = sp

RE: PERL OSX - reading a local text file with white space

2003-03-18 Thread David Gilden
Thanks Dave for the while loop, I need to protect against blank lines and spurious white space that could show up in the data. No doubt the file will edited in Note pad (on widows 98), and I want to put the data in to the hash in a clean format. and since the this is basically a price list nam

Re: PERL OSX --- reading a local text file

2003-03-18 Thread David Gilden
OK, one problem is solved, which was the path to the data file. I know there is a simple way to read in a file like the following: apple,2 banana,4 kiwi,1 and produce a HASH. The code below works I get the feeling there is a more compact way to accomplish this. --- #!/usr/bin/perl -w use

Re: PERL OSX --- reading a local text file

2003-03-18 Thread David Gilden
icle > that has been posted to perl.beginners as well. > > >>>>> "David" == David Gilden <[EMAIL PROTECTED]> writes: > > David> Hi List, > David> Any reason why this dies? error: " could not open data.txt No such

PERL OSX --- reading a local text file

2003-03-18 Thread David Gilden
Hi List, Any reason why this dies? error: " could not open data.txt No such file or directory" -->The file and script reside in the same directory!!! #!/usr/bin/perl -w use strict; my $data = "data.txt"; open (FH,$data) || die "could not open $data $!"; local $/; my $tmp = ; my @tmp =

getting the number of characters

2003-03-12 Thread David Gilden
Hello, I am looking for the $num to treated as a string and get the number of characters, in this case I am look for 3 to be returned. Later I want to use this number to pad a string with zeros Thanks! Dave #!/usr/bin/perl -w $num =123; ($match) = ($num =~ m/(\d)/); print "$match \n";

removing elements from an array

2003-03-05 Thread David Gilden
Hi, I would like to remove elements from an array that are eq to string '0' The following does not work, can someone shed some light on the proper way to do this. Thanks! Dave G. #!/usr/bin/perl -w @bag_quantity = ( '0', 1, '0', '0', '0', '0', '0', '0', '0' ); for (@bag_quantity){ shift if $_

incrementing inside a s///

2003-02-11 Thread David Gilden
How do get $i do increment inside the substitution below? Thanks Dave #!/usr/bin/perl -w my $i = 0; while(<>) { chomp; s/name=\"order/name=\"order$i++/; print "$_\n"; } == Cora Connection: Your West African Music Source

OSX Perl

2002-12-25 Thread David Gilden
Here's a quick question: #!/usr/bin/perl -w use strict; print "Hello, Perl!\n"; # return "Hello, Perl!\n"; # tried this as well bash2.05a % perl Hello\ World.pl > test-hello.txt bash2.05a % bbedit test-hello.txt test-hello.txt is empty, what did I miss? Thanks! Dave ==

check against two different passwords.

2002-12-23 Thread David Gilden
Hello, in the following # Goal: check against two different passwords. #!/usr/bin/perl my $qs = 'c'; my $secret_word = 'a'; my $secret_word_guest = 'b'; if ($qs !~ /$secret_word_guest|$secret_word/) { print "fail\n"; } else { print "go, ok\n"; } another ver

rename((1,2) and file permissions

2001-11-12 Thread David Gilden
Hello, what is causing the renamed file to take permissions of 755 instead of 644? -- am I doing this correctly -- there will be only one user of the script .. do I need 'file lock' here? Thanks to Bob Showalter for the formatting info on 'strftime' "man 3c strftime" --> http://www.cs.princeton

syntax @{ $records{$_} }

2001-11-09 Thread David Gilden
Could some explain what this is? @{ $records{$_} } is it a Array? thanks! DAve ** * Cora Connection Your West African Music Source * * http://www.coraconnection.com/ * * Resources, Recordings, Instrum

Perl Filter problem

2001-10-27 Thread David Gilden
Can anyone please tell me what is wrong here, Thnx Dave cold:~/cgi$ perl -pie 's/;"\);/"\);/ ' * Can't open perl script "s/;"\);/"\);/ ": No such file or directory What I want to do is change all files in the current directory. Find lines that contain: ;"); And change them to: "); ---

Re: problem with 'use strict'

2001-10-26 Thread David Gilden
On Friday, October 26, 2001 at 5:38 PM, [EMAIL PROTECTED] (Brett W. McCoy) wrote: > > Sorry, I meant that to say "And it runs without 'use strict'? Yes the code works fine, untill I try to use strict Dave ** * Cora Connection Your We

problem with 'use strict'

2001-10-26 Thread David Gilden
Hi, As an exercise I have two files, a library file and a main file. If I try to 'use strict' my script won't run. What do I have to change so that things will work correctly with out clobbering any of my $vars? Thanks and have a good weekend, Dave G. - # library file dbi-lib.pl my $user

Data Structures

2001-10-03 Thread David Gilden
Hi, I am having bit of a struggle getting the following code to work: Here are my two questions, first is there a cleaner way of dealing the 'radio button group' next is the building of a hash of hashs, and I can not seem to sort desired criteria. As a PERL neophyte all help is appreciated

Perl one-liner problem

2001-09-07 Thread David Gilden
Any idea why this aint working? perl -wpi.org -e s@/cgi-bin/forum_idx.pl@/fakecgi/fakeforum_idx.pl@ Thanks Dave -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Search --> Replace on Unix

2001-09-06 Thread David Gilden
Hello, What is the best way do to search and replace operation on a whole directory on a UNIX box? Sed? Awk? Perl? I know this is wrong, what I want to do is a search and replace, find '../forum_idx.pl' and replace with '../forum_idx.pl' I have to hit a whole directory with this change, (and

PERL / UNIX File manipulation

2001-08-17 Thread David Gilden
Hi, How would you approach the following: in a directory (on a UNIX box) file-a file-b file-c file-d This what I like have after I run a script or a mysterious UNIX command: 1-file-a 2-file-b 3-file-c 4-file-d *** OR *** new-file-a new-file-b new-file-c new-file-d Possible script untest

Dynamic Data structures

2001-07-18 Thread David Gilden
Take this Data structure (which is an anonymous hash) # # $bears = { # # # rec0 => { # name => 'sweaterie', # type => 'sweater', # color => 'golden brown', # food => 'mixed berries', # }, # ect # }; I am

Cmd Line args

2001-07-16 Thread David Gilden
if I invoke this script as follows: perl bears.pl ARGV[0] never seems to be false even though there are no args.. What did I do wrong here? Thanks Dave #!/usr/bin/perl -w $sort_order = $ARGV[0] || $usage; # grab command line args $usage =" # Type a number after the script name to choose the

upper-casing the first char & hashs of hashs

2001-07-16 Thread David Gilden
Hello, The following uppercase'S the whole string, when all I want is the first letter. &uppercase($bears->{"rec$n"}{name}), uc($bears->{"rec$n"}{type}) # works but caps the whole string } u\$bears->{"rec$n"}{type} # does not work... sub uppercase{ ($s) = @_; \u$s = scalar $s; ## does n

modules & path to perl

2001-07-05 Thread David Gilden
How do I list what my ISP has on there server in terms of Modules? And what is the command (at the command line) to tell me what version The server has on it / and or the path to perl. Thanks Dave G. Looking for Web Talent, You found it! portfolio: w

Format & Sprintf

2001-07-02 Thread David Gilden
Hello, The following is based on the first example in Programming Perl, and have a question about some of the syntax (and or why it was doen this way) $grades{$student} .= $grade . " "; Why not $grades{$student} = $grade; Why the concatenation and the extra space? $average = sprintf ("%3d",

removing white space

2001-06-26 Thread David Gilden
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; or would it be more efficient to it thus: # two passes $data =~ s/^\s+)//; $data =~ s/\s+$)//; Final comment when I am

RE: Variable scoop

2001-06-26 Thread David Gilden
Here's the latest revision, I don't know why it was not working earlier when emailLog = 'logs/email_log'; was out of the sub block. This script is contained in one file, with on 'use' or 'require' statements. The next revision I see is to move the regrex up to top of the sub where the append t

Variable scope

2001-06-26 Thread David Gilden
Quick question, I could not get the following sub to work until I had to move $emailLog inside the sub to get this to work on the server. What did I miss or not understand? Thanks Dave ## not seen by the sub, $emailLog = 'logs/email_log'; # Send E-Mail &send_mail; # Append email lo

Re: $hash{$_}++

2001-06-18 Thread David Gilden
How about a an example or 2 where you would use this, $hash{$_}++ Thnx, Dave, Looking for Web Talent, You found it! portfolio: www.coraconnection.com/web/ email: [EMAIL PROTECTED] tel/fax: (860) 231-9988

RE: Sort hash by values

2001-06-18 Thread David Gilden
Thanks for all who helped with my Perl coding, I thought some folks here might benefit from me posting the final code I used on a current project: ---snip--- if ($sort_order == 1) { # sort by name (front part of the key) foreach my $key (sort {lc($a) cmp lc($b)} keys %index){ &print_ta

$hash{$_}++

2001-06-18 Thread David Gilden
I am having trouble understanding just what the following does, and how to you use it: $hash{$_}++ i.e. are we increment the value or the key? I would appreciate any guidance here! Thanks, Dave G.

More sorting

2001-06-15 Thread David Gilden
_rows { my ($fileName, $subject, $date) = @_; ($name = $fileName) =~ s/_\d+$//; $name =~ tr/_/ /; print < $subject $name$date data } -- From: Wagner-David Sorry, but as soon as I saw the input coming back I knew it was really untested. Should be sort {lc($a->[1]) cmp lc($b-

sort by number...

2001-06-15 Thread David Gilden
Good day, keys look like: Dowda_23241506142001 This is wrong, but not sure how the syntax is, Where are $a,$b coming from, I thought of a sub, but how do assign $a, $b foreach my $key (sort { /_(\d+)$/; $a <=> $b } (keys %subjects)) { # /_(\d+)$/ grabs the number at the end of the string,

Sort hash by values

2001-06-14 Thread David Gilden
Hello, Stuck here, The first sort block works like a charm! if ($sort_order == 1) { # sort by name # $key is really the filename with out the path and '.html' foreach my $key (sort {lc($a) cmp lc($b)} keys %subjects){ my $name; ($name = $key ) =~ s/_(\d+)$//; $name =~ tr/_/ /

Slicing and dicing

2001-06-14 Thread David Gilden
Is one style better then the other here? Thanks, Dave - sub print_table_rows { my $name = shift; my $key = shift; my $date = shift; print < $thread{$key} $name$date data --- alt sub print_table_rows { my ($name,$key,$date) = @_[0..2] print < $thread{$key} $name$date data

avoiding duplicates

2001-06-14 Thread David Gilden
Greetings, a couple of questions here, --- # Text colors @colors = qw[ #F0F8FF #00 #7FFFD4 #F0 #F5F5DC #FFE4C4 #00 #FF #8A2BE2 #A52A2A #5F9EA0 #7FFF00 #FF7F50 #DC143C #00 #8B #008B8B #B8860B #FA8072 #F4A460 #2E8B57 #A0522D #6A5ACD #00FF7F #4682B4 #D2B48C #008080

Re: avoiding duplicate values

2001-06-07 Thread David Gilden
> On Jun 7, David Gilden said: > > >@colors = qw[ #F0F8FF #00 #7FFFD4 #F0 #F5F5DC #FFE4C4 #4169E1 > >#8B4513 #FA8072 #F4A460 #2E8B57 #A0522D ]; > > > > > ># choose a color! > >$color_choice1 = rand $#colors; On Thursday, June 7, 2001 at 3:40

avoiding duplicate values

2001-06-07 Thread David Gilden
Is this the correct way to avoid getting the same value twice? # Text colors @colors = qw[ #F0F8FF #00 #7FFFD4 #F0 #F5F5DC #FFE4C4 #4169E1 #8B4513 #FA8072 #F4A460 #2E8B57 #A0522D ]; # choose a color! $color_choice1 = rand $#colors; # make sure we don't get same color twice $color_c

m#^/\*# .. m#^\*/#;

2001-06-06 Thread David Gilden
Could someone please break this down, I am not sure how to read this: m#^/\*# .. m#^\*/#; # using the range operator match (# is the delimiter) at the start of a line /\* (and this where I lose it!) Frm Jason King #!perl -w use strict; open FILE, 'Cfile' or die "Bad open: $!

regrex delimiters

2001-06-06 Thread David Gilden
Hi, What is going on with the [] at the end of the regrex? Thnx, Dave G. I so understand s/// however... I am little confused with following: #!/usr/bin/perl -w $s = "long string of stuff"; ($r = $s) =~ s/l\w+/[]gsx; print $r; __END__ File "untitled 15"; Line 6: Substitution replace

Which Regrex

2001-06-04 Thread David Gilden
Is version 2 a better choice here? Thx Dave #!/usr/bin/perl # desired result ""bill gates the third" $name= "bill_gates_the_third_132506042001.html"; # vers 1: $name =~ s/^(\w+?)_(\d+).html$/$1/; $name =~ tr/_/ /; print "$name\n"; # # vers 2: $name= "bill_gates_the_third_132

command line switches?

2001-06-04 Thread David Gilden
Which perldoc will list the command line switches? Thanks Dave ** * Cora Connection Your West African Music Source * * http://www.coraconnection.com/ * * Resources, Recordings, Instruments & More! * *

multi word strings (with spaces) in a hash key?

2001-06-03 Thread David Gilden
> Quick question: can I use multi word strings (with spaces) in a hash key? > > $hash{time to upgrade} # note the spaces, Well, yes, you can. But it's not a very good idea. If you absolutely must, enclose the string in quotes. $hash{'time to upgrade'} any comments on why this a b

one last thought on printf

2001-06-02 Thread David Gilden
In the following chunk, ($sec, $min, $hour, $wday, $month, $year) = (localtime)[0..5]; 1: $year += 1900; 2: $wday = "0" . $wday if $wday < 10; # adds a leading zero , not needed 3: $month++; # perl counts from -1 on occasion 4: $month = "0" . $month if $month < 10; # same as above # this

push(@everyline, $_); vers $longstring .= $_;

2001-06-01 Thread David Gilden
Is one of these preferred over the other? open(FROMFILE,$filename); while(){ push(@everyline, $_); } $longstring = join("",@everyline); @oldentries = split(//,$longstring); ---OR--- open(FROMFILE,$filename); while (){ $longstring .= $_; } @ent

printf and other stuff

2001-06-01 Thread David Gilden
Good afternoon, Is there a way to combine the last two statements? #!/usr/bin/perl -w $sort_order =0; $sort_type = ($sort_order) ? 'Newest First' : 'Oldest First'; # are the () optional? print $sort_type; ##this does not work print ($sort_order) ? 'Newest First' : 'Oldest First';

basic questions!

2001-05-31 Thread David Gilden
Hi folks, In my effort to fully understand online documentation [ perldoc ] I see all kinds of examples like the following : This approach of treating C and C like object methods calls doesn't work for the diamond operator. That's because it's a real operator, not just a function with a comma

iinfinite loop

2001-05-30 Thread David Gilden
The following seems to never break out of the loop, any comments? Thanks Dave #!/usr/bin/perl -w $data = 'some multi line string'; while($data){ push(@everyline, $_); }

RE: use strict / explicit packages

2001-05-29 Thread David Gilden
Did I touch a nerve here or what? Ge, all of this totally is confusing me, So you know where I am coming from, I'm taking a second on-line CGI/PERL class that leaves a lot to be desired (if anyone knows a good up-todate on-line class, please let me know!) I will move up to learning CGI.pm, b

RE: use strict / explicit packages

2001-05-29 Thread David Gilden
Hello, I am using MacPerl here. After adding: ' use strict; ' and am now getting several warnings.. In my library I have %FORM_DATA declared, File "hd:Perl:Cgi class:useractive:guest book:guestin.pl"; Line 9: Global symbol "FORM_DATA" requires explicit package name. How can I avoid the ab

Perl library question

2001-05-24 Thread David Gilden
Hello, I have moved my subroutines to a second file and have named it "subs_lib.pl" In the main file I have: require "subs_lib.pl"; Is the following equivalent: use "subs_lib.pl"; - Secondly do I need: #!/usr/bin/perl as the first line in my "subs_lib.pl" and are Libraries really modu

Regrex question

2001-05-23 Thread David Gilden
Hello, Thanks for all the help this list is providing, Here is today's problem: #!/usr/bin/perl $test = "dave David Davy"; $i=0; ### Does not work want to count the number of matches... $regex= ($test=~ s/(dav)/$i++ $1/eig); print "$regex $i\n"; ### This does work.. $regex= ($test=~

foreach confusion

2001-05-22 Thread David Gilden
As an exercise here I want to play with this for a few minutes, and have a few basic questions #!/usr/bin/perl # First question do I use # ( ) OR { ... } @lines = qq{dave john mike drew}; # First error, should be qw( ... ) # qq is garbage, right? # is the ',' correct in my($a,$b) can

Multiple submit buttons CGI question

2001-05-22 Thread David Gilden
Hello, Can any one tell where I went wrong here? (I remember reading that a html form can have multiple submit forms as long as you parse them via their value) Thanks! Dave - In the html: -- #!/usr/bin/perl $forminfo = ; @key_value_pairs = split(/&/,$forminfo); foreach $pair

print statment

2001-04-23 Thread David Gilden
Original from the class: print "\n"; Is this bad style? print '',"\n"; better? print ''. "\n"; I do believe that these 3 statements are all equivalent. Thanks Dave

quick PERL question

2001-04-23 Thread David Gilden
Dear Casey and the list, Thanks for your all of your valuable help, What is $|++ for? #!/usr/local/bin/perl -w use strict; $|++; while ( ) { chomp; print( &validate( $_ ) ? 'valid entry' : 'try again punk' ); print "\n"; } sub validate { my $currency = shift; # return false if we

print with => ??

2001-04-23 Thread David Gilden
Hello, Sorry to ask this, as I am quite new at this. And the online class that I am just now finishing has lots of bad code for examples! >From this list: print "'$file' => '$newfile'\n"; ^ What does this line mean, this a renaming convention? Thanks Dave -

Validating price (US Currency)

2001-04-23 Thread David Gilden
Is there a better way of doing this? Thanks! Dave if ($in{'price'} eq "") {print '• Missing '; } elsif (&checkPrice($in{'price'})) { print '• Wrong Format'; } sub checkPrice{ if ($_[0] =~ /\$?(\d*)(\.\d{0,2})?/) { return 1; } else { return 0; } } Allowable input:

Populating Hashs and checking multi form fields

2001-04-20 Thread David Gilden
Hello, Here is code fragment that I can't seem to solve. All help, suggestions are appreciated. Thanks! Dave What I want to do is to check for either if the username or password is good: The $pwfile contains (exactly like it is here): username1|password1 username2|password2 ect. # stuff $p

matching with a loop

2001-04-19 Thread David Gilden
Hello, What I want to is to load a file "$bw" and then have my regrex find if any of the bad words are in any of the form fields. The code I have here does not work. # $in{$i} are the form fields, that need to be checked for # any of the bad words, contained in the bad_words.txt $bw ='../cla

Digest version please

2001-04-19 Thread David Gilden
Can we get a digest version of list? Thanks Dave ** * Cora Connection Your West African Music Source * * http://www.coraconnection.com/ * * Resources, Recordings, Instruments & More! * *===