| JupiterHost.Net 2004-11-30, 8:56 pm |
| > Sure...if I know someone can do the job. I'll just go to rentacoder.com
I'd be more than happy to consult for your Perl needs, send me an email
off list if you're interested.
>
>
> So you don't take examples you find off the net? Is this not stealing?
> Whatever...
Ok time for everyone to calm down and be happy :)
I think by "stealing" he means "expect someone to code for free" without
even trying to do it yourself first.
Regardless, the point is this is a beginners list, but there needs to be
more effort because its not a free script writing service.
Now back to your question:
1) use strict; and use warnings; always always always! that will tell
you about problems before you even know about them and solve 90% of your
troubles
2) you'd use a regexp to get the part you want (`perldoc perlre`)
3) you open CHECKFILE but read and close INFILE so that code wouldn't
even compile if you tried it (one of the things they mentioned about
more effort - actually running the sample code to see if there are
errors that may point you in the right direction)
#!/usr/bin/perl
use strict;
use warnings;
open CHECKFILE, '< file.in' or die qq(Cannot open file "file.in": $!);
for(<CHECKFILE> ) {
print "Line is $_";
my ($number) = $_ =~ m/N: (\d+)/;
print "number is $number\n";
}
close (CHECKFILE);
HTH to get you started :) just next time use strict and warnings and
make sure the sample code actually compiles and try to look at perldoc
or cpan or google for information first.
Then when you run into problems with code you have you can have a
specific question about how specific code works and it will be easier to
assist (and less likely to get the frustration of people who help many
people for free a lot)
Lee.M - JupiterHost.Net
|