develooper Front page | perl.beginners | Postings from February 2002

RE: file names with spaces in perl

Thread Previous | Thread Next
From:
Johnson, Shaunn
Date:
February 27, 2002 08:42
Subject:
RE: file names with spaces in perl
Message ID:
73309C2FDD95D11192E60008C7B1D5BB0452E013@snt452.corp.bcbsm.com
--Sorry 'bout that:

--Yeah, I did cut and past, but I missed
the backticks at the beginning and
end of the command (mkisofs) and
the end of the line.

--The readdir option - not sure if I follow,
but I will look for something about readdir
instead of `ls -1` for what I have to.

--But what I don't get is, when I did a print
of the dir, it looked okay ... why can't I
capture the entire file (or, list) in a
variable?  Maybe I missed that entirely ...
someone was telling me to try to use double
quotes for that ... but I haven't gotten it
to work ...

--Thanks!

-X



-----Original Message-----
From: Jenda Krynicky [mailto:Jenda@Krynicky.cz]
Sent: Wednesday, February 27, 2002 11:32 AM
To: beginners@perl.org
Subject: Re: file names with spaces in perl


From:           	"Johnson, Shaunn" <SJohnson6@bcbsm.com>
> I'm having a problem with trying to get
> a list of files with spaces in them.
> 
> I'm writing a perl script that goes into
> a directory, get a list of files with spaces
> in them (this is a file.doc) and run a
> mkisofs command against it.
> 
> I can get a list of the files:
> 
> [example]
> 
> $debug=2;
> foreach $cmd (`ls -1 $report_dir`)
> 
> [/example]
> 
> This *looks* like it gives me what i want (a list
> of directories that have spaces in them, but
> when i try something like this:

Please don't shell out (start external processes) unless you have to.
Use readdir or glob instead!

> [example]
> 
>  {
>         $mkisofs -f -J -r -hide-joliet-trans-tbl -V 'Report' -T -v -o
> '$iso_dir/$cmd.iso' "$report_dir";
>         }
> __END__
> [/example]

print the command instead of executing it, Maybe you'll notice 
what the problem is. Also ... I don't see any system(), backticks or 
whatever in your code, didn't you copy&pasted the real code into 
your post?

Jenda


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About