RE: Firewall
hmmm we'llyou can't tell anything from port 80 (http) coz (by the sounds of things) the firewall is configured to let that traffic thru (probably). now, you could sniff to see what other connections you can make (21 etc) but, if you make a connection or get some sorta reading back on a port then this doesn't prove or deny the existance of a firewall (coz the firewall could be configured to let those pckts thru). A better approach would be to fingerprint the os of the webserver (from info from port 80) and then compare that to the finger print your getting back from responses from other ports (e.g. an os has its on peculiar quirks in handshaking tcp/ip - its these quirks which all OSs to be fingerprinted based on tcp/ip behaviour). If the finger print for all ports (including odd ones which a firewall wont be configured to allow thru) match then might be able to say there is no firewall. NMAP would probably be a better option joel -Original Message- From: Fred Sahakian [mailto:[EMAIL PROTECTED]] Sent: 17 April 2002 20:37 To: >; > Subject: Firewall Anyone know of a perl script that can determine if a website is actually behind a firewall? thanks! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: regex question
hi john i implementet your solution. mine actually did work, but yours seemed more logical. it works nicely. thank you martin On Wed, Apr 17, 2002 at 12:58:07PM -0700, John W. Krahn wrote: > [EMAIL PROTECTED] wrote: > > > > hi, > > Hello, > > > im pasting some more of the lines i need to parse. i guess > > im just learning regex and just espesially learning how to > > ask the correct questions! heh, dont ask regex without > > showing enuf of the stuff you want to parse :) > > > > theres is these three basic entries (skakkebaek is spelled awfully. only skak >matches em all :-) : > > > > Hits Cited Author Cited WorkVolume Page Year > > >__ > > > > [_][667] 279 ...Skakkebaek NE ENVIRON HEALTH PERSP 104 741 > 1996 > > [_] 1 SKAKKEBAEK NE EARLY DETECTION TEST26 >1981 > > [_] 3 SKAKKEBAEK NE EARLY DETECTION TEST >1981 > > > > then there is these freaks: > > this one contains NE in the name and NE in GENE so GENE is truncated if care is >not taken. > > > > [_][718] 18 ...Skakkebaek NE GENE CHROMOSOME CANC 20 412 > 1997 > > > > here the journal name starts with 7 > > > > [_] 3 SKAKKEBAEK NE 7 WORLD C FERT STER >1971 > > > > here the journal name ends with a digit thus entangling it in the following page >number 101. > > > > [_] 1 SKAKKEBAEK NE ENV HLTH PERSPECT S2 101 1 >1993 > > > > here is my mathing routine - works with all but the last freak!: > > > > [snip code] > > > This works with the data above: > > while ( ) { > chomp; > my @field = split /\s{2,}/; > > shift @field if $field[0] =~ /]$/; > (my $citations) = (shift @field) =~ /(\d+)$/; > > shift @field if $field[0] =~ /skak.*ne$/i; > > my $journal = shift @field; > my $year= pop @field || ''; > my $page= pop @field || ''; > my $volume = pop @field || ''; > > print "Citation: $citations\nJournal: $journal\nVolume: $volume\nPage: >$page\nYear: $year\n\n"; > } > > __DATA__ > [_][667] 279 ...Skakkebaek NE ENVIRON HEALTH PERSP 104 741 >1996 > [_] 1 SKAKKEBAEK NE EARLY DETECTION TEST26 1981 > [_] 3 SKAKKEBAEK NE EARLY DETECTION TEST1981 > [_][718] 18 ...Skakkebaek NE GENE CHROMOSOME CANC 20 412 >1997 > [_] 3 SKAKKEBAEK NE 7 WORLD C FERT STER 1971 > [_] 1 SKAKKEBAEK NE ENV HLTH PERSPECT S2 101 1 1993 > > > > > John > -- > use Perl; > program > fulfillment > > -- > 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]
Sudoers Regex
Hi I am trying to parse a string of text from a sudoers file, what I am trying to get out is the HOSTCLUSTER name and the hosts. Host_Alias HOSTCLUSTER = host1, host2, \ host3, host4, \ host5, host6 The first problem is I split using "=" so $hostAlias[0] contains "Host_Alias HOSTCLUSTER" and I just need to return the HOSTCLUSTER part and disgard Host_Alias so I will need a regex for that. And the second bit needs to return the hosts I know there are no examples but I have tried numerous ways and cannot solve this.. My Current code snippet ... my$sudoerFile="/home/dblackb/SUDOERS/sudoers.current"; open (FH,"< $sudoerFile")||die "Couldn't open $sudoerFile for reading: $!\n"; while (){ if ($_ =~ /^Host_Alias/){ my@hostAlias = split(/=/,$_); REGEX HERE } } close (FH); Regards David Blackburn " This message contains information that may be privileged or confidential and is the property of the Cap Gemini Ernst & Young Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message ". -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: about formal sub routine declartions
> "drieux" == drieux <[EMAIL PROTECTED]> writes: drieux> "Currently Perl subroutines have fairly limited support for drieux> formal parameter lists. You can specify the number of drieux> parameters and their type, but you still have to manually drieux> take them out of the `@_' array yourself. drieux> does [coding] this still make sense? Yep. So much sense, in fact, that someone's already done it. Have a look at Perl6::Parameters, on the CPAN. It works as you'd imagine - just uses Filter::Simple with regexps to transform sub definitions. - Chris. -- $a="printf.net"; Chris Ball | chris@void.$a | www.$a | finger: chris@$a As to luck, there's the old miners' proverb: Gold is where you find it. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Firewall
http://www.packetfactory.net/Projects/Firewalk/ > > Anyone know of a perl script that can determine if a website > is actually > behind a firewall? > > thanks! > > > -- > 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]
use of $_
Hi all, I've got a script that read in a HTML template file to an array, and then write it out a number of times substituting part of the text. Can anyone tell me why the following code fragment works __BEGIN__ my $line=''; print $line while ($line=shift @HTML)!~/^/; # skip to end of comment print "blah\n"; # insert replacement code print "$_" foreach (@HTML); # copy rest of file __END__ while this one, using $_ instead of $line fails stating once per line before the break that I'm using an uninitialised variable on the 'while' line __BEGIN__ print while (shift @HTML)!~/^/; # skip to end of comment print "blah\n"; # insert replacement code print "$_" foreach (@HTML); # copy rest of file __END__ -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Studying & Source Code
How's the best way to get the most out of studying and studying source code? I'm always reading that looking at source code (and coding in general) is the best way to learn to program. I'm taking stuff of the net and going through it and trying to make sure I can "read" it and trying to see what it does. Is this the correct method? Any advice on how to get the most out of this and studying/practicing/learning a language? Right now, I'm reading and doing the exercises from Learning Perl for Win32. Then, I review what I've learned in the past by writing practice exercises which make use of whatever I'm focusing on (ex., control statements, arrays, etc.). These are similar to technical exercises that a musician does and I'm doing because I'm in the learning stages of the language. I then try to study code but it's usually beyond me. I feel frustrated at times because I'm putting in the time (2-3 hours daily) but I feel like I'm inefficient and that others would get more out of my sessions than me. Any advice? Thanks! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how to return an array reference from a subroutine
Drieux - Thanks for your reply. Your suggestion for the use of foreach makes sense and as been implemented. However, I do not understand your comments about the return value of map. Does not map return a reference to an anonymous arrar, not a hash? Dick Fell Drieux wrote: > > On Wednesday, April 17, 2002, at 02:09 , richard noel fell wrote: > [..] > > sub create_menu_bar > > { > > my $mb = $MW->Menu(); > > $MW->configure(-menu=>$mb); > > opendir DIR, "./" or die " cannot open current directory: $!"; > > my $current_directory = cwd; > >my @directories = grep { !/^\.\.?$/ && -d "$current_directory/$_" } > > readdir DIR; > > map {$mb->cascade(-label => '~'.$_, -menuitems=>\&sub_menu($_))} > > @directories; > > sub sub_menu > > { > > chdir "$_[0]" or die "Cannot change directory: $!"; # change to > > Algebra1 sub-directory, then Algebra2, etc. > > opendir SUB_DIR, "./" or die " cannot open current directory: $!"; > > my $current_sub_directory = cwd; > > my @sub_directories = grep { !/^\.\.?$/ && -d > > "$current_sub_directory/$_" } readdir SUB_DIR; > >map {[ 'cascade', '~'.$_]} @sub_directories; > >} > > } > > creative use of a sub directory > > from the perldoc -f map > > I normally think of 'map' being used in the form > > my %retHash = map {[ 'cascade', '~'.$_]} @sub_directories; > > at which point I would simply return the Hash > > %retHash ; > > my other concern is with > > map {$mb->cascade(-label => '~'.$_, -menuitems=>\&sub_menu($_))} > @directories; > > wouldn't that be simpler to write as say > > $mb->cascade(-label => '~'.$_, -menuitems=>\&sub_menu($_)) > foreach (@directories); > > without using the 'map' processeing around it??? > > ciao > drieux > > --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: use of $_
on Thu, 18 Apr 2002 13:26:21 GMT, [EMAIL PROTECTED] (Gary Stainburn) wrote: > [..] > while this one, using $_ instead of $line fails stating once per line > before the break that I'm using an uninitialised variable on the > 'while' line > > __BEGIN__ > print while (shift @HTML)!~/^
Re: Studying & Source Code
From: "Anthony Beaman" <[EMAIL PROTECTED]> > How's the best way to get the most out of studying and studying source > code? I'm always reading that looking at source code (and coding in > general) is the best way to learn to program. You should not just look at the code. You should play with it. - "Hey, what's this? How's that working?" - "Let's add some prints into it so that I can see how it changes the data and where it goes through." - "Let's see what will it do if I change this or that." - "Aha, so I can do this ... could I also do that?" > I'm taking stuff of the > net and going through it and trying to make sure I can "read" it and > trying to see what it does. Is this the correct method? Don't only try to see WHAT it does. Dissect the pieces that look unfamiliar to you, try that concept in other contexts, try to see WHY it does what it does. > Right now, I'm reading and doing the exercises from Learning > Perl for Win32. Then, I review what I've learned in the past by > writing practice exercises which make use of whatever I'm focusing on > (ex., control statements, arrays, etc.). These are similar to > technical exercises that a musician does and I'm doing because I'm in > the learning stages of the language. Oh how I hated technical exercises when I played the flute as a boy. But they are needed in programming as well as in music :-( Though here I would recommend you to add some improvisation. Do not only implement exactly what you were told to. Try to add features, try to change the task description a little and see how does that affect the implementations. And always ... do not take that as a work. You are playing a game, the best game there is. (But don't get addicted. You wouldn't want to end up like me, would you? ;-) > I then try to study code but it's > usually beyond me. I feel frustrated at times because I'm putting in > the time (2-3 hours daily) but I feel like I'm inefficient and that > others would get more out of my sessions than me. Any advice? Thanks! I can assure you everybody felt that way. For me it was not that much with Perl since I knew other languages before so most of the features of Perl were old friends in different dress, but I assure you I DID feel that way. After some time the things will start to fall into place. Jenda === [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Studying & Source Code
> How's the best way to get the most out of studying and > studying source code? I'm always reading that looking > at source code (and coding in general) is the best way > to learn to program. The best way is to join a programming project, and learn the required aspects of the language you need to do part of the project. Studying other peoples Perl code is probably a Bad Thing, since Perl doesn't enforce any style, design, efficency or robustness on the programmer. If you don't feel quite ready to attemp a programming project with others, try using Perl for something smaller. An example might be to try CGI scripting for your homepage, using the free cgi-bin directories some ISPs offer. Try doing things with a purpose, you'll enjoy it far more that way. Programming until 3 am doesn't sound enjoyable until you know what it's like to be engrossed in a project, being "almost finished/debugged" :) > I'm taking stuff of the net and going through it and > trying to make sure I can "read" it and trying > to see what it does. Is this the correct method? Not in my opinion. As above, many perl scripts available I wouldn't want to touch with a barge pole. > Then, I review what I've learned in the past by writing > practice exercises which make use of whatever I'm focusing > on (ex., control statements, arrays, etc.). Good. Learn how to use 'perldoc'. > These are similar to technical exercises that a musician > does and I'm doing because I'm in the learning stages of > the language. Keep perl REALLY close. > I then try to study code but it's usually beyond me. Don't, not yet. Learn to study code by practice, only ONCE you understand the language. E.g. this is a construct you might come across, and is one of my favourites: my %stuff = { 'first' => \&first, 'second' => \&second }; $stuff{$item}->(@_); It is simple, yet complicated if you don't understand the Perl way of doing things - and it's operators. > I feel frustrated at times because I'm putting in the time > (2-3 hours daily) but I feel like I'm inefficient and that > others would get more out of my sessions than me. I got paid to learn, as a summer student. I also felt bad because I spent so much time learning, not producing. The effort required to learn a subsequent language, or a module of Perl will be must less over time - and your efforts start to really pay off. 2-3 hours isn't much at a keyboard, but far too long with a book. IMHO. Anyway, keep at it! 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]
Re: how to return an array reference from a subroutine
on Thu, 18 Apr 2002 12:56:43 GMT, [EMAIL PROTECTED] (Richard Noel Fell) wrote: > However, I do not understand your > comments about the return value of map. Does not map return a > reference to an anonymous arrar, not a hash? 'map' returns a *list*. This list can be coerced into an array or into a hash (if it has an even number of elements). It's the same as literal list assigment; you can both do: @array = (1,2,3,4); %hash = (1,2,3,4); Also @array = (1,2,3); But not (gives an 'Odd number of elements in hash assignment' error): %hash = (1,2,3); But remember: map never returns a reference! See perldoc -f map for the details. -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how to return an array reference from a subroutine
Felix - Thanks for the very clear explanation. Dick Felix Geerinckx wrote: > > on Thu, 18 Apr 2002 12:56:43 GMT, [EMAIL PROTECTED] (Richard Noel Fell) > wrote: > > > However, I do not understand your > > comments about the return value of map. Does not map return a > > reference to an anonymous arrar, not a hash? > > 'map' returns a *list*. This list can be coerced into an array or into a > hash (if it has an even number of elements). It's the same as literal > list assigment; you can both do: > > @array = (1,2,3,4); > %hash = (1,2,3,4); > > Also > > @array = (1,2,3); > > But not (gives an 'Odd number of elements in hash assignment' error): > > %hash = (1,2,3); > > But remember: map never returns a reference! See > > perldoc -f map > > for the details. > > -- > felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: use of $_
On Thursday 18 April 2002 1:52 pm, Felix Geerinckx wrote: > on Thu, 18 Apr 2002 13:26:21 GMT, [EMAIL PROTECTED] (Gary > > Stainburn) wrote: > > [..] > > while this one, using $_ instead of $line fails stating once per line > > before the break that I'm using an uninitialised variable on the > > 'while' line > > > > __BEGIN__ > > print while (shift @HTML)!~/^
Re: Studying & Source Code
on Thu, 18 Apr 2002 13:01:39 GMT, [EMAIL PROTECTED] (Jonathan e. paton) wrote: > Studying other peoples Perl code is probably a Bad Thing, > since Perl doesn't enforce any style, design, efficency > or robustness on the programmer. > [...] > Not in my opinion. As above, many perl scripts available > I wouldn't want to touch with a barge pole. But don't generalize this to *all* code. E.g., I learned a hell of a lot from the Perl Cookbook, which is full of useful and well-written example code. I guess you'll have to find sources you can 'trust'. Another great way to learn, imho, is to follow the news groups and mailing lists (like this one). When someone asks a question, *first* try to find an answer yourself, *then* look at the answers of the other posters. -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: use of $_
on Thu, 18 Apr 2002 14:09:57 GMT, [EMAIL PROTECTED] (Gary Stainburn) wrote: > While your answer makes sense, why doesn't shift use the $_ as I > obviously expected? If you perldoc perlvar and look for the description of '$_', you will see where it is 'assumed'. To complicate matters, the 'shift' operator has it's own default argument, which is '@_', since 'shift' needs an array as parameter. -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Perl simple array
$d = 'test1,test2,test3,test4'; @data = split(/,/, $d); print $data[1]; -Original Message- From: Daniel Falkenberg [mailto:[EMAIL PROTECTED]] Sent: Wednesday, April 17, 2002 9:54 PM To: [EMAIL PROTECTED] Subject: Perl simple array Hey All, Just wondering why the following code won't print anything at all. @data = "test1,test2,test3,test4"; @data = split(/,/); print $data[1]; Will not print anything... Any ideas? Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: how to return an array reference from a subroutine
> But, the script below does not work. I get an error message : > Not an ARRAY reference at > /usr/local/ActivePerl-5.6/lib/site_perl/5.6.1/i686-linux-threa > d-multi/Tk/Menu.pm > line 69. The cause of this is the subroutine sub_menu. As I > understand things, the argument to -menuitems must be a > reference to an anonymous array. Am I correct? Is there a way > of getting sub_menu to return such a value or is there > another way to do this? To return a reference to an array, use: return \@array; HTH, -dave -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to thread in Perl?
On Wed, 2002-04-17 at 19:06, Ahmed Moustafa wrote: > > You are better off trying > > > > $SIG{CHLD} = 'IGNORE'; > > > > at the top of your program and seeing if zombies are left out there. If > > so then you might want to use pop or shift like this > > > > waitpid shift @children while @children; > > Do I really need to hold the pid's of the kids process somewhere? > Can't I do something like that my $forked = fork; waitpid $forked, > &WNOHANG;? > What do you think? > > Thanks, > > Ahmed I am not an expert WNOHANG which means to return immediately if no child has exited. This says to me that wait returns (after doing nothing) if it cannot find a child to reap. If I remember your application correctly you may want to add a "wait &WNOHANG;" to your main loop removing the PIDs it returns from your array (which might be better implemented as a hash now) like this: until ($terminate) { #main loop #do stuff that forks off children and stores #their PIDs in %running my $child = wait &WNOHANG; if ($child != -1) { #child just got reaped #$running{PID} should == 1 if the PID is really a child unless (delete $running{$child}) { die "reaped a process I didn't know about"; } } } #the main loop has exited, so we should check to see if there are #any unreaped children waitpid $_ for keys %running; -- Today is Pungenday the 35th day of Discord in the YOLD 3168 Hail Eris! Missile Address: 33:48:3.521N 84:23:34.786W -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: about formal sub routine declartions
On Wed, 2002-04-17 at 20:25, drieux wrote: > > I just found this in the perldoc > > " Currently Perl subroutines have fairly limited > support for formal parameter lists. You can specify the > number of parameters and their type, but you still have to > manually take them out of the `@_' array yourself. Write a > source filter that allows you to have a named parameter > list. Such a filter would turn this: > > sub MySub ($first, $second, @rest) { ... } > > into this: > > sub MySub($$@) { >my ($first) = shift ; >my ($second) = shift ; >my (@rest) = @_ ; >... > } > " > > does this still make sense? > > does it improve the compiled object any? > > and why not > > sub MySub($$@) { > my( $first, $second, @rest ) = @_; > ... > } > > > > > ciao > drieux The use of shift instead of () = @_ is mainly a style issue; however, there is one important difference: when you call a subroutine like this &subname -- note the lack of parenthesis -- the @_ variable gets passed into it. Shift removes elements from @_ so they don't trickle down. As for formal parameters in Perl 5.x, they come with massive caveats: only take effect if the sub is declared before it is seen in code, if you say &subname() then the parameter definitions are ignored, the parameter check is only done at compile time so it is useless for OO code, and a pack of other warnings. I really hope they straighten out this mess for Perl 6 (from what I have been reading it looks like they have). -- Today is Pungenday the 35th day of Discord in the YOLD 3168 Missile Address: 33:48:3.521N 84:23:34.786W -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Studying & Source Code
On Thursday, April 18, 2002, at 05:35 , Anthony Beaman wrote: [..] > I then try to study code but it's usually beyond me. [..] always remember perldoc -m will let you skim through the module completely - POD/Code/Comments. the three responses I have seen from Felix, Jonathan and Jenda each covers their strengths in their area - So the simpler rules are: 1) play with the beginner's list questions any solution posited - should be challenged by you in the privacy of your own code space - if it 'works' know WHY it works. eg: so WriterFoo posited X - what if I do Y to it if You Can't Blow It Up - you are just not trying. 2) look at the questions being raised here see how you would solve that problem - and why, as well as which specific clues in the perldoc are more relevant to your solution. 3) become a friend of 'use Benchmark;' - so that you do not fall prey to the 'popular myths' - establish the standard that you will use for your own analysis. BENCHMARK IT! PROVE IT! IF there Ain't Smoke, you clearly could lean on it harder... 4) have a 'coding buddy' - someone who will be willing to do code reviews with you - and run the 'idiot drills' - if you can not explain what it does - in the comments/POD - then rework it. { did I mention - Benchmark it for you to verify that the 'make test' part works as advertised } TRUST NO ONE! Trust ONLY the Code that you have validated yourself. Now, assuming that you are interested in this as a profession, try to establish your own professional standards. Most PerlMongers do this because of our unresolved childhood issues and other forms of obsessive compulsive disorders. We are beyond repair or rescue. You may be able to learn from our mutant mistakes. Hence a) get a life - understand the difference between you and the code that you hack. Be ready to kill off any code that you have hacked if you find a better way. It is not You, You are Not Your Code. b) don't code till Oh Dark Squat - remember your higher order analytics fail first - hence if you think that is a bright idea - it will still be a bright idea in the light of day - IF it is a bright idea. If as many of us have learned the hard way - it looks like the stack of old pizza boxes, munchies, and other bio-hazards in your coding place - RUN AWAY FROM IT! c) learn to forget. Merely because you have figured out as I did yesterday - the difference between my, our, local - if this does not change your core rules on how you manage memory allocation by variables - note why the tricks work and then forget them, and stick to your guns. d) write some "cute" code - forget to document it - and come back in a year or two and try to figure out what in god's green earth it does and/or why ever did you write it. this will teach you to eschew all 'cute code' that you do not document appropriately - since it is better that you plan to have this experience, than that your production code comes back to BITE YOU. e) eat real food regularly. f) exercise daily g) change your socks and underwear. h) My God Man get that BioHazard out of your Coding Place any questions? ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Studying & Source Code
Play with it. The more you play the better you will get, (just not too much or you'll go blind). Good books are: Perl by Example (the Example books are an excellent place to START) Perl in a Nutshell Also it takes time. You will not learn everything in 24 hours like some books advertise. PKE -Original Message- From: Anthony Beaman [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 18, 2002 7:36 AM To: [EMAIL PROTECTED] Subject: Studying & Source Code How's the best way to get the most out of studying and studying source code? I'm always reading that looking at source code (and coding in general) is the best way to learn to program. I'm taking stuff of the net and going through it and trying to make sure I can "read" it and trying to see what it does. Is this the correct method? Any advice on how to get the most out of this and studying/practicing/learning a language? Right now, I'm reading and doing the exercises from Learning Perl for Win32. Then, I review what I've learned in the past by writing practice exercises which make use of whatever I'm focusing on (ex., control statements, arrays, etc.). These are similar to technical exercises that a musician does and I'm doing because I'm in the learning stages of the language. I then try to study code but it's usually beyond me. I feel frustrated at times because I'm putting in the time (2-3 hours daily) but I feel like I'm inefficient and that others would get more out of my sessions than me. Any advice? Thanks! -- 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]
Incrementing the letters in an array
Hi, I have an array which contains letters. I need to increment these letters in the array one at a time. For example going from B to C. I was trying something like $array[$x]++; however that increments the letter to the number 1. Does anyone have any ideas? Thanks in advance. Allison -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Incrementing the letters in an array
Must be missing something. Here is simple code and increments the current letter the next: my $x = 'E'; $x++; my @array = (); $array[0] = 'G'; $array[0]++; printf "%-s %-s\n", $x, $array[0]; Output: F H Wags ;) -Original Message- From: Allison Ogle [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 18, 2002 09:05 To: a a Subject: Incrementing the letters in an array Hi, I have an array which contains letters. I need to increment these letters in the array one at a time. For example going from B to C. I was trying something like $array[$x]++; however that increments the letter to the number 1. Does anyone have any ideas? Thanks in advance. Allison -- 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: Incrementing the letters in an array
This works: use warnings; use strict; my @letters = qw( A B C D ); for (my $n = 0; $n < 4; $n++){ $letters[$n]++; } print "@letters\n"; > -Original Message- > From: Allison Ogle [mailto:[EMAIL PROTECTED]] > Sent: Thursday, April 18, 2002 12:05 PM > To: a a > Subject: Incrementing the letters in an array > > > Hi, > > I have an array which contains letters. I need to increment > these letters > in the array one at a time. For example going from B to C. > I was trying > something like > > $array[$x]++; > > however that increments the letter to the number 1. Does > anyone have any > ideas? Thanks in advance. > > Allison > > > -- > 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: Incrementing the letters in an array
Are you looking for something like this? $array[$x++]; #Moves to the next element in the array -Original Message- From: Allison Ogle [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 18, 2002 9:05 AM To: a a Subject: Incrementing the letters in an array Hi, I have an array which contains letters. I need to increment these letters in the array one at a time. For example going from B to C. I was trying something like $array[$x]++; however that increments the letter to the number 1. Does anyone have any ideas? Thanks in advance. Allison -- 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: Incrementing the letters in an array
Oh, wait. I misread that. Are you sure the array contains letters? Usually an array will return 1 for an increment when the previous value was '', 0, or undef. -Original Message- From: Timothy Johnson [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 18, 2002 9:15 AM To: 'Allison Ogle'; a a Subject: RE: Incrementing the letters in an array Are you looking for something like this? $array[$x++]; #Moves to the next element in the array -Original Message- From: Allison Ogle [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 18, 2002 9:05 AM To: a a Subject: Incrementing the letters in an array Hi, I have an array which contains letters. I need to increment these letters in the array one at a time. For example going from B to C. I was trying something like $array[$x]++; however that increments the letter to the number 1. Does anyone have any ideas? Thanks in advance. Allison -- 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]
Fwd: Incrementing the letters in an array
> On Thursday, April 18, 2002, at 09:04 , Allison Ogle wrote: > >> Hi, >> >> I have an array which contains letters. I need to increment these >> letters >> in the array one at a time. For example going from B to C. I was trying >> something like >> >> $array[$x]++; > > did you check that you were still 'in bounds'? > > [jeeves:/tmp/drieux/perl] drieux% perl prin* > Letters are now a b c d e f g h i j k l m n o p > Letters are now b c d e f g h i j k l m n o p q > Letters are now b c d e f g h i j k l m n o p q 1 > [jeeves:/tmp/drieux/perl] drieux% > > was generated using: >#!/usr/bin/perl -w >use strict; >my @array = qw/ a b c d e f g h i j k l m n o p /; > >my $len = $#array ; > >print "Letters are now @array \n"; >my $x = 0; >while( $x <= $len ) { > $array[$x]++; > $x++; >} > >print "Letters are now @array \n"; >$array[$x]++; > > print "Letters are now @array \n"; > > > notice how when I 'increment beyond the length of the > actual array - I start with the 'uninitialized' value > of '0' and increment to 1.. > > hence either your $x is out of bounds, or your @array > was actually nulled out at some point? ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: about formal sub routine declartions
On Thursday, April 18, 2002, at 07:54 , Chas Owens wrote: [..] p0: thanks for the clarification on the @_; since my coding with that - like my habits with subs in general is based not upon any sense of 'understanding or knowledge' - but based solely upon a) ripped that off from someone b) it worked for me c) no observed dilitorious side effects Hence, ok, to be honest I may have started with sub fooBar { my ($val1, $val2 ) = @_; } and then 'extend that function' later on with say sub fooBar { my ( $val1, $val2, $val3 ) = @_; . } and if done right only the 'new ones' who actually pass in a 3rd variable get any of the 'value' of that... the ones passing in 2 args see no difference... but I am still working on whether I 'like' this 'feature'. > As for formal parameters in Perl 5.x, they come with massive caveats: > only take effect if the sub is declared before it is seen in code, if > you say &subname() then the parameter definitions are ignored, the > parameter check is only done at compile time so it is useless for OO > code, and a pack of other warnings. I really hope they straighten out > this mess for Perl 6 (from what I have been reading it looks like they > have). p1: which I guess is my other question - here, I grew under the tutelage of the use vars qw//; use subs qw//; . # some subs # the main loop and the idea of doing some form of 'predeclaration' with formal arguments would not seem an enhancement unless I really got the correct sort of compile time optimization So my summary seems to be: Neat idea - may get cleaned up in perl6 back in line behind my Seth and not to go there ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Win32API::Time - setting the system clock
Hi folks, Anyone know where to get hold of the module Win32API::Time ?? It's listed on ASPN but doesn't seem to be available through ppm or the obvious download lists. If there are any other suggestions for setting the system clock via a perl script I would be greatful. Thanks, Craig :) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: about formal sub routine declartions
On Thu, 2002-04-18 at 13:22, drieux wrote: > So my summary seems to be: > > Neat idea - may get cleaned up in perl6 > back in line behind my Seth and not to go there That is pretty much the long and short of it. I wouldn't recommend using prototypes unless you meet these three criteria: 1. You don't do OO 2. All of your subs are included from modules 3. You want to do nifty stuff like "my_push @a1 @a2" instead of "my_push \@a1 @a2". In general I think prototypes are were an interesting experiment that taught Larry et al some valuable lessons. I have lots of hope that Perl 6 will fix the problems (and not introduce new ones). -- Today is Pungenday the 35th day of Discord in the YOLD 3168 Frink! Missile Address: 33:48:3.521N 84:23:34.786W -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Incrementing the letters in an array
Maybe it is because I am assigning my array to a line from another document and not assigning letters dirtectly to the array because it still doesn't work. It could be there is something wrong with my code too. $word=; #where is the filehandle and therefore $word gets the string from the inputfile. Something like ABCD for example chomp $word; @code = split //,$word; #this assigns thestring to the array @code. The values stored in @code are now A B C D $y=0; if($code[$y] ne "F"){ print "$code[$y]\n"; $code[$y]=$code[$y]+1; print "$code[$y]\n";} This prints A and then 1. I can't figure out why. Is there something wrong with my coding? Thanks for the help so far. Allison -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
string reading 5-4
Hi How can I read a string 5 - 4 and get 1? thanks Pierre _ 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]
RE: Incrementing the letters in an array
No, you need ++ vs +1. As they say in perl, ++ is magical and will do want you want. + 1 will not. Wags ;) ps -- is not magical in the same sense as ++ either. -Original Message- From: Allison Ogle [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 18, 2002 10:58 To: a a Subject: Incrementing the letters in an array Maybe it is because I am assigning my array to a line from another document and not assigning letters dirtectly to the array because it still doesn't work. It could be there is something wrong with my code too. $word=; #where is the filehandle and therefore $word gets the string from the inputfile. Something like ABCD for example chomp $word; @code = split //,$word; #this assigns thestring to the array @code. The values stored in @code are now A B C D $y=0; if($code[$y] ne "F"){ print "$code[$y]\n"; $code[$y]=$code[$y]+1; print "$code[$y]\n";} This prints A and then 1. I can't figure out why. Is there something wrong with my coding? Thanks for the help so far. Allison -- 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: how to return an array reference from a subroutine
On Thursday, April 18, 2002, at 06:05 , Felix Geerinckx wrote: > on Thu, 18 Apr 2002 12:56:43 GMT, [EMAIL PROTECTED] (Richard Noel Fell) > wrote: > >> However, I do not understand your >> comments about the return value of map. Does not map return a >> reference to an anonymous arrar, not a hash? > > 'map' returns a *list*. hence map {[ 'cascade', '~'.$_]} @sub_directories; as the last line of the sub should have returned a 'list' back to the caller just as the sub foo { qw/ 1 2 3 4 5 6 7 8 9 / } ; would return a 'list' ??? or should he have coerced it foist: @array = map {[ 'cascade', '~'.$_]} @sub_directories; @array ; # our default return } # end of this function ( ? ) > This list can be coerced into an array or into a > hash (if it has an even number of elements). It's the same as literal > list assigment; you can both do: > > @array = (1,2,3,4); > %hash = (1,2,3,4); > > Also > > @array = (1,2,3); > > But not (gives an 'Odd number of elements in hash assignment' error): > > %hash = (1,2,3); > good Point! I guess I have always seen map, when used with has in the classic form %hash = map { doFooFunk($_) => $_ } @array; and have never seen it in the form of @chars = map(chr, @nums); so had never paused to 'think it through'. ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Incrementing the letters in an array
You are right, $code[$y]=$code[$y]++; shouldn't work, since it increments after the assignment. $code[$y]++; works for me, as does $code[$y]=++$code[$y]; This code: @code = split //,"ABCD"; #values stored in @code are now A B C D $y=0; if($code[$y] ne "F"){ print "$code[$y]\n"; $code[$y]++; print "$code[$y]\n"; $code[$y]=++$code[$y]; print "$code[$y]\n"; } prints: A B C on my machine. I apologize for being cryptic in my initial response and not looking deep enough at your code. /\/\ark -Original Message- From: Allison Ogle [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 18, 2002 11:05 AM To: Mark Anderson Subject: RE: Incrementing the letters in an array If you're suggesting trying $code[$y]=$code[$y]++; it brings me one step closer in that it prints A A rather than A 1 but it still doesn't increment. Unless you are suggesting something else. $code[$y]++; doesn't work either. -Original Message- From: Mark Anderson [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 18, 2002 1:59 PM To: Allison Ogle Subject: RE: Incrementing the letters in an array I believe that the problem is your +1 should be ++. /\/\ark -Original Message- From: Allison Ogle [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 18, 2002 10:58 AM To: a a Subject: Incrementing the letters in an array Maybe it is because I am assigning my array to a line from another document and not assigning letters dirtectly to the array because it still doesn't work. It could be there is something wrong with my code too. $word=; #where is the filehandle and therefore $word gets the string from the inputfile. Something like ABCD for example chomp $word; @code = split //,$word; #this assigns thestring to the array @code. The values stored in @code are now A B C D $y=0; if($code[$y] ne "F"){ print "$code[$y]\n"; $code[$y]=$code[$y]+1; print "$code[$y]\n";} This prints A and then 1. I can't figure out why. Is there something wrong with my coding? Thanks for the help so far. Allison -- 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: Incrementing the letters in an array
Adding one and incrementing are different. You're adding 1. Did you try incrementing the character? Instead of this: $code[$y]=$code[$y]+1; try ($code[$y])++; #!/usr/bin/perl @code = qw( A B C D ); $y = 0; if( $code[$y] ne "F" ){ print "$code[$y]\n"; ($code[$y])++; print "$code[$y]\n"; } prints A then B... -Original Message- From: Allison Ogle [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 18, 2002 10:58 AM To: a a Subject: Incrementing the letters in an array Maybe it is because I am assigning my array to a line from another document and not assigning letters dirtectly to the array because it still doesn't work. It could be there is something wrong with my code too. $word=; #where is the filehandle and therefore $word gets the string from the inputfile. Something like ABCD for example chomp $word; @code = split //,$word; #this assigns thestring to the array @code. The values stored in @code are now A B C D $y=0; if($code[$y] ne "F"){ print "$code[$y]\n"; $code[$y]=$code[$y]+1; print "$code[$y]\n";} This prints A and then 1. I can't figure out why. Is there something wrong with my coding? Thanks for the help so far. Allison -- 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: Writing formatted results to a file
Hi Bob, I am having trouble writing another new format into the same file as the one I mentioned in the previous email. I executed the following code and it prints out the SUMMARY format but NOT the SUMMARY1 format into the same file. Any ideas ? Thanks in advance Tony The code is as follows : sub create_summary_report { my (@record, @record_processed, $element, $rows_copied, $rows_processed, $line_output, $oldhandle); @record = qw(A B C D); @record_processed = qw(ACCOUNT); $rows_copied= "rows copied"; $rows_processed = "rows_processed"; $element = 0; open SUMMARYTMP, "<$bcp_file_directory$reports_file_summary_tmp" or die "Unable to open $reports_file_summary_tmp for reading: $!\n"; open SUMMARY, ">$reports_directory$reports_file_summary_final" or die "Unable to open $reports_file_summary_final for writing: $!\n"; print SUMMARY "Extraction Summary Details\n"; print SUMMARY "--\n"; print SUMMARY "Server: $server\n"; print SUMMARY "Database : $db\n"; print SUMMARY "User : $user\n"; print SUMMARY "Account (From): $fromAccount\n"; print SUMMARY "Account (To) : $toAccount\n"; print SUMMARY "Start Time: $start_time\n"; print SUMMARY "End Time : $end_time\n\n\n"; print SUMMARY "Record (Bulk Copied)\n"; print SUMMARY "--\n"; while() { chop; $line_output = $_; if ($line_output =~ /\b$rows_copied\b/) { write(SUMMARY); $element = $element + 1; } } $element = 0; print SUMMARY "\n\nRecord (Processed)\n"; print SUMMARY "\n"; while() { chop; $line_output = $_; print "$line_output\n"; if ($line_output =~ /\b$rows_processed\b/) { $oldhandle = select(SUMMARY); $~ = "SUMMARY1"; select($oldhandle); write(SUMMARY); $element = $element + 1; } } close SUMMARYTMP or die "Error closing $reports_file_summary_tmp"; close SUMMARY or die "Error closing $reports_file_summary_final"; format SUMMARY = @<<<: @<<< $record[$element], $line_output .. format SUMMARY1 = @<<<: @<<< $record_processed[$element], $line_output .. } -Original Message- From: bob ackerman [mailto:[EMAIL PROTECTED]] Sent: 16 April 2002 19:36 To: [EMAIL PROTECTED] Subject: Re: Writing formatted results to a file On Tuesday, April 16, 2002, at 10:11 AM, Ho, Tony wrote: > Hi guys > I was wondering if you could help me. > Does anybody know how to write formatted results to a file ? > > I am getting the following error : > > write() on closed filehandle main::ADDRESSLABEL at ./test.pl line 2785, > line 5. > write() on closed filehandle main::ADDRESSLABEL at ./test.pl line 2785, > line 15. > write() on closed filehandle main::ADDRESSLABEL at ./test.pl line 2785, > line 21. > > This is the section of my perl code reads results from an BCP output file > and is as follows : > > sub create_summary_report > { > my (@record, $element, $rows_copied, $line_output); > @record = qw(A B C); > $rows_copied = "rows copied"; > $element = 0; > > open SUMMARYTMP, "<$bcp_file_directory$log_file_summary_tmp" > or die "Unable to open $log_file_summary_tmp for reading: $!\n" > ; > > open SUMMARY, ">$log_directory$log_file_summary_final" > or die "Unable to open $log_file_summary_final for writing: > $!\n"; > > print SUMMARY "Summary Details\n"; > print SUMMARY "--\n"; > print SUMMARY "Account (From) : $fromAccount\n"; > print SUMMARY "Account (To) : $toAccount\n\n\n"; > print SUMMARY "Record Types\n"; > print SUMMARY "\n"; > > format ADDRESSLABEL = > @<, @< > $record[$element], $line_output > .. > > while() { > chop; > $line_output = $_; > if ($line_output =~ /\b$rows_copied\b/) { > print SUMMARY write(ADDRESSLABEL); > $element = $element + 1; > } > } > in addition you need to quote the format label when assigning: $~ = 'ADDRESSLABEL'; > close SUMMARYTMP > or die "Error closing $log_file_summary_tmp"; > > close SUMMARY > or die "Error closing $log_file_summary_final"; > } > > I would be most grateful with any advice. > > Thanks in advance > Tony > -- 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: string reading 5-4
> How can I read a string 5 - 4 and get 1? Hallucinations may cause such strange errors. If the string is really "5 - 4", and you get "1" then your grey matter has failed. I suggest updating to a more reliable version ;) Oh, hang on... I know what you are talking about now! You want to evaluate the string "5 - 4", and the numerical result. This is an area frought with security issues, however this should be safe: my $string = "5 - 4"; die "Invalid characters in string" if $string !~ /^(\s|\d|[()\-\+\*\/])*$/; print eval $string; --- you'll need to modify it if you need taint mode. This is restrictive for a reason, don't blindly use eval without thinking first. 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]
Re: how to return an array reference from a subroutine
on Thu, 18 Apr 2002 18:07:38 GMT, Drieux wrote: > hence > > map {[ 'cascade', '~'.$_]} @sub_directories; > > as the last line of the sub should have returned a 'list' > back to the caller just as the > > sub foo { qw/ 1 2 3 4 5 6 7 8 9 / } ; > > would return a 'list' ??? Yes > > or should he have coerced it foist: > > @array = map {[ 'cascade', '~'.$_]} @sub_directories; > > @array ; # our default return > > } # end of this function > > ( ? ) No, this is not necessary. Personally, however, I prefer an explicit 'return' statement, as in return map { ($_ => 1) }, @array; (The () are optional). -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Writing formatted results to a file - PLEASE IGNORE PREVIOUS EMAIL
Hi guys I managed to resolve the issue regarding the previous issue. First problem - $rows_processed = "rows_processed"; should be : $rows_processed = "rows processed"; After the first WHILE loop, I added a close and open (in this order) of SUMMARYTMP and it worked. Thanks again for the help. Tony -Original Message- From: Ho, Tony Sent: 18 April 2002 20:12 To: 'bob ackerman'; [EMAIL PROTECTED] Subject: RE: Writing formatted results to a file Hi Bob, I am having trouble writing another new format into the same file as the one I mentioned in the previous email. I executed the following code and it prints out the SUMMARY format but NOT the SUMMARY1 format into the same file. Any ideas ? Thanks in advance Tony The code is as follows : sub create_summary_report { my (@record, @record_processed, $element, $rows_copied, $rows_processed, $line_output, $oldhandle); @record = qw(A B C D); @record_processed = qw(ACCOUNT); $rows_copied= "rows copied"; $rows_processed = "rows_processed"; $element = 0; open SUMMARYTMP, "<$bcp_file_directory$reports_file_summary_tmp" or die "Unable to open $reports_file_summary_tmp for reading: $!\n"; open SUMMARY, ">$reports_directory$reports_file_summary_final" or die "Unable to open $reports_file_summary_final for writing: $!\n"; print SUMMARY "Extraction Summary Details\n"; print SUMMARY "--\n"; print SUMMARY "Server: $server\n"; print SUMMARY "Database : $db\n"; print SUMMARY "User : $user\n"; print SUMMARY "Account (From): $fromAccount\n"; print SUMMARY "Account (To) : $toAccount\n"; print SUMMARY "Start Time: $start_time\n"; print SUMMARY "End Time : $end_time\n\n\n"; print SUMMARY "Record (Bulk Copied)\n"; print SUMMARY "--\n"; while() { chop; $line_output = $_; if ($line_output =~ /\b$rows_copied\b/) { write(SUMMARY); $element = $element + 1; } } $element = 0; print SUMMARY "\n\nRecord (Processed)\n"; print SUMMARY "\n"; while() { chop; $line_output = $_; print "$line_output\n"; if ($line_output =~ /\b$rows_processed\b/) { $oldhandle = select(SUMMARY); $~ = "SUMMARY1"; select($oldhandle); write(SUMMARY); $element = $element + 1; } } close SUMMARYTMP or die "Error closing $reports_file_summary_tmp"; close SUMMARY or die "Error closing $reports_file_summary_final"; format SUMMARY = @<<<: @<<< $record[$element], $line_output .. format SUMMARY1 = @<<<: @<<< $record_processed[$element], $line_output .. } -Original Message- From: bob ackerman [mailto:[EMAIL PROTECTED]] Sent: 16 April 2002 19:36 To: [EMAIL PROTECTED] Subject: Re: Writing formatted results to a file On Tuesday, April 16, 2002, at 10:11 AM, Ho, Tony wrote: > Hi guys > I was wondering if you could help me. > Does anybody know how to write formatted results to a file ? > > I am getting the following error : > > write() on closed filehandle main::ADDRESSLABEL at ./test.pl line 2785, > line 5. > write() on closed filehandle main::ADDRESSLABEL at ./test.pl line 2785, > line 15. > write() on closed filehandle main::ADDRESSLABEL at ./test.pl line 2785, > line 21. > > This is the section of my perl code reads results from an BCP output file > and is as follows : > > sub create_summary_report > { > my (@record, $element, $rows_copied, $line_output); > @record = qw(A B C); > $rows_copied = "rows copied"; > $element = 0; > > open SUMMARYTMP, "<$bcp_file_directory$log_file_summary_tmp" > or die "Unable to open $log_file_summary_tmp for reading: $!\n" > ; > > open SUMMARY, ">$log_directory$log_file_summary_final" > or die "Unable to open $log_file_summary_final for writing: > $!\n"; > > print SUMMARY "Summary Details\n"; > print SUMMARY "--\n"; > print SUMMARY "Account (From) : $fromAccount\n"; > print SUMMARY "Account (To) : $toAccount\n\n\n"; > print SUMMARY "Record Types\n"; > print SUMMARY "\n"; > > format ADDRESSLABEL = > @<, @< > $record[$element], $line_output > .. > > while() { > chop; > $line_output = $_; > if ($line_output =~ /\b$rows_copied\b/) { > print SUMMARY write(ADDRESSLABEL); > $element = $element + 1; > } > } > in addition you need to quote the format label when assigning: $~ = 'ADDRESSLABEL'; > close SUMMARYTMP > or die "Error closing $log_file_s
Re: how to return an array reference from a subroutine
On Thursday, April 18, 2002, at 11:21 , Felix Geerinckx wrote: [..] > Personally, however, I prefer an explicit 'return' statement, as in > > return map { ($_ => 1) }, @array; > > (The () are optional). [..] Ok, I can go there... so my test code shows me [jeeves:~/tmp/perl/misc] drieux% perl perl MapMe.pl SUB: /tmp /usr/bin /bin Got me a :cascade ~/tmp: Got me a :cascade ~/usr/bin: Got me a :cascade ~/bin: [jeeves:~/tmp/perl/misc] drieux% #!/usr/bin/perl -w use strict; my @dir = qw! /tmp /usr/bin /bin !; sub doMe { my @themDir = @_; print "SUB: @themDir \n"; return map {[ 'cascade', '~'.$_]} @themDir; } # end doMe my @retList = doMe(@dir); print "Got me a :@{$_}: \n" foreach(@retList); The HARSH is that the 'map' is returning 'arrays references' in this case.. hence the fun of @{$_} otherwise it's the old Got me a :ARRAY(0x12798): Got me a :ARRAY(0x127c8): Got me a :ARRAY(0x127f8): so if one wanted that to return the 'list' of things rather than the list of references to the thing it should have been return map {( 'cascade', '~'.$_)} @themDir; using the () vice [ ] ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Funny character on a dir name.
Not necessarily a perl question. One of the users (on a Unix box) created a directory with a dash at the beginning of the name (no idea how he did it) and he needs to remove it. The name of the file is -testing is there a way to remove it using perl or other means. I removed it using the inode number of the directory. Is there another way? Regards Yanet -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Funny character on a dir name.
> "Yanet" == Yanet Leon, <[EMAIL PROTECTED]> writes: Yanet> Not necessarily a perl question. One of the users (on a Unix Yanet> box) created a directory with a dash at the beginning of the Yanet> name (no idea how he did it) and he needs to remove it. The Yanet> name of the file is -testing is there a way to remove it Yanet> using perl or other means. I removed it using the inode Yanet> number of the directory. Is there another way? Yup. rm -- -testing. If you read man rm, you'll see that '--' signifies the end of switches, so it knows whatever follows is a path to a file. But this really is very off-topic. :-) - Chris. -- $a="printf.net"; Chris Ball | chris@void.$a | www.$a | finger: chris@$a As to luck, there's the old miners' proverb: Gold is where you find it. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Funny character on a dir name.
> -Original Message- > From: Leon, Yanet I,,DMDCWEST [mailto:[EMAIL PROTECTED]] > Sent: Thursday, April 18, 2002 3:03 PM > To: [EMAIL PROTECTED] > Subject: Funny character on a dir name. > > > Not necessarily a perl question. One of the users (on a Unix > box) created a > directory with a dash at the beginning of the name (no idea > how he did it) > and he needs to remove it. The name of the file is -testing > is there a way > to remove it using perl or other means. I removed it using > the inode number > of the directory. Is there another way? > > Regards > > Yanet $ rmdir ./-testing or $ perl -e 'rmdir "-testing"' -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Funny character on a dir name.
On Thu, 2002-04-18 at 15:03, Leon, Yanet I,,DMDCWEST wrote: > Not necessarily a perl question. One of the users (on a Unix box) created a > directory with a dash at the beginning of the name (no idea how he did it) > and he needs to remove it. The name of the file is -testing is there a way > to remove it using perl or other means. I removed it using the inode number > of the directory. Is there another way? > > Regards > > Yanet > rmdir -- -testing The -- tells rmdir (and most other commands) to stop processing switches. -- Today is Pungenday the 35th day of Discord in the YOLD 3168 Kallisti! Missile Address: 33:48:3.521N 84:23:34.786W -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Funny character on a dir name.
Hello Try, from the command line rm ./ name_ of_ directory -Original Message- From: Leon, Yanet I,,DMDCWEST [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 18, 2002 12:03 PM To: [EMAIL PROTECTED] Subject: Funny character on a dir name. Not necessarily a perl question. One of the users (on a Unix box) created a directory with a dash at the beginning of the name (no idea how he did it) and he needs to remove it. The name of the file is -testing is there a way to remove it using perl or other means. I removed it using the inode number of the directory. Is there another way? Regards Yanet -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
this may be offtopic: Open Source web-based email package?
Hello, I'm looking for an open source web-based email package that will allow me to offer visitors free web-based email accounts (However, I don't want to have to setup system user accounts - as this would be a huge security risk). Any info/help is appreciated! = Anthony Ettinger [EMAIL PROTECTED] http://apwebdesign.com home: 415.504.8048 mobile: 415.385.0146 __ Do You Yahoo!? Yahoo! Tax Center - online filing with TurboTax http://taxes.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how to return an array reference from a subroutine
On Wednesday, April 17, 2002, at 02:09 , richard noel fell wrote: > sub create_menu_bar > { > my $mb = $MW->Menu(); > $MW->configure(-menu=>$mb); > opendir DIR, "./" or die " cannot open current directory: $!"; > my $current_directory = cwd; >my @directories = grep { !/^\.\.?$/ && -d "$current_directory/$_" } > readdir DIR; > map {$mb->cascade(-label => '~'.$_, -menuitems=>\&sub_menu($_))} > @directories; One of the problems I have is that I do not have the TK package and have had only a limited amount of time to do the CPAN read and heed on this, so the question seems to be down to the method 'cascade' and what it is expecting to have returned to it with the -menuitems. so if it is expecting to see the list qw/cascade , ~/foo , cascade, ~/bar , /; then map {( 'cascade', '~'.$_)} @sub_directories; would seem to be the right answer but it is not clear to me that -menuitems=>\&sub_menu($_) would actually 'invoke' the sub_menu function and 'fill in' what will be needed - rather that it sends the reference to the function to be invoked.. ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: this may be offtopic: Open Source web-based email package?
> I'm looking for an open source web-based email package > that will allow me to offer visitors free web-based > email accounts (However, I don't want to have to setup > system user accounts - as this would be a huge > security risk). Two PHP based solutions: www.squirrelmail.org www.horde.org/imp the latter is the heavier of the two. Jonathan Paton NB: Using google might have been more appropriate __ 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]
Re: Incrementing the letters in an array
Allison Ogle wrote: > > Maybe it is because I am assigning my array to a line from another document > and not assigning letters dirtectly to the array because it still doesn't > work. It could be there is something wrong with my code too. > > $word=; #where is the filehandle and therefore $word gets the > string from the inputfile. Something like ABCD for example > chomp $word; > @code = split //,$word; #this assigns thestring to the array @code. The > values stored in @code are now A B C D > $y=0; > if($code[$y] ne "F"){ > print "$code[$y]\n"; > $code[$y]=$code[$y]+1; > print "$code[$y]\n";} > > This prints A and then 1. I can't figure out why. Is there something wrong > with my coding? Thanks for the help so far. If you are trying to determine if 'F' is included in $word: chomp( my $word = ); if ( $word =~ tr/F// ) { # $word has the letter 'F' in it } If you want to increment the characters of $word: chomp( my $word = ); $word =~ s/(.)/++($a=$1)/eg; If you want to increment the characters of $word only if they are not equal to "F" chomp( my $word = ); $word =~ s/(.)/($a=$1)eq"F"?$1:++$a/eg; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: this may be offtopic: Open Source web-based email package?
http://turtle.ee.ncku.edu.tw/openwebmail/ This is by far the best one that I have seen, and it is even written in Perl! -James -Original Message- From: Anthony E. [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 18, 2002 12:36 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: this may be offtopic: Open Source web-based email package? Hello, I'm looking for an open source web-based email package that will allow me to offer visitors free web-based email accounts (However, I don't want to have to setup system user accounts - as this would be a huge security risk). Any info/help is appreciated! = Anthony Ettinger [EMAIL PROTECTED] http://apwebdesign.com home: 415.504.8048 mobile: 415.385.0146 __ Do You Yahoo!? Yahoo! Tax Center - online filing with TurboTax http://taxes.yahoo.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]
What Causes PerlMongering
volks, One of the question sets that I really wonder about at times reviewing some of the questions that come up here is how much of what folks are working on is due to a) not knowing what has already been done in Perl a la the CPAN b) other alternatives that exist in other open source solutions c) Wanting to just try to re-implement FOO to better understand what is really going on in FOO d) the documentation for FOO::BAR is not as clear as it could be. e) "I am not really a software developer, but I need to automate this little thing" and hence because perl is basically that simple - "why not?" - and it just grows from there... Hence how can we as PerlGeeks improve the overall process here? ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: What Causes PerlMongering
> a) not knowing what has already been done in Perl > a la the CPAN A lot of my early work would have been spared if I knew that CPAN had EVERYTHING close to perfect that I wrote badly. > > b) other alternatives that exist in other open source solutions Eh... I let someone else do it as often as possible > > c) Wanting to just try to re-implement FOO to better > understand what is really going on in FOO I come across this often. Most of the time it's someone else's script that needs to made better. This is about 60% of my work. > > d) the documentation for FOO::BAR is not as clear as it > could be. > Docs? I don't think Docs are the problem... it's COMMENTS! 20% of work is trying to figure out why/what/how someone did something when a comment would have helped alleviate that problem. > e) "I am not really a software developer, but I need to automate > this little thing" and hence > because perl is basically > that simple - "why not?" - and it just > grows from there... there goes the other 20% of my work. I am the PerlGuru at my company, (kinda sad). And all I do it write this and that for others most of the time, and then I maintain it, fix it, enhance it, etc... > > Hence how can we as PerlGeeks improve the overall process here? IMHO There should be a Perl "Let's get busy the smart way" Doc for really really basic crap like where things are and how to look for them. Documentation should be the first thing, where/how/why. Modules should be the second thing, where/how/why. External sources should be the third thing, maillists/FAQs/Books/etc. That would answer about 1-10 of the questions we see on this list everyday. 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: How to thread in Perl?
Chas, Thanks a lot! > #the main loop has exited, so we should check to see if there are > #any unreaped children > waitpid $_ for keys %running; My main loop is iterating forever i.e. a daemon; thus, any code after the main loop will not be executed. So, what do you think? Once again, thanks. Ahmed -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Incrementing the letters in an array
On Thu, 18 Apr 2002 [EMAIL PROTECTED] wrote: > No, you need ++ vs +1. As they say in perl, ++ is magical and will do want >you want. + 1 will not. > > Wags ;) ps -- is not magical in the same sense as ++ either. How would you decrement a character then? There surely has to be a way? Elias -- "There are people who don't like capitalism, and there are people who don't like PCs, but there's no one who likes the PC who doesn't like Microsoft." -- Bill Gates -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Incrementing the letters in an array
On Thursday, April 18, 2002, at 03:14 , Elias Assmann wrote: > On Thu, 18 Apr 2002 [EMAIL PROTECTED] wrote: >> No, you need ++ vs +1. As they say in perl, ++ is magical and will >> do want you want. + 1 will not. >> >> Wags ;) ps -- is not magical in the same sense as ++ either. > > How would you decrement a character then? There surely has to be a > way? perldoc -f ord perldoc -f chr my $len = $#array ; my $x = 0; $array[$x++] = chr( ord($array[$x]) - 1 ) while( $x <= $len ); ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to thread in Perl?
On Thursday, April 18, 2002, at 02:27 , Ahmed Moustafa wrote: > Chas, > > Thanks a lot! > >> #the main loop has exited, so we should check to see if there are >> #any unreaped children >> waitpid $_ for keys %running; > > My main loop is iterating forever i.e. a daemon; thus, any code after the > main loop will not be executed. So, what do you think? you might want to have your 'main loop' in our $still_going = 1; $SIG{TERM} = sub { $still_going = 0 }; # correcting Chas's Issues... 8-) while ( $still_going ) { # the main loop } # # now to close down gracefully # ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Incrementing the letters in an array
>>> No, you need ++ vs +1. As they say in perl, ++ is magical and will >>> do want you want. + 1 will not. >>> >>> Wags ;) ps -- is not magical in the same sense as ++ either. >> >> How would you decrement a character then? There surely has to be a >> way? > >perldoc -f ord >perldoc -f chr > > my $len = $#array ; > my $x = 0; > $array[$x++] = chr( ord($array[$x]) - 1 ) while( $x <= $len ); This decrements ever character in an array. The ++ is magical in that "a" increments to "b" and "z" increments to "aa". (ultimately leading to a cute little japh) Your solution takes "abcde" and returns "`abcd" which is not the opposite of the ++ operator. The chr(ord($char)-1) part makes sense and applied to "b" gives you "a" and "z" gives you "y", but "a" gives you "`" and it doesn't make sense for strings. To decrement a character you would have to define a boundary condition for the case of a single "a". Generally though, you just use substr to strip off the last character and replace it with it's decrement. If the last character is "a", then you strip off the second to last character, replace it with it's decrement and tack a 'z' onto the end. If you have a string of all 'a', then you eventually have to produce a string one character shorter of all 'z'. Ultimately you have to deal with your boundary condition (undef?). /\/\ark -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
TK madness
I'm trying to develop a user interface for a program I've written - What I need the program to do is print out the results of the current process to the TK interface. I absolutely can not figure out how to do a simple printing to TK function!@@!# For example, I would have a program that does something like: for (1 .. 10) { print "$_\n"; } Well, I need to print that into the canvas in TK. How the hell do I do this?! It seems like something so trivial, yet not even the Perl/TK tutorial talks about something as simple as this. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to check installed Modules in perl
On Wednesday, April 17, 2002, at 09:24 , Jaimee Spencer wrote: > > #!/usr/bin/perl > # list all of the perl modules installed > use File::Find ; > for (@INC) { find(\&modules,$_) ; } > > sub modules > { > if (-d && /^[a-z]/) { $File::Find::prune = 1 ; return } > return unless /\.pm$/ ; > my $fullPath = "$File::Find::dir/$_"; > $fullPath =~ s!\.pm$!!; > $fullPath =~ s#/(\w+)$#::$1# ; > print "$fullPath \n"; > } the great Trick - and thank you for the snappy intro to File::Find since I have never been there... thank you! what I did run into is one of those odd annomalies that happens - that piece of code 'ran away' for reasons that were not clear until I started to check with: http://www.wetware.com/drieux/CS/lang/Perl/Beginners/simpleFindTest.txt it seems that this form of find causes a bit of a Mess if you pass in the $_ - I tried a few variations on a them #find(\&wants,$_) for(@The_Inc_We_Use); #for(@The_Inc_We_Use) { find(\&wants,$_) ; } #foreach( sort(@The_Inc_We_Use)) {find(\&wants,$_) ;} and they all 'ate it' - and this was true across three OS's. darwin, solaris, linux redhat 7.2 ... perl 5.6.1 but it will work with foreach my $dir (@The_Inc_We_Use) { find(\&wants,$dir); } since I wanted the idea to work - but wanted it to be sorted down to just the module names I offer you: http://www.wetware.com/drieux/CS/lang/Perl/Beginners/findModules.txt If this is actually a 'bug' how should it get reported back I can not find a $VERSION nor anyone on the hoof for maintaining this. ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Incrementing the letters in an array
On Thursday, April 18, 2002, at 03:37 , Mark Anderson wrote: > No, you need ++ vs +1. As they say in perl, ++ is magical and will do want you want. + 1 will not. Wags ;) ps -- is not magical in the same sense as ++ either. >>> >>> How would you decrement a character then? There surely has to be a >>> way? >> >> perldoc -f ord >> perldoc -f chr >> >> my $len = $#array ; >> my $x = 0; >> $array[$x++] = chr( ord($array[$x]) - 1 ) while( $x <= $len ); > > This decrements ever character in an array. The ++ is magical in that "a" > increments to "b" and "z" increments to "aa". (ultimately leading to a > cute > little japh) > > Your solution takes "abcde" and returns "`abcd" which is not the opposite > of > the ++ operator. actually no the code and run of the code is shown in details below one could rewrite $array[$x++] = chr( ord($array[$x]) - 1 ) while( $x <= $len ); as while( $x <= $len ) { my $letter = $array[$x];# assign nth letter my $val = ord($letter);# get it's ordinal value $val--; # decrement the ordinal $array[$x] = chr($val); # insert the Char back in x++;# increment on down the way. } and it may be a bit more obvious that we are walking ourselves through an 'array of letters' - since the question had been posited in regards to decrementing letters sorry if the flatlining of it was not as obvious. [..] #!/usr/bin/perl -w use strict; my @array = qw/ a b c d e f g h i j k l m n o p /; print "Letters are now @array \n"; my $len = $#array ; my $x = 0; $array[$x++] = chr( ord($array[$x]) - 1 ) while( $x <= $len ); print "Letters are now @array \n"; $array[$x]++; print "Letters are now @array \n"; [jeeves:/tmp/drieux/perl] drieux% perl !$ perl pr* Letters are now a b c d e f g h i j k l m n o p Letters are now ` a b c d e f g h i j k l m n o Letters are now ` a b c d e f g h i j k l m n o 1 [jeeves:/tmp/drieux/perl] drieux% ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: TK madness
The following has been taken from perldoc Tk::Canvas TEXT ITEMS A text item displays a string of characters on the screen in one or more lines. Text items support indexing and selection, along with the following text-related canvas methods: dchars, focus, icursor, index, insert, select. Text items are created with methods of the following form: $canvas->createText(x, y, ?option, value, option, value, ...?) The arguments x and y specify the coordinates of a point used to position the text on the display (see the options below for more information on how text is displayed). After the coordinates there may be any number of option-value pairs, each of which sets one of the configuration options for the item. These same option-value pairs may be used in itemconfigure methods to change the item's configuration. There is more to it.. For more details, u can refer to perldoc Tk::Canvas I hope this helps Regards Mayank James Taylor wrote: > > I'm trying to develop a user interface for a program I've written - What > I need the program to do is print out the results of the current process > to the TK interface. I absolutely can not figure out how to do a simple > printing to TK function!@@!# For example, I would have a program that > does something like: > > for (1 .. 10) { >print "$_\n"; > } > > Well, I need to print that into the canvas in TK. How the hell do I do > this?! It seems like something so trivial, yet not even the Perl/TK > tutorial talks about something as simple as this. > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- Regards Mayank "The difference between ordinary and extraordinary is that little extra" -Anon -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: TK madness
This request brings up a good point, though, in that we have this great thing, namely tk, that can be a great shortcut to creating graphical applications from the normally flexible but often spartan Perl, and there doesn't seem to be a really good resource for learning or reference. So I will posit the question to members of this list: What resource do you use when you need to learn about a feature of Tk? -Original Message- From: Mayank Ahuja To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: 4/18/02 9:44 PM Subject: Re: TK madness The following has been taken from perldoc Tk::Canvas TEXT ITEMS A text item displays a string of characters on the screen in one or more lines. Text items support indexing and selection, along with the following text-related canvas methods: dchars, focus, icursor, index, insert, select. Text items are created with methods of the following form: $canvas->createText(x, y, ?option, value, option, value, ...?) The arguments x and y specify the coordinates of a point used to position the text on the display (see the options below for more information on how text is displayed). After the coordinates there may be any number of option-value pairs, each of which sets one of the configuration options for the item. These same option-value pairs may be used in itemconfigure methods to change the item's configuration. There is more to it.. For more details, u can refer to perldoc Tk::Canvas I hope this helps Regards Mayank James Taylor wrote: > > I'm trying to develop a user interface for a program I've written - What > I need the program to do is print out the results of the current process > to the TK interface. I absolutely can not figure out how to do a simple > printing to TK function!@@!# For example, I would have a program that > does something like: > > for (1 .. 10) { >print "$_\n"; > } > > Well, I need to print that into the canvas in TK. How the hell do I do > this?! It seems like something so trivial, yet not even the Perl/TK > tutorial talks about something as simple as this. > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- Regards Mayank "The difference between ordinary and extraordinary is that little extra" -Anon -- 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: TK madness
> So I will posit the question to members of this list: What resource do you > use when you need to learn about a feature of Tk? In Tk we have the concept of widgets. Everything like canvas, menubar, radio button, button, window is a widget. And fortunately many of them have been given a quite intutive name (some are not e.g. combo box type of widget is knows as Optionmenu). If u have installed all the docs. The point to start is : perldoc Tk perldoc Tk::overview perldoc Tk::UserGuide "perldoc Tk" will also show u all the available Tk modules/geometry managers/binding events etc. Suppose u have a widget Canvas then perldoc Tk::Canvas will list details about this widget. U can also view the documentation on CPAN. But if the above doesn't help u, u can refer to "Learning Perl/Tk" by Nancy Walsh (Publishers: O'Reilly) (It's the only book i have read on Perl/Tk, so i'm not sure if this is the best) The book is quite similar to the perldoc but has an excellent chapter explaining geometry managers and also has been arranged in a nice way. Cheers Mayank Timothy Johnson wrote: > > > This request brings up a good point, though, in that we have this great > thing, namely tk, that can be a great shortcut to creating graphical > applications from the normally flexible but often spartan Perl, and there > doesn't seem to be a really good resource for learning or reference. > > So I will posit the question to members of this list: What resource do you > use when you need to learn about a feature of Tk? > > -Original Message- > From: Mayank Ahuja > To: [EMAIL PROTECTED] > Cc: [EMAIL PROTECTED] > Sent: 4/18/02 9:44 PM > Subject: Re: TK madness > > The following has been taken from perldoc Tk::Canvas > > TEXT ITEMS > A text item displays a string of characters on the screen in > one or more lines. Text items support indexing and > selection, along with the following text-related canvas > methods: dchars, focus, icursor, index, insert, select. > Text items are created with methods of the following form: > > $canvas->createText(x, y, ?option, value, option, value, ...?) > > The arguments x and y specify the coordinates of a point > used to position the text on the display (see the options > below for more information on how text is displayed). After > the coordinates there may be any number of option-value > pairs, each of which sets one of the configuration options > for the item. These same option-value pairs may be used in > itemconfigure methods to change the item's configuration. > > There is more to it.. > For more details, u can refer to perldoc Tk::Canvas > > I hope this helps > > Regards > Mayank > > James Taylor wrote: > > > > I'm trying to develop a user interface for a program I've written - > What > > I need the program to do is print out the results of the current > process > > to the TK interface. I absolutely can not figure out how to do a > simple > > printing to TK function!@@!# For example, I would have a program that > > does something like: > > > > for (1 .. 10) { > >print "$_\n"; > > } > > > > Well, I need to print that into the canvas in TK. How the hell do I > do > > this?! It seems like something so trivial, yet not even the Perl/TK > > tutorial talks about something as simple as this. > > > > -- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > -- > Regards > Mayank > > "The difference between ordinary and extraordinary is that little extra" > -Anon > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- Regards Mayank "The difference between ordinary and extraordinary is that little extra" -Anon -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]