Perl / Interpret Unix If statement


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Perl / Interpret Unix If statement
# 1  
Old 06-29-2008
Perl / Interpret Unix If statement

Hi all,
I am a newbie, so please let me know if there is a better way to do this. I coded a perl script, that scans a Unix script and picks out certain strings (strings that precede ".log"). However I want to limit the strings it picks up based on the "If statements" in the unix script.


So is there a way to evaluate the unix "if statements" from my perl script. Thanks a lot for your help!

San.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert Update statement into Insert statement in UNIX using awk, sed....

Hi folks, I have a scenario to convert the update statements into insert statements using shell script (awk, sed...) or in database using regex. I have a bunch of update statements with all columns in a file which I need to convert into insert statements. UPDATE TABLE_A SET COL1=1 WHERE... (0 Replies)
Discussion started by: dev123
0 Replies

2. Shell Programming and Scripting

Perl - what does this statement mean -Regex

push @MACARRAY, "$+{catalog} $+{machine}\n" if ($info =~ /(?<catalog>catalog).+?(?<machine>\*+)/ms); I am (still) trying to solve problem. Looking around on the server I found this piece of code. Specifically what does "$+{catalog} $+{machine}\n" do ? Thanks in advance (1 Reply)
Discussion started by: popeye
1 Replies

3. Shell Programming and Scripting

Understanding perl statement

can someone help me how to interpret this line? my ($class, $hashref) = @_; my $portfolio = {}; if ($hashref->{portfolio_id}) { ($portfolio) = GEmySQL->get ("select * from portfolio where portfolio.id=$hashref->{portfolio_id}"); } =============== Question: how do... (2 Replies)
Discussion started by: onlinelearner02
2 Replies

4. UNIX for Dummies Questions & Answers

Help with Perl If statement

Hi All, I am writing a perl script where I take 2 variables from the user as STDIN to scan the lines of a file to produce as output. How can I do an IF loop to test this for example in the mock file 12 10 35 20 37 5 45 12if I take user input as 40 and 10, how can I get the output lines in... (3 Replies)
Discussion started by: pawannoel
3 Replies

5. Shell Programming and Scripting

Perl nested if statement

I'm just having a bit of trouble running this code. It tells me that there's a syntax error on line 29. Any help appreciated. #!/usr/bin/perl # # Phone Book Application # %phonebook = ( "Wayne", '34687368', "Home", '378643287', "Work", '017374637', "School",... (2 Replies)
Discussion started by: cabaiste
2 Replies

6. Shell Programming and Scripting

Condition statement in perl

#!/usr/bin/perl $output1 = "/home/log.txt" $output2 = "/home/grep.txt" #Statement1 creates an output file called log.txt. #Statement2 greps a line from log.txt and store the result in grep.txt I want to create a condition where if the file grep.txt is empty repeat process. Thanks. (1 Reply)
Discussion started by: sureshcisco
1 Replies

7. Shell Programming and Scripting

Help with perl and if file statement

Hello and thank you in advance. I have a perl script that will basically copy files out of a directory , creat a new current date stamped dir and move them that current time stamped dir and append the file names with current time stamp. I need to add line(s) that this is only run if FileX... (1 Reply)
Discussion started by: Dadwith2boys
1 Replies

8. Shell Programming and Scripting

Problem with if statement in perl

if (($fields eq $hwp) && ($fields eq 'Y')) { $fields = "INTEGRAL"; } elsif ($fields eq $hwp) { $fields = "INTEGRAL"; } elsif ($fields ne $hwp) { $fields = "SEPARATE"; } print "$fields $fields $fields\n"; Output: The problem here is that the first... (2 Replies)
Discussion started by: kamitsin
2 Replies

9. Shell Programming and Scripting

Can't interpret variable in if statement

Can someone help me out here. I can't get this piece of code to work. i.e. $ALL_EVENTS does not get interpreted in the if brackets. The first part is the code, the second part is the execution of the code. Note: $ALL_EVENTS does equal 2, but there is no value once passed to the if statement. ... (4 Replies)
Discussion started by: jwholey
4 Replies

10. Shell Programming and Scripting

perl if statement

Hello guys, I was wondering why my code doesn't read a variable when using if statement as follows: $userlist='users.txt'; $user='b999'; open (ACTULOG, ">>$userlist"); print ACTULOG "$user\n"; close (ACTULOG) this will work and prints... (3 Replies)
Discussion started by: Bashar
3 Replies
Login or Register to Ask a Question
Test::Script(3) 					User Contributed Perl Documentation					   Test::Script(3)

NAME
Test::Script - Basic cross-platform tests for scripts DESCRIPTION
The intent of this module is to provide a series of basic tests for 80% of the testing you will need to do for scripts in the script (or bin as is also commonly used) paths of your Perl distribution. Further, it aims to provide this functionality with perfect platform-compatibility, and in a way that is as unobtrusive as possible. That is, if the program works on a platform, then Test::Script should always work on that platform as well. Anything less than 100% is considered unacceptable. In doing so, it is hoped that Test::Script can become a module that you can safely make a dependency of all your modules, without risking that your module won't on some platform because of the dependency. Where a clash exists between wanting more functionality and maintaining platform safety, this module will err on the side of platform safety. FUNCTIONS
script_compiles script_compiles( 'script/foo.pl', 'Main script compiles' ); The "script_compiles" test calls the script with "perl -c script.pl", and checks that it returns without error. The path it should be passed is a relative unix-format script name. This will be localised when running "perl -c" and if the test fails the local name used will be shown in the diagnostic output. Note also that the test will be run with the same perl interpreter that is running the test script (and not with the default system perl). This will also be shown in the diagnostic output on failure. script_runs script_runs( 'script/foo.pl', 'Main script runs' ); The "script_runs" test executes the script with "perl script.pl" and checks that it returns success. The path it should be passed is a relative unix-format script name. This will be localised when running "perl -c" and if the test fails the local name used will be shown in the diagnostic output. The test will be run with the same perl interpreter that is running the test script (and not with the default system perl). This will also be shown in the diagnostic output on failure. SUPPORT
All bugs should be filed via the bug tracker at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Script> For other issues, or commercial enhancement and support, contact the author. AUTHOR
Adam Kennedy <adamk@cpan.org> SEE ALSO
prove, <http://ali.as/> COPYRIGHT
Copyright 2006 - 2009 Adam Kennedy. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. perl v5.18.2 2009-11-23 Test::Script(3)