RE: REGEX PROBLEM (fwd)

2003-07-25 Thread magelord
--- Begin Message ---
Hi
A way to solve your problem is to use the FILE module and take the filename
out using basename.
I think BaseName.pm can be downloaded form CPAN.
Please try the following:

use File::Basename;
@filenames = qw (/tmp/test/.test.txt /tmp/test/hallo.txt
/tmp/test/xyz/abc.txt /var/log/ksy/123.log);
foreach $files (@filenames)
{


if ((basename $files) !~ /^\./)
{
print (basename $files);
}
}


Thankyou
VENU

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Friday, July 25, 2003 2:39 PM
To: [EMAIL PROTECTED]
Subject: REGEX PROBLEM


hi, i have the follwing strings:


/tmp/test/.test.txt
/tmp/test/hallo.txt
/tmp/test/xyz/abc.txt
/var/log/ksy/123.log


now i need a regex that matches all lines but the one that contains a
filename starting with a point. like ".test.txt". how can i do that?

this is what i have:

'\.(?!tgz)[^.]*$' this matches everything, but tgz at the end of a
line, so

'(?!\.)[^.]*$' should do the job, but it doesnt:(


THANK YOU:)

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

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

REGEX PROBLEM

2003-07-25 Thread magelord
hi, i have the follwing strings:


/tmp/test/.test.txt
/tmp/test/hallo.txt
/tmp/test/xyz/abc.txt
/var/log/ksy/123.log


now i need a regex that matches all lines but the one that contains a
filename starting with a point. like ".test.txt". how can i do that?

this is what i have:

'\.(?!tgz)[^.]*$' this matches everything, but tgz at the end of a
line, so

'(?!\.)[^.]*$' should do the job, but it doesnt:( 


THANK YOU:)

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



NEED HELP WITH REGEX....

2003-07-14 Thread magelord
hi, i have this regex:


\.(?!.png|.log)[^.]*$


how can i replace the .before png and log with nothing? the problem is,
the alternation can be longer, like that:

\.(?!.png|.log|.txt|.c|.cpp and so on )[^.]*$

how could i do that?

THANKS:-)

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



-M filetest operator

2003-07-11 Thread magelord
hi, why cant i check the age of a file when the path contains a point?

---
use File::Basename;
#$path="/home/raid/golchert/.cxoffice/dotwine/filelist.dat";
$path="/tmp/someFile";
print "\n alter von $path = ".(-M $path). "\n" if (-M $path <=4 &&
!(dirname($path)=~/\./) && !(-d $path));

---

maybe you have to change the path so its a file on your system. is
there a workaround for that? the line that is commented out does not
work

THANKS:-)

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



Getting the size of special files in a directory?

2003-07-03 Thread magelord
hi, is it possible to get the size of special files in a directory? i
need the size of all gz or html files. this works, i did it with glob.
but how can i get the size of files that match a pattern? for example
all filesnames that contain the string "setup". or all files that are
younger than 7 days and not bigger as 100k and end with gz. can this
alo be done with globbing? i hope you know,what i mean


THANKS A LOT:)

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



Regex question

2003-07-01 Thread magelord
hi, i have this regex:

\.[^(gz|html)]$

this regex should match all files (lines) NOT ending with gz or html.
but this is not working. the lines ending with .gz are still found.
whats wrong with that?

THANKS A LOT :)

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



How can i make this faster?

2003-06-27 Thread magelord
hi, i wrote this little program. it reads a file and puts the output
into a treelike structure. the content of the file is the output of the
du command. something like that:

124k /var/backups/dpkg.status.3.gz
12k /var/log/auth.log.1.gz
12k /var/log/daemon.log.1.gz
12k /var/log/debug.1.gz
12k /var/log/syslog.2.gz
12k /var/log/syslog.3.gz
132k /var/backups/dpkg.status.1.gz
132k /var/backups/dpkg.status.2.gz
4.0k /var/log/auth.log.2.gz
4.0k /var/log/debug.2.gz
4.0k /var/log/kern.log.1.gz

the program works fine for a small directory, but as soon as the
directory is bigger, it takes a long time to start. do you have any
idea how to make this faster?


---

#!/usr/bin/perl
use diagnostics;
use strict;
use Tk;
use Tk::HList;
use Tk::Tree;
use File::Basename;


my $mw = tkinit;
my $hl = $mw->ScrlTree(-separator=> '/',
   -drawbranch   => 1,
   -scrollbars   => 'osoe',
   -selectmode   => 'extended',
   -selectforeground => 'red',
  )
->pack(-fill => 'both',
   -expand   => 1
  );

open SD,';

my %hash = reverse map split, ; #;
print "Datei '$_' belegt '$hash{$_}'.\n" for sort keys %hash;


$hl->add('/');
$hl->item('create', '/', 0, -text => '/');
for my $file (sort keys %hash) {
print "file: '$file'\n";
my @path = split '/', $file;
shift @path; # leeren Eintrag vorn entfernen
print "path: '@path'\n";
my $path = "";
for my $pt (@path) {
print "inpatharray: $pt\n";
$path .= "/$pt";
print "path: $path\n";


if (! $hl->info('exists', $path)) {
my $realFile= fileparse($file);
if (-d $path) {
$hl->add($path);
$hl->item('create',
  $path,
  0,
  -text  => "$path",
  -image => $hl->Getimage('folder'),
 );
$hl->autosetmode;
}
else {
$hl->add($path);
$hl->item('create',
  $path,
  0,
  -text  => "$path",
  -image => $hl->Getimage('file'),
 );
$hl->autosetmode;
}
}
else {
print "weder noch\n";
}
}
}
---

to create the LIST file, simply do:

du -h -a /usr> /tmp/all 2>/dev/null -->or /var or any big directory
sort +1 /tmp/all > /tmp/LIST


zhis should generate a file called LIST in the /tmp directory. i hope
someone has an idea because this is really important. 


THANKS YOU VERY MUCH :-)

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



put path together?

2003-06-26 Thread magelord
hello to everyone. when i have a path like that:

/usr/X11R6/lib/X11/locale

how can i cut this path into strings like that:

/
/usr
/usr/X11R6
/usr/X11R6/lib
/usr/X11R6/lib/X11
/usr/X11R6/lib/X11/locale

and write this at the beginning of a file? i tried many things, but all
things i tried failed:(

THANK YOU

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



(kein Betreff)

2003-06-25 Thread magelord
hi, i wrote this little program. it shows a directory structure using
tree and hlist. it reads the directoycontent from a file. when i
display small directories, the program starts fast, but as soon as the
directory is big, it takes a long time to start. for example when i use
the /var directory.

to test, simply generate a file and read that file. maybe you have to
change the file name within the program.

du- ha >/tmp/yourfilename1
sort +1 /tmp/yourfilename1 > /tmp/LIST

heres the code:


#!/usr/bin/perl
use diagnostics;
use strict;
use Tk;
use Tk::HList;
use Tk::Tree;
use File::Basename;


my $mw = tkinit;
my $hl = $mw->ScrlTree(-separator=> '/',
   -drawbranch   => 1,
   -scrollbars   => 'osoe',
   -selectmode   => 'extended',
   -selectforeground => 'red',
  )->pack(-fill  => 'both',
   -expand   => 1);

open DATA,';

my %hash = reverse map split, ; #;
print "Datei '$_' belegt '$hash{$_}'.\n" for sort keys %hash;


$hl->add('/');
$hl->item('create', '/', 0, -text => '/');
for my $file (sort keys %hash) {
my @path = split '/', $file;
shift @path; # leeren Eintrag vorn entfernen
my $path = "";
for my $pt (@path) {

$path .= "/$pt";


if (! $hl->info('exists', $path)) {
my $realFile= fileparse($file);
if (-d $path) {
$hl->add($path);
$hl->item('create',
  $path,
  0,
  -text  => "$path",
  -image => $hl->Getimage('folder'),
 );
$hl->autosetmode;
}
else {
$hl->add($path);
$hl->item('create',
  $path,
  0,
  -text  => "$path",
  -image => $hl->Getimage('file'),
 );
$hl->autosetmode;
}
}
else {
#print "weder noch\n";
}
}
}


MainLoop;
__DATA__


THANK YOU VERY MUCH

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



using FIle::Find::name if regex to filter

2003-06-23 Thread magelord
hi, how can i use a real regex with this:

File::Find::name if -x?

the filetestops are working fine, but how can i filter things like
.gz$? i tried many ways, but all failed. any idea? thanks!!

bye andreas

-- 
.::Please visit my homepage::.
http://www.math55.de.vu

.::A very good JAVA site (worth a visit)::.
http://www.javaCore.de

.::Please visit the ANTI - TCPA homepage::. 
http://www.antitcpa.com

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