> ok ill send again from the correct address... > > >Actually you were probably 'sure', and it is probably failing for some > 'reason'. > ... > > >Start with a spell checker, use punctuation, work on the grammar. Have > a look at: > > yes i know i can not spell, im a dislexic moron > thank you i will read the page from the link. >
Dyslexia does not make one a moron, though it must make programming significantly more challenging. I thought something might be up, which is why my comments were made, but not intentionally hurtful. Sometimes people really are that lazy.... > > > > > > thank you. > > RichT > > > > > > /scanPoller.cfg.pl================================================== > > more scanPoller.cfg.pl > > #!/usr/local/bin/perl > > # > > > > use strict; > > use warnings; > > use Getopt::Long; > > > > my > > > ($inFile,$USAGE,$showKey,$site,$found,$foundKeys,@dataFile,@foundSegments,$value); > > Declaring all of your variables up front defeats the purpose of 'strict' > and makes it far less useful. You should declare your variables at first > usage and in the proper scopes. > > are i allways beleaved you should declare them like this... > how should i?? some thing like: > > my $USAGE = ... > > and will this work if the first time the variables is used is in a loop? Yes. There is no hard rule, the variable should be declared at the tightest scope possible. So if the variable is only needed in a loop, then declare it in the loop. If it needs a less specific scope, then scope it where you need to. For more on scoping check out: http://perl.plover.com/FAQs/Namespaces.html > > > my ($opt_inFile, $opt_listAllFields, $opt_help ) = (0,0,0); > > my $opt_findField = "agentAddress"; > > my $opt_showFields = "segment,agentAddress,community"; > > > > $USAGE = <<USAGETEXT; > > usage: $0 ipaddress > > the following options are also availble > > [-inFile filename ] input filename > > [-findField fieldName ] this is the search key (default is > > agentAddress) > > [-showFields field names ] feilds to output (default is > > segment,agentAddress,community) > > [-listAllFields ] list avalible fields > > [-help] this help text > > USAGETEXT > > > > >The above is ok, but you might consider taking the advice of the > >Getopt::Long docs and using Pod::Usage to generate error messages and > help text via pod. > > ill look in to this. i have been using "O'reilly's Programming Perl > /Learning Perl" which say nothing of using Pod > Yes the first is a reference about language features rather than a good source of best practices, the second is excellent for teaching, but as such tends to keep snippets short in the interest of teaching the specific subject at hand. Both are excellent for their intended purpose, which is not always developing full programs. > > &GetOptions( "inFile=s", > > "findField=s", > > "showFields=s", > > "listAllFields", > > "help|h|H|?|HELP", > > ); > > > > >You should drop the C<&> it is not needed in this context. You should > also go back to the docs for Getopt::Long, it does not have the default > $opt_ variables for the options, it instead uses references or a hash. I > assume this is left over from Getopt::Std, and in that case you would > have to declare your $opt_ variables with C<our> instead of C<my>. > > > > > print " listAllFields =$opt_listAllFields\n"; #testing > > print " help =$opt_help\n"; #testing > > > > Docs can be found at > http://search.cpan.org/~jv/Getopt-Long-2.34/lib/Getopt/Long.pm > > And I have an example template that uses Getopt::Long and incorporates > Pod::Usage available here: > > http://danconia.org/cgi-bin/request?handler=Content;content=StaticPage;label=getopt_long_template > > <snip> > > http://danconia.org > > > > ok i have had a look at the cpan doc and made some adjustments... > it will take me a while to digest the pod bit though > They often do, being able to read the docs and pull from the API is probably the most important skill in Perl (programming in general). > > also i am having a problem with the > #Data collections / inputfile part > > " foreach $value (@dataFile) { # loop for each line/site in dataFile > chomp $value ; > @foundSegments=findVars($searchKey,$value);" > Generally when looping over a file you should use a C<while> construct instead to reduce memory overhead. > > it is only storing the last value should i be doing something like > > "@foundSegments[$i]=findVars($searchKey,$value); > $i++" This would be a very C way of doing it, which is ok, but in Perl we are provided with the C<push> function, which is signifcantly easier, perldoc -f push push @foundSegments, findVars($searchKey, $value); > > thank you for your help... > > RichT Keep at it... http://danconia.org > > New code======================================================= <snip> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>