Re: regex question
rory oconnor wrote: > > I am using LWP to hit a page and save the source to a file. But before > it saves it I want it to strip out the client id from the urls. They > are always in the same format: > > client=& # 8 digits and then ampersand > > so what I want to strip out is stuff like: > > client=23894749& to strip out stuff like that just do $content =~ s/client=23894749&//g; experiment a bit with it (and read some about it) and you'll learn the basics in notime. Expecially if you allready know how to use modules. /Jon > > i am a newbie so regex is a little out of my league. any help > appreciated! > > thanks, > > Rory > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: regex question
sorry about that answer, too early in the morning to answer questions...i even thought it was the newest. I wish I could go back to sleep /jon -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Sites
setup your own server !?!!? On Wed, 13 Feb 2002, Naveen Parmar wrote: > Any recommendations on free Web sites where you may upload Perl scripts and > execute CGI scripts? > > TIA, > - NP > > > > _ > Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp. > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Help can't figure this one out
Bruce Ambraal wrote: > > I have written following coding to produce a triangle pattern(see below); > I now want to produce following paterns I can't figer this out > > (a)(b) (c) (d) diamond >** * * * * * * * * * * > * * * * * ** * * ** * * >* * * * * ** * * * * * * > * * * * * ** * * * * * * >* * * * * * ** * * * > * * * > * > __ > #!/usr/local/bin/perl -w > my $num_rows; > my $i; > my $r; > > $num_rows = ; > > for ($r = 1; $r <= $num_rows; $r++) > { > # indent by printing num_rows - r spaces > for ($i = 1; $i <= $num_rows - $r; $i++) {print (" \n");} > # print r asterisks >for ($i=1; $i<= $r; $i++) { print (" *");} > # drop cursor to a new line > print "\n"; > } > # end for #!/usr/local/bin/perl -w use strict; my $num_rows = shift || die "usage: $0 rows\n"; print "a)\n"; print ' ' x (($num_rows+1) - $_), ' *' x $_, "\n" for 1 .. $num_rows; print "\n"; print "b)\n"; print ' ', ' *' x $_, "\n" for reverse 1 .. $num_rows; print "\n"; print "c)\n"; print ' ' x (($num_rows+1) - $_), ' *' x $_, "\n" for reverse 1 .. $num_rows; print "\n"; print "d)\n"; print ' ' x (($num_rows+1) - $_), ' *' x (2 * $_ - 1), "\n" for 1 .. ($num_rows/2+1), reverse 1 .. ($num_rows/2); print "\n"; __END__ John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: finding max value
I can't tell by this code alone, but does the benchmark time the entire script that's running, or just the iterate/sort part? i.e. is the 'rand' function timed also, and will the time difference between generating 20 and 10,000 numbers mess up the results? Sorry I can't test this myself, I'm at a computer w/out perl :O !! Cheers, Carl Please don't cc me. I'm on the list. > > my @bob = rand for (1..20); > my @joe = rand for (1..10_000); > sub maxOne > { > my $max = (sort {$b<=>$a} @bob)[0] > } > sub maxTwo > { > my $max = (sort {$b<=>$a} @joe)[0] > } > sub maxThree > { > my $max = $bob[0]; > for (@bob) > { > $max = $_ if $_ > $max > } > } > sub maxFour > { > my $max = $joe[0]; > for (@joe) > { > $max = $_ if $_ > $max > } > } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
stuck again downloading file
Ok, I'm having a problem downloading a .zip file from a webpage. If I type in the filename in the browser URL textbox I get redirected to the main site. I can navigate through the main site and get to the same web page I typed in and then download the file, but I cannot go directly there. This causes a problem with LWP::UserAgent as it gets redirected to the main site and cannot download the file. I have no idea why I can navigate to it, but cannot download directly. I thought it might have something to do with cookies, so I added a cookie jar to UserAgent but to no avail. Does anyone know why I am getting redirected and what I can do in perl to prevent my UserAgent from getting redirected? Thanks! Tanton -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Generating for loop paterns HELP!
Hi I have done (b) for coding see below, could someone assist with (a) (b) (d) #!/usr/local/bin/perl -w my $num_rows; my $i; my $r; $num_rows = ; for ($r = 1; $r <= $num_rows; $r++) { for ($i=1; $i<= $r; $i++) {print (" \n");} for ($i = $num_rows + 1 - $r;$i>=1; $i--){ print (" * ");} }# end for print (" \n"); solution: - 5 * * * * * * * * * * * * * * * Thanks Bruce --- Begin Message --- I have written following coding to produce a triangle pattern(see below); I now want to produce following paterns I can't figer this out (a)(b) (c) (d) diamond ** * * * * * * * * * * * * * * * ** * * ** * * * * * * * ** * * * * * * * * * * * ** * * * * * * * * * * * * ** * * * * * * * __ #!/usr/local/bin/perl -w my $num_rows; my $i; my $r; $num_rows = ; for ($r = 1; $r <= $num_rows; $r++) { # indent by printing num_rows - r spaces for ($i = 1; $i <= $num_rows - $r; $i++) {print (" \n");} # print r asterisks for ($i=1; $i<= $r; $i++) { print (" *");} # drop cursor to a new line print "\n"; } # end for - unxsup:/home/bruce$ perl triangle.pl 5 * * * * * * * * * * * * * * * Cheer Bruce -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- End Message --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: stuck again downloading file
Try removing all cookies you have in your browser and set it to ask for allowing cookies, then you'll really see if there are any cookies /Jon Tanton Gibbs wrote: > > Ok, I'm having a problem downloading a .zip file from a webpage. If I type > in the filename in the browser URL textbox I get redirected to the main > site. I can navigate through the main site and get to the same web page I > typed in and then download the file, but I cannot go directly there. This > causes a problem with LWP::UserAgent as it gets redirected to the main site > and cannot download the file. I have no idea why I can navigate to it, but > cannot download directly. I thought it might have something to do with > cookies, so I added a cookie jar to UserAgent but to no avail. Does anyone > know why I am getting redirected and what I can do in perl to prevent my > UserAgent from getting redirected? > > Thanks! > Tanton > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
urgent info required
hi, i want to know how to replace a single \ (back slash) with single / (forward slash) . please let me know. regards, sreemathi ** This email (including any attachments) is intended for the sole use of the intended recipient/s and may contain material that is CONFIDENTIAL AND PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or distribution or forwarding of any or all of the contents in this message is STRICTLY PROHIBITED. If you are not the intended recipient, please contact the sender by email and delete all copies; your cooperation in this regard is appreciated. ** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Generating for loop paterns HELP!
This smells homework! /jon Bruce Ambraal wrote: > > Hi > > I have done (b) for coding see below, could someone assist with > (a) (b) (d) > > #!/usr/local/bin/perl -w > my $num_rows; > my $i; > my $r; > > $num_rows = ; > > for ($r = 1; $r <= $num_rows; $r++) > { > for ($i=1; $i<= $r; $i++) {print (" \n");} > for ($i = $num_rows + 1 - $r;$i>=1; $i--){ print (" * ");} > }# end for > print (" \n"); > > solution: > - > > 5 > > * * * * * > > * * * * > > * * * > > * * > > * > > Thanks > Bruce > > > > Subject: Help can't figure this one out > Date: Thu, 14 Feb 2002 08:24:11 +0200 > From: "Bruce Ambraal" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]> > > I have written following coding to produce a triangle pattern(see below); > I now want to produce following paterns I can't figer this out > > (a)(b) (c) (d) diamond >** * * * * * * * * * * > * * * * * ** * * ** * * >* * * * * ** * * * * * * > * * * * * ** * * * * * * >* * * * * * ** * * * > * * * > * > __ > #!/usr/local/bin/perl -w > my $num_rows; > my $i; > my $r; > > $num_rows = ; > > for ($r = 1; $r <= $num_rows; $r++) > { > # indent by printing num_rows - r spaces > for ($i = 1; $i <= $num_rows - $r; $i++) {print (" \n");} > # print r asterisks >for ($i=1; $i<= $r; $i++) { print (" *");} > # drop cursor to a new line > print "\n"; > } > # end for > > - > unxsup:/home/bruce$ perl triangle.pl > 5 > > * > > * * > > * * * > > * * * * > * * * * * > > Cheer > Bruce > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Generating for loop paterns HELP!
Hi Everyone had to crawl before they could walk, JON, stop being polite and help me I need your assistance now... Cheers Bruce >>> Jon Molin <[EMAIL PROTECTED]> 02/14/02 12:00PM >>> This smells homework! /jon Bruce Ambraal wrote: > > Hi > > I have done (b) for coding see below, could someone assist with > (a) (b) (d) > > #!/usr/local/bin/perl -w > my $num_rows; > my $i; > my $r; > > $num_rows = ; > > for ($r = 1; $r <= $num_rows; $r++) > { > for ($i=1; $i<= $r; $i++) {print (" \n");} > for ($i = $num_rows + 1 - $r;$i>=1; $i--){ print (" * ");} > }# end for > print (" \n"); > > solution: > - > > 5 > > * * * * * > > * * * * > > * * * > > * * > > * > > Thanks > Bruce > > > > Subject: Help can't figure this one out > Date: Thu, 14 Feb 2002 08:24:11 +0200 > From: "Bruce Ambraal" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]> > > I have written following coding to produce a triangle pattern(see below); > I now want to produce following paterns I can't figer this out > > (a)(b) (c) (d) diamond >** * * * * * * * * * * > * * * * * ** * * ** * * >* * * * * ** * * * * * * > * * * * * ** * * * * * * >* * * * * * ** * * * > * * * > * > __ > #!/usr/local/bin/perl -w > my $num_rows; > my $i; > my $r; > > $num_rows = ; > > for ($r = 1; $r <= $num_rows; $r++) > { > # indent by printing num_rows - r spaces > for ($i = 1; $i <= $num_rows - $r; $i++) {print (" \n");} > # print r asterisks >for ($i=1; $i<= $r; $i++) { print (" *");} > # drop cursor to a new line > print "\n"; > } > # end for > > - > unxsup:/home/bruce$ perl triangle.pl > 5 > > * > > * * > > * * * > > * * * * > * * * * * > > Cheer > Bruce > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: urgent info required
On Thu, Feb 14, 2002 at 03:26:13PM +0530, Sreemathi_M wrote: > hi, > > i want to know how to replace a single \ (back slash) with > single / (forward slash) . > > regards, > sreemathi ---end quoted text--- Well the best way to know is to take some time and read some documentation or books. A Short-term solution to your needs is this: $_='s\s\s\s\s\s'; # the original string print "$_\n"; # print the original string s!\\!/!;# use a regex (! used for clarity) print "$_\n"; # show the changes. I'm not even sure if this is exactly what you want. You could have meant: 1) All instances of \ not \\: s!\\([^\])!/$1!g; * 2) All instances of \ : s!\\!/!g; 3) One instances of \ not \\: s!\\([^\])!/$1!; * 4) Only a single instances of \ : s!\\!/!; I've opted for the latter (4). The best advice I can _really_ give, and I hope it's not patronizing, is to spend some time phrasing your question, quite often you'll find the answer as you're writing the email; if not we're in a better postion to help. It saves time in the end. * not tested. -- Frank Booth - Consultant Parasol Solutions Limited. (www.parasolsolutions.com) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: print stock market page every so often
On Wed, Feb 13, 2002 at 05:01:33PM -0800, Peter wrote: > hi guys, just wondering if I can use perl to email me > a text based copy of a web page, maybe copy and paste > to a file then e-mail the info. I can probably use > something like a macro in windows nt to create a > procedure or somethingany ideas? thanks...maybe > someone has done this before. I would like to get > periodic updates on my stocks. ---end quoted text--- For this I'd recommend: LWP::Simple;# To get the page (presuming no cookie or password needed HTML::Parser or a regex # To grab the pertinent stuff I'm not sure how mail works on NT but I'd check CPAN for that IIWY. -- Frank Booth - Consultant Parasol Solutions Limited. (www.parasolsolutions.com) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: stuck again downloading file
Hi All, I trying to find some information (examples) about forks or thread for perl on win32, can anyone help me? Basically want to run 'X' simultanous processes in a continous loop. That is there will alway be 'X' number of processes running. I thought I could do it with use Thread but I get back a message saying This perl was built for "ithreads", which currently does not support Thread.pm etc is there another/better way without using fork/threads? Thanks Mark -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Help me out
I have just started learning perl a day ago. Can anybody guide me on how to start? I am really interested in learning the language AMRINDER _ Join the worlds largest e-mail service with MSN Hotmail. http://www.hotmail.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
forks or thread for perl on win32
(please forgive the dulpicate post - last one has wrong subject Doh!) Hi All, I trying to find some information (examples) about forks or thread for perl on win32, can anyone help me? Basically want to run 'X' simultanous processes in a continous loop. That is there will alway be 'X' number of processes running. I thought I could do it with use Thread but I get back a message saying This perl was built for "ithreads", which currently does not support Thread.pm etc is there another/better way without using fork/threads? Thanks Mark -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: forks or thread for perl on win32
>Hi All, > > I trying to find some information (examples) about forks > or thread for perl on win32, can anyone help me? > > Basically want to run 'X' simultanous processes in a > continous loop. That is there will alway be 'X' number > of processes running. > [snip] > Is there another/better way without using fork/threads? Get a Real Operating System! Perl threads are experimental, and forking is the recommended solution at the moment (AFAIK). Under Window's this is simulated, and quite slow. Try something along the lines of: my $servers = 10; while (1) { exec system("/path/to/program") unless ($actual >= $servers); sleep 1; # Avoid respawning too quickly } but then you'd need a way to find out the number actually running... something that is easy under Unix! Why exactly do you need to maintain a pool of processes? CGI is covered by installing FastCGI, which is the most common requirement - in other cases you can get away without forking (only server programs usually need to fork) Jonathan Paton __ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
CPAN
I have a Linux Box and I am attempting to install perl 5.6. I can get onto CPAN but it wont find the perl 5.6 distro. When I search I see it but i can't find the 'keyword' that it will like to install it. Can anyone help? __ Do You Yahoo!? Send FREE Valentine eCards with Yahoo! Greetings! http://greetings.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Help can't figure this one out
> -Original Message- > From: Bruce Ambraal [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 14, 2002 1:24 AM > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] > Subject: Help can't figure this one out > > > I have written following coding to produce a triangle > pattern(see below); > I now want to produce following paterns I can't figer this out > > ... > > # indent by printing num_rows - r spaces > for ($i = 1; $i <= $num_rows - $r; $i++) {print (" \n");} A suggestion: if you want to write Perl programs, you should resist the temptation to write them like C programs. This kind of thing can be simplified to something like: print " \n" for 1 .. ($num_rows - $r); or better yet: print " \n" x ($num_rows - $r); If you haven't done so already, grab a copy of Schwartz' Learning Perl and work through it. That will show you some of the idioms that can greatly simplify your programs. (BTW, are you aware that this statement does not do what the comment says it does. You should fix one or the other.) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Perplexing server error (premature end of script headers)
On Wed, 13 Feb 2002 15:54:16 -0500, [EMAIL PROTECTED] (Peter Cline) wrote: >I am getting a premature end of script headers error when running a >particular script from a browser. It runs fine the command line, printing >the proper header and all. The first thing to do is check the server logs for a clue to the error. If you cant get to the logs add: use CGI::Carp qw(fatalsToBrowser); to your script to see if you can get an clue to the error. Always check your scripts for dos line endings if on an unix server. You say it runs on the commandline. Is this on your desktop? Have you ssh'd into the server and actually ran it from the commandline on the server? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
mbox (email) handlers?
Does anyone have suggestions for Perl packages that would allow me work through email mbox's and change the read status of some emails and delete some emails? Pretty much everything I can find is limited to reading mbox's (or I would have to cycle through a mbox a write emails to keep and mdofied emails to a temp file and then copy that temp file over the original file - seems messy and prone to errors) Since I'm a beginner, examples would be great. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Help me out
I really suggest the O'Reilly books, "Learning Perl" 3rd edition. ISBN 0-596-00132-0 Also go to www.CPAN.org, and follow the FAQ on what you need to run a Perl environment on your system. After you've setup an environment, you can start by running some examples in the book to get a grasp. V -Original Message- From: amrinder singh [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 14, 2002 7:25 AM To: [EMAIL PROTECTED] Subject: Help me out I have just started learning perl a day ago. Can anybody guide me on how to start? I am really interested in learning the language AMRINDER _ Join the world's largest e-mail service with MSN Hotmail. http://www.hotmail.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Mail on W2K vs NT
I got an email script to work on my W2K box using the W32::OLE module, but when I use it on an NT box, I get "Invalid class string" on this line: my $session = Win32::OLE->new('MAPI.session','Logoff'); Can anyone help? V -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
unwinding hash or what it is?
hi i have inherited this piece of code and i have been wondering hard about how i can print the different @records returned from the subroutine? im not even sure whats on my hand here. is this a hash of arrays or a hash of array references? and how do i unwind those? martin, beginning perl. my @records = &parse_pubmed_fcgi( [ qw(UI AU TI TA VI IP PG DA) ] ); ## subroutines sub parse_pubmed_fcgi { my ( $keys ) = @_; my ( @records, $record, $record_id, $line, $key ); my %wants = map { $_ => 1 } @{ $keys }; while ( defined ($line = <>) ) { chop $line; if ( $line =~ /^(UI)\s*-/ ) { $key = $1; if ( $record ) { push @records, $record; undef $record; } } if ( $line =~ /^([A-Z]+)\s*-\s*(.+)/ ) { $key = $1; push @{ $record->{ $key } }, $2 if $wants{ $key }; } elsif ( $line =~ /^\s+(\S.*)/ ) { $record->{ $key }->[-1] .= " $1" if $wants{ $key }; } } push @records, $record if $record; if ( wantarray ) { return @records; } else { return \@records; } } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Forking in NT
My advice is not to use fork if you want your script to run cross platform. You will have enough problems writing cross-platform, multi-process perl code without dragging fork into it. The safest and simplist way to do what you want is to use open2 or open3 to pipe to and from child processes. Yes, you loose efficiency on unix, but by avoiding fork, your program will be truely multi-process on win32. If you want to lower the overhead on process startup consider not letting child processes die but instead have them signal the parent that they are ready for another task. Any way you cut it, multi-process with cross-platform is a pain in the ass. Your best bet may be to write cross platform modules with all the general application code and then write two different process managers, one for unix using fork and one for win32 using open2. If the code must be exactly the same for both platforms then code on win32 and port to unix. Unix can be too nice to you and you may take behaviour for granted and be stuck when win32 isn't so nice. - Johnathan ps. no flame war intended, but there are other languages you might want to consider that have robust support for multi-threading. java or python may be a better choice... but with any luck perl6 will let me stop saying that. srinivas krish wrote: >Hi!, > >I have to make a platform independent script that will >start a server and client in the script. I attempted >this using fork method. Although the script runs well >in UNIX, it does not run on Nt - giving the error: >The process cannot access the file because >it is being used by another process. >The Unsupported function fork function is >unimplemented at > line 60. >I have Active Perl 5.6 in my case. Even the document >says that "On some platforms such as Windows where the >fork() system call is not available, Perl can be built >to emulate fork() at the interpreter level. " > >can anyone guide as to how the script can be made to >run in UNIX and DOS(I am using cygwin32 for NT)? > >Regards >srinivas > > > >Looking for a job? Visit Yahoo! India Careers > Visit http://in.careers.yahoo.com > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: unwinding hash or what it is?
On Thu, 2002-02-14 at 10:19, Martin A. Hansen wrote: > > hi > > i have inherited this piece of code and i have been wondering hard about how i can >print the different @records returned from the subroutine? im not even sure whats on >my hand here. is this a hash of arrays or a hash of array references? and how do i >unwind those? > > > > martin, beginning perl. > > > > > my @records = &parse_pubmed_fcgi( [ qw(UI AU TI TA VI IP PG DA) ] ); > > > ## subroutines > > > sub parse_pubmed_fcgi { > > my ( $keys ) = @_; > > my ( @records, $record, $record_id, $line, $key ); > > my %wants = map { $_ => 1 } @{ $keys }; > > while ( defined ($line = <>) ) { > chop $line; > > if ( $line =~ /^(UI)\s*-/ ) { > $key = $1; > > if ( $record ) { > push @records, $record; > undef $record; > } > } > > if ( $line =~ /^([A-Z]+)\s*-\s*(.+)/ ) { > $key = $1; > push @{ $record->{ $key } }, $2 if $wants{ $key }; > } > elsif ( $line =~ /^\s+(\S.*)/ ) { > $record->{ $key }->[-1] .= " $1" if $wants{ $key }; > } > } > > push @records, $record if $record; > > if ( wantarray ) { > return @records; > } else { > return \@records; > } > > } > Data::Dumper is your friend. If you have a data structure and you don't know what is in it just say: print Dumper(\@Records); and bingo the data structure is printed out to the screen. -- Today is Setting Orange the 45th day of Chaos in the YOLD 3168 Kallisti! Missle Address: 33:48:3.521N 84:23:34.786W -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Help me out
I am in the same boat. I have found the best way to do it is to dive right in. I rely heavily on the O'Reilly book, "Programming Perl". It is a pretty complete resource book with a nice function list and really good code explanation. Also another really good resource type of book is from O'Reilly as well, "The Perl Cookbook". Noticing a pattern? =) The O'Reilly series is excellent and I have found a lot of useful information from this mailing list as well. -_-Aaron -Original Message- From: Victoria Elliott [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 14, 2002 6:45 AM To: 'amrinder singh'; [EMAIL PROTECTED] Subject: RE: Help me out I really suggest the O'Reilly books, "Learning Perl" 3rd edition. ISBN 0-596-00132-0 Also go to www.CPAN.org, and follow the FAQ on what you need to run a Perl environment on your system. After you've setup an environment, you can start by running some examples in the book to get a grasp. V -Original Message- From: amrinder singh [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 14, 2002 7:25 AM To: [EMAIL PROTECTED] Subject: Help me out I have just started learning perl a day ago. Can anybody guide me on how to start? I am really interested in learning the language AMRINDER _ Join the world's largest e-mail service with MSN Hotmail. http://www.hotmail.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: octal file permissions
On Wed, 13 Feb 2002 15:14:39 -0900, [EMAIL PROTECTED] (Michael Fowler) wrote: >You have it backwards. Octal 100500 is 33088 in decimal. You just did the >conversion with the oct operator. > >You're confused about what oct does; it returns the decimal representation >of an octal value. Also, Perl is going to trip you up here; the decimal After putting on the dunce cap and typing 100 times: "the oct function takes a decimal value and returns octal, and (stat file)[2] returns a decimal value" I finally see it. I think I do anyways. :-) #!/usr/bin/perl use strict; use warnings; #usage testmode file, file defaults to self my $open = shift || $0; my $mode = (stat $open)[2]; print '(stat(file))[2] is ',$mode,' which is decimal representation of the octal value with file types',"\n"; printf "Permissions are %04o",$mode & 0; print ' with file type masked off',"\n"; my $val = sprintf("%o", $mode); print "$mode in oct is $val\n"; my $perms = (stat("$open"))[2] & 0; my $oct_perms = sprintf "%lo", $perms; print 'decimal perms are ',$perms,' with file type masked off',"\n"; print 'octal_perms are ',"$oct_perms",' with file type masked off',"\n"; print 'oct(',$perms,') ','is ',sprintf("%o",$perms),"\n"; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: unwinding hash or what it is?
On Thu, Feb 14, 2002 at 10:40:20AM -0500, Chas Owens wrote: > On Thu, 2002-02-14 at 10:19, Martin A. Hansen wrote: > > > > hi > > > > i have inherited this piece of code and i have been wondering hard about how i can >print the different @records returned from the subroutine? im not even sure whats on >my hand here. is this a hash of arrays or a hash of array references? and how do i >unwind those? > > > > > > > > martin, beginning perl. > > > > > > > > > > my @records = &parse_pubmed_fcgi( [ qw(UI AU TI TA VI IP PG DA) ] ); > > > > > > ## subroutines > > > > > > sub parse_pubmed_fcgi { > > > > my ( $keys ) = @_; > > > > my ( @records, $record, $record_id, $line, $key ); > > > > my %wants = map { $_ => 1 } @{ $keys }; > > > > while ( defined ($line = <>) ) { > > chop $line; > > > > if ( $line =~ /^(UI)\s*-/ ) { > > $key = $1; > > > > if ( $record ) { > > push @records, $record; > > undef $record; > > } > > } > > > > if ( $line =~ /^([A-Z]+)\s*-\s*(.+)/ ) { > > $key = $1; > > push @{ $record->{ $key } }, $2 if $wants{ $key }; > > } > > elsif ( $line =~ /^\s+(\S.*)/ ) { > > $record->{ $key }->[-1] .= " $1" if $wants{ $key }; > > } > > } > > > > push @records, $record if $record; > > > > if ( wantarray ) { > > return @records; > > } else { > > return \@records; > > } > > > > } > > > > Data::Dumper is your friend. If you have a data structure and you don't > know what is in it just say: > > print Dumper(\@Records); > > and bingo the data structure is printed out to the screen. > > -- > Today is Setting Orange the 45th day of Chaos in the YOLD 3168 > Kallisti! > > Missle Address: 33:48:3.521N 84:23:34.786W > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > ok, if Data::Dumper is my friend, how can i print all record fields of type AU only? martin -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Very Basic Help
Why do I keep getting a premature end of script headers error when I try to run this script? I am going crazy! #!usr/bin/perl #hmres1.pl print "Content-type:text/html\n\n"; $test = 100; print "Test\n"; print "\n"; print "$test\n"; print "\n"; print "\n"; Thanks, Andrew -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Very Basic Help
On Feb 14, Hughes, Andrew said: >Why do I keep getting a premature end of script headers error when I try to >run this script? I am going crazy! First, this is better suited for the beginners-cgi mailing list. Second, I suggest you check the... err... checklist at http://www.perl.com/doc/FAQs/cgi/idiots-guide.html Please ignore the filename if that sort of thing offends you. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** what does y/// stand for? why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Very Basic Help
what errors messages are seen in the web server logs? IE: (linux/appache) what is in /var/logs/httpd/error_log ??? (name might be off, dont have a linux box ate my disposal atm) -Ron > -Original Message- > From: Hughes, Andrew [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 14, 2002 10:55 > To: [EMAIL PROTECTED] > Subject: Very Basic Help > > > Why do I keep getting a premature end of script headers error > when I try to > run this script? I am going crazy! > > #!usr/bin/perl > #hmres1.pl > print "Content-type:text/html\n\n"; > > $test = 100; > > print "Test\n"; > print "\n"; > print "$test\n"; > print "\n"; > print "\n"; > > Thanks, > Andrew > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Very Basic Help
Also. I don't have much CGI experience, but couldn't you just nix all those print statements with, 'qq' or 'EOLN'? -_-Aaron -Original Message- From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 14, 2002 7:59 AM To: Hughes, Andrew Cc: [EMAIL PROTECTED] Subject: Re: Very Basic Help On Feb 14, Hughes, Andrew said: >Why do I keep getting a premature end of script headers error when I try to >run this script? I am going crazy! First, this is better suited for the beginners-cgi mailing list. Second, I suggest you check the... err... checklist at http://www.perl.com/doc/FAQs/cgi/idiots-guide.html Please ignore the filename if that sort of thing offends you. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** what does y/// stand for? why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Urgent - Getting the left most 3 characters from a string...
I am getting the HTTP result codes and trying to parse just the left most 3 characters: 500 Can't connect to www.1k2k3k4j.com:80 (Bad hostname 'www.1k2k3k4j.com') I only want 500 In VB I could use: if left($result,3) = "500" Then Do whatever Else Blah Blah Blah End If In Perl I want to do: if (left($result), 3) = 500 { Do whatever; } else { Blah Blah Blah; } How can I do the left in Perl TIA! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Very Basic Help
One thing that I noticed is your shebang line. You have: #!usr/bin/perl I suspect you want: #!/usr/bin/perl -wT Rob Good judgement comes from experience, and experience - well, that comes from poor judgement. On Thu, 14 Feb 2002, Andrew Hughes wrote: > Why do I keep getting a premature end of script headers error when I try to > run this script? I am going crazy! > > #!usr/bin/perl > #hmres1.pl > print "Content-type:text/html\n\n"; > > $test = 100; > > print "Test\n"; > print "\n"; > print "$test\n"; > print "\n"; > print "\n"; > > Thanks, > Andrew > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Urgent - Getting the left most 3 characters from a string...
On Thu, 14 Feb 2002, Chris wrote: > if left($result,3) = "500" Then > Do whatever > Else > Blah Blah Blah > End If > > In Perl I want to do: > > if (left($result), 3) = 500 { > Do whatever; > } else { > Blah Blah Blah; > } > > How can I do the left in Perl if(substr($result, 0, 3) == 500) { perldoc -f substr -- Brett http://www.chapelperilous.net/ Who made the world I cannot tell; 'Tis made, and here am I in hell. My hand, though now my knuckles bleed, I never soiled with such a deed. -- A.E. Housman -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Help me out
get the O'Riley learning perl book get the black book get the cookbook ( O'Riley ) you'll be a pro. - Original Message - From: "amrinder singh" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, February 14, 2002 12:24 PM Subject: Help me out > I have just started learning perl a day ago. > > Can anybody guide me on how to start? I am really interested in learning > the language > > > AMRINDER > > > _ > Join the worlds largest e-mail service with MSN Hotmail. > http://www.hotmail.com > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Urgent - Getting the left most 3 characters from a string...
> "chris" == chris <[EMAIL PROTECTED]> writes: chris> if left($result,3) = "500" Then Do whatever Else Blah Blah chris> Blah End If if (substr($result,0,3) == 500) { do(stuff); } else { do(more_stuff); } Note the arguments to substr are the start position (0 - the first digit) and the range (three digits), and note the == to make a comparison rather than an assignment. Hope this helps, - Chris. -- $a="printf.net"; Chris Ball | chris@void.$a | www.$a | finger: chris@$a "In the beginning there was nothing, which exploded." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Help me out
its that simple? WoW! I must have fubarbed somewhere, I have those books as well as several others and hell I am not even close to be a pro!/me dreams about the day I can be a perl gawd like Randel (spelling) -Ron > -Original Message- > From: Matthew Peter Lyon [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 14, 2002 11:49 > To: amrinder singh; [EMAIL PROTECTED] > Subject: Re: Help me out > > > get the O'Riley learning perl book > get the black book > get the cookbook ( O'Riley ) > > you'll be a pro. > > - Original Message - > From: "amrinder singh" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Thursday, February 14, 2002 12:24 PM > Subject: Help me out > > > > I have just started learning perl a day ago. > > > > Can anybody guide me on how to start? I am really > interested in learning > > the language > > > > > > AMRINDER > > > > > > _ > > Join the worlds largest e-mail service with MSN Hotmail. > > http://www.hotmail.com > > > > > > -- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: octal file permissions
On Thu, Feb 14, 2002 at 10:43:41AM -0500, zentara wrote: > On Wed, 13 Feb 2002 15:14:39 -0900, [EMAIL PROTECTED] (Michael Fowler) wrote: > > >You have it backwards. Octal 100500 is 33088 in decimal. You just did the > >conversion with the oct operator. > > > >You're confused about what oct does; it returns the decimal representation > >of an octal value. Also, Perl is going to trip you up here; the decimal > > After putting on the dunce cap and typing 100 times: > "the oct function takes a decimal value and returns octal, > and (stat file)[2] returns a decimal value" I finally see it. Heh, you still have that backwards. oct() interprets its argument as an octal value, and returns its decimal equivalent. Also, it's best not to think of functions returning numbers in a specific base. Functions simply return numbers, its when you output them that they have to be interpreted in a certain base. > #!/usr/bin/perl > use strict; > use warnings; > #usage testmode file, file defaults to self > my $open = shift || $0; > my $mode = (stat $open)[2]; > print '(stat(file))[2] is ',$mode,' which is decimal representation of the octal > value with file types',"\n"; Correct. > printf "Permissions are %04o",$mode & 0; > print ' with file type masked off',"\n"; Correct. > my $val = sprintf("%o", $mode); > print "$mode in oct is $val\n"; Correct. > my $perms = (stat("$open"))[2] & 0; > my $oct_perms = sprintf "%lo", $perms; > print 'decimal perms are ',$perms,' with file type masked off',"\n"; Correct. > print 'octal_perms are ',"$oct_perms",' with file type masked off',"\n"; Correct. > print 'oct(',$perms,') ','is ',sprintf("%o",$perms),"\n"; Given all that I'm not sure how you came to this incorrect conclusion. oct($perms) is not sprintf("%o", $perms). Given a decimal $perms of 320, sprintf("%o", $perms) returns "500", and oct($perms) returns 208. I'm tempted to say oct and sprintf's %o are symmetric, meaning they reverse each other. You can think of it that way if it helps, but it might confuse you in the case of oct(0500) and sprintf("%o", 0500). Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: unwinding hash or what it is?
On Thu, 2002-02-14 at 10:46, [EMAIL PROTECTED] wrote: > On Thu, Feb 14, 2002 at 10:40:20AM -0500, Chas Owens wrote: > > On Thu, 2002-02-14 at 10:19, Martin A. Hansen wrote: > > > > > > hi > > > > > > i have inherited this piece of code and i have been wondering hard about how i >can print the different @records returned from the subroutine? im not even sure whats >on my hand here. is this a hash of arrays or a hash of array references? and how do i >unwind those? > > > > > > > > > > > > martin, beginning perl. > > > > > > > > > > > > > > > my @records = &parse_pubmed_fcgi( [ qw(UI AU TI TA VI IP PG DA) ] ); > > > > > > > > > ## subroutines > > > > > > > > > sub parse_pubmed_fcgi { > > > > > > my ( $keys ) = @_; > > > > > > my ( @records, $record, $record_id, $line, $key ); > > > > > > my %wants = map { $_ => 1 } @{ $keys }; > > > > > > while ( defined ($line = <>) ) { > > > chop $line; > > > > > > if ( $line =~ /^(UI)\s*-/ ) { > > > $key = $1; > > > > > > if ( $record ) { > > > push @records, $record; > > > undef $record; > > > } > > > } > > > > > > if ( $line =~ /^([A-Z]+)\s*-\s*(.+)/ ) { > > > $key = $1; > > > push @{ $record->{ $key } }, $2 if $wants{ $key }; > > > } > > > elsif ( $line =~ /^\s+(\S.*)/ ) { > > > $record->{ $key }->[-1] .= " $1" if $wants{ $key }; > > > } > > > } > > > > > > push @records, $record if $record; > > > > > > if ( wantarray ) { > > > return @records; > > > } else { > > > return \@records; > > > } > > > > > > } > > > > > > > Data::Dumper is your friend. If you have a data structure and you don't > > know what is in it just say: > > > > print Dumper(\@Records); > > > > and bingo the data structure is printed out to the screen. > > > > -- > > Today is Setting Orange the 45th day of Chaos in the YOLD 3168 > > Kallisti! > > > > Missle Address: 33:48:3.521N 84:23:34.786W > > > > > > -- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > ok, if Data::Dumper is my friend, how can i print all record fields of type AU only? > > martin > -- Data::Dumper isn't that good of a friend (he may loan you his truck, but he won't help you move). #you can print all subsubrecords of type subrecord type KEYONE by uttering #foreach my $record (@$VAR1) { # foreach my $subrecord (@{$record->{KEYONE}}) { # print $subrecord # } #} #see below for my reasoning sub parse_pubmed_fcgi { my ( $keys ) = @_; my ( @records, $record, $record_id, $line, $key ); my %wants = map { $_ => 1 } @{ $keys }; while ( defined ($line = <>) ) { chop $line; #UI appears to be the start of record signal if ( $line =~ /^(UI)\s*-/ ) { $key = $1; #I suspect this because the old record (if there is one)#gets pushed onto the return array here if ( $record ) { push @records, $record; undef $record; } } #It also appears to be the first subrecord since #this isn't an elsif. Anywho, any line that starts with A #through Z is a subrecord. The first word is the key and the #data follows on the dash if ( $line =~ /^([A-Z]+)\s*-\s*(.+)/ ) { $key = $1; #apparently we can specify what keys to hover up from #the file. If we want this subrecord type then we push #the subrecord onto an array contained in the hash #based on the subrecord type push @{ $record->{ $key } }, $2 if $wants{ $key }; } elsif ( $line =~ /^\s+(\S.*)/ ) { #ooo, looky: we can have line continuations, this #data is just part of the last subrecord $record->{ $key }->[-1] .= " $1" if $wants{ $key }; } } #this is more evidence that ^UI starts a record since the file ends #before we get another one push @records, $record if $record; if ( wantarray ) { #if the function is in list context return the array return @records; } else { #else retrun a reference to the array (don't worry #another array will be created by a second call #so there are no messy pointer issues like in C return \@records; } } #so we have an array (@records) of hashes ($record, repeatedly) #whose keys match ^A-Z+ and whose values are arrays of file entries #that m
sort help
Folks, I have this little sort routine ## ## UGLY HACK to sort the dates correctly ## ($name, $date, $time, $wonid, $cheat, $server) = split(/\|/, $a); ($wday,$month,$mday,$year) = split(/\s+/, $date); ($hour,$min,$secs) = split(/:/, $time); $TIME = timelocal($secs,$min,$hour,$mday,$mon,$year); ($name2, $date2, $time2, $wonid2, $cheat2, $server2) = split(/\|/, $b); ($wday2,$month2,$mday2,$year2) = split(/\s+/, $date2); ($hour2,$min2,$secs2) = split(/:/, $time2); $TIME2 = timelocal($secs2,$min2,$hour2,$mday2,$mon2,$year2); ## ## ## # sort values if ($table_sort eq "adate") { return $TIME <=> $TIME2; } elsif ($table_sort eq "ddate") { return $TIME2 <=> $TIME; } elsif ($table_sort eq "name") { return $name <=> $name2; } elsif ($table_sort eq "wonid") { return $wonid <=> $wonid2; } elsif ($table_sort eq "cheat") { return $cheat <=> $cheat2; } } yes, it is ugly (needs clean up) not sure why, but the output is not sorted as I would expect. I thought it would sort on the unix time and put thing in order, but it does not. the dates are sorted by the day of the month *boggle* for out put go here http://www.sampier.com/cheaters/busted.html Regards, Ron Ronald J. Yacketta Principal Consultant Ciber, INC 345 Woodcliff Dr. Fairport, NY 14450 --- The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer. -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Urgent - Getting the left most 3 characters from a string...
Brett W. McCoy wrote: > On Thu, 14 Feb 2002, Chris wrote: > > >>if left($result,3) = "500" Then >>Do whatever >>Else >> Blah Blah Blah >>End If >> >>In Perl I want to do: >> >>if (left($result), 3) = 500 { >>Do whatever; >>} else { >> Blah Blah Blah; >>} >> >>How can I do the left in Perl >> > > if(substr($result, 0, 3) == 500) { > > perldoc -f substr > > -- Brett > http://www.chapelperilous.net/ > > Who made the world I cannot tell; > 'Tis made, and here am I in hell. > My hand, though now my knuckles bleed, > I never soiled with such a deed. > -- A.E. Housman > > Thanks! Had to revert back to the original, as time was running out, and this was MC! (Mission Critical).. Here is what is failing...: (Its running on Win32, btw) $filename = "c:\pingtest.txt"; $hostname = "http://thisisgoingtofail.com";; @access; sub access { $result = ""; open (DUMPFILE,">>$filename"); print DUMPFILE " \n"; print DUMPFILE "*\n"; print DUMPFILE "* $hostname\n"; print DUMPFILE "*\n"; $result = substr(getprint("$hostname"),0 ,3); print "Results - $result\n"; # Note - the above shows the code to be 500!!! my $newresult = $result; print "New Results - $$newresult\n"; my $resultcode; print "Result Code - $$resultcode;\n"; if ($newresult = 200) { $resultcode = "Code 200 - Access successful\n"; } elsif ($newresult = 400) { $resultcode = "Code 400 - Bad Request\n"; } elsif ($newresult = 403) { $resultcode = "Code 403 - Forbidden\n"; } elsif ($newresult = 404) { $resultcode = "Code 404 - Not Found\n"; } elsif ($newresult = 405) { $resultcode = "Code 405 - Method Not Allowed\n"; } elsif ($newresult = 406) { $resultcode = "Code 406 - Not Acceptable\n"; } elsif ($newresult = 407) { $resultcode = "Code 407 - Proxy Authentication Required\n"; } elsif ($newresult = 408) { $resultcode = "Code 408 - Request Timeout\n"; } elsif ($newresult = 409) { $resultcode = "Code 409 - Conflict\n"; } elsif ($newresult = 410) { $resultcode = "Code 410 - Gone\n"; } elsif ($newresult = 500) { $resultcode = "Code 500 - Internal Server Error\n"; } elsif ($newresult = 501) { $resultcode = "Code 501 - Not Implemented\n"; } elsif ($newresult = 502) { $resultcode = "Code 502 - Bad Gateway\n"; } elsif ($newresult = 503) { $resultcode = "Code 503 - Service Unavailable\n"; } elsif ($newresult = 504) { $resultcode = "Code 504 - Gateway Timeout\n"; } elsif ($newresult = 505) { $resultcode = "Code 505 - HTTP Version Not Supported\n"; } else { $resultcode = "Unknown error...\n"; } print "\nNew Results Code - $resultcode\nNew Results - $newresult\nOld Results - $result"; print DUMPFILE "* $result\n"; print DUMPFILE "*\n"; close (DUMPFILE); } Here are the results... (I am not sure why that '1'prints out, but it is never to the file...) C:\scripts\perl>ping.pl 1500 Can't connect to www.thiswillfail.com:80 (Bad hostname 'www.thiswillfail.com') http://www.thiswillfail.com> Results - 500 New Results - Result Code - ; New Results Code - Code 200 - Access successful New Results - 200 Old Results - 500 C:\scripts\perl> Any advice is greatly appreciated.. And the substr was EXTREMELY helpful! :) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Modifers to the table function of CGI
Hello, I have read the CGI.pm documentation that comes with the distibution, but I can't find any reference to the modifers of the 'table' function. Basically, I have dynamic data populating each table element, but I would like to standardize the size of each 'td' so it doesn't look ugly. I would really appreciate it if someone could point me to some documentation (web, book, newgroup). Thanks! -James James Kelty Sr. Unix Systems Administrator The Ashland Agency 541.488.0801 [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Modifers to the table function of CGI
The first couple of hits seems relevant, look there. http://www.google.com/search?hl=en&q=CGI.pm also, in the future send cgi questions to the cgi list /jon James Kelty wrote: > > Hello, > > I have read the CGI.pm documentation that comes with the distibution, but I > can't find any reference to the modifers of the 'table' function. Basically, > I have dynamic data populating each table element, but I would like to > standardize the size of each 'td' so it doesn't look ugly. I would really > appreciate it if someone could point me to some documentation (web, book, > newgroup). Thanks! > > -James > > James Kelty > Sr. Unix Systems Administrator > The Ashland Agency > 541.488.0801 > [EMAIL PROTECTED] > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Counting every character in a textfile
Hi all, I'm trying to figure out how to count characters in a textfile. The count has to include all letters, numbers, non-letters, whitespaces, newlines tabs, etc. I was thinking about something along the lines of: #!/usr/bin/perl -w use strict; my $count = 0; my $text = 'c:\marcus\temp\bonn.txt'; open(TEXT, $text) or die "Konnte $text nicht öffnen"; while() { if(/[\d\D]/){ $count++ } } print $count; But it doesn't work and I don't know why. As far as I understood [\d\D] is supposed to match every number and every non-number including newlines. Marcus Willemsen Online Redaktion Juve Verlag Agrippastr. 10 50676 Köln tel: ++49(0)221 91 38 80 16 fax: ++49(0)221 91 38 80 18 www.juve.de [EMAIL PROTECTED] [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Counting every character in a textfile
By using length($_), this should give you a good count. You are not chomping the input, so it will return the linefeed(carriage return). Wags ;) -Original Message- From: Marcus Willemsen [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 14, 2002 09:30 To: [EMAIL PROTECTED] Subject: Counting every character in a textfile Hi all, I'm trying to figure out how to count characters in a textfile. The count has to include all letters, numbers, non-letters, whitespaces, newlines tabs, etc. I was thinking about something along the lines of: #!/usr/bin/perl -w use strict; my $count = 0; my $text = 'c:\marcus\temp\bonn.txt'; open(TEXT, $text) or die "Konnte $text nicht öffnen"; while() { if(/[\d\D]/){ $count++ } } print $count; But it doesn't work and I don't know why. As far as I understood [\d\D] is supposed to match every number and every non-number including newlines. Marcus Willemsen Online Redaktion Juve Verlag Agrippastr. 10 50676 Köln tel: ++49(0)221 91 38 80 16 fax: ++49(0)221 91 38 80 18 www.juve.de [EMAIL PROTECTED] [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: sort help
On Thu, Feb 14, 2002 at 12:08:34PM -0500, Yacketta, Ronald wrote: >($name, $date, $time, $wonid, $cheat, $server) = split(/\|/, $a); >($wday,$month,$mday,$year) = split(/\s+/, $date); >($hour,$min,$secs) = split(/:/, $time); >$TIME = timelocal($secs,$min,$hour,$mday,$mon,$year); > >($name2, $date2, $time2, $wonid2, $cheat2, $server2) = split(/\|/, $b); >($wday2,$month2,$mday2,$year2) = split(/\s+/, $date2); >($hour2,$min2,$secs2) = split(/:/, $time2); >$TIME2 = timelocal($secs2,$min2,$hour2,$mday2,$mon2,$year2); Time::Local::timelocal's month argument should be in the range 0..11. Assuming your input has month dates in the range 1..12, you're off by one. ># sort values >if ($table_sort eq "adate") { return $TIME <=> $TIME2; } >elsif ($table_sort eq "ddate") { return $TIME2 <=> $TIME; } >elsif ($table_sort eq "name") { return $name <=> $name2; } >elsif ($table_sort eq "wonid") { return $wonid <=> $wonid2; } >elsif ($table_sort eq "cheat") { return $cheat <=> $cheat2; } > } Where is $table_sort set, and what is it set to? > not sure why, but the output is not sorted as I would expect. I thought it > would sort on the unix time and put thing in order, but it does not. the > dates are sorted by the day of the month *boggle* for out put go here > http://www.sampier.com/cheaters/busted.html You give us sample output (which is difficult to read for date information, consider splitting the middle column into more columns and using a fixed-width font), but sample input is a little more important for determining what's going wrong. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Help can't figure this one out
Just because you CAN take shortcuts in Perl doesn't necessarily mean that you should. Even though it's less typing, it might be more difficult to understand what's going on to someone else reading your code, or to yourself after looking at the code some time later. That's what I always believed, but that's just me. On Thursday 14 February 2002 05:47 am, you wrote: > > -Original Message- > > From: Bruce Ambraal [mailto:[EMAIL PROTECTED]] > > Sent: Thursday, February 14, 2002 1:24 AM > > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] > > Subject: Help can't figure this one out > > > > > > I have written following coding to produce a triangle > > pattern(see below); > > I now want to produce following paterns I can't figer this out > > > > ... > > > > # indent by printing num_rows - r spaces > > for ($i = 1; $i <= $num_rows - $r; $i++) {print (" \n");} > > A suggestion: if you want to write Perl programs, you should > resist the temptation to write them like C programs. This kind > of thing can be simplified to something like: > >print " \n" for 1 .. ($num_rows - $r); > > or better yet: > >print " \n" x ($num_rows - $r); > > If you haven't done so already, grab a copy of Schwartz' > Learning Perl and work through it. That will show you some > of the idioms that can greatly simplify your programs. > > (BTW, are you aware that this statement does not do what the > comment says it does. You should fix one or the other.) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Urgent - Getting the left most 3 characters from a string...
You need to use == for comparison (that is two equal signs ), you are just using one and that means assignment. For example, my $value = 100; print "value = $value\n"; if( $value == 300 ) { print "value = $value\n"; } elsif( $value = 200 ) { print "value = $value\n"; } will print out value = 100 value = 200 because an assignment to a non zero value is true. HTH, Tanton - Original Message - From: "Chris" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, February 14, 2002 12:11 PM Subject: Re: Urgent - Getting the left most 3 characters from a string... > Brett W. McCoy wrote: > > On Thu, 14 Feb 2002, Chris wrote: > > > > > >>if left($result,3) = "500" Then > >>Do whatever > >>Else > >> Blah Blah Blah > >>End If > >> > >>In Perl I want to do: > >> > >>if (left($result), 3) = 500 { > >>Do whatever; > >>} else { > >> Blah Blah Blah; > >>} > >> > >>How can I do the left in Perl > >> > > > > if(substr($result, 0, 3) == 500) { > > > > perldoc -f substr > > > > -- Brett > > http://www.chapelperilous.net/ > > > > Who made the world I cannot tell; > > 'Tis made, and here am I in hell. > > My hand, though now my knuckles bleed, > > I never soiled with such a deed. > > -- A.E. Housman > > > > > > Thanks! > > Had to revert back to the original, as time was running out, and this > was MC! (Mission Critical).. > > Here is what is failing...: > (Its running on Win32, btw) > > $filename = "c:\pingtest.txt"; > $hostname = "http://thisisgoingtofail.com";; > @access; > > sub access { > > $result = ""; > open (DUMPFILE,">>$filename"); > print DUMPFILE > " \n"; > print DUMPFILE "*\n"; > print DUMPFILE "* $hostname\n"; > print DUMPFILE "*\n"; > $result = substr(getprint("$hostname"),0 ,3); > print "Results - $result\n"; > # Note - the above shows the code to be 500!!! > my $newresult = $result; > print "New Results - $$newresult\n"; > my $resultcode; > print "Result Code - $$resultcode;\n"; > if ($newresult = 200) { > $resultcode = "Code 200 - Access successful\n"; > } elsif ($newresult = 400) { > $resultcode = "Code 400 - Bad Request\n"; > } elsif ($newresult = 403) { > $resultcode = "Code 403 - Forbidden\n"; > } elsif ($newresult = 404) { > $resultcode = "Code 404 - Not Found\n"; > } elsif ($newresult = 405) { > $resultcode = "Code 405 - Method Not Allowed\n"; > } elsif ($newresult = 406) { > $resultcode = "Code 406 - Not Acceptable\n"; > } elsif ($newresult = 407) { > $resultcode = "Code 407 - Proxy Authentication Required\n"; > } elsif ($newresult = 408) { > $resultcode = "Code 408 - Request Timeout\n"; > } elsif ($newresult = 409) { > $resultcode = "Code 409 - Conflict\n"; > } elsif ($newresult = 410) { > $resultcode = "Code 410 - Gone\n"; > } elsif ($newresult = 500) { > $resultcode = "Code 500 - Internal Server Error\n"; > } elsif ($newresult = 501) { > $resultcode = "Code 501 - Not Implemented\n"; > } elsif ($newresult = 502) { > $resultcode = "Code 502 - Bad Gateway\n"; > } elsif ($newresult = 503) { > $resultcode = "Code 503 - Service Unavailable\n"; > } elsif ($newresult = 504) { > $resultcode = "Code 504 - Gateway Timeout\n"; > } elsif ($newresult = 505) { > $resultcode = "Code 505 - HTTP Version Not Supported\n"; > } else { > $resultcode = "Unknown error...\n"; > } > print "\nNew Results Code - $resultcode\nNew Results - > $newresult\nOld Results - $result"; > print DUMPFILE "* $result\n"; > print DUMPFILE "*\n"; > close (DUMPFILE); > > } > > > Here are the results... > > (I am not sure why that '1'prints out, but it is never to the file...) > > C:\scripts\perl>ping.pl > 1500 Can't connect to www.thiswillfail.com:80 (Bad hostname > 'www.thiswillfail.com') > http://www.thiswillfail.com> > Results - 500 > New Results - > Result Code - ; > > New Results Code - Code 200 - Access successful > > New Results - 200 > Old Results - 500 > C:\scripts\perl> > > Any advice is greatly appreciated.. > > And the substr was EXTREMELY helpful! :) > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Very Basic Help
You should probably read about about the CGI module before attempting to create CGI programs... BUT, to answer your question, you would do something like this: #!/usr/bin/perl use CGI qw/:standard/; use strict; my $test = 1000; print header; print start_html; print "$test\n"; print end_html; On Thursday 14 February 2002 07:54 am, you wrote: > Why do I keep getting a premature end of script headers error when I try to > run this script? I am going crazy! > > #!usr/bin/perl > #hmres1.pl > print "Content-type:text/html\n\n"; > > $test = 100; > > print "Test\n"; > print "\n"; > print "$test\n"; > print "\n"; > print "\n"; > > Thanks, > Andrew -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Urgent - Getting the left most 3 characters from a string...
Tanton Gibbs wrote: > You need to use == for comparison (that is two equal signs ), you are just > using one and that means assignment. > > For example, > > my $value = 100; > print "value = $value\n"; > > if( $value == 300 ) { > print "value = $value\n"; > } > elsif( $value = 200 ) { > print "value = $value\n"; > } > > will print out > value = 100 > value = 200 > > because an assignment to a non zero value is true. > > HTH, > Tanton > - Original Message - > From: "Chris" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Thursday, February 14, 2002 12:11 PM > Subject: Re: Urgent - Getting the left most 3 characters from a string... > > > >>Brett W. McCoy wrote: >> >>>On Thu, 14 Feb 2002, Chris wrote: >>> >>> >>> if left($result,3) = "500" Then Do whatever Else Blah Blah Blah End If In Perl I want to do: if (left($result), 3) = 500 { Do whatever; } else { Blah Blah Blah; } How can I do the left in Perl >>>if(substr($result, 0, 3) == 500) { >>> >>>perldoc -f substr >>> >>>-- Brett >>> http://www.chapelperilous.net/ >>> >>>Who made the world I cannot tell; >>>'Tis made, and here am I in hell. >>>My hand, though now my knuckles bleed, >>>I never soiled with such a deed. >>>-- A.E. Housman >>> >>> >>> >>Thanks! >> >>Had to revert back to the original, as time was running out, and this >>was MC! (Mission Critical).. >> >>Here is what is failing...: >>(Its running on Win32, btw) >> >>$filename = "c:\pingtest.txt"; >>$hostname = "http://thisisgoingtofail.com";; >>@access; >> >>sub access { >> >> $result = ""; >> open (DUMPFILE,">>$filename"); >> print DUMPFILE >>" \n"; >> print DUMPFILE "*\n"; >> print DUMPFILE "* $hostname\n"; >> print DUMPFILE "*\n"; >> $result = substr(getprint("$hostname"),0 ,3); >> print "Results - $result\n"; >> # Note - the above shows the code to be 500!!! >> my $newresult = $result; >> print "New Results - $$newresult\n"; >> my $resultcode; >> print "Result Code - $$resultcode;\n"; >> if ($newresult = 200) { >> $resultcode = "Code 200 - Access successful\n"; >> } elsif ($newresult = 400) { >> $resultcode = "Code 400 - Bad Request\n"; >> } elsif ($newresult = 403) { >> $resultcode = "Code 403 - Forbidden\n"; >> } elsif ($newresult = 404) { >> $resultcode = "Code 404 - Not Found\n"; >> } elsif ($newresult = 405) { >> $resultcode = "Code 405 - Method Not Allowed\n"; >> } elsif ($newresult = 406) { >> $resultcode = "Code 406 - Not Acceptable\n"; >> } elsif ($newresult = 407) { >> $resultcode = "Code 407 - Proxy Authentication Required\n"; >> } elsif ($newresult = 408) { >> $resultcode = "Code 408 - Request Timeout\n"; >> } elsif ($newresult = 409) { >> $resultcode = "Code 409 - Conflict\n"; >> } elsif ($newresult = 410) { >> $resultcode = "Code 410 - Gone\n"; >> } elsif ($newresult = 500) { >> $resultcode = "Code 500 - Internal Server Error\n"; >> } elsif ($newresult = 501) { >> $resultcode = "Code 501 - Not Implemented\n"; >> } elsif ($newresult = 502) { >> $resultcode = "Code 502 - Bad Gateway\n"; >> } elsif ($newresult = 503) { >> $resultcode = "Code 503 - Service Unavailable\n"; >> } elsif ($newresult = 504) { >> $resultcode = "Code 504 - Gateway Timeout\n"; >> } elsif ($newresult = 505) { >> $resultcode = "Code 505 - HTTP Version Not Supported\n"; >> } else { >> $resultcode = "Unknown error...\n"; >> } >> print "\nNew Results Code - $resultcode\nNew Results - >>$newresult\nOld Results - $result"; >> print DUMPFILE "* $result\n"; >> print DUMPFILE "*\n"; >> close (DUMPFILE); >> >>} >> >> >>Here are the results... >> >>(I am not sure why that '1'prints out, but it is never to the file...) >> >>C:\scripts\perl>ping.pl >>1500 Can't connect to www.thiswillfail.com:80 (Bad hostname >>'www.thiswillfail.com') >> http://www.thiswillfail.com> >>Results - 500 >>New Results - >>Result Code - ; >> >>New Results Code - Code 200 - Access successful >> >>New Results - 200 >>Old Results - 500 >>C:\scripts\perl> >> >>Any advice is greatly appreciated.. >> >>And the substr was EXTREMELY helpful! :) >> >> >>-- >>To unsubscribe, e-mail: [EMAIL PROTECTED] >>For additional commands, e-mail: [EMAIL PROTECTED] >> >> > Thanks, But unfortunatly that gives me: C:\>\scripts\perl\ping.pl 1500 Can't connect to www.thiswillfail.com:80 (Bad hostname 'www.thiswillfail.com') http://www.thiswillfail.com> Results - 500 New Results - Result Code - ; New Results Code - Unknown error... New Results - Old Results - 500 C:\> Which,m as is posted in my ea
Re: Perplexing server error (premature end of script headers)
On Wed, 13 Feb 2002 15:54:16 -0500, [EMAIL PROTECTED] (Peter Cline) wrote: >I am getting a premature end of script headers error when running a >particular script from a browser. It runs fine the command line, printing >the proper header and all. Just out of curiosity I tried to run your script. I found 1 problem when running from my server: You need full urls http://localhost/cgi-bin/cube_root.cgi";> instead of That got it running. The bad news is the algorithm doesn't work right. For instance if I submit 27, I get back 13. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
String manipulation help needed
I need a string in the form Wed, 18 Jul 2001 14:20 Of course my line doesn't quite cut it. my $emaildate = join " ", $record->{day}, $record->{month}, $record->{year}, $record->{hour}, $record->{minute}; I'm weak in string manipulation in perl - any help people? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: String manipulation help needed
On Thu, 14 Feb 2002, Brian Johnson wrote: > I need a string in the form > Wed, 18 Jul 2001 14:20 > > Of course my line doesn't quite cut it. > my $emaildate = join " ", $record->{day}, $record->{month}, > $record->{year}, $record->{hour}, $record->{minute}; Just interpolate the variables directly inside double quotes: my $emaildate = "$record->{day}, $record->{month} $record->{year} $record->{hour}:$record->{minute}"; -- Brett http://www.chapelperilous.net/ When a lot of remedies are suggested for a disease, that means it can't be cured. -- Anton Chekhov, "The Cherry Orchard" -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: forks or thread for perl on win32
I just responded to a similar post "Forking in NT" but... Use open2 or open3 to comunicate with child processes. If you're just coding for win32 then you may want to also look at the Win32 modules, especcially Process.pm and Event.pm. There are some examples in C:\Perl\site\lib\Win32. Below is a simple one I wrote. It was supposed to be simple but then it blew out of all proportion. Its a simple frame of a parent and child relationship where the parent launches a number of children and then they comunicate back and forth using pipes and Win32::Event. Email me if you need an explanation for anything thats going on there. Does anyone know if there is a similar mechanism in Unix to Win32::Event? - Johnathan In parent.pl: #!/usr/bin/perl use strict; use IO::Handle; use IPC::Open2; use Win32::Event; autoflush STDOUT; my %child; for(my $i=0; $i<5; ++$i){ my $in = new IO::Handle; my $out = new IO::Handle; my $pid = open2($out,$in,"perl C:\\tmp\\child.pl"); print "LAUNCHED CHILD $i ($pid)\n"; $in->autoflush(); $in->print("YOU ARE NUMBER $i\n"); my $event; until($event){$event = Win32::Event->open("child_ready_$i")}; print "GOT EVENT FROM CHILD $i\n"; $event->wait(); my $message = readline($out); $message =~ s/\s+$//; print "CHILD $i SAID '$message'\n"; my $x = int(rand 5); $in->print("SLEEP $x SECONDS\n"); print "TOLD CHILD $i TO SLEEP FOR $x SECONDS\n"; $child{$pid} = {in=>$in,number=>$i,event=>$event,called=>1}; } while(%child) { my @active_pids = keys %child; my @events = map {$child{$_}->{event}} @active_pids; print "ACTIVE CHILDREN: ",join(',',sort(map {$child{$_}->{number}} @active_pids)),"\n"; my $active = Win32::Event::wait_any(@events); $active or die("Something odd happened"); if($active > 0){ my $pid = $active_pids[$active-1]; my $message = readline($child{$pid}->{out}); $message =~ s/\s+$//; print "child $child{$pid}->{number} said '$message'\n"; if($child{$pid}->{called} > 5){ $child{$pid}->{in}->print("EXIT\n"); print "TOLD CHILD $child{$pid}->{number} TO EXIT\n"; waitpid $pid, undef; print "CHILD $child{$pid}->{number} EXITED\n"; delete $child{$pid}; } else { my $x = int(rand 5); $child{$pid}->{in}->print("SLEEP $x SECONDS\n"); print "TOLD CHILD $child{$pid}->{number} TO SLEEP FOR $x SECONDS\n"; ++$child{$pid}->{called}; } } elsif($active == 0){ die("THIS CAN'T BE!!! I DID'T TELL IT TO TIME OUT!!!"); } else { my $pid = @active_pids[$active*-1 - 1]; print "CHILD $child{$pid}->{number} DIED!\n"; delete $child{$pid}; } } In child.pl: #!/usr/bin/perl use strict; use IO::Handle; use Win32::Event; autoflush STDOUT; my($number) = =~ /YOU ARE NUMBER (\d+)/; my $event = Win32::Event->new(0,1,"child_ready_$number"); print "entering command cycle\n"; while(my $command = ){ chomp $command; last if($command eq 'EXIT'); if($command =~ /^SLEEP (\d+) SECONDS$/){ sleep $1; print "slept for $1 seconds\n"; $event->set(); } else { print "unknown command\n"; } } insomniak wrote: >(please forgive the dulpicate post - last one has wrong subject Doh!) >Hi All, > >I trying to find some information (examples) about forks or thread for perl >on win32, can anyone help me? > >Basically want to run 'X' simultanous processes in a continous loop. That is >there will alway be 'X' number of processes running. > >I thought I could do it with use Thread but I get back a message saying >This perl was built for "ithreads", which currently does not support >Thread.pm etc > >is there another/better way without using fork/threads? > >Thanks >Mark > > > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: forks or thread for perl on win32
In parent.pl, >$child{$pid} = {in=>$in,number=>$i,event=>$event,called=>1}; was supposed to be: $child{$pid} = {in=>$in,out=>$out,number=>$i,event=>$event,called=>1}; - Johnathan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Caching Large Data Structures To Disk
Hello all. First off, I want to thank everybody on this list who has helped me with with my previous questions. Thank you. I am working with input file of very large size. Sometimes up to and greater than a gig of data. I have previously gotten out of memory errors (people at work don't like when I do this). I was wondering if there was a way to cache large data structures to disk. We have a program here called SAS that runs on a Windows server (blek). Anyways, SAS allows me to operate on unlimited sizes of data, and always uses large temp files. Maybe there is a Disk::Cache module or something that I can use to store my data on disk instead of memory. I know it will be slower, but is something I am willing to deal with. TIA. --J-e-s-s-- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Caching Large Data Structures To Disk
Just to verify, since you didn't specify, You're not loading the entire file to memory before you start working with it, are you? For example: open(BIGFILE,"log.tmp"); @bigfile = ; probably wouldn't be a great idea. open(BIGFILE,"log.tmp"); while(){ do something to each line ($_)... } would be better. -Original Message- From: Balint, Jess [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 14, 2002 12:11 PM To: [EMAIL PROTECTED] Subject: Caching Large Data Structures To Disk Hello all. First off, I want to thank everybody on this list who has helped me with with my previous questions. Thank you. I am working with input file of very large size. Sometimes up to and greater than a gig of data. I have previously gotten out of memory errors (people at work don't like when I do this). I was wondering if there was a way to cache large data structures to disk. We have a program here called SAS that runs on a Windows server (blek). Anyways, SAS allows me to operate on unlimited sizes of data, and always uses large temp files. Maybe there is a Disk::Cache module or something that I can use to store my data on disk instead of memory. I know it will be slower, but is something I am willing to deal with. TIA. --J-e-s-s-- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This email may contain confidential and privileged material for the sole use of the intended recipient. If you are not the intended recipient, please contact the sender and delete all copies. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Caching Large Data Structures To Disk
Hashes can be stored in dbm files. Also you can use Data::Dumper to create a string that contains valid Perl syntax to create a give data structure. You can then write that string to a data file. When you need that data again you can read the file back into a string and eval it. See perldoc -f dbmopen, perldoc -f dbmclose, and perldoc Data::Dumper for more info. On Thu, 2002-02-14 at 15:10, Balint, Jess wrote: > Hello all. First off, I want to thank everybody on this list who has helped > me with with my previous questions. Thank you. > > I am working with input file of very large size. Sometimes up to and greater > than a gig of data. I have previously gotten out of memory errors (people at > work don't like when I do this). I was wondering if there was a way to cache > large data structures to disk. We have a program here called SAS that runs > on a Windows server (blek). Anyways, SAS allows me to operate on unlimited > sizes of data, and always uses large temp files. Maybe there is a > Disk::Cache module or something that I can use to store my data on disk > instead of memory. I know it will be slower, but is something I am willing > to deal with. TIA. > > --J-e-s-s-- > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- Today is Setting Orange the 45th day of Chaos in the YOLD 3168 Kallisti! Missle Address: 33:48:3.521N 84:23:34.786W -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
is it a bug? (less-equal compare)
I do: $lowerlimit = "89" le "100"; response "" I do: $lowerlimit = "89" le "99"; response "1" please help me! I dont get it! is this a bug? or am I nuts? perl -ver "This is perl, version 5.005_03 built for i386-freebsd" -- berlin.de - meine stadt im netz. Jetzt eigene eMail-adresse @berlin.de sichern! http://www.berlin.de/home/MeineStadt/Anmeldung -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Caching Large Data Structures To Disk
> -Original Message- > From: Balint, Jess [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 14, 2002 3:11 PM > To: '[EMAIL PROTECTED]' > Subject: Caching Large Data Structures To Disk > > > Hello all. First off, I want to thank everybody on this list > who has helped > me with with my previous questions. Thank you. > > I am working with input file of very large size. Sometimes up > to and greater > than a gig of data. I have previously gotten out of memory > errors (people at > work don't like when I do this). I was wondering if there was > a way to cache > large data structures to disk. We have a program here called > SAS that runs > on a Windows server (blek). Anyways, SAS allows me to operate > on unlimited > sizes of data, and always uses large temp files. Maybe there is a > Disk::Cache module or something that I can use to store my > data on disk > instead of memory. I know it will be slower, but is something > I am willing > to deal with. TIA. If you go the DBM route, be sure to check out the MLDBM module on CPAN. Very nice. I use MLDBM with Storable and DB_File to manage a large intranet data store. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: is it a bug? (less-equal compare)
le and ge does a string comparison... you want a numerical comparison < and > "89" le "100" is false because 8 is bigger than 1 on the ASCII chart "89" le "99" is true because 8 is smaller than 9 "98" le "99" is also true... "089" le "100" is true because 0 is smaller than 1 Try it.. but le and ge are for string comparisons... remember it goes down the string one charater at a time and is ordered as on the ASCII chart by the decimal value. -Original Message- From: Dittrich G. Michael [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 14, 2002 3:57 PM To: [EMAIL PROTECTED] Subject: is it a bug? (less-equal compare) I do: $lowerlimit = "89" le "100"; response "" I do: $lowerlimit = "89" le "99"; response "1" please help me! I dont get it! is this a bug? or am I nuts? perl -ver "This is perl, version 5.005_03 built for i386-freebsd" -- berlin.de - meine stadt im netz. Jetzt eigene eMail-adresse @berlin.de sichern! http://www.berlin.de/home/MeineStadt/Anmeldung -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
returning a 2-D array to C
Hi, I'm stuck with a bit of a nasty problem. I have a perl sub that returns a 2D array, but now I need to impliment this sub inside of a C program. Unfortunatly, just about all the documentation talks about returning numbers to C, I haven't been able to find anything on strings or 1D arrays, let alone @D arrays. I would appreciate any help you could give me. Thanks, tony -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Passing an array from a 2-D array
# The array, unchecked_dfa_states, is going to be an array of arrays ( 2-D ). # dfa_state_creation is a subroutine that returns an array, and takes an array # or single number, and a scalar, as parameters. push @unchecked_dfa_states, [ dfa_state_creation( $nfa_start_state, $epsilon ) ]; # I want it to loop until this array is empty. while ( $#unchecked_dfa_states > 0 ) { # I remove the first array and add it to another 2-D array. Syntax may be wrong. @checked_dfa_state = shift( [ $unchecked_dfa_state[ 0 ] ); # alphabet is an array of symbols( letters or numbers ) foreach $symbol ( @alphabet ) { # I'm having trouble here passing the array, as a whole, to the subroutine. I don't# think that I'm getting the syntax right. The subroutine will eventually return an array that will be # pushed on to the 2-D array unchecked_dfa_states. push(@unchecked_dfa_states, dfa_state_creation( [ unchecked_dfa_states[ 0 ] ], $symbol ) ); } # End foreach. So, in a nutshell, I want to pass an array from a 2-D array to a subroutine that will perform some calculations on it and return an array to another 2-D array. I have Learning Perl, Programming Perl, Perl Cookbook, and Advanced Perl Programming. All good books, but I can't seem to find the answer I'm looking for. I hope I stated the problem clearly enough. If any clarification is needed, I can post or explain more code. Ian P. Thomas Of course it runs NetBSD www.netbsd.org _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: is it a bug? (less-equal compare)
lt, le, ge, gt, eq, ne and cmp all do lexical comparisons. <, <=, >=, >, ==, !=, and <=> do numerical comparisons. "89" le "100" is false. but "89" <= "100" is true. If you are trying to sort lexcally but you have some numeric data tossed in: @array = ('foo','bar','23 Skidoo','pizza',',100 bottles of beer','665 neighbor of the beast',93); Then you may want to use both $a < $b or ($a == $b and $a le $b) If you are rolling your own sort, it might look like would look like: @array = sort {$a <=> $b or $a cmp $b} @array; the new order is: ('23 Skidoo',93,'100 bottles of beer','665 neighbor of the beast','bar','foo','pizza'); - Johnathan Dittrich G. Michael wrote: >I do: >$lowerlimit = "89" le "100"; >response "" > >I do: >$lowerlimit = "89" le "99"; >response "1" > >please help me! I dont get it! is this a bug? or am I nuts? > >perl -ver >"This is perl, version 5.005_03 built for i386-freebsd" >-- >berlin.de - meine stadt im netz. Jetzt eigene eMail-adresse @berlin.de sichern! >http://www.berlin.de/home/MeineStadt/Anmeldung > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
AW: RE: is it a bug? (less-equal compare)
oh! Thanks! by the way: is there a online source for command reference? My source is really poor! Thanks in forward Von: Nikola Janceski <[EMAIL PROTECTED]> Datum: 2002/02/14 Do PM 03:05:04 GMT-06:00 An: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>, [EMAIL PROTECTED] Betreff: RE: is it a bug? (less-equal compare) le and ge does a string comparison... you want a numerical comparison < and > "89" le "100" is false because 8 is bigger than 1 on the ASCII chart "89" le "99" is true because 8 is smaller than 9 "98" le "99" is also true... "089" le "100" is true because 0 is smaller than 1 Try it.. but le and ge are for string comparisons... remember it goes down the string one charater at a time and is ordered as on the ASCII chart by the decimal value. -Original Message- From: Dittrich G. Michael [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 14, 2002 3:57 PM To: [EMAIL PROTECTED] Subject: is it a bug? (less-equal compare) I do: $lowerlimit = "89" le "100"; response "" I do: $lowerlimit = "89" le "99"; response "1" please help me! I dont get it! is this a bug? or am I nuts? perl -ver "This is perl, version 5.005_03 built for i386-freebsd" -- berlin.de - meine stadt im netz. Jetzt eigene eMail-adresse @berlin.de sichern! http://www.berlin.de/home/MeineStadt/Anmeldung -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- berlin.de - meine stadt im netz. Jetzt eigene eMail-adresse @berlin.de sichern! http://www.berlin.de/home/MeineStadt/Anmeldung -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: is it a bug? (less-equal compare)
On Thu, Feb 14, 2002 at 02:56:46PM -0600, Dittrich G. Michael wrote: > $lowerlimit = "89" le "100"; > response "" [snip] > $lowerlimit = "89" le "99"; > response "1" > > please help me! I dont get it! is this a bug? or am I nuts? Neither, you're just using the wrong operator. 'le' is for strings, you want '<='. Numerically, 100 may be more than 89, but when calculating based on string value, adding each character by its numeric value, "89" is greater. I'm not sure if you're familiar with this, so I will explain it briefly. Each character has an equivalent numeric value, determined by the character set. This is because computers deal with numbers, not characters. For example, in the ASCII character set, the character "8" has a numeric value of 56 (it's the 57th character in the ASCII character set (yes, 57th; character sets are zero-based)), "9" has a numeric value of 57. You can get the numeric value of a character with the ord operator, see perldoc -f ord. So, in a string-wise comparison, each character in the left string is examined one-by-one, and compared to the corresponding character in the right string. "8" is compared to "1", "9" to "0", and "" (because there is no third character in "89") to "0". In your le comparison, the first two characters are compared, "8" and "1". If their numeric values are equal, then the next two characters are compared; if they aren't (which, of course, they aren't) then the numeric values are compared; if the numeric value of "8" is less than the numeric value of "1", true is returned, otherwise, 0 is returned. To express this in terms of Perl, "89" le "100" does something along the lines of: if (ord("8") != ord("1")) { return ord("8") < ord("1") } elsif (ord("9") != ord("0")) { return ord("9") < ord("0") } elsif (ord("") != ord("0")) { return ord("") < ord("0") } else { return 1 } Anyways, to reiterate, use '<=', not 'le', for numbers. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: octal file permissions
On Thu, 14 Feb 2002 07:57:07 -0900, [EMAIL PROTECTED] (Michael Fowler) wrote: >I'm tempted to say oct and sprintf's %o are symmetric, meaning they reverse >each other. You can think of it that way if it helps, but it might confuse >you in the case of oct(0500) and sprintf("%o", 0500). Ok, I have to give it one last try. #!/usr/bin/perl use strict; use warnings; #usage testmode file, file defaults to self my $open = shift || $0; my $mode = (stat $open)[2]; print '(stat(file))[2] is ',$mode,' which is decimal representation of the octal perms with file types',"\n"; my $val = sprintf("%o", $mode); print "$mode in oct is $val\n"; printf "Octal perms are %04o",$mode & 0; print ' with file type masked off',"\n"; my $perms = (stat("$open"))[2] & 0; my $oct_perms = sprintf "%lo", $perms; print 'decimal perms are ',$perms,' with file type masked off',"\n"; #print 'octal_perms are ',"$oct_perms",' with file type masked off',"\n"; print "If octal perms are $oct_perms, then to convert to decimal perms,",' oct(',$oct_perms,') is ',oct($oct_perms),"\n"; print 'Then if dec perms are ',$perms,' you convert to octal with sprintf("%o",',$perms,') which is ', sprintf("%o",$perms),"\n"; print 'sprintf("%o",oct($oct_perms)) is ', sprintf("%o",oct($oct_perms)),"\n"; print 'and conversely oct(sprintf("%o",oct($oct_perms)) is ',oct(sprintf("%o",oct($oct_perms))),"\n"; print 'I\'m a tortured nit-pik but I think I figured out octals :-)',"\n" -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: AW: RE: is it a bug? (less-equal compare)
On the command line type perldoc perl for a listing of docs type perldoc -f funcname to get info for individual functions type perldoc -q term to search the faq a particular term ie perldoc -q hash On Thu, 2002-02-14 at 16:21, Dittrich G. Michael wrote: > oh! Thanks! > > by the way: is there a online source for command reference? My source is really poor! > > Thanks in forward > > > Von: Nikola Janceski <[EMAIL PROTECTED]> > Datum: 2002/02/14 Do PM 03:05:04 GMT-06:00 > An: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>, > [EMAIL PROTECTED] > Betreff: RE: is it a bug? (less-equal compare) > > le and ge does a string comparison... you want a numerical comparison < and > > > > "89" le "100" is false because 8 is bigger than 1 on the ASCII chart > "89" le "99" is true because 8 is smaller than 9 > > "98" le "99" is also true... > "089" le "100" is true because 0 is smaller than 1 > > Try it.. but le and ge are for string comparisons... remember it goes down > the string one charater at a time and is ordered as on the ASCII chart by > the decimal value. > > > -Original Message- > From: Dittrich G. Michael [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 14, 2002 3:57 PM > To: [EMAIL PROTECTED] > Subject: is it a bug? (less-equal compare) > > > I do: > $lowerlimit = "89" le "100"; > response "" > > I do: > $lowerlimit = "89" le "99"; > response "1" > > please help me! I dont get it! is this a bug? or am I nuts? > > perl -ver > "This is perl, version 5.005_03 built for i386-freebsd" > -- > berlin.de - meine stadt im netz. Jetzt eigene eMail-adresse @berlin.de > sichern! > http://www.berlin.de/home/MeineStadt/Anmeldung > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > The views and opinions expressed in this email message are the sender's > own, and do not necessarily represent the views and opinions of Summit > Systems Inc. > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > -- > berlin.de - meine stadt im netz. Jetzt eigene eMail-adresse @berlin.de sichern! > http://www.berlin.de/home/MeineStadt/Anmeldung > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- Today is Setting Orange the 45th day of Chaos in the YOLD 3168 Pzat! Missle Address: 33:48:3.521N 84:23:34.786W -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Help me out
Yeah I agree, I owe about 5 perl books and have read them all but still find it difficult to code the most basic of things. I wish there were more step by step how to's out there. I'm documenting my progress and plan to do a site sometime that caters to the most uneducated of learners. If any sites like that exist already let me know. Sometimes I learn better from seeing, being on the artistic side of the mind. - Naika http://www.naikaonline.com -Original Message- From: Yacketta, Ronald [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 14, 2002 8:50 AM To: [EMAIL PROTECTED] Subject: RE: Help me out its that simple? WoW! I must have fubarbed somewhere, I have those books as well as several others and hell I am not even close to be a pro!/me dreams about the day I can be a perl gawd like Randel (spelling) -Ron > -Original Message- > From: Matthew Peter Lyon [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 14, 2002 11:49 > To: amrinder singh; [EMAIL PROTECTED] > Subject: Re: Help me out > > > get the O'Riley learning perl book > get the black book > get the cookbook ( O'Riley ) > > you'll be a pro. > > - Original Message - > From: "amrinder singh" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Thursday, February 14, 2002 12:24 PM > Subject: Help me out > > > > I have just started learning perl a day ago. > > > > Can anybody guide me on how to start? I am really > interested in learning > > the language > > > > > > AMRINDER > > > > > > _ > > Join the worlds largest e-mail service with MSN Hotmail. > > http://www.hotmail.com > > > > > > -- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Help me out
The books that Matthew suggested are excellent resources, I've found (though I would also recommend "Programming Perl", also from O'Reilly). Another excellent way of learning how to program is read other peoples' code, figure out how to break it and fix it, and adapt it to your own needs. My father-in-law, a C/C++/Java programmer, tells me that there has only ever been one program written. The rest are just hacks off of that one program. I found it very useful, when learning the basics (as I still am, actually), to go to free script archive sites, such as Matt's Script Archive, download some scripts, read the documentation to learn how to tweak them, and play with that. On Thu, 2002-02-14 at 15:48, Naika - EV1 wrote: > Yeah I agree, I owe about 5 perl books and have read them all but still find > it difficult to code the most basic of things. I wish there were more step > by step how to's out there. I'm documenting my progress and plan to do a > site sometime that caters to the most uneducated of learners. If any sites > like that exist already let me know. Sometimes I learn better from seeing, > being on the artistic side of the mind. > > - Naika > http://www.naikaonline.com > > > > -Original Message- > From: Yacketta, Ronald [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 14, 2002 8:50 AM > To: [EMAIL PROTECTED] > Subject: RE: Help me out > > > its that simple? WoW! I must have fubarbed somewhere, I have those books as > well as several others and hell I am not even close to be a pro!/me dreams > about the day I can be a perl gawd like Randel (spelling) > > -Ron > > > -Original Message- > > From: Matthew Peter Lyon [mailto:[EMAIL PROTECTED]] > > Sent: Thursday, February 14, 2002 11:49 > > To: amrinder singh; [EMAIL PROTECTED] > > Subject: Re: Help me out > > > > > > get the O'Riley learning perl book > > get the black book > > get the cookbook ( O'Riley ) > > > > you'll be a pro. > > > > - Original Message - > > From: "amrinder singh" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Sent: Thursday, February 14, 2002 12:24 PM > > Subject: Help me out > > > > > > > I have just started learning perl a day ago. > > > > > > Can anybody guide me on how to start? I am really > > interested in learning > > > the language > > > > > > > > > AMRINDER > > > > > > > > > _ > > > Join the worlds largest e-mail service with MSN Hotmail. > > > http://www.hotmail.com > > > > > > > > > -- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > -- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Sliante, Richard S. Crawford mailto:[EMAIL PROTECTED] http://www.mossroot.com AIM: Buffalo2K ICQ: 11646404 Yahoo!: rscrawford MSN: [EMAIL PROTECTED] "It is only with the heart that we see rightly; what is essential is invisible to the eye." --Antoine de Saint Exupery "Push the button, Max!" -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: is it a bug? (less-equal compare)
On Thu, 14 Feb 2002, Dittrich G. Michael wrote: > I do: > $lowerlimit = "89" le "100"; > response "" > > I do: > $lowerlimit = "89" le "99"; > response "1" > > please help me! I dont get it! is this a bug? or am I nuts? You are comparing strings here when you really want to be comparing numbers. In terms of strings, "100" is less than "89". What you want is $lowerlimit = 89 < 100; -- Brett http://www.chapelperilous.net/ Don't try to outweird me, three-eyes. I get stranger things than you free with my breakfast cereal. -- Zaphod Beeblebrox -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Help me out
For my $.02 I'd say that the best book I've come across for teaching the uninitiated is Perl from the Ground Up by Michael McMillan (Osborne/McGraw Hill Publishing). I got more into the O'Reilley books after I was a little more comfortable with Perl. -Original Message- From: Richard Crawford [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 14, 2002 1:57 PM To: Naika - EV1 Cc: Yacketta, Ronald; [EMAIL PROTECTED] Subject: RE: Help me out The books that Matthew suggested are excellent resources, I've found (though I would also recommend "Programming Perl", also from O'Reilly). Another excellent way of learning how to program is read other peoples' code, figure out how to break it and fix it, and adapt it to your own needs. My father-in-law, a C/C++/Java programmer, tells me that there has only ever been one program written. The rest are just hacks off of that one program. I found it very useful, when learning the basics (as I still am, actually), to go to free script archive sites, such as Matt's Script Archive, download some scripts, read the documentation to learn how to tweak them, and play with that. On Thu, 2002-02-14 at 15:48, Naika - EV1 wrote: > Yeah I agree, I owe about 5 perl books and have read them all but still find > it difficult to code the most basic of things. I wish there were more step > by step how to's out there. I'm documenting my progress and plan to do a > site sometime that caters to the most uneducated of learners. If any sites > like that exist already let me know. Sometimes I learn better from seeing, > being on the artistic side of the mind. > > - Naika > http://www.naikaonline.com > > > > -Original Message- > From: Yacketta, Ronald [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 14, 2002 8:50 AM > To: [EMAIL PROTECTED] > Subject: RE: Help me out > > > its that simple? WoW! I must have fubarbed somewhere, I have those books as > well as several others and hell I am not even close to be a pro!/me dreams > about the day I can be a perl gawd like Randel (spelling) > > -Ron > > > -Original Message- > > From: Matthew Peter Lyon [mailto:[EMAIL PROTECTED]] > > Sent: Thursday, February 14, 2002 11:49 > > To: amrinder singh; [EMAIL PROTECTED] > > Subject: Re: Help me out > > > > > > get the O'Riley learning perl book > > get the black book > > get the cookbook ( O'Riley ) > > > > you'll be a pro. > > > > - Original Message - > > From: "amrinder singh" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Sent: Thursday, February 14, 2002 12:24 PM > > Subject: Help me out > > > > > > > I have just started learning perl a day ago. > > > > > > Can anybody guide me on how to start? I am really > > interested in learning > > > the language > > > > > > > > > AMRINDER > > > > > > > > > _ > > > Join the world's largest e-mail service with MSN Hotmail. > > > http://www.hotmail.com > > > > > > > > > -- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > -- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Sliante, Richard S. Crawford mailto:[EMAIL PROTECTED] http://www.mossroot.com AIM: Buffalo2K ICQ: 11646404 Yahoo!: rscrawford MSN: [EMAIL PROTECTED] "It is only with the heart that we see rightly; what is essential is invisible to the eye." --Antoine de Saint Exupery "Push the button, Max!" -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This email may contain confidential and privileged material for the sole use of the intended recipient. If you are not the intended recipient, please contact the sender and delete all copies. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Regular Expressions - matching the first time
I have string, something like: $String = "aaa bbb: fffd: sdfsdf qweqd: adfsdf qwcdsfs: qwdq qchuti: qwiojd"; Now, I want to extract everything from the start of the string, up through the FIRST colon ":" -- in this case "aaa bbb". My regex looks like this: $String =~ /^(.*):/ ; So: ^ starts at the beginning, (.*) to grab everything in the middle, and : to match the colon. What I am getting is, everything from the start of the string up until the last colon. In this example: $1 = "aaa bbb: fffd: sdfsdf qweqd: adfsdf qwcdsfs: qwdq qchuti" What I want is: $1 = "aaa bbb" I even tried using: $String =~ /^(.*):{1}/ ; Thinking the {1} would match the first occurance of :, but that didn't change the results (I was runningn out of ideas). Now, I could split $String on :, but I have to think that there is a better way and I'm missing some modifier that I can't find in the FAQ or any of the three books that have been dumped on my desk. Any help is appreciated. Russell J Foster Subject, Wills, & Company e. [EMAIL PROTECTED] v. 630-572-0240 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Help me out
Yeah I can honestly say I learn more from analysing other peoples code. I notice some mistakes in books and sometimes that really confuses me. After about 2 years of reading and studying I can now read, understand and manipulate other peoples code but I have yet to write my own from scratch (asides from hello.pl), something I aim to do. Maybe its just fear or the fact, like you say, most are already written and out there. Thanks for the help. - Naika http://www.naikaonline.com -Original Message- From: Nikola Janceski [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 14, 2002 2:04 PM To: 'Naika - EV1' Subject: RE: Help me out If you learn by seeing then look at other people's code to learn. Correct their mistakes, make the code more efficient and easier to read/understand. I learned Perl 3 years ago and that was with Perl4. I didn't really learn perl until I started having to look at other people's code (even some of the core perl code and modules). I have to say for 2 years I was still a beginner and only in this last year when I started to look at my own code again did realize that I was an imbicil (sp?) perl when I thought I was getting good. My code was hard to read and harder to understand why I wrote something the way I did (little or no comments in my code) so I ended up rewriting everything, and learning that someone (most of the time) wrote a module that does what I wanted. Search on search.cpan.org for modules, and use perldoc to find the module you might use! Believe me... the only way to learn is trial and error, you start to get better at not repeating bad habits (no comments, 80 lines of code that could have been 10 subroutines, bad bad pattern matching). Ask people for some of there old code and try to rewrite it or add more functionality to it. I started learning perl for formatting files into a prettier layout, but realized that there is sooo much more. -Original Message- From: Naika - EV1 [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 14, 2002 6:48 PM To: Yacketta, Ronald; [EMAIL PROTECTED] Subject: RE: Help me out Yeah I agree, I owe about 5 perl books and have read them all but still find it difficult to code the most basic of things. I wish there were more step by step how to's out there. I'm documenting my progress and plan to do a site sometime that caters to the most uneducated of learners. If any sites like that exist already let me know. Sometimes I learn better from seeing, being on the artistic side of the mind. - Naika http://www.naikaonline.com -Original Message- From: Yacketta, Ronald [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 14, 2002 8:50 AM To: [EMAIL PROTECTED] Subject: RE: Help me out its that simple? WoW! I must have fubarbed somewhere, I have those books as well as several others and hell I am not even close to be a pro!/me dreams about the day I can be a perl gawd like Randel (spelling) -Ron > -Original Message- > From: Matthew Peter Lyon [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 14, 2002 11:49 > To: amrinder singh; [EMAIL PROTECTED] > Subject: Re: Help me out > > > get the O'Riley learning perl book > get the black book > get the cookbook ( O'Riley ) > > you'll be a pro. > > - Original Message - > From: "amrinder singh" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Thursday, February 14, 2002 12:24 PM > Subject: Help me out > > > > I have just started learning perl a day ago. > > > > Can anybody guide me on how to start? I am really > interested in learning > > the language > > > > > > AMRINDER > > > > > > _ > > Join the world's largest e-mail service with MSN Hotmail. > > http://www.hotmail.com > > > > > > -- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Regular Expressions - matching the first time
The * operator is greedy, grabbing as much of the string as it can with still being able to match. The ? operator limits this behavior, so I think what you want is: $String =~ /^(.*?):/; /\/\ark -Original Message- From: Russ Foster [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 14, 2002 2:10 PM To: '[EMAIL PROTECTED]' Subject: Regular Expressions - matching the first time I have string, something like: $String = "aaa bbb: fffd: sdfsdf qweqd: adfsdf qwcdsfs: qwdq qchuti: qwiojd"; Now, I want to extract everything from the start of the string, up through the FIRST colon ":" -- in this case "aaa bbb". My regex looks like this: $String =~ /^(.*):/ ; So: ^ starts at the beginning, (.*) to grab everything in the middle, and : to match the colon. What I am getting is, everything from the start of the string up until the last colon. In this example: $1 = "aaa bbb: fffd: sdfsdf qweqd: adfsdf qwcdsfs: qwdq qchuti" What I want is: $1 = "aaa bbb" I even tried using: $String =~ /^(.*):{1}/ ; Thinking the {1} would match the first occurance of :, but that didn't change the results (I was runningn out of ideas). Now, I could split $String on :, but I have to think that there is a better way and I'm missing some modifier that I can't find in the FAQ or any of the three books that have been dumped on my desk. Any help is appreciated. Russell J Foster Subject, Wills, & Company e. [EMAIL PROTECTED] v. 630-572-0240 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Regular Expressions - matching the first time
all quantifiers (ie * + {2,7} ) are all "greedy" which means they will try to match as much as possible as long as it's true. To make the quantifier not "greedy" put a ? (question mark) after it, then it will match the least as possible as long as it's true. what you want is $String =~ /^(.*?):/; now $1 is everything up to the first : excluding the colon. -Original Message- From: Russ Foster [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 14, 2002 5:10 PM To: '[EMAIL PROTECTED]' Subject: Regular Expressions - matching the first time I have string, something like: $String = "aaa bbb: fffd: sdfsdf qweqd: adfsdf qwcdsfs: qwdq qchuti: qwiojd"; Now, I want to extract everything from the start of the string, up through the FIRST colon ":" -- in this case "aaa bbb". My regex looks like this: $String =~ /^(.*):/ ; So: ^ starts at the beginning, (.*) to grab everything in the middle, and : to match the colon. What I am getting is, everything from the start of the string up until the last colon. In this example: $1 = "aaa bbb: fffd: sdfsdf qweqd: adfsdf qwcdsfs: qwdq qchuti" What I want is: $1 = "aaa bbb" I even tried using: $String =~ /^(.*):{1}/ ; Thinking the {1} would match the first occurance of :, but that didn't change the results (I was runningn out of ideas). Now, I could split $String on :, but I have to think that there is a better way and I'm missing some modifier that I can't find in the FAQ or any of the three books that have been dumped on my desk. Any help is appreciated. Russell J Foster Subject, Wills, & Company e. [EMAIL PROTECTED] v. 630-572-0240 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Regular Expressions - matching the first time
I think maybe $String =~ s/:.*//; would work. -Original Message- From: Russ Foster [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 14, 2002 5:10 PM To: '[EMAIL PROTECTED]' Subject: Regular Expressions - matching the first time I have string, something like: $String = "aaa bbb: fffd: sdfsdf qweqd: adfsdf qwcdsfs: qwdq qchuti: qwiojd"; Now, I want to extract everything from the start of the string, up through the FIRST colon ":" -- in this case "aaa bbb". My regex looks like this: $String =~ /^(.*):/ ; So: ^ starts at the beginning, (.*) to grab everything in the middle, and : to match the colon. What I am getting is, everything from the start of the string up until the last colon. In this example: $1 = "aaa bbb: fffd: sdfsdf qweqd: adfsdf qwcdsfs: qwdq qchuti" What I want is: $1 = "aaa bbb" I even tried using: $String =~ /^(.*):{1}/ ; Thinking the {1} would match the first occurance of :, but that didn't change the results (I was runningn out of ideas). Now, I could split $String on :, but I have to think that there is a better way and I'm missing some modifier that I can't find in the FAQ or any of the three books that have been dumped on my desk. Any help is appreciated. Russell J Foster Subject, Wills, & Company e. [EMAIL PROTECTED] v. 630-572-0240 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Regular Expressions - matching the first time
On Thu, 14 Feb 2002, Russ Foster wrote: > I have string, something like: > > $String = "aaa bbb: fffd: sdfsdf qweqd: adfsdf qwcdsfs: qwdq qchuti: > qwiojd"; > > Now, I want to extract everything from the start of the string, up through > the FIRST colon ":" -- in this case "aaa bbb". My regex looks like this: I would go with split here. This is the kind of thing split is intended for: my $String = "aaa bbb: fffd: sdfsdf qweqd: adfsdf qwcdsfs: qwdq qchuti: qwiojd"; my $str1 = (split /:\s+/, $String)[0]; print "$str1\n"; -- Brett http://www.chapelperilous.net/ The distinction between Freedom and Liberty is not accurately known; naturalists have been unable to find a living specimen of either. -- Ambrose Bierce -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: CPAN
Shaun [[EMAIL PROTECTED]] quoth: *>I have a Linux Box and I am attempting to install perl 5.6. I can get onto CPAN but it wont find *>the perl 5.6 distro. When I search I see it but i can't find the 'keyword' that it will like to http://cpan.valueclick.com/src/ 5.6.1 is the latest stable release. e. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Help me out
hey, leading off this... a question for the group... are the ways in programming to solve problems / situations called 'design patterns' ? I find this is often my stumbling block --> i just have no idea where to start. - Original Message - From: "Naika - EV1" <[EMAIL PROTECTED]> To: "Yacketta, Ronald" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Thursday, February 14, 2002 3:48 PM Subject: RE: Help me out > Yeah I agree, I owe about 5 perl books and have read them all but still find > it difficult to code the most basic of things. I wish there were more step > by step how to's out there. I'm documenting my progress and plan to do a > site sometime that caters to the most uneducated of learners. If any sites > like that exist already let me know. Sometimes I learn better from seeing, > being on the artistic side of the mind. > > - Naika > http://www.naikaonline.com > > > > -Original Message- > From: Yacketta, Ronald [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 14, 2002 8:50 AM > To: [EMAIL PROTECTED] > Subject: RE: Help me out > > > its that simple? WoW! I must have fubarbed somewhere, I have those books as > well as several others and hell I am not even close to be a pro!/me dreams > about the day I can be a perl gawd like Randel (spelling) > > -Ron > > > -Original Message- > > From: Matthew Peter Lyon [mailto:[EMAIL PROTECTED]] > > Sent: Thursday, February 14, 2002 11:49 > > To: amrinder singh; [EMAIL PROTECTED] > > Subject: Re: Help me out > > > > > > get the O'Riley learning perl book > > get the black book > > get the cookbook ( O'Riley ) > > > > you'll be a pro. > > > > - Original Message - > > From: "amrinder singh" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Sent: Thursday, February 14, 2002 12:24 PM > > Subject: Help me out > > > > > > > I have just started learning perl a day ago. > > > > > > Can anybody guide me on how to start? I am really > > interested in learning > > > the language > > > > > > > > > AMRINDER > > > > > > > > > _ > > > Join the world's largest e-mail service with MSN Hotmail. > > > http://www.hotmail.com > > > > > > > > > -- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > -- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Help me out
NO! Don't use Matt's Script Archive!!! That code is old and full of errors. Go to http://nms-cgi.sourceforge.net/ and you will find "the rest of the story" and equivalent scripts that are well written and tested. Also, check out http://perl.about.com/ for some good beginners stuff. Good Luck! Dennis -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
determine if exe is compiled perl
Does anyone know of a way to tell if an NT exe is a compiled perl script? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Passing an array from a 2-D array
On Thu, Feb 14, 2002 at 04:14:39PM -0500, Ian P. Thomas wrote: > > # The array, unchecked_dfa_states, is going to be an array of arrays ( 2-D ). > # dfa_state_creation is a subroutine that returns an array, and takes an array > # or single number, and a scalar, as parameters. > push @unchecked_dfa_states, [ dfa_state_creation( $nfa_start_state, $epsilon ) ]; > # I want it to loop until this array is empty. > while ( $#unchecked_dfa_states > 0 ) The typical idiom is: while (@unchecked_dfa_states) > { > # I remove the first array and add it to another 2-D array. Syntax > may be wrong. > @checked_dfa_state = shift( [ $unchecked_dfa_state[ 0 ] ); shift expects an array, not an array reference. This won't even parse correctly, for that reason and because you have an unmatched bracket. Did you copy and paste your code, or type it in? What I believe you want is: @checked_dfa_states = @{ shift(@unchecked_dfa_states) }; That pulls off the first element of @unchecked_dfa_states and dereferences it. > # alphabet is an array of symbols( letters or numbers ) > foreach $symbol ( @alphabet ) > { > # I'm having trouble here passing the array, as a whole, to the > subroutine. I don't # think that I'm getting the syntax right. > The subroutine will eventually return an array that will be > # pushed on to the 2-D array unchecked_dfa_states. > push(@unchecked_dfa_states, dfa_state_creation( > [ unchecked_dfa_states[ 0 ] ], $symbol ) ); > } # End foreach. I believe you want: push( @unchecked_dfa_states, dfa_state_creation($unchecked_dfa_states[0], $symbol) ); It's very hard to determine what it is you're trying to accomplish from your code and description. I'm not sure what's a typo and what's misunderstanding. If the above doesn't help you should send another message to the list describing more of what you want to happen, with at least parseable code. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Regular Expressions - matching the first time
On Thu, Feb 14, 2002 at 04:10:06PM -0600, Russ Foster wrote: > I have string, something like: > > $String = "aaa bbb: fffd: sdfsdf qweqd: adfsdf qwcdsfs: qwdq qchuti: > qwiojd"; > > Now, I want to extract everything from the start of the string, up through > the FIRST colon ":" -- in this case "aaa bbb". My regex looks like this: > > $String =~ /^(.*):/ ; As mentioned by a couple of people, the non-greedy version of * is one way of going about it: $String =~ /^(.*?):/; A faster way, however, is to realize that what you really want is anything-but-a-colon followed by a colon: $String =~ /^([^:]+):/; Please see perldoc perlretut and perldoc perlre. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Regular Expressions - matching the first time
On Feb 14, Michael Fowler said: >As mentioned by a couple of people, the non-greedy version of * is one way >of going about it: > >$String =~ /^(.*?):/; > >A faster way, however, is to realize that what you really want is >anything-but-a-colon followed by a colon: > >$String =~ /^([^:]+):/; As of Perl 5.6.2 (not released yet), /^(.*?):/ and /^([^:]*):/ will have the same efficiency (read: speed). If you're curious, currently /^.*?:/ and /^[^:]*:/ have the same speed -- it's the capturing that killed .*?, but I have fixed that. And personally, I'd use /([^:]*)/ instead of /^([^:]*):/, since they match the same thing (assuming there IS a colon in the string). Or I'd use /(.*?):/ instead of /^(.*?):/ but whatever. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** what does y/// stand for? why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Trying to extract an email address
Hi all, I am a newbie and really enjoy this list. I have what i am sure is a fairly easy question, but I need help. I have a text file which contains much un-needed data, but also contains a bunch of email addresses I need. I have been succesful in the basics of opening the file and putting the contents into an array. However, I have had a problem extracting the email addresses. I used the grep/@/ function an this returned all the lines that contained an email address. However, I don't want the whole line, just the email address. I tried the nongreedy modifier grep/@?/ but this didn't work. Any suggestions. Thanks in advance. MMM __ Do You Yahoo!? Send FREE Valentine eCards with Yahoo! Greetings! http://greetings.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
windows paths
Hi all, I am putting together a script on windows. It uses filehandles. The problem is that for some reason it dosen't like the path and won't create the folders and/or file. Regards Stuart Clark $OutFile = "c:\\invoices\\current\\sales"; open (OUTSALES,">$OutFile") || die "could not create $OutFile"; ##Blah Blah rest of script## The error is : could not create c:\invoices\current\sales
help with extracting text from a string
Hi all, I have a string that is read in and assigned to a veriable. String looks something like this: 10.00 c$cpi c$ul (Sample Number:) c$sh /Courier 0 c$fnt ( SA-01-0C8A8) c$sh ( ) c$sh /Courier 0 c$fnt I need the string between the second set of ()'s. There may or may not be a leading space, if so, I need to strip it out. There are not the exact same number of charecters in the string, the only thing constant is the value I need is in the second set of ()'s. Any idaes on this? Thanx for any input! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: help with extracting text from a string
On Feb 14, Bill Akins said: >I have a string that is read in and assigned to a veriable. String >looks something like this: >10.00 c$cpi c$ul (Sample Number:) c$sh /Courier 0 c$fnt ( >SA-01-0C8A8) c$sh ( ) c$sh /Courier 0 c$fnt > >I need the string between the second set of ()'s. There may or may not >be a leading space, if so, I need to strip it out. There are not the >exact same number of charecters in the string, the only thing constant >is the value I need is in the second set of ()'s. You can match it like so: my ($second_paren) = ($string =~ /\((.*?)\)/g)[1]; or my ($second_paren) = ($string =~ /\(([^)]*)\)/g)[1]; -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** what does y/// stand for? why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Help me out
On Thu, 14 Feb 2002, Matthew Peter Lyon wrote: > hey, leading off this... a question for the group... are the ways in > programming to solve problems / situations called 'design patterns' ? Well, sorta... 'design patterns' refers to a specific way of analyisng software design. It actually comes from the theories of an architect named Christopher Alexander (http://www.math.utsa.edu/sphere/salingar/Chris.text.html). These ideas were applied to a variety of things, like analyzing oriental carpet design, and object-oriented software design. There are many different ways of looking at software design and solving problems with them. There's a lot you can learn in, say a CompSci curriculum, and a lot also comes from experience and playing with structures and algorithms people have worked before. These techniques can't tell you how to program, but how to think about programming. There are tons of books out there, some good for the budding programmer, some at the college CS level. One book I do recommend taking a look at is from our old friends Brian Kernighan & Robert Pike, entitled _The Practice of Programming_. While they specifically look at C the most int terms of exmaples, the pricniples they touch apply to any language (and yes, they do a little Perl). They look at things like top-level design, debugging techniques, testing, style, etc. -- Brett http://www.chapelperilous.net/ Help me, I'm a prisoner in a Fortune cookie file! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
regular expressions
If my input is in the form: Name: Happy, Species: Cat, Gender: Male Name: Peanut, Species: Hamster, Gender: Female how come foreach (keys %names) { if ($names{$_} =~ /\s*Gender:\s*$gen\s*/i) { AND if ($names{$_} =~ /\s*Species:\s*$sp\s*/i) { WORK why doesn't if ($names{$_} =~ /\s*Name:\s*$pn\s*/i) { Thanks, Terri _ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: regular expressions
On Feb 15, terri harrison said: >Name: Happy, Species: Cat, Gender: Male >Name: Peanut, Species: Hamster, Gender: Female > >if ($names{$_} =~ /\s*Gender:\s*$gen\s*/i) { >if ($names{$_} =~ /\s*Species:\s*$sp\s*/i) { > >WORK > >why doesn't >if ($names{$_} =~ /\s*Name:\s*$pn\s*/i) { I can't tell without some data. What of $gen, $sp, and $pn? -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** what does y/// stand for? why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: regular expressions
On Fri, 15 Feb 2002, terri harrison wrote: > If my input is in the form: > > Name: Happy, Species: Cat, Gender: Male > Name: Peanut, Species: Hamster, Gender: Female > > how come > foreach (keys %names) { > if ($names{$_} =~ /\s*Gender:\s*$gen\s*/i) { > AND > if ($names{$_} =~ /\s*Species:\s*$sp\s*/i) { > > WORK > > why doesn't > if ($names{$_} =~ /\s*Name:\s*$pn\s*/i) { In what context? What are you expecting them to do? What are you doing with the data? Where are the variables $gen, $sp and $pn coming from? Going by the two lines of data at the top, my first inclination would be to break them up into key & value pairs and get them into a hash (using splits, one to split onf commas, then on the :), then not even worry about those regular expressions you are attempting. -- Brett http://www.chapelperilous.net/ Day of inquiry. You will be subpoenaed. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: windows paths
Stuart Clark wrote: > > Hi all, > > I am putting together a script on windows. > > It uses filehandles. > > The problem is that for some reason it dosen't like the path and won't create the >folders and/or file. > > Regards > Stuart Clark > > $OutFile = "c:\\invoices\\current\\sales"; > > open (OUTSALES,">$OutFile") || die "could not create $OutFile"; > > ##Blah Blah rest of script## > > The error is : could not create c:\invoices\current\sales Include the $! and/or $^E variables in your error message to find out _why_ the error occured. open OUTSALES, ">$OutFile" or die "could not create $OutFile\n $!\n $^E"; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Anyone use request tracker before?????
Anyone has use the request tracker before?I tried installing rt but was in vain! Drop me a mail if U have installed rt successfully ;o) thks!~! __ Do You Yahoo!? Got something to say? Say it better with Yahoo! Video Mail http://mail.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Trying to extract an email address
- Original Message - From: "Marc Morrison" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> > I have a text file which contains much un-needed data, > but also contains a bunch of email addresses I need. > I have been succesful in the basics of opening the > file and putting the contents into an array. > > However, I have had a problem extracting the email > addresses. Assuming a line of text contain max. of an email address, the following should help; open FILE, 'data.txt' or die "$!\n"; while (){ print "$1\n" if /([^ ]+@[^ ]+)/; }; close FILE; _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]