artofchobo
asked on
How to adhere to 8.3 naming conventions
Hi guys,
I'm a newbie in perl.
I would like to have some ideas on how to convert a text file with filenames, seperated by \n (newline) to become 8.3 format using perl.
Meaning to say that
salarytext.file becomes salary~1.fil (8.3 naming convention)
Basically, its should just be like DOS...
I need some tips....
Thanks
Regards,
chobo
I'm a newbie in perl.
I would like to have some ideas on how to convert a text file with filenames, seperated by \n (newline) to become 8.3 format using perl.
Meaning to say that
salarytext.file becomes salary~1.fil (8.3 naming convention)
Basically, its should just be like DOS...
I need some tips....
Thanks
Regards,
chobo
ASKER
#!/usr/bin/perl
$j = 1;
$i = 0;
$k = 0;
@freq = 0;
while(<>)
{
# $first = substr($_, 0, 8);
m/\w{1,8}/;
$first = $&;
m/\.\w{3}/;
$second = $&;
$filename = "$first"."$second\n";
push @x, $filename;
}
for ($k = 0; $k < $#x+1; $k++)
{
for ($i = $j; $i < $#x+1; $i++)
{
# print "$x[$i]";
if ($x[$k] == $x[$i])
{
$freq[$k] +=1;
transform($x[$i]);
}
}
$j++;
}
print @x;
sub transform
{
$trunc = shift();
substr($trunc, 0, 6)."_freq[$k]";
$x[$i]=$trunc;
}
This is what I have in mind right now... but its not working......
$j = 1;
$i = 0;
$k = 0;
@freq = 0;
while(<>)
{
# $first = substr($_, 0, 8);
m/\w{1,8}/;
$first = $&;
m/\.\w{3}/;
$second = $&;
$filename = "$first"."$second\n";
push @x, $filename;
}
for ($k = 0; $k < $#x+1; $k++)
{
for ($i = $j; $i < $#x+1; $i++)
{
# print "$x[$i]";
if ($x[$k] == $x[$i])
{
$freq[$k] +=1;
transform($x[$i]);
}
}
$j++;
}
print @x;
sub transform
{
$trunc = shift();
substr($trunc, 0, 6)."_freq[$k]";
$x[$i]=$trunc;
}
This is what I have in mind right now... but its not working......
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thanks
Any particular reason for the 'B'? I thought that I had gone above and beyond with sufficient information to warrent an 'A'.
Any particular reason for the 'B'? I thought that I had gone above and beyond with sufficient information to warrent an 'A'.
ASKER
Mis-click....
I dont mind giving better records.....
Sorry... I havent tried it out yet but I guess the code should work!.
I dont mind giving better records.....
Sorry... I havent tried it out yet but I guess the code should work!.
ASKER
So far, I have done
while(<>)
{
m/w{1,8}/;
$first = $&;
m/\.\w{3}/;
$second = $&;
$filename = "$first"."$second";
}