Hi All,
I am writing the following Perl Scrip and need your help in Pattern matching :
I have the following Shell Script that would read line by line from the file (file_svn) and would inturn calls the Perl Script:
#!/bin/bash
perl_path="/home/dev/filter"
version_file_path="/home/dev/filter"
version_file="file_svn"
perl_file="SVN_Extract_Script_1.pl"
while read line
do
echo "Printing $line"
$perl_path/$perl_file -v $line --> Included options -v , actually not necessary
done < "/home/dev/filter/file_svn"
The file file_svn contains the following:
https://ims-svnus.com/dev/DB/trunk/feeds/templates/shell_script.txt -r860
https://ims-svnus.com/dev/DB/trunk/db/sec_db/stored_procedures/alter.sql -r990
https://ims-svnus.com/dev/DB/trunk/com/bin/aim/filter.java -r456
..so on
From the above,
1) Get the path after trunk and then create those directories under the /home/dev/filter/build/tmpl/ and /home/dev/filter/build/ovrd/ if they dont exists.
(excluding -r860 ..etc)
Example:
After Running the Perl Script for first line:
https://ims-svnus.com/dev/DB/trunk/feeds/templates/shell_script.txt -r860
The directories (/feeds/templates/) doesn't exists under /home/dev/filter/build/tmpl/ and /home/dev/filter/build/ovrd/ , then we have to create them.
Then the file should be saved as
/home/dev/filter/build/tmpl/feeds/templates/shell_script.txt
Fyi -> svn export (firstline) <<path>> would actually saves the file under the given path.
The Perl Script is below:
#!/usr/bin/perl
use Getopt::Std;
getopts('v:', %opts) || die "Invalid options passed\n"; --> not sure why this is not working
$ver=$opts{"v"};
$build_home="/home/dev/filter/build/";
$root_dir="/home/dev/filter/";
$vob_dir="https://ims-svnus.com/dev/DB/trunk/";
$dest_tmpl_path="/home/dev/filter/build/tmpl/";
$dest_ovrd_path="/home/dev/filter/build/ovrd/";
unless ( $ver =~ /\.java$/ ) -- If the line contains other than .java
{
($full_path, $version) = split(' ',$ver);
$temp = reverse $full_path;
($file) = split(/\//, $temp);
$file = reverse $file;
$full_path =~ /^${vob_dir}(.*)${file}$/;
$full_path = $1;
$full_path =~ s/templates\///;
$dest_tmpl_path .= "$full_path";
$dest_ovrd_path .= "$full_path";
`mkdir -p $dest_tmpl_path` if (! -e $dest_tmpl_path );
`mkdir -p $dest_ovrd_path` if (! -e $dest_ovrd_path );
`svn export $ver $dest_tmpl_path$file`; --> $file should contain the entire path after trunk including the filename
<<<< I will perform someother things here >>>>
}
IF << .java>>> in theline
then
Perform the same things as above
But << I will not performthe other things that I am doing in above step >>>
END
Could someone please help me out in finishing the above perl script.
I would really appreciate your help and time.