PDA

View Full Version : File Groups : optimizing with Perl



NewsArchive
12-11-2001, 01:00 AM
Any Perl masters out there that can help?

I have a Perl script which scans all the File Groups for duplicate
references to the same files. Currently it is very simple and just outputs a
report saying:

abc.dll is referenced by: aaa.fgl bbb.fgl ccc.fgl
xyz.dll is referenced by: aaa.fgl eee.fgl fff.fgl

Then I have to decide myself how I can optimize the files into common
groups.

Anyone know how in Perl I can generate a report that says:

The following files:

abc.dll
def.dll
xyz.dll

can be moved to one File Group and associated with the following Components:

DLLs_SelfReg

Thanks,
Dave Stiff
Trango Software
http://www.trangosoft.com

NewsArchive
12-11-2001, 01:00 AM
Without access to your perl script I can suggest a generalized solution.

On the surface, I would say do the following (In pseudo code):
Take the Extension of the file (ex. DLL)
Check the File Group properties (Share, Self_Reg)
Suggest a File Group called Extension_Properities. In this case lets say it
is Shared, Self_Registering) then ex:
if $prop!=""

printf "$ext_\n";
for loop through $prop array
printf "$prop"
next
all done then printf "\n";

Granted that's not exactly Perl code but at least that gives you an idea.

David Stiff <davids@trangosoft.com> wrote in message
news:3c1626af$1@news.installshield.com...
> Any Perl masters out there that can help?
>
> I have a Perl script which scans all the File Groups for duplicate
> references to the same files. Currently it is very simple and just outputs
a
> report saying:
>
> abc.dll is referenced by: aaa.fgl bbb.fgl ccc.fgl
> xyz.dll is referenced by: aaa.fgl eee.fgl fff.fgl
>
> Then I have to decide myself how I can optimize the files into common
> groups.
>
> Anyone know how in Perl I can generate a report that says:
>
> The following files:
>
> abc.dll
> def.dll
> xyz.dll
>
> can be moved to one File Group and associated with the following
Components:
>
> DLLs_SelfReg
>
> Thanks,
> Dave Stiff
> Trango Software
> http://www.trangosoft.com
>
>

NewsArchive
12-11-2001, 01:00 AM
The Perl script is quite simple. It compiles a list of files based on all
the File99= lines in the File Groups and then uses NT's FINDSTR to grep and
create list of FGL matches.

Thanks. Actually I am not going to worry about the File Group proprties. I
am going to assume that if two or more File Groups are referencing the same
file then they have the same properties.

I am not certain if I need a multi-dimensional array or an associative
array. (Neither of which I have experience with).

Basically all I have to work with is the filename and the File Groups it is
contained in.

I am not even certain how to explain it. I need to group as many files as
possible together based on the File Groups they match, suggest a new File
Group and tell the user which Components need to include this File Group.

The data would be something like:

FILENAME FILEGROUPS
abc1.dll fg1.fgl fg2.fgl
abc2.dll fg1.fgl fg2.fgl
abc3.dll fg1.fgl fg2.fgl
abc4.dll fg2.fgl fg3.fgl
abc5.dll fg2.fgl fg3.fgl
abc6.dll fg2.fgl fg3.fgl
abc7.dll fg2.fgl fg3.fgl

The report would be something like:

Recommend new File Group for:
FILES: abc1.dll abc2.dll abc3.dll

The Compenents that need to include this File Group are:
COMPONENTS: CoreDLLs, EnglishDLLs, MyDLLs

Too bad there is no Tool in InstallShield now that could do this. This would
be an amazing feature.

Thanks,
Dave Stiff
Trango Software

"Bob Cheek" <RCheek@Verbind.com> wrote in message
news:3c165a2c$1@news.installshield.com...
> Without access to your perl script I can suggest a generalized solution.
>
> On the surface, I would say do the following (In pseudo code):
> Take the Extension of the file (ex. DLL)
> Check the File Group properties (Share, Self_Reg)
> Suggest a File Group called Extension_Properities. In this case lets say
it
> is Shared, Self_Registering) then ex:
> if $prop!=""
>
> printf "$ext_\n";
> for loop through $prop array
> printf "$prop"
> next
> all done then printf "\n";
>
> Granted that's not exactly Perl code but at least that gives you an idea.
>
> David Stiff <davids@trangosoft.com> wrote in message
> news:3c1626af$1@news.installshield.com...
> > Any Perl masters out there that can help?
> >
> > I have a Perl script which scans all the File Groups for duplicate
> > references to the same files. Currently it is very simple and just
outputs
> a
> > report saying:
> >
> > abc.dll is referenced by: aaa.fgl bbb.fgl ccc.fgl
> > xyz.dll is referenced by: aaa.fgl eee.fgl fff.fgl
> >
> > Then I have to decide myself how I can optimize the files into common
> > groups.
> >
> > Anyone know how in Perl I can generate a report that says:
> >
> > The following files:
> >
> > abc.dll
> > def.dll
> > xyz.dll
> >
> > can be moved to one File Group and associated with the following
> Components:
> >
> > DLLs_SelfReg
> >
> > Thanks,
> > Dave Stiff
> > Trango Software
> > http://www.trangosoft.com
> >
> >
>
>

NewsArchive
12-12-2001, 01:00 AM
I was using the properties of the file group to suggest the name of the file
group.
Anyway, my perl is a little rusty but here's a Perl Script file you. Below
is a sample output:
---------------------------------------- Begin of
script -----------------------------------
#use diagnostics;

#use strict;
{
local %arryFiles=();
local %arryFileGroups=();

&AddFile ("abc1.dll", "fg1.fgl");
&AddFile ("abc1.dll", "fg2.fgl");
&AddFile ("abc2.dll", "fg1.fgl");
&AddFile ("abc2.dll", "fg2.fgl");
&AddFile ("abc3.dll", "fg1.fgl");
&AddFile ("abc3.dll", "fg2.fgl");
&AddFile ("abc4.dll", "fg2.fgl");
&AddFile ("abc4.dll", "fg3.fgl");
&AddFile ("abc5.dll", "fg2.fgl");
&AddFile ("abc5.dll", "fg3.fgl");
&AddFile ("abc6.dll", "fg2.fgl");
&AddFile ("abc6.dll", "fg3.fgl");
&AddFile ("abc7.dll", "fg2.fgl");
&AddFile ("abc7.dll", "fg3.fgl");
&AddFile ("Abc8.dll", "fg2");

printf ("Recommend new File Group for:\n ");
foreach $strFileName (sort (keys (%arryFiles)))
{
if (&NumGroups($strFileName)>1){
printf ($strFileName . " ");
}
}
printf ("\n");
}

sub AddFile{

my ($strFileName, $strFileGroup) = @_;
$strFileName = lc($strFileName);
$strFileGroup = lc($strFileGroup);

if (length($arryFiles{$strFileName})== 0){
$arryFiles{$strFileName} = $strFileGroup;
}
else {
$arryFiles{$strFileName} = $arryFiles{$strFileName} . "\|" .
$strFileGroup;
}
}
sub NumGroups{

my ($strFileName) = @_;

my @list = split /\|/, $arryFiles{$strFileName}; #create an array of file
Groups
my $totNum = @list; #Total Count in List
return ($totNum);
}
---------------------------------------- end of
script -----------------------------------

<<< SAMPLE OUTPUT >>>>
Notice: File abc8.dll is not listed. That's because it is only in one file
group.

Recommend new File Group for:
abc1.dll abc2.dll abc3.dll abc4.dll abc5.dll abc6.dll abc7.dll


David Stiff <davids@trangosoft.com> wrote in message
news:3c166c4c$1@news.installshield.com...
> The Perl script is quite simple. It compiles a list of files based on all
> the File99= lines in the File Groups and then uses NT's FINDSTR to grep
and
> create list of FGL matches.
>
> Thanks. Actually I am not going to worry about the File Group proprties. I
> am going to assume that if two or more File Groups are referencing the
same
> file then they have the same properties.
>
> I am not certain if I need a multi-dimensional array or an associative
> array. (Neither of which I have experience with).
>
> Basically all I have to work with is the filename and the File Groups it
is
> contained in.
>
> I am not even certain how to explain it. I need to group as many files as
> possible together based on the File Groups they match, suggest a new File
> Group and tell the user which Components need to include this File Group.
>
> The data would be something like:
>
> FILENAME FILEGROUPS
> abc1.dll fg1.fgl fg2.fgl
> abc2.dll fg1.fgl fg2.fgl
> abc3.dll fg1.fgl fg2.fgl
> abc4.dll fg2.fgl fg3.fgl
> abc5.dll fg2.fgl fg3.fgl
> abc6.dll fg2.fgl fg3.fgl
> abc7.dll fg2.fgl fg3.fgl
>
> The report would be something like:
>
> Recommend new File Group for:
> FILES: abc1.dll abc2.dll abc3.dll
>
> The Compenents that need to include this File Group are:
> COMPONENTS: CoreDLLs, EnglishDLLs, MyDLLs
>
> Too bad there is no Tool in InstallShield now that could do this. This
would
> be an amazing feature.
>
> Thanks,
> Dave Stiff
> Trango Software
>
> "Bob Cheek" <RCheek@Verbind.com> wrote in message
> news:3c165a2c$1@news.installshield.com...
> > Without access to your perl script I can suggest a generalized solution.
> >
> > On the surface, I would say do the following (In pseudo code):
> > Take the Extension of the file (ex. DLL)
> > Check the File Group properties (Share, Self_Reg)
> > Suggest a File Group called Extension_Properities. In this case lets say
> it
> > is Shared, Self_Registering) then ex:
> > if $prop!=""
> >
> > printf "$ext_\n";
> > for loop through $prop array
> > printf "$prop"
> > next
> > all done then printf "\n";
> >
> > Granted that's not exactly Perl code but at least that gives you an
idea.
> >
> > David Stiff <davids@trangosoft.com> wrote in message
> > news:3c1626af$1@news.installshield.com...
> > > Any Perl masters out there that can help?
> > >
> > > I have a Perl script which scans all the File Groups for duplicate
> > > references to the same files. Currently it is very simple and just
> outputs
> > a
> > > report saying:
> > >
> > > abc.dll is referenced by: aaa.fgl bbb.fgl ccc.fgl
> > > xyz.dll is referenced by: aaa.fgl eee.fgl fff.fgl
> > >
> > > Then I have to decide myself how I can optimize the files into common
> > > groups.
> > >
> > > Anyone know how in Perl I can generate a report that says:
> > >
> > > The following files:
> > >
> > > abc.dll
> > > def.dll
> > > xyz.dll
> > >
> > > can be moved to one File Group and associated with the following
> > Components:
> > >
> > > DLLs_SelfReg
> > >
> > > Thanks,
> > > Dave Stiff
> > > Trango Software
> > > http://www.trangosoft.com
> > >
> > >
> >
> >
>
>