Sponsored Content
Top Forums Shell Programming and Scripting Help regarding a Perl Program Post 302602563 by hemasid on Monday 27th of February 2012 05:37:33 PM
Old 02-27-2012
Question

Thanks for the help.
but if latest was only a part of my string what should i do.
i mean i have folder like
'ABC/a/c/g(base) /123_latest_6678090765abcww12/ Tail?

I am am trying to learn perl and thinking of what all i can handle with various scenarios.

Will be glad if you can help.

Thanks

Quote:
Originally Posted by Skrynesaver
Code:
perldoc -f opendir 
perldoc -f readdir

I'm not sure I follow your question but you can use the above to to read through directories and thus select your file.
something like the following may suit or at least be hackable into something that suits
Code:
my $base='ABC/a/c/g';
my $tail='z/x/c';
opendir BASE, $base;
my @subdirs = readir BASE;
for my $dir (@subdirs){
   if (($dir=~/latest/) && ( -d "$base/$dir")){
      if ( -f  "$base/$dir/$tail/final.html"){
         print "$base/$dir/$tail/final.html";
      }
   }
}

Of course I may have wildly misunderstood your spec and something like File::Find may be more suitable for your needs.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

My crap PERL program

Hey all, I've been trying to learn Perl on my BSD box. When it came to printing the files out, it bothered me that the lines weren't numbered. So here's my little *crap* claim to some-form-of-fame Perl script which numbers files: ... (9 Replies)
Discussion started by: WIntellect
9 Replies

2. Linux

an error in perl program

Hi I am having a file with 243 lines.. The file format s given below eg P25787 hsa03050 1 P20618 hsa03050 1 P25786 hsa03050 1 P49721 hsa03050 1 P54132 hsa03440 1 Q13472 hsa03470 1 Q05513 hsa04530 hsa04910 hsa04930 3 Q04759 ... (0 Replies)
Discussion started by: binnybio
0 Replies

3. Shell Programming and Scripting

perl program

I wish to write a Perl program that will provide a listing of files in a directory. The files must be listed in sorted order by the file name. • By default, the program displays only file names. • By default, the program lists the files in the current directory. • The program must provide the... (2 Replies)
Discussion started by: livewire06
2 Replies

4. Shell Programming and Scripting

perl program

could i get any help with how to link this program together. i dont know what to put where the X's are print `flush`; thank(); #print thank header use Getopt::Std; # use declaration with the options function getopts("ld:") or usage() and exit; ... (3 Replies)
Discussion started by: livewire06
3 Replies

5. Homework & Coursework Questions

Calling compiled C program with Perl program

Long story short: I'm working inside of a Unix SSH under a bash shell. I have to code a C program that generates a random number. Then I have to call the compiled C program with a Perl program to run the C program 20 times and put all the generated random #s into a text file, then print that text... (1 Reply)
Discussion started by: jdkirby
1 Replies

6. Shell Programming and Scripting

Exiting a program! - perl

how would you exit out of a programm correctly, without having for the program to crash? for example print "Enter quit"; $input = <STDIN>; if ($input eq "quit") { {QUIT THE PROGRAM} } else { print "invalid input"; } one more thing, how do u exit a program "correctly", if... (3 Replies)
Discussion started by: bshell_1214
3 Replies

7. Programming

Perl program

Hi I am new to perl, i need to write a program to convert horizontal words to vertical eg: cat, dog, cow,.....(text file) this should be written as 1.cat 2.dog like this. can u pls help me to work out.. (4 Replies)
Discussion started by: nitha
4 Replies

8. Shell Programming and Scripting

getting no output with my perl program

hi, i have posted the same kind of the question in some other forum of the same site. but realized that it is supposed to be here so i am reposting it .this is the perl script written to check for particular pattern. my file 1 would look like this hwk:678:9878:asd:09: abc cfgb 12 nmjk ......... (3 Replies)
Discussion started by: anurupa777
3 Replies

9. Shell Programming and Scripting

Perl program

can anyone help me out to write a code by connecting to the sql database and I need to print the list of tables present in the databse. any ideas please. (1 Reply)
Discussion started by: ramkumar15
1 Replies

10. Shell Programming and Scripting

Perl program get a response before the program quits

I created a program, so a kid can practice there math on it. It dispenses varies math problems and the kid must input an answer. I also want it to grade the work they have done, but I can't find the best place for it to print out the grade. I have: if ( $response =~ m/^/ ) { $user_wants_to_quit... (1 Reply)
Discussion started by: germany1517
1 Replies
Xacobeo::Conf(3pm)					User Contributed Perl Documentation					Xacobeo::Conf(3pm)

NAME
Xacobeo::Conf - Application's configuration. SYNOPSIS
use Xacobeo::Conf; my $conf = Xacobeo::Conf->get_conf; my $icon = $conf->share_file('images', 'xacobeo.png'); # /usr/share/images/xacobeo.png my $po_folder = $conf->share_folder('locale'); # /usr/share/locale DESCRIPTION
Utility class that provides a way for accessing all configuration parameters that are needed at runtime.. PROPERTIES
The following properties are defined: dir The root directory where the application has been installed. METHODS
The following methods are available: get_conf Returns the current configuration instance. This class is a singleton so there's no constructor. share_dir Returns the path of a folder in the application's share directory. Parameters: o @path The path parts relative to the share directory. share_file Returns the path of a file in the application's share directory. Parameters: o @path The path parts relative to the share directory. app_name Returns the application's name. plugin_folders Returns the folders that are scanned for plugins. AUTHORS
Emmanuel Rodriguez <potyl@cpan.org>. COPYRIGHT AND LICENSE
Copyright (C) 2008,2009 by Emmanuel Rodriguez. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available. perl v5.14.2 2011-11-16 Xacobeo::Conf(3pm)
All times are GMT -4. The time now is 03:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy