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

[MacPerl] Re: Beginner trying to learn Perl ...




 > 2nd problem
 >  
 > I chapter 6 "Reading & Writing files". I could read files as long as I
 > specified Mac path to file but there was no way that I could create a file
 > within a MacPerl program.  Any information here will greatly appreciated.
 
 
 I am not sure about the first problem but regarding the 2nd problem, the
 following script works on my Mac.  This script, "writefile.pl", lives in the
 same folder as a folder called "SomeDir_Level1".  It creates and writes to a
 file called "some_file" in "SomeDir_Level1".
 
 I hope this answers your question.

	#!/usr/local/bin/perl -w
	# "writefile.pl"
	#
	
	#$fn = "some_file";                # Writes to "some_file" in same dir.
	$fn = ":SomeDir_Level1:some_file"; # Writes to "some_file" in "SomeDir_Level1"
	
	open(SF, ">$fn") or die "Could not open file: \"$fn\"\n";
	print SF "Hello world.\n";
	close(SF);

****************************************
****    Steve Banville              ****
****    4560 Horton Street          ****
****    Emeryville CA 94608         ****
****    (510)923-2559               ****
****    steveb@chiron.com           ****
****************************************