Using filenames with Unicode chars

2014-06-08 Thread Octavian Rasnita
Hello, Do you know if there is a *portable* way in Perl for working with filenames with Unicode chars? I mean, I need to create/rename/move/copy/modify/delete files. It should work at least under Windows/Mac/Linux. The standard way of using open() doesn't seem to be working. T

Re: cgi and absolute filenames

2009-12-20 Thread Randal L. Schwartz
> "reader" == reader writes: reader> When using cgi to run scripts over html, what is the right addressing reader> scheme when the script needs to open or alter files on the server. *Most* CGI execution engines "cd" to the path of the script when executing that script. Hence opening ">foo"

cgi and absolute filenames

2009-12-20 Thread reader
This may belong somewhere else... but I'm pretty sure someone here can tell me about this. When using cgi to run scripts over html, what is the right addressing scheme when the script needs to open or alter files on the server. For example... a cgi writes a page for viewing. the cgi needs to ope

Re: Changing some filenames

2008-12-27 Thread M.Lewis
John W. Krahn wrote: M.Lewis wrote: I have a need to manipulate some filenames. The files are all in a single directory. They are currently named in the form: 01012003-Rattler.tar.gz 01162003-Rattler.tar.gz 01312003-Rattler.tar.gz 02152003-Rattler.tar.gz These are backup files from a

Re: Changing some filenames

2008-12-27 Thread John W. Krahn
M.Lewis wrote: I have a need to manipulate some filenames. The files are all in a single directory. They are currently named in the form: 01012003-Rattler.tar.gz 01162003-Rattler.tar.gz 01312003-Rattler.tar.gz 02152003-Rattler.tar.gz These are backup files from a machine. What I will

Re: Changing some filenames

2008-12-27 Thread John Refior
> So all I have is the filenames to put the files in date order. I believe > this would be the proper format to do this: > > 20030101-Rattler.tar.gz > 20030116-Rattler.tar.gz > 20030131-Rattler.tar.gz > 20030215-Rattler.tar.gz > > I wrote a short script to do this, and

Changing some filenames

2008-12-27 Thread M.Lewis
I have a need to manipulate some filenames. The files are all in a single directory. They are currently named in the form: 01012003-Rattler.tar.gz 01162003-Rattler.tar.gz 01312003-Rattler.tar.gz 02152003-Rattler.tar.gz These are backup files from a machine. What I will ultimately be doing

How to perform filetests on unicode filenames?

2007-06-13 Thread tinaa
I was trying to write a program that extracts filenames from an XML file. The filenames in the XML are represented as URLs with percent encoding. So I converted those to a regular path string (as used in Windows XP SP2) and tried to perform a -e filetest to see if the file is actually present

Re: get only filenames and not directory names under a specific path.

2006-07-27 Thread Alan_C
On Wednesday 26 July 2006 00:59, Rob Dixon wrote: > Hello Alan > > Alan_C wrote: > > On Tuesday 25 July 2006 15:56, Rob Dixon wrote: > >>Nishi Bhonsle wrote: [ snip ] > > [ snip ] [ snip ] > > #!/usr/bin/perl > >use strict; > >use warnings; > > > >my @dir = do { > > # opend

Re: get only filenames and not directory names under a specific path.

2006-07-26 Thread Rob Dixon
, '/home/al/temp4' or die $!; > # grep -f, readdir $dh; > readdir $dh; >}; > >print "$_\n" foreach @dir; > # print @dir, "\n"; At least use print "@dir\n" or the filenames will all be concatenated together without being

Re: get only filenames and not directory names under a specific path.

2006-07-25 Thread Alan_C
On Tuesday 25 July 2006 15:56, Rob Dixon wrote: > Nishi Bhonsle wrote: > > I got the last soln, ie to use File::Basename module. Please ignore the > > last thread. > > > > I am still interested to know why Rob's soln doesnt work for me? > > So was I, and it's because I made a mistake. Because t

Re: get only filenames and not directory names under a specific path.

2006-07-25 Thread Dr.Ruud
"Nishi Bhonsle" schreef: [don't! top-post!] > [IO:All] > Currently, it prints > C:\..\..\..\File1.txt > etc > I really want it only print File1.txt I don't understand how you read the documentation. Just search for 'filename'. And start to grok the 'All' in IO::All. -- Affijn, Ruud "Gewoon i

Re: get only filenames and not directory names under a specific path.

2006-07-25 Thread Rob Dixon
Nishi Bhonsle wrote: > > I got the last soln, ie to use File::Basename module. Please ignore the > last thread. > > I am still interested to know why Rob's soln doesnt work for me? So was I, and it's because I made a mistake. Because the values returned by readdir don't include a full path, the

Re: get only filenames and not directory names under a specific path.

2006-07-25 Thread Nishi Bhonsle
I got the last soln, ie to use File::Basename module. Please ignore the last thread. I am still interested to know why Rob's soln doesnt work for me? Thanks much! On 7/25/06, Nishi Bhonsle <[EMAIL PROTECTED]> wrote: Hi: In addition can i modify the all_files to return only the absolute fil

Re: get only filenames and not directory names under a specific path.

2006-07-25 Thread Nishi Bhonsle
Hi: In addition can i modify the all_files to return only the absolute filename and not the filename alongwith the entire path? Currently, it prints C:\..\..\..\File1.txt etc I really want it only print File1.txt Thanks! On 7/25/06, Nishi Bhonsle <[EMAIL PROTECTED]> wrote: Yes, all_files wo

Re: get only filenames and not directory names under a specific path.

2006-07-25 Thread Nishi Bhonsle
Yes, all_files works. Its in the doc, and i missed it. Its my bad. Rob, I tried the code snippet you mentioned, apparently it doesnot return anything under the directory. Thanks, Nishi. On 7/25/06, Dr.Ruud <[EMAIL PROTECTED]> wrote: Rob Dixon schreef: >use strict; >use warnings; > >

Re: get only filenames and not directory names under a specific path.

2006-07-25 Thread Dr.Ruud
Rob Dixon schreef: >use strict; >use warnings; > >my @dir = do { > opendir my $dh, 'C:\build\Sample\NewDir' or die $!; > grep -f, readdir $dh; For newbies, maybe put a comment here that the closedir() is implicit. >}; > >print "$_\n" foreach @dir; -- Affijn, Ruud

Re: get only filenames and not directory names under a specific path.

2006-07-25 Thread Rob Dixon
Nishi Bhonsle wrote: > > I am not able to get the files at just the first level. > ie > print "$_\n" for $io->all(0); prints all level down > and > print "$_\n" for $io->all(1); prints the files and the dir name at the > first level > ie > issuing the command for path C:\build\Sample\NewDir > p

Re: get only filenames and not directory names under a specific path.

2006-07-24 Thread Dr.Ruud
"Nishi Bhonsle" schreef: > I am not able to get the files at just the first level. > ie > print "$_\n" for $io->all(0); prints all level down > and > print "$_\n" for $io->all(1); prints the files and the dir name at > the first level "All" and "all(0)" are the same. "all" and "all(1)" are t

Re: get only filenames and not directory names under a specific path.

2006-07-24 Thread Mumia W.
On 07/24/2006 06:35 PM, Nishi Bhonsle wrote: Hi: If I need to get the files without the "." and the ".." at the first level only, [...] use File::Slurp; my @files = read_dir('mydirectory'); Do you have the perl documentation installed? This should give you information about File::Slurp: perl

Re: get only filenames and not directory names under a specific path.

2006-07-24 Thread Nishi Bhonsle
Hi: I am not able to get the files at just the first level. ie print "$_\n" for $io->all(0); prints all level down and print "$_\n" for $io->all(1); prints the files and the dir name at the first level ie issuing the command for path C:\build\Sample\NewDir prints the below C:\build\Sample\NewDi

Re: get only filenames and not directory names under a specific path.

2006-07-24 Thread Dr.Ruud
"Nishi Bhonsle" schreef: > If I need to get the files without the "." and the ".." at the first > level only, then how can i modify the find command? > ie > Currently using find(sub {push(@new,$_) if ( -f ) }, $path); gives > me all files under NewDir as well as NewSubDirectory > C:\build\Sample

Re: get only filenames and not directory names under a specific path.

2006-07-24 Thread Nishi Bhonsle
Hi: If I need to get the files without the "." and the ".." at the first level only, then how can i modify the find command? ie Currently using find(sub {push(@new,$_) if ( -f ) }, $path); gives me all files under NewDir as well as NewSubDirectory C:\build\Sample\NewDir\File1.txt C:\build\Sample\

Re: get only filenames and not directory names under a specific path.

2006-07-22 Thread Dr.Ruud
"Wagner, David --- Senior Programmer Analyst --- WGO" schreef: > if ( !/^\.{1,2}/ ) That would fail "..x" &c. If you are only interested in files and not directories, use -f. -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-

Re: get only filenames and not directory names under a specific path.

2006-07-21 Thread Nishi Bhonsle
.{1,2}/ ) }, $path); If not 1 or 2 periods push on to @new; Wags ;) > > open FILE,">>$logfile"; > > print FILE "$_\n" foreach @new; > close FILE; > > In addition to printing filenames and directories, it also printed > the "." Th

RE: get only filenames and not directory names under a specific path.

2006-07-21 Thread Wagner, David --- Senior Programmer Analyst --- WGO
If going into other directories and pulling those files also then add: and ! -d $_ to the if Wags ;) >> >> open FILE,">>$logfile"; >> >> print FILE "$_\n" foreach @new; >> close FILE; >> >> In addition to prin

RE: get only filenames and not directory names under a specific path.

2006-07-21 Thread Wagner, David --- Senior Programmer Analyst --- WGO
rint FILE "$_\n" foreach @new; > close FILE; > > In addition to printing filenames and directories, it also printed > the "." The log file contained > . > file1.txt > file2.txt > > How can I not include the "." ? > > Thanks! > &g

Re: get only filenames and not directory names under a specific path.

2006-07-21 Thread Nishi Bhonsle
I tried it but didnt work. my @new; find(sub {push @new, $_}, $path); open FILE,">>$logfile"; print FILE "$_\n" foreach @new; close FILE; In addition to printing filenames and directories, it also printed the "." The log file contained . file1.txt

Re: get only filenames and not directory names under a specific path.

2006-07-21 Thread Rob Dixon
fy the above code so that no directory name is printed in the ouputfile but only filenames are printed. ie File1.txt and File2.txt are printed in the output file without the NewSubDirectory printed in it? I am looking for some way that before getting the entries into the new array, i can remove the en

Re: get only filenames and not directory names under a specific path.

2006-07-20 Thread Edi STOJICEVIC
;." and $_ ne ".." } readdir DIR; > closedir DIR; > > open FILE,">>c:/buildlist2.txt"; > print FILE "$_\n" foreach @new; > close FILE; > > Can I modify the above code so that no directory name is printed in the > ouputfile but

get only filenames and not directory names under a specific path.

2006-07-20 Thread Nishi Bhonsle
]; opendir DIR, $path or die "Can't open $path: $!"; my @new = grep { $_ ne "." and $_ ne ".." } readdir DIR; closedir DIR; open FILE,">>c:/buildlist2.txt"; print FILE "$_\n" foreach @new; close FILE; Can I modify the above code so that no

RE: write out filenames of files existing on a filesystem into afile

2006-07-20 Thread Venkat Saranathan
06 10:44 AM To: Nishi Bhonsle; beginners@perl.org Subject: Re: write out filenames of files existing on a filesystem into afile On 7/19/06, Prabu <[EMAIL PROTECTED]> wrote: > Nishi Bhonsle wrote: > > Hi: > > > > How do I look for the string in the following file

Re: write out filenames of files existing on a filesystem into afile

2006-07-20 Thread Jay Savage
On 7/19/06, Prabu <[EMAIL PROTECTED]> wrote: Nishi Bhonsle wrote: > Hi: > > How do I look for the string in the following file > so that > i can insert something between the tags > > insert some bla text here > > in the following file? > > -

Re: write out filenames of files existing on a filesystem into afile

2006-07-19 Thread Prabu
Nishi Bhonsle wrote: Hi: How do I look for the string in the following file so that i can insert something between the tags insert some bla text here in the following file? http:/

Re: write out filenames of files existing on a filesystem into afile

2006-07-19 Thread Nishi Bhonsle
wrote: > > > >>>>>>"Rob" == Rob Dixon <[EMAIL PROTECTED]> writes: > > > > Rob> Not much chance of that I'm afraid Shawn. I can do without the > apology, I > > Rob> just wish he'd confirm that his original critique was

Re: write out filenames of files existing on a filesystem into afile

2006-07-17 Thread Rob Dixon
John W. Krahn wrote: Rob Dixon wrote: To check whether a directory's empty or not you need to read /that/ directory in turn. Not necessarily, you should be able to tell by stat()ing the size of the directory (this works on Linux, I don't know about DOS/Windows.) Thanks John As far as I can

Re: write out filenames of files existing on a filesystem into afile

2006-07-17 Thread Dr.Ruud
Rob Dixon schreef: > Nishi Bhonsle wrote: > > > > If I am still using the below logic, how can i modify the below > prog > to ignore empty directories and list only directories > containing > directories > > and files in buildlist.txt ? > > > > opendir DIR, $path or die "Can't open $path: $!

Re: write out filenames of files existing on a filesystem into afile

2006-07-17 Thread John W. Krahn
Rob Dixon wrote: > Nishi Bhonsle wrote: >> >> If I am still using the below logic, how can i modify the below prog >> to ignore empty directories and list only directories containing >> directories >> and files in buildlist.txt ? >> >> opendir DIR, $path or die "Can't open $path: $!"; >> >> #my @n

Re: write out filenames of files existing on a filesystem into afile

2006-07-17 Thread Rob Dixon
Nishi Bhonsle wrote: > > If I am still using the below logic, how can i modify the below prog > to ignore empty directories and list only directories containing > directories > and files in buildlist.txt ? > > opendir DIR, $path or die "Can't open $path: $!"; > > #my @new = grep /[^.]/, readdir D

Re: write out filenames of files existing on a filesystem into afile

2006-07-16 Thread Nishi Bhonsle
Hi: If I am still using the below logic, how can i modify the below prog to ignore empty directories and list only directories containing directories and files in buildlist.txt ? opendir DIR, $path or die "Can't open $path: $!"; #my @new = grep /[^.]/, readdir DIR; my @new = grep { $_ ne "." a

Re: Randal L. Schwartz is Wrong (WAS:write out filenames of files existing on a filesystem into afile)

2006-07-13 Thread Dave Gray
On 7/13/06, Chad Perrin <[EMAIL PROTECTED]> wrote: On Thu, Jul 13, 2006 at 01:44:40AM -0400, Mr. Shawn H. Corey wrote: > > It comes down to this, either he will post an apology for stating a > third party should not post his comments, or I'll leave this list, never > to return. 1. You may have

Re: write out filenames of files existing on a filesystem into afile

2006-07-13 Thread Jay Savage
On 7/12/06, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote: Jay Savage wrote: > opendir(DIR, $somedir) or die "$!\n"; > my @files = grep { $_ !~ /^\.{1,2}$/ && -f "$somedir/$_" } readdir(DIR); > closedir(DIR); my @files = grep { -f } glob( "$somedir/*" ); If you're not interested in subdire

Re: Randla L. Schwartz is Wrong (WAS:write out filenames of files existing on a filesystem into afile)

2006-07-12 Thread Chad Perrin
On Thu, Jul 13, 2006 at 01:16:37AM -0400, Omega -1911 wrote: > > So I ask, can someone up front stop the car, stop the arguing, simply > pull over, ask for some directions and lead us to where ever it is we > are supposedly going...As I forgot the map, starting to feel car-sick, > and I gotta peee

Re: Randal L. Schwartz is Wrong (WAS:write out filenames of files existing on a filesystem into afile)

2006-07-12 Thread Chad Perrin
On Thu, Jul 13, 2006 at 01:44:40AM -0400, Mr. Shawn H. Corey wrote: > > It comes down to this, either he will post an apology for stating a > third party should not post his comments, or I'll leave this list, never > to return. 1. You may have been able to garner some sympathy if you hadn't used

Re: Randal L. Schwartz is Wrong (WAS:write out filenames of files existing on a filesystem into afile)

2006-07-12 Thread Mr. Shawn H. Corey
Jeff Peng wrote: > Shawn is always kind to reply all kinds of questions here with > high-level skills.I think both you are great to people in the perl > world.So don't be angry for something that's not so important > please.This's a technology lists,too much topics about personal feeling > shoud ge

Re: Randla L. Schwartz is Wrong (WAS:write out filenames of files existing on a filesystem into afile)

2006-07-12 Thread Omega -1911
On 7/13/06, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote: I thought about this; then I thought about this; and then I thought about this. Randal L. Schwartz wrote: >>"Shawn" == "Mr Shawn H Corey" <[EMAIL PROTECTED]> writes: > > > Shawn> Not everyone who reads this mailing list posts to it.

Re: Randla L. Schwartz is Wrong (WAS:write out filenames of files existing on a filesystem into afile)

2006-07-12 Thread Jeff Peng
Randla L. Schwartz is great on Perl field,I think everyone here has read some of his books.Those books bring us into Perl world and let us know what's the essence of Perl.I think he just want to let every answer here know the basic rules for asking/answering the questions.Follow the suggestions

Re: Randla L. Schwartz is Wrong (WAS:write out filenames of files existing on a filesystem into afile)

2006-07-12 Thread Mr. Shawn H. Corey
I thought about this; then I thought about this; and then I thought about this. Randal L. Schwartz wrote: >>"Shawn" == "Mr Shawn H Corey" <[EMAIL PROTECTED]> writes: > > > Shawn> Not everyone who reads this mailing list posts to it. What impression > Shawn> would his comments leave on them

Re: write out filenames of files existing on a filesystem into afile

2006-07-12 Thread Mr. Shawn H. Corey
Jay Savage wrote: > opendir(DIR, $somedir) or die "$!\n"; > my @files = grep { $_ !~ /^\.{1,2}$/ && -f "$somedir/$_" } readdir(DIR); > closedir(DIR); my @files = grep { -f } glob( "$somedir/*" ); If you're not interested in subdirectories, you only need glob(). And yes, it doesn't list hidd

Re: write out filenames of files existing on a filesystem into afile

2006-07-12 Thread Jay Savage
On 7/12/06, Nishi Bhonsle <[EMAIL PROTECTED]> wrote: Hi: Sorry to start this thread again, but it would not have been wise to ask my related question in a different thread. I tried to run the program on a windows machine, apparently the regex in question only lists directories within directories

Re: write out filenames of files existing on a filesystem into afile

2006-07-12 Thread Rob Dixon
t on that score :) I just looked at your original post again, and it may well be that you're not interested in the directory path to the file at all, in which case change the line again to: find(sub {push @new, $_ if -f}, $path); which will leave just the bare filenames in the array. Re

Re: write out filenames of files existing on a filesystem into afile

2006-07-12 Thread Rob Dixon
Nishi Bhonsle wrote: > > Hi: > Sorry to start this thread again, but it would not have been wise to ask my > related question in a different thread. > I tried to run the program on a windows machine, apparently the regex in > question only lists directories within directories and not the files wit

Re: write out filenames of files existing on a filesystem into afile

2006-07-12 Thread Nishi Bhonsle
nce more to explain my true stance, which you seem keen to obfuscate. (Randal L. Schwartz) wrote: > >>>>>>"Rob" == Rob Dixon <[EMAIL PROTECTED]> writes: > > Rob> Not much chance of that I'm afraid Shawn. I can do without the apology, I > Ro

Re: write out filenames of files existing on a filesystem into afile

2006-07-11 Thread Rob Dixon
D]> writes: > > Rob> Not much chance of that I'm afraid Shawn. I can do without the apology, I > Rob> just wish he'd confirm that his original critique was wrong instead of > Rob> banging on about filenames with three dots. I think leaving people with > Rob> th

Re: write out filenames of files existing on a filesystem into afile

2006-07-11 Thread Ask Bjoern Hansen
Rob Dixon wrote: Not much chance of that I'm afraid Shawn. I can do without the apology, I just wish he'd confirm that his original critique was wrong instead of banging on about filenames with three dots. I think leaving people with that misinformation uncorrected is a lot more impor

Re: write out filenames of files existing on a filesystem into afile

2006-07-11 Thread Randal L. Schwartz
> "Shawn" == "Mr Shawn H Corey" <[EMAIL PROTECTED]> writes: Shawn> Not everyone who reads this mailing list posts to it. What impression Shawn> would his comments leave on them? How can we encourage people to use Shawn> Perl if they think they will receive harsh criticism? The fact that the Sh

Re: write out filenames of files existing on a filesystem into afile

2006-07-11 Thread Randal L. Schwartz
>>>>> "Rob" == Rob Dixon <[EMAIL PROTECTED]> writes: Rob> Not much chance of that I'm afraid Shawn. I can do without the apology, I just Rob> wish he'd confirm that his original critique was wrong instead of banging on Rob> about filenames

Re: write out filenames of files existing on a filesystem into afile

2006-07-11 Thread Randal L. Schwartz
>>>>> "Mumia" == "Mumia W " writes: Mumia> Not quite. Rob's program works for rational input data. And that attitude creates fragile, eventually broken code. Many years ago, people wrote shell scripts that couldn't deal with spaces in filenames

Re: write out filenames of files existing on a filesystem into afile

2006-07-10 Thread Rob Dixon
Mr. Shawn H. Corey wrote: > > After all, we don't want people frighten into learning that other language > that starts with P ;) Why? I like Pascal. :) R -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: write out filenames of files existing on a filesystem into afile

2006-07-10 Thread Chad Perrin
On Mon, Jul 10, 2006 at 06:34:48PM -0400, Mr. Shawn H. Corey wrote: > > I think he owes you an apology, regardless of whether he was right or > wrong, regardless of whether you were right or wrong. > > Not everyone who reads this mailing list posts to it. What impression > would his comments leav

Re: write out filenames of files existing on a filesystem into afile

2006-07-10 Thread Mr. Shawn H. Corey
Rob Dixon wrote: > Not much chance of that I'm afraid Shawn. I can do without the apology, > I just > wish he'd confirm that his original critique was wrong instead of > banging on > about filenames with three dots. I think leaving people with that > misinformation

Re: write out filenames of files existing on a filesystem into a file

2006-07-10 Thread Dr.Ruud
"Nishi Bhonsle" schreef: > Can you please tell me how to modify the above program to ignore the > "." and "..", so that they donot get printed in C:/filelist.txt ? Since you want only files, see "perldoc -f -f". -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROT

Re: write out filenames of files existing on a filesystem into afile

2006-07-10 Thread Rob Dixon
ch chance of that I'm afraid Shawn. I can do without the apology, I just wish he'd confirm that his original critique was wrong instead of banging on about filenames with three dots. I think leaving people with that misinformation uncorrected is a lot more important. Anyway, nice to k

Re: write out filenames of files existing on a filesystem into afile

2006-07-10 Thread John W. Krahn
Jay Savage wrote: > On 7/10/06, Mumia W. <[EMAIL PROTECTED]> wrote: >> Randal L. Schwartz wrote: >> >> "Rob" == Rob Dixon <[EMAIL PROTECTED]> writes: >> > Just to (hopefully) put an end to this thread :-) the OP said: Nishi Bhonsle wrote: > > Can you please tell me how to modify the above pro

Re: write out filenames of files existing on a filesystem into afile

2006-07-10 Thread Mr. Shawn H. Corey
Rob Dixon wrote: > Just because Randal has publications to his name doesn't make him any > less prone > to mistakes, as we have seen in his original post on this thread. That > he is > more aggressive and vociferous than most don't to me make him more worth > reading. To me he is just a regular guy

Re: write out filenames of files existing on a filesystem into afile

2006-07-10 Thread Rob Dixon
hould check Rob's responses for accuracy. In fact, given that > this is a beginner's list, that probably holds true in other instances. I wasn't the OP, but I assume you mean me. Randal didn't just say my responses should be checked for accuracy, he said (above): :: I will warn othe

Re: write out filenames of files existing on a filesystem into afile

2006-07-10 Thread Jay Savage
On 7/10/06, Mumia W. <[EMAIL PROTECTED]> wrote: Randal L. Schwartz wrote: >> "Rob" == Rob Dixon <[EMAIL PROTECTED]> writes: > > Rob>my @new = grep /[^.]/, readdir DIR; > > This is still the wrong regex. While it's narrow enough for windows, it will > *break* on Unix. No reason not to do

RE: write out filenames of files existing on a filesystem into afile

2006-07-10 Thread Ryan Frantz
> -Original Message- > From: Mumia W. [mailto:[EMAIL PROTECTED] > Sent: Monday, July 10, 2006 11:55 AM > To: Beginners List > Subject: Re: write out filenames of files existing on a filesystem into > afile > > Randal L. Schwartz wrote: > >>>>

Re: write out filenames of files existing on a filesystem into afile

2006-07-10 Thread Mumia W.
Randal L. Schwartz wrote: "Rob" == Rob Dixon <[EMAIL PROTECTED]> writes: Rob>my @new = grep /[^.]/, readdir DIR; This is still the wrong regex. While it's narrow enough for windows, it will *break* on Unix. No reason not to do the right thing here: grep { $_ ne "." and $_ ne "..

Re: write out filenames of files existing on a filesystem into afile

2006-07-10 Thread Randal L. Schwartz
> "Rob" == Rob Dixon <[EMAIL PROTECTED]> writes: Rob>my @new = grep /[^.]/, readdir DIR; This is still the wrong regex. While it's narrow enough for windows, it will *break* on Unix. No reason not to do the right thing here: grep { $_ ne "." and $_ ne ".." } readdir DIR; Rob,

Re: write out filenames of files existing on a filesystem into afile

2006-07-10 Thread Rob Dixon
lter out any of the lines because they still contain the line terminator "\n" from the read, which will match /[^.]/. Changing the loop to: while ( ) { chomp; print "$_\n" if /[^.]/; } will give the results you expect. The chomp was unnecessary in the previo

Re: write out filenames of files existing on a filesystem into afile

2006-07-09 Thread Alan_C
[ . . ] Hi, my @new = grep /[^.]/, readdir DIR; (on Linux I tried it) that eliminates . and .. from the catch. *But the next code prints all 8 lines of data it does not eliminate . and .. from the catch, print* Isn't that a character class that says "not a dot" So, why the difference (readdi

Re: write out filenames of files existing on a filesystem into afile

2006-07-09 Thread Nishi Bhonsle
he following -- > 1)Flatten out the directory structure into a file containing the dir and > files within the dir into > C:\buildlist.txt > 2)Read the lines from a file say files2.txt and modify the lines to contain > the filenames fetched into C:\buildlist.txt. Write out the modif

Re: write out filenames of files existing on a filesystem into afile

2006-07-09 Thread Rob Dixon
odify the lines to contain > the filenames fetched into C:\buildlist.txt. Write out the modified lines > into result.txt. > > $path = "$ARGV[0]"; > opendir ( DIR, $path ) or die "Can't open $path: $!"; > while(defined($DIR = readdir DIR)) >{ &

Re: write out filenames of files existing on a filesystem into afile

2006-07-09 Thread Nishi Bhonsle
Hi: Thanks for all your suggestions and help. I was able to do the following -- 1)Flatten out the directory structure into a file containing the dir and files within the dir into C:\buildlist.txt 2)Read the lines from a file say files2.txt and modify the lines to contain the filenames fetched

Re: write out filenames of files existing on a filesystem into afile

2006-07-09 Thread Rob Dixon
e\oneone >>> C:\Temp\one\onetwo >>> C:\Temp\one\onethree but then you posted a solution which just opened a single directory and listed the files from there. Which is it tht you need? It's also important to note that your list will include both files and directories; again

Re: write out filenames of files existing on a filesystem into a file

2006-07-08 Thread Mathew Snyder
ourth " and between the fifth and > > sixth > > " one by one. > > > > "SL/" "%HOME%/server/bin/" "" NA > > as in > > "SL/one" "%HOME%/server/bin/one" "one" NA >

Re: write out filenames of files existing on a filesystem into afile

2006-07-08 Thread Rob Dixon
(Randal L. Schwartz) wrote: Hi Randal >>"Rob" == Rob Dixon <[EMAIL PROTECTED]> writes: > > > Rob> I favour > > Rob>print FILE "$_\n" foreach grep /[^.]/, readdir DIR; > > Rob> for clarity > > But certainly not for correctness! It's easy to look pretty if you don't care > about the right

Re: write out filenames of files existing on a filesystem into afile

2006-07-08 Thread Randal L. Schwartz
> "Rob" == Rob Dixon <[EMAIL PROTECTED]> writes: Rob> I favour Rob>print FILE "$_\n" foreach grep /[^.]/, readdir DIR; Rob> for clarity But certainly not for correctness! It's easy to look pretty if you don't care about the right answer. Your regex rejects *any* filename that contains

Re: write out filenames of files existing on a filesystem into afile

2006-07-08 Thread Rob Dixon
John W. Krahn wrote: Hi John [snip OP] use warnings; use strict; my $path = $ARGV[ 0 ]; open FILE, '>', 'c:/filelist.txt' or die "Can't open c:/filelist.txt: $!"; opendir DIR, $path or die "Can't open $path: $!"; print FILE map /^\.\.?$/ ? () : "$_\n", readdir DIR; I favour print FILE

Re: write out filenames of files existing on a filesystem into a file

2006-07-07 Thread John W. Krahn
Nishi Bhonsle wrote: > I was able to writeout the files on a filesystem to a file C:/filelist.txt > using the program - > > $path = "$ARGV[0]"; > opendir ( DIR, $path ) or die "Can't open $path: $!"; > while(defined($DIR = readdir DIR)) > { > push(@array_A,$DIR) > } > closedir DIR; >

Re: write out filenames of files existing on a filesystem into a file

2006-07-07 Thread Nishi Bhonsle
uot;SL/one" "%HOME%/server/bin/one" "one" NA Thanks again. On 7/7/06, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote: Nishi Bhonsle wrote: > Hi: > > Can you please help me write a perl script that takes the files from a > directory and spits out the fi

Re: write out filenames of files existing on a filesystem into a file

2006-07-07 Thread Mr. Shawn H. Corey
Nishi Bhonsle wrote: > Hi: > > Can you please help me write a perl script that takes the files from a > directory and spits out the filenames into a file. > say. > I have a file structure on a file system such as > C:\Temp\one > C:\Temp\two > C:\Temp\one\oneone > C:

write out filenames of files existing on a filesystem into a file

2006-07-07 Thread Nishi Bhonsle
Hi: Can you please help me write a perl script that takes the files from a directory and spits out the filenames into a file. say. I have a file structure on a file system such as C:\Temp\one C:\Temp\two C:\Temp\one\oneone C:\Temp\one\onetwo C:\Temp\one\onethree The original file contains lines

Re: spaces in filenames on winXX

2005-02-21 Thread Jean-Sébastien Guay
Harry, You have three choices. [...] snipped techniques So back to my original question: Is there a module or something that takes care of that pre processing for me? I think you misunderstood. The problem with your script is not the spaces in the string. It's that you used a single b

RE: spaces in filenames on winXX

2005-02-21 Thread Charles K. Clarkson
Harry Putnam <> wrote: : So back to my original question: : Is there a module or something that takes care of that pre : processing for me? There is no pre-processing. I use this same idiom on either platform. What do you mean by pre-processing? my $file = 'foo/bar/baz/no pre-processing

Re: spaces in filenames on winXX

2005-02-21 Thread Harry Putnam
"Charles K. Clarkson" <[EMAIL PROTECTED]> writes: [...] > You have three choices. [...] snipped techniques So back to my original question: Is there a module or something that takes care of that pre processing for me? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands

RE: spaces in filenames on winXX

2005-02-20 Thread Charles K. Clarkson
Harry Putnam <> wrote: : Here is an example of problems before even getting to spaces. : Doesn't this mean that some kind of preprocessing must take : place? : : #!C:\Perl\bin -w Shame! Always use strictures (except when mumble, mumble, mumble). use strict; : ## This is the format that

Re: spaces in filenames on winXX

2005-02-20 Thread Harry Putnam
"Jenda Krynicky" <[EMAIL PROTECTED]> writes: > Try to write the script you need and come back if you run into > problems. This isn't in keeping with Johns point about using opendir/readdir but I'm not sure I followed that anyway. Here is an example of problems before even getting to spaces. Do

Re: spaces in filenames on winXX

2005-02-20 Thread Jenda Krynicky
script that checks for and then deletes massive > numbers of files. I'm sure many will have spaces in the name. Perl generaly doesn't have any problems handling such files, you may have to enclose the filenames in quotes when starting other executables, but if you stay within Perl you d

Re: spaces in filenames on winXX

2005-02-20 Thread John W. Krahn
Harry Putnam wrote: Scripting in perl on a Windows OS and spaces in file names. I'm pretty sure this has been covered many times here, and I believe there are modules and such devoted to the problem but searching on www.cpan.org with various search strings hasn't turned up something specificall

spaces in filenames on winXX

2005-02-20 Thread Harry Putnam
Scripting in perl on a Windows OS and spaces in file names. I'm pretty sure this has been covered many times here, and I believe there are modules and such devoted to the problem but searching on www.cpan.org with various search strings hasn't turned up something specifically for this problem,

Re: Diamond Operator and Filenames

2005-02-18 Thread John W. Krahn
urrently parsing in there. Is that possible? Do I have access to the individual filenames AS they are being used in the while statement? I believe that $ARGV[0] has the file being processed. No, the array @ARGV doesn't change inside the while loop. Sorry, see my other post which shows that @

Re: Diamond Operator and Filenames

2005-02-18 Thread John W. Krahn
Larsen, Errin M HMMA/IT wrote: So, the <> operator shift()s the filenames off the top of @ARGV? That's usefull knowledge. Yes, but it does it before the loop starts! $ perl -le' print for @ARGV; print; while (<>) { print "$ARGV\t$ARGV[0]" if $. == 1; close

RE: Diamond Operator and Filenames

2005-02-18 Thread Wagner, David --- Senior Programmer Analyst --- WGO
errors/ ); >>> } >>> >>> Of course, my problem is that I'm not filling in $filename in that >>> print statement with a value. I'd really like to be able to put the >>> name of the file the diamond ('<>') operator is currently p

Re: Diamond Operator and Filenames

2005-02-18 Thread John W. Krahn
n there. Is that possible? Do I have access to the individual filenames AS they are being used in the while statement? I believe that $ARGV[0] has the file being processed. No, the array @ARGV doesn't change inside the while loop. John -- use Perl; program fulfillment -- To unsubscrib

Re: Diamond Operator and Filenames

2005-02-18 Thread John W. Krahn
if( /with errors/ ); } Of course, my problem is that I'm not filling in $filename in that print statement with a value. I'd really like to be able to put the name of the file the diamond ('<>') operator is currently parsing in there. Is that possible? Do I have access

RE: Diamond Operator and Filenames

2005-02-18 Thread Wagner, David --- Senior Programmer Analyst --- WGO
rint "$filename:\n$_" if( /with errors/ ); >>> } >>> >>> Of course, my problem is that I'm not filling in $filename in that >>> print statement with a value. I'd really like to be able to put the >>> name of the file the diamond (

RE: Diamond Operator and Filenames

2005-02-18 Thread Larsen, Errin M HMMA/IT
; > > Of course, my problem is that I'm not filling in $filename in that > > print statement with a value. I'd really like to be able > to put the > > name of the file the diamond ('<>') operator is currently > parsing in > > there. Is th

RE: Diamond Operator and Filenames

2005-02-18 Thread Wagner, David --- Senior Programmer Analyst --- WGO
gs; > while( <> ) { > print "$filename:\n$_" if( /with errors/ ); > } > > Of course, my problem is that I'm not filling in $filename in that > print statement with a value. I'd really like to be able to put the > name of the file the diamond ('&

  1   2   >