Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Tool to create Perl based scripts

Reply
Thread Tools

Tool to create Perl based scripts

 
 
IJALAB
Guest
Posts: n/a
 
      02-20-2007
Hi All,

I have to automate a lot of validation scripts in Perl. Is there a
simple way/tool to do the same. basically log files will be created
and i have to look for certain keywords in the log files and make a
decision to validate the tests. I am just looking to save time in
automating my perl writing task.
any pointers welcome..thanks a lot

regards
bala

 
Reply With Quote
 
 
 
 
johngnub
Guest
Posts: n/a
 
      02-20-2007
On Feb 20, 3:52 am, "IJALAB" <(E-Mail Removed)> wrote:
> Hi All,
>
> I have to automate a lot of validation scripts in Perl. Is there a
> simple way/tool to do the same. basically log files will be created
> and i have to look for certain keywords in the log files and make a
> decision to validate the tests. I am just looking to save time in
> automating my perl writing task.
> any pointers welcome..thanks a lot
>
> regards
> bala


Well, Not a CS major, but willing to try ..Some step by step tasks,
und allways in Perl, more then one way around the barn to milk the
cow...

# To open a file:
open (IN,"<some.dat");
@then = <IN>;close (IN);

# Now then has data, info from the file

To loop over a file, the array of lines from the file, in the array
then:
foreach $line (@then){
# To see if it has "fun", simple match,
if ($line =~ /fun/ ) {
print "OH fun!\n";
}
# simiple but usefull regex meta opers, ,
# \s+ equiv to spaces, \S+ equiv to words that are not spaces, \d+
digits,
# To see if its a word then fun, thus ich bin "foo fun bar"
if ($line =~ /\S+\s+fun\s+\S+/ ) {
print "A word then fun and a word.\n";
}
# close out the loop, hint use the "%" key in vi to spy the (){} of
life.
}
# The end.

# PS: put the car in 1st gear, then step on the pedal, NASCAR is not a
good way to learn how to drive. Yada. jb.





 
Reply With Quote
 
 
 
 
usenet@DavidFilmer.com
Guest
Posts: n/a
 
      02-20-2007
On Feb 20, 1:13 pm, "johngnub" <(E-Mail Removed)> wrote:

> @then = <IN>;

......
> foreach $line (@then){


Never, ever, ever read a file into an array if your only intention is
to process the file line-by-line.

Just read each line and process it as it is read:

foreach my $line(<$in>) { #and use lexical filehandles
#do something with each $line
}

--
The best way to get a good answer is to ask a good question.
David Filmer (http://DavidFilmer.com)

 
Reply With Quote
 
Billy Patton
Guest
Posts: n/a
 
      02-22-2007
I prefer perl above all other languages. But sometimes it's not the best
language for the job.
If you are simply looking for keywords within a file I would suggest using
csh,sh,ksh,bash or zsh to do simple grep commands.
It's very fast. If, your on a unix box, cygwin, mingw or mac osx.

"IJALAB" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Hi All,
>
> I have to automate a lot of validation scripts in Perl. Is there a
> simple way/tool to do the same. basically log files will be created
> and i have to look for certain keywords in the log files and make a
> decision to validate the tests. I am just looking to save time in
> automating my perl writing task.
> any pointers welcome..thanks a lot
>
> regards
> bala
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Python Scripts with IIS - ASP or Python-based CGI scripts withIIS - which makes more sense? davidj411 Python 0 06-27-2008 04:38 PM
What is required for perl scripts to run correct when launched from rc scripts on HPUX 11? deanjones7@gmail.com Perl Misc 13 09-10-2007 11:58 AM
any perl tool to create a flow of perl scripts iarunkumar@gmail.com Perl Misc 9 02-27-2007 10:17 AM
Stupid question: Making scripts python-scripts Jan Danielsson Python 8 07-22-2005 12:20 AM
Re: Stupid question: Making scripts python-scripts Jp Calderone Python 0 07-21-2005 02:38 PM



Advertisments