[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl-Toolbox] How do I parse FSSpec?



At 15.04 +0200 2000.01.24, Shai Spharim wrote:
>I have a path of a file and i would like to create another file next
>to it on the same folder.
>
>For example: I have the path "MyHD:Mac Perl:some.pl" and I would like
>to create file with the path  "MyHD:Mac Perl:some.pl.copy".

I am not sure what you want.

  use File::Basename;
  my $file1 = 'MyHD:Mac Perl:some.pl';
  my $dir = dirname($file);
  my $file2 = "$dir:some.pl.copy";

Is that what you want?  Or do you want to just copy the file?

  use File::Copy;
  copy $file1, $file2 or die $!;

If you want to just create the file, then:

  open F, ">$file2" or die $!;
  close F;

Or:

  use Mac::Files;
  FSpCreate($file2, $creator, $type) or die $^E;

Hopefully that helped somewhere along the way ...

-- 
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-toolbox-request@macperl.org