Re: Reading Directory

2002-09-05 Thread Omanakuttan

opendir DIR, dir
while (defined(my $file=readdir(DIR))) {
next unless $file=~/\.mp3$/i ;
push(@files,$file); 
}

works for me.



Omanakuttan N,
C,C++,Networking, perl, Linux
Tata Elxsi Ltd,
ph.8410 222 x 414.
---
'   ...follow me' , the wise man said, but he walked behind ...




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




dos2unix.pl not working...

2002-08-30 Thread Omanakuttan

I am trying to strip off ^Ms from a number of text files.
The following does not seem to work. any suggestions?

my $filename  ;
while ($filename = shift) {
 open (INF, $filename) or die Could not open $filename. $! ;
 my @file = INF ;
 close INF ;
 open (OUT, $filename) or die Could not open $filename. $! ;
 foreach my $line (@file) {
   $line =~ s/\015\012// ;## = something wrong with this?
   print OUT $line,\n ;
 }
 close OUT ;
}
Thank you.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: uniq elements of an array

2002-08-29 Thread Omanakuttan

eg. To get all the unique elements of an array in linux I use a
 simple  one liner

@unique = grep{!/$seen{$_}++/} @all_elements;


The above expression did not work for me,
I could not even found out how this should work. So I created a small file
with...

@all_elements = qw(hello all elements hello all this that this) ;
@unique = grep{!/$seen{$_}++/} @all_elements;
print @unique ;

in cygwin, error was Quantifier follows nothing before HERE mark in regex
m/+  HERE +/ at try2.pl line 2.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Multidimensional Associative Arrays --- do they exist ?

2002-08-27 Thread Omanakuttan

$myhash {23_59_54_20_08_2002} = [30,20,45] ;
my $x = $myhash{23_59_54_20_08_2002},\n ;
for my $i (0..$#{$x}) {
 print $myhash{23_59_54_20_08_2002}-[$i],  ;
}
print \n ;

HTH.
Om.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Newbie Question.

2002-08-27 Thread Omanakuttan

open (FH, $filename) or die $! ;
my @arr = FH ;

HTH.
Om.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: conditional statement

2002-08-27 Thread Omanakuttan

 if (($vbpcount==1) ||($dspcount==1))
 {  die \n\nThe element ($PN) is not allowed to be added to
 ClearCase,Because a project already exists.\n;
 }

 elsif(($vbpcount==1)  ($dspcount==1))
 {die \n\nThe element ($PN) is not allowed to be added to
ClearCase,Because
 a project already exists.\n;
 }

The logic seems to suspect.
elsif part may never execute..


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]