473,406 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to create a txt,word file in c:,d: harddrives using perl?

Hi
I tried to create a file using sysopen command as the following

Expand|Select|Wrap|Line Numbers
  1. sysopen( SUSI,'c:\\susi.html',O_RDWR|O_EXCL|O_CREAT, 0755);
  2. printf HTML "<html>\n";
  3. printf HTML "<head>\n";
  4. printf HTML "<title>Susintha Home page</title>;
  5. printf HTML "</head>\n";
  6. printf HTML "<body>\n";
  7. printf HTML "<p align='center'>this is an html
  8. page with a paragraph.</p>";
  9. printf HTML "</body>\n";
  10. printf HTML "</html>\n";
  11. close (HTML);
  12.  
But the file is not shown in c:
can anybody guide me to create the file in C or in D:
Jun 26 '07 #1
5 1921
KevinADC
4,059 Expert 2GB
Did you load the Fcntl module?
Jun 26 '07 #2
No I did not load the module.
Is it needed to create a file with size in windows?
Jun 26 '07 #3
I tried this command ,it creating a directory and the file.
But I am unable to create a file if i get the filesize from the user.
can we do that by using that Fcntl module?
$dirname=chandani;
$subdir=arun;
system ("mkdir -p $dirname/$subdir touch $dirname/$subdir");
open (FILE1,">$dirname/$subdir/susi.txt");
Jun 26 '07 #4
KevinADC
4,059 Expert 2GB
In your code you have:

sysopen( SUSI,'c:\\susi.html',O_RDWR|O_EXCL|O_CREAT, 0755);

these are constants:

O_RDWR|O_EXCL|O_CREAT

but they have no meaning unless you load them by using the Fcntl module. But you are using windows and I am not sure if O_RDWR and O_EXCL are supported by windows, but the file permission 0755 is not. You really do not have to use sysopen() to do what you want. And there is no need to shell out to the 'mkdir' command because perl has an internal function of the same name that does the same thing:

Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. use warnings;
  3. my $dirname = 'chandani';
  4. my $subdir = 'arun';
  5. mkdir "$dirname/$subdir" or die "Can't mkdir $dirname/$subdir: $!";
  6. open (FILE1,">$dirname/$subdir/susi.txt") or die "Can't open susi.txt: $!";
  7.  
you should be using the "strict" and "warnings' pragmas which is especially important for new perl coders.
Jun 26 '07 #5
Hi,

Thanks for clear my doubts
Jun 26 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: sandycat05 | last post by:
Hello all, I am a new Perl programmer. Below is the beginnings of a code that I am using to manipulate an Excel spreadsheet via Perl using win32::OLE. However, what I'd like to do is the following:...
2
by: Mikey | last post by:
Sample VB .NET source code to create mailing labels or customized letters using MS Word MailMerge This VB .NET source code will start MS Word and call methods and set properties in MS Word to...
0
by: funeeldy | last post by:
I need to locate a particular table in a document. I cannot hardcode the table number since it could be different in every doc. I do have some header text that comes right before it consistently,...
2
by: Vinodhg | last post by:
Hello Sir/Madam, I am writing a perl script to find a word from a file.. #!/usr/local/bin/perl unless (open(VINODH, "vinodh.txt")) { die("Cannot open input file vinodh.txt") }...
3
crazy4perl
by: crazy4perl | last post by:
Hi All, I have some doubt related to xml. Actually I want to update a file which is in some format. So I am converting that file using Tap3edit perl module in a hash. Now I m trying to create a...
5
by: Nitin Mahajan | last post by:
Guys Is there a way in C# to create a word object directly from a memory stream without passing that to hard disk (file stream). I think it doesn't makes sense to create a file just to read it...
2
by: arivusudar.nc | last post by:
I have to open word document in web page using php coding in linux server.. already i worte in windows supporting php code. but it is not working in my linux server so, i need how to open word...
5
by: Sevla | last post by:
hello guys i set this code , and i would like to know if its possible set "quotes" on the searched word. Thank You #word searching program within a txt file #!C:/perl/bin/perl.exe start:
3
by: Sevla | last post by:
hello, im having a problem to change a particular word in a line, can´t find where is my mistake also i would like to know how to make this program check automatically if a particular word...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.