Perlfect Solutions

Perl File Handling: open, read, write and close files

This article describes the facilities provided for Perl file handling.

Opening files

Opening a file in perl in straightforward: open FILE, "filename.txt" or die $!; The command above will associate the FILE filehandle with the file filename.txt. You can use the filehandle to read from the file. If the file doesn't exist - or you cannot read it for any other reason - then the script will die with the appropriate error message stored in the $! variable.

What if you wanted to modify the file instead of just reading from it? Then you'd have to specify the appropriate mode using the three-argument form of open.

open FILEHANDLE, MODE, EXPR The available modes are the following:

mode operand create truncate
read <
write >
append >>

Each of the above modes can also be prefixed with the + character to allow for simultaneous reading and writing.

mode operand create truncate
read/write +<
read/write +>
read/append +>>

Notice, how both +< and +> open the file in read/write mode but the latter also creates the file if it doesn't exist or truncates (deletes) an existing file. So, if you wanted to open a file for writing, creating it if it doesn't exist and truncating it first if does, you'd do the following: open FILE, ">", "filename.txt" or die $! This operation might fail if for example you don't have the appropriate permissions. In this case $! will be set appropriately.

The mode and the filename in the three-argument form can be combined, so the above can also be written as: open FILE, ">filename.txt" or die $!; As you might have guessed already if you just want read access you can skip the mode just as we did in the very first example above.

Reading files

If you want to read a text file line-by-line then you can do it as such: my @lines = <FILE>; The <FILE> operator - where FILE is a previously opened filehandle - returns all the unread lines of the text file in list context or a single line in scalar context. Hence, if you had a particularly large file and you wanted to conserve memory you could process it line by line: while (<FILE>) { print $_; } The $_ variable is automatically set for you to the contents of the current line. If you wish you may name your line variable instead: while (my $line = <FILE>) { ... will set the $line variable to the contents of the current line. The newline character at the end of the line is not removed automatically. If you wish to remove it you can use the chomp command. After all lines have been read the <FILE> operator will return a false value hence causing the loop to terminate.

There may cases where you need to read a file only a few characters at a time instead of line-by-line. This may be the case for binary data. To do just that you can use the read command. open FILE, "picture.jpg" or die $!; binmode FILE; my ($buf, $data, $n); while (($n = read FILE, $data, 4) != 0) { print "$n bytes read\n"; $buf .= $data; } close(FILE); There is a lot going on here so let's take it step by step. In the first line of the above code fragment a file is opened. As you can guess from the filename it is a binary file. Binary files need to treated differently than text files on some operating systems (eg, Windows). The reason is that on these platforms a newline "character" is actually represented within text files by the two character sequence \cM\cJ (that's control-M, control-J). When reading the text file Perl will convert the \cM\cJ sequence into a single \n newline characted. The converse also holds when writing files. Clearly, when reading binary data this behavior is undesired and calling binmode on the filehandle will make sure that this conversion is avoided.

The read command takes either 3 or 4 arguments. The 3-argument form is: read FILEHANDLE, SCALAR, LENGTH while the 4-argument form is: read FILEHANDLE, SCALAR, LENGTH, OFFSET In the first case LENGTH characters of data are read in the variable specified by SCALAR from FILEHANDLE. The return value of read is the number of characters actually read, 0 at the end of the file or undef in the case of an error. Returning to our example above the third line of code will read at most 4 characters of data into the $data variable. The number of characters read will be stored in $n. Successive read operations on the same filehandle will set the current file position to be just before the first unread character. Thus the code above will read the contents of the file picture.jpg and store them in $buf, printing the number of characters read at every iteration.

If OFFSET is specified then the characters read will be placed at that position within the SCALAR. Taking advantage of this we could rewrite the loop above as such: my ($data, $n, $offset); while (($n = read FILE, $data, 4, $offset) != 0) { print "$n bytes read\n"; $offset += $n; }

Even though the example above demonstrates binary reading the read command works just as well on text files - just make sure to use (for binary) or not use (for text) binmode accordingly.

Writing files

Now that you know how to open and read files learning how to write to them is straighforward. Take a look at the following code: open FILE, ">file.txt" or die $!; print FILE $str; close FILE; Not much is new here. The only thing to observe is the two-argument use of print, the first argument being the FILEHANDLE to write to and the second an expression to be written. The expression can be anything: a scalar, a list, a hash, etc. Appending to a file can be accomplished in exactly the same manner - apart from specifying the appropriate (>>) mode of course.

At this point you are probably thinking that a description of the write is what follows. Actually, as the manual page for write puts it:
Note that write is not the opposite of read. Unfortunately.
Instead write is used to write formatted records to file, a subject outside the scope of this article.

Closing files

Once you are done reading and writing you should close any open filehandles. open FILE1, "file.txt" or die $!; open FILE2, "picture.jpg" or die $!; ... close FILE2; close FILE1; If you forget to close a filehandle Perl will do it for you before your script exists but it is good practice to close yourself what you have opened.

The close command may also fail returning false, eg, if you try to close a closed filehandle. If you want to catch these errors you can check the return value of close and the approriate error message stored in $! as is done in the following example: close FILE or die $!

Summary of perl file handling

The open, close, print and read commands will allow you to perform most common file operations. However, much more is possible. Apart from opening files you may open pipes to other commands using the | mode and read from them or write to them using the techniques described. This and more in an article to come.

Comments

Your name:
Your comments:

Security check *

 

David   

Posted at 6:38am on Tuesday, June 26th, 2007

Cool tutorials but the perl installation file. havidworld@yahoo.co.nz

fountain_spray   

Posted at 12:50pm on Wednesday, June 27th, 2007

Not describing Format for Write is a cop-out!

Where do I turn for THAT tutorial?

Richard Wicks   

Posted at 4:11pm on Thursday, August 23rd, 2007

Well, great, I can read binary files now. How the heck do I write them?

Tobias Maier   

Posted at 7:13am on Thursday, August 30th, 2007

You can use 'pack' to write binary files.
E.g.: The following snippet writes all numbers between 0 and zero as unsigned characters.

open(BIN, '>', 'binary_file')
or die "Couldn't open file for writing: $!n";
foreach my $i (0 ... 255) {
print BIN pack('C', $i);
}
close BIN;

Jo   

Posted at 9:09am on Monday, September 24th, 2007

I need to be able to read the first 20 lines of a txt file. How about that.
@ARGV?

Richard   

Posted at 2:57pm on Tuesday, September 25th, 2007

open(FILE, "

Richard   

Posted at 2:59pm on Tuesday, September 25th, 2007

open(FILE, "

Richard   

Posted at 3:00pm on Tuesday, September 25th, 2007

Sorry, I don't know why it won't take my entire comment :(

Sasi   

Posted at 9:25am on Monday, October 1st, 2007

I have a hash variable with 10K records and I want to write 1000 records at one shot into the file. Is there a way in perl?

Clement   

Posted at 1:42pm on Monday, October 1st, 2007

Thanks for this site, it is really good. If I want to read several files such as c_1, c_2, c_3 etc in the same directory, how do I write the perl script to do this for me. Please, you could send me a response to agclems@yahoo.com Many thanks for your help.

Regards,

Clement.

Salvor   

Posted at 12:47am on Tuesday, October 23rd, 2007

I think it's better to write here and not send you a private response. Anyelse can read it, so:

my $i=1;
while (-e "c_$i"){
open (FILE, "c_$i") || die ("What the hell??? Can't open c_$i!!!");
my @lines = ;
close FILE;
doincrediblethingswhiththe(@lines);
$i++;
}

Salvor   

Posted at 12:50am on Tuesday, October 23rd, 2007

Sorry, the forum eat some of my comment. 4th line:
my @lines = <FILE>;

well, you know, read all file into an array, as explained before in this page.

Regards.

Norton   

Posted at 7:13am on Wednesday, November 21st, 2007

I would really like to see how can you store the contents of the file in an array, where lines are appended as array elements.

Could you please add it to this tutorial?
Cheers, Norton

Johan   

Posted at 4:17am on Friday, December 7th, 2007

Norton: to add a file to an array,

@array = ;

should do the trick.

harsh   

Posted at 8:55am on Thursday, December 13th, 2007

read multiple files from same directory
opendir DIR, "C:/perl/bin/1" || die "Cannot opendir 1 $!";
while ( $filename = readdir(DIR) ) {
if($filename=~/.*.htm/){
open IN, "C:/perl/bin/1/$filename";
open OUT,">>C:/perl/bin/1/all.txt";
while(){ chomp ($_);
and so on}

by using this you can read multiple files from directory 1 and write all the files in a new file.

regards
harsh

Jared   

Posted at 9:19am on Wednesday, December 19th, 2007

This:
foreach my $i (0 ... 255) {
print BIN pack('C', $i);
}

Could also be written as:

print BIN map(pack($_),@{[0..255]});

:)

cris   

Posted at 10:37am on Wednesday, December 26th, 2007

how do you open a image and print it?

Nikhil   

Posted at 2:52pm on Saturday, December 29th, 2007

How do you search for a pattern and then delete all the lines above and below it?
eg
abbbbbbbbbcioiheiodnweiniwqoed
Serial Number
iuawheiuhoiehoqwiheeewq

I want to search for Serial Number and delete all three lines..
I want to repeat this all over the file wherever the Serial Number occurs..

kumar   

Posted at 12:06pm on Thursday, January 3rd, 2008

I need a script for the below task.I have a txt file with xxxxx numbers , one number each line.
I should run a perl script so that my script should read this txt file line 1 and then line 2 , then line 3 etc till the predefined match is found.I wanna use this line 1 value in the command executed below this script.this command output should be updated to a new file always.
Obiliged if any answers for my query.

SK Rahman   

Posted at 4:49am on Friday, January 4th, 2008

if i run the following script i am getting a binary file
but when i open with hex editor
i am able see that the actual numbers are

"01 02 03 04 05 06 07 08 09"
what i wanted output like this
"12 34 56 78"
please help me to write a script for this...
thanks in advance


open(BIN, '>', 'binary_file')
or die "Couldn't open file for writing: $!n";

foreach my $i (1 ... 9)
{
binmode BIN;
print BIN pack('C', $i);
}
close BIN;

ZwribMaster   

Posted at 6:39pm on Thursday, January 17th, 2008

Hi, I want to try to open a file, and if it fails, I want to write the filename to a log file but continue on with my program to open the other files in my list. Is there an alternative to using open the file || or die?

ZwribMaster   

Posted at 6:52pm on Thursday, January 17th, 2008

Hi Nikhil,

You can read the file contents into an array, and then use a foreach loop to scan each line of the array. For ex:

open(PAGE,"yourfile.txt") || die "I can't open yourfile.txt";
#store the contents of the file into the File array
@File = ;
close(PAGE);
$Ctr = 0;

#then loop through the file...
foreach (@File){
if ($File[$Ctr] =~ m/SerialNumber/){
#remove the 3 lines from the array
$File[$Ctr] = "";
$File[$Ctr+1] = "";
$File[$Ctr-1] = "";
}
$Ctr = $Ctr+1; #increment through the rest of array

} #end foreach

#write the array contents to the file...
open(PAGE,">yourfile.txt") || die "I can't open yourfile.txt"; #open the file to read
print PAGE @File;
close(PAGE);

Dave   

Posted at 8:51am on Sunday, January 20th, 2008

I'm trying to load a txt file into an array and filter out specific data. I used ZwribMaster post as a template and it has helped a lot. I have one issue. Instead of removing the lines from the array, it is just replacing them with a blank space. Here is sample of what I'm running:


#Open and Load Input file to array
open INPUT_FILE, "data.txt" or die $!;
print OUTPUT_FILE "@Data";
close OUTPUT_FILE;

Any help would be appreciated,,

Thanks,
Dave C

DaveC   

Posted at 11:24am on Sunday, January 20th, 2008

It's seems my script was cut off in my last post.


#Open and Load Input file to array
open INPUT_FILE, "data.txt" or die $!;
print OUTPUT_FILE "@Data";
close OUTPUT_FILE;

Sai Ram   

Posted at 9:52pm on Monday, January 21st, 2008

How to make use oF APIs in perl..please help me out...i am lost becoz of this.. :-(
I need this immediately...

Sylvia   

Posted at 8:05am on Tuesday, January 29th, 2008

Hi there!
I would like to print the same content to 4 output files at the same time, is there anyway to do this, or do I have to do it on four separate lines?

eg
print FILE_1 "example";
print FILE_2 "example";
print FILE_3 "example";
print FILE_4 "example";

can I do something like this?
print {FILE_1 FILE_2 FILE_3 FILE_4} "example";

thanks for your help

Kiran   

Posted at 2:24am on Friday, February 1st, 2008

Hi Friends!! I need to write a script which will logon to sftp server & then check for files in a particular directory if the file is present it should append that file is present ina text file if not it should append file not present how this can be achieved i am stuck up at logging on to sftp server please help thanks in advance

Kiran   

Posted at 11:23pm on Wednesday, February 13th, 2008

Hi,
I have 2 files, say file1 & file2. I have some, variable in file1 say $work. I want to read this in file2 & use it in file2.
Could anyone help me in this
Thanks
Kiran

Rich   

Posted at 8:39pm on Saturday, February 23rd, 2008

Kiran, regarding your question on the thirteenth, simply open both files, and copy the $work to file2.

Kiran   

Posted at 2:46am on Monday, February 25th, 2008

Guys can any body help me on question posted on 1st feb 08
" need to write a script which will logon to sftp server & then check for files in a particular directory if the file is present it should append that file is present ina text file if not it should append file not present how this can be achieved i am stuck up at logging on to sftp server please help thanks in advance"

Torsten   

Posted at 3:17am on Friday, March 14th, 2008

Hi,

I have the following problem:
I want to open a file and read its content into a variable.
After that a standard input should be read into another variable. But after this input, the script gets stuck.
If I swap both, the script works. Here a part of my script:

open FILE, "c:/tmp/mail_receivers.txt" or die "Couldn't open: $!";
local $/;
$receiver = ;
close FILE;
print ("nPlease enter mail subject.");
$subject = ;
print ("nSubject: $subject");
print("$receiver");

Can anybody help me?
Thanks,
Torsten

Bassir   

Posted at 11:23pm on Sunday, March 16th, 2008

i have too many problems with doing an algorithm

Manojg   

Posted at 11:23am on Wednesday, March 19th, 2008

Hi,

I tried to open a file by using

open FILE, ">", "filename.txt" or die $!

The script did not give any error and there was no any file opened. Where does it open the file? in memory? How do I open a file in disk?

Thanks.

Shruthi   

Posted at 1:12am on Monday, March 24th, 2008

How do i write perl script for reading a file and how i can see output from this.
If any body knows please send it back as comments in this same page.

Suresh,S   

Posted at 1:44am on Monday, March 24th, 2008

created a excel sheet as Book1.xls

just tried this coding for opening Book1.xls unable to open the excel file the output is coming in Dos prompt itself why?

#!/usr/local/bin/perl
open (MYFILE, 'Book1.xls');
while () {
chomp;
print "$_n";
}
close (MYFILE);

Just reply the solution Immediately

Jacob   

Posted at 11:24am on Wednesday, April 2nd, 2008

Hi all..

Im trying to make this littel hash cracker in perl (JTR dosent take saltet hash), and it works fine, but now i want it to goto next hash, when it finds a correct password, insted of trying the intire paasword list.. (aka for more speed)

The script looks like this:

#!/usr/bin/perl

use Digest::MD5 qw(md5_hex);
use Data::Dumper;

open(FH0, " < digits"); #long list of passwords
while(){
chomp;
($password,$b) = split(/:/);

open(FH1, "< alle1"); #long list of hash
while() {
chomp;
($last,$hash,$salt,$mail) = (split(/:/))[0,1,2,3]; {

open (FH2, '>>data.txt');
print FH2 "$mail:$passwordn" if(md5_hex($salt.$password) eq $hash);

# print "BINGO CHAMPn" if(md5_hex($salt.$password) eq $hash);
# print "$passwordn";
}
}
}
close(FH0);
close(FH1);
close(FH2);

Can someone help me whit that?

Pramod Badgujar   

Posted at 10:17pm on Tuesday, April 8th, 2008

How to replace the content of line with the another text?

Pramod Badgujar   

Posted at 10:22pm on Tuesday, April 8th, 2008

How to replace the content of line with the another text?
Please give me answer of the above question.

emma   

Posted at 9:10am on Friday, April 11th, 2008

Hi all,

I am new to Perl scripting and need your help.
Here is the problem I am having .

I have a file with some strings each delimited by a "|'character.
I have to open the file , each each line and replace the '|' with a tab or space and then copy them to to a file.
Eg: file ABC
Contents are as follows -
asdfd|||sdhh||sdghhgd|||
afsgasfd||asdsadsad|adff||||||fasffasf|
etc
Desired output

asdfd sdkjf dsfhdh
sffhjd djfhjhds dhfjhfjh (ie no "|" characters.)

I appreciate your help.
Please some one help me with the perl code to do this task . I am sure it is easy job for perl experts.

Bharath   

Posted at 6:42pm on Monday, April 21st, 2008

Hi,

I want to open an image and see the binary values of that image.Is there a way to open an jpeg or png or bmp file and prints the contents of that file in zeroes and ones using perl.

Thanks in advance,
Bharath

reddy   

Posted at 3:00pm on Tuesday, April 29th, 2008

Does anybody answer here or just post Q's?

The bumbling bee   

Posted at 12:44pm on Saturday, May 10th, 2008

Hi Emma,

Can the following piece of code do?

$fileName = "ABC";

open(FILE,"

The bumbling bee   

Posted at 12:48pm on Saturday, May 10th, 2008

The bumbling bee

Hi Emma,

How do I avoid the "eating" of comments after the "<" glyph?

The bumbling bee   

Posted at 12:52pm on Saturday, May 10th, 2008

Ok, trying one more time!

$fileName = "ABC";

open(FILE,"< $fileName") or die "Could not open file $fileName";
while ($line = < FILE> ) {
$line =~ s/|+$//; ## **1 (see below)
$line =~ s/|+/ /g; ## **2 (see below)
print $line;
}
close(FILE);



## BRIEF EXPLANATION:
## ------------------
## The command "s/+++/***/" substitute "+++" with "***".
## The "|+" is regular expression matching one or more
## consecutive "|" chars.
##
##
## EXPLANATION OF "**1":
## The regular expression "|+$" requires one or more
## consecutive "|" chars at the end of the line since
## "$" match end-of-line. This is replaced by nothing.
##
## EXPLANATION OF "**2":
## The regular expression "|+$" requires one or more
## consecutive "|" as before. This is replaced by a
## single space.
## The option "g" (global) in the end indicates, that
## several sequences may be replaced if such exist.
##

beta32c   

Posted at 12:22am on Thursday, May 15th, 2008

Can we open files which are more than 2gb in size. Im not able to open my files for processing which are more than 2gb.. any ways.. reply back.

kumar   

Posted at 8:50am on Tuesday, May 20th, 2008

I have a file which the format is ".dat". I would like to read the information from this file and convert all the information to txt format. Is the perl able to do this.

Joe   

Posted at 6:51am on Friday, May 30th, 2008

what drives me nuts about many perl people offering suggestions is they offer squat. Try using this,try using that. For newbies this is no help at all. Explain it or don't bother offering suggestions. I keep seeing tons of people posting things like try this in your code. Suppose the person asking doesn't even know how to begin let alone put the code in the proper place in the script. Suppose the person has spent hours trying to figure it out and just wants some help and needs the entire script. Get real posters. I'm fed up with those who don't post the complete solution.

Newbies - start here   

Posted at 9:56am on Friday, June 13th, 2008

A lot of you are asking questions that are hard to answer if you don't know hardly anything about perl. Teach yourself the basics here: http://www.pageresource.com/cgirec/index2.htm. Or search google for beginning perl tutorial. There are many books as well. To try to help some of you, here is a full working script that will read a file in, process the file and save it to a new file. The files will be in the same folder as the perl script. This will overwrite your output file each time you run it.

#!/usr/bin/perl -w
use strict;

my $infile = 'in.txt'; # name of the file you are reading - must be in same folder as script
my $outfile = 'out.txt'; # name of file that will be created for output

open (FILEHANDLE, '' will create the file if necessary
# WARNING: this will overwrite your $outfile if it exists - copy to new file if you want to save what you have in your output file
print OUT $outdata; # write the data - will overwrite whatever you had in the output file previously
close OUT; # close the file

exit; # you are done

Anonymous   

Posted at 10:14am on Friday, June 13th, 2008

OK. One last try with the HTML characters escaped. (In fact, I escaped the characters, like <> using my script below)

A lot of you are asking questions that are hard to answer if you don't know hardly anything about perl. Teach yourself the basics here: http://www.pageresource.com/cgirec/index2.htm. Or search google for beginning perl tutorial. There are many books as well. To try to help some of you, here is a full working script that will read a file in, process the file and save it to a new file. The files will be in the same folder as the perl script. This will overwrite your output file each time you run it.

#!/usr/bin/perl -w
use strict;

my $infile = 'in.txt'; # name of the file you are reading - must be in same folder as script
my $outfile = 'out.txt'; # name of file that will be created for output

open (FILEHANDLE, '<', $infile); # this makes the file ready for reading from FILEHANDLE
# '<' means read only

my @inlines; # this is an array. An array holds a list of items. Each list item will be 1 line from the input file
@inlines = <FILEHANDLE>; # this reads the input file into the array - each array item holds 1 line of the file
my @outlines; # we will put the output lines here

#we're done reading the file - close it
close FILEHANDLE;

foreach my $line (@inlines) { # this cycles through the input file info 1 line at a time

chomp($line); # remove newline character at end of line

# I will show a few examples of what you can do to process each line
# just uncomment the code (remove the # in front of the code) to use what you want

# # change all '|' characters to tabs
# $line =~ s/\|/\t/g;

# # separate each word - one word per line - changes whitespace (spaces, tabs, etc) to new lines
# $line =~ s/\s+/\n/g;

# # replace the line with new content
# $line = "Goodbye my friend." if ($line =~ /^Hello everyone!$/); # if the line said 'Hello everyone!', now it will say 'Goodbye my friend.'

# # replace a word with another
# my $search_word = 'aks';
# my $replace_word = 'ask';
# $line =~ s/$search_word/$replace_word/gi; # g replaces all occurances, i makes it case insesitive - matches lower case and upper case

# url encode the line to make it safe for posting, so that < characters won't mess it up (such as for the comments at http://www.perlfect.com/articles/perlfile.shtml)
# $line =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;

#escape HTML Characters "<", ">", "&" etc.
$line =~ s/([^\w\s])/sprintf ("&#%d;", ord ($1))/ge;

# put the line in the output array
push(@outlines,$line);
}

# join the output lines into one variable with a newline character between each line
my $outdata = join("\n",@outlines);

# save $outdata to the $outfile
open (OUT,">", $outfile); # this will open the $outfile for writing, and '>' will create the file if necessary
# WARNING: this will overwrite your $outfile if it exists - copy to new file if you want to save what you have in your output file
print OUT $outdata; # write the data - will overwrite whatever you had in the output file previously
close OUT; # close the file

exit; # you are done

hiru..   

Posted at 2:38am on Wednesday, June 18th, 2008

i want to write an array into a textfile. i m using active perl in windows xp....

noor   

Posted at 11:57pm on Wednesday, June 18th, 2008

how to delete a portion or couple lines from the file basically text file

Anonymous   

Posted at 5:05am on Thursday, July 3rd, 2008

i have one already open file . please tell how to delete the 4 th line . again i needto addd differnt data to fil

Barney   

Posted at 2:58pm on Friday, July 4th, 2008

I want to manually process many text files as follows:

myscript.pl file1.txt
myscript.pl differentfilename.txt

I am able to read the file into an array as follows:
my @INFILE = ;

But I don't know how to get the filenames to uniquely assign output files (ie. file1_out.txt, differentfilename_out.txt)

Thanks in advance.

Ravindra   

Posted at 4:31am on Tuesday, July 15th, 2008

MY task is to read a file from verilog and have to listout the input and output in readed file to the screen?Pls help me out today i have to submit it

jaichaud   

Posted at 7:10am on Wednesday, July 16th, 2008

Ravindra - can you give a few more details about how the data file is structured - maybe even a small snippet? Without knowing the data file layout, it's hard to offer any code.

milli   

Posted at 10:01am on Friday, July 18th, 2008

hi i need to open a file WICH I GOT THE NAME OF THE FILE FROM THE USER and to find how many times a specific word apeared (eg APPLE) and change apart of the word to something else(eg from APPLE to APACH), CAN U HELP ME...

M@ Hardcastle   

Posted at 3:51pm on Thursday, July 24th, 2008

my ($filename) = @ARGV;
open my($filehand), $filename;
my $file = join '', <$filehand>;
$file =~ s/(?!bAP)PLE(?=(?:b.))/ACH/g;
print $file;

Example
--------
apple.pl apple.txt > apple.txt

vaskar deka   

Posted at 2:38am on Saturday, July 26th, 2008

i need to read a file character by character using array through perl

cory   

Posted at 9:07am on Friday, August 1st, 2008

Hello, sorry to post another question but I just encountered a new problem with file writing that I never have before. I've been using this logger function on many of my scripts and it has been working just fine:

sub logger()
{
if($#_ == "-1")
{
print "Error: logger requires a logfile pathnamen";
return 0;
}

my $logfilename=shift(@_);
my $message;

if($#_ == "-1")
{
$message="";
}

else
{
$message=shift(@_);
}

my $tmplog = new IO::File;
$tmplog->open("+>>$logfilename") or die("Can't open $logfilenamen");
$tmplog->print("$messagen");
$tmplog->close;
return 1;
}

In my new script, the function will log only a couple lines of data and nothing else past that, even though sometimes the file does in fact get larger. I have the permissions set fine, and I've been trying every different form of file handling, file locking, file permissions,file caching etc. HOWEVER, some of the scripts functions are able to print more than one line, but when I issue the following, only "type" prints out:

logger("$masterlog","Type: $mode{$sys}{$type}");
logger("$masterlog","Hostname: $hostname{$sys}{eth0}");

I've even redefined $masterlog before every call, still nothing. Can anyone help me?!? Thanks so much.

cory   

Posted at 9:09am on Friday, August 1st, 2008

Sorry, that comment got skewed a little. Corrections:
$tmplog->print("$messagen");
$tmplog->open("+>>$logfilename") or die("Can't open $logfilename");

Lee   

Posted at 8:38pm on Saturday, August 16th, 2008

Hi there,
i got a question about inputing data from a .txt file and using the data in a perl script (.pl) , can someone tell me what i need to type in the command line thanks.

Cool Dude   

Posted at 11:44pm on Sunday, August 17th, 2008

Hi, need help.

Env: Windows
Ver: 5.10

I want get the status, if the file is in use [even if by notepad].
My requirement is I want to skip the files in the directory which are not in use.

Friends any suggestions?

Todd L   

Posted at 2:48am on Thursday, August 21st, 2008

Hi!

I am using Perl v5.8.8 on a MS Win32-x86 system (XP Prof SP2).
I am trying to read a *.doc file(STDIN) & split it into multiple files based on the split pattern "* * * * * AREA"
The criteria is to use the split function & to get the following outcome:

the * * * * * AREA 1 line & above lines & written to an output file e.g. AREA1.out,
the * * * * * AREA2 line & above lines up to(not including * * * * * AREA 1 line written to an output file eg. AREA2.out & so on up to AREA 40.


aaaaa
bbbbb AREA1.out
ccccc
ddddd
* * * * * AREA 1

eeeee
eeeee
ffffffffff
fffffffff AREA2.out
gggg
gggg
* * * * * AREA 2
....
....
....
....
* * * * * AREA 40

Looking at other forums & threads Ive come across similar code requests (below 1 is a Unix-based solution).
http://www.unix.com/shell-programming-scripting/14576-split-file-using-awk.html

Your advice & help is appreciated.

Thanks Todd

Kopu   

Posted at 7:12am on Tuesday, August 26th, 2008

Todd L ... i'll give you an example for one file - you'll make it for several :)

my $filename = 'input.doc'; #this is your file name
my $splitpatt = '*******\n'; #you must know your pattern
open FH, "$filename";
print FH $file[$_];
close FH;
}


this is simplied idea i've got ... i did not check it if it work ... but the idea is clear :) i hope ...
call me at kopu.bg@gmail.com if you need some more ... :)

Kopu   

Posted at 7:17am on Tuesday, August 26th, 2008

damn this cutting things ...
Todd L ... i'll give you an example for one file - you'll make it for several :)

my $filename = 'input.doc'; #this is your file name
my $splitpatt = '*******\n'; #you must know your pattern
open FH, "$filename";
print FH $file[$_];
close FH;
}

Anonymous   

Posted at 7:20am on Tuesday, August 26th, 2008

Grrrrrrrrrrrrr ...

my $filename = 'input.doc'; #this is your file name
my $splitpatt = '*******\n'; #you must know your pattern
open FH, "\$filename";
print FH $file[$_];
close FH;
}

Kopu   

Posted at 7:22am on Tuesday, August 26th, 2008

i give up ... Todd ... write one email ... i'll send you the script ... than if you can - post it here ... i give up ...

Todd L   

Posted at 3:35pm on Tuesday, August 26th, 2008

Hi Kopu,
Thanks for your reply.I've emailed you there.
Todd

NewToPerl   

Posted at 6:15pm on Tuesday, August 26th, 2008

Hi,
I have two scripts say t1 and t2. "t1" is printing some lines and "t2" is reading from STDIN. I need to run only t1 and pass all the output to STDIN of t2. I tried with pipe, fork-exec combination in t1 but does not seem to work. Is there any easier way to do this? Effectively i need to achieve the functionality of "./t1 | ./t2" by running only t1 script.
Thanks for your help

omar   

Posted at 12:55am on Thursday, August 28th, 2008

hello guys i need help please in perl i have this program if any body can do it for me i will appreciate it a lot for him this is the program:
A log of internet downloads is kept and bills are issued once a month.
The log has the following structure:

userID;MBDowloaded

Your task is to write an algorithm that analyses the log and creates a bill for each userID.
To produce the bill, you will need to look up the name and credit card number of each user from a hash table provided.
An input file is included in the assignment files - assignment1.txt
When you run your script, take the name of the file from the command line.
If the command line parameter is missing, prompt the user for the file name to use and keep prompting until they enter something.
If the file cannot be found (assume it is in the current directory, that is the same place the script is running from) then display a message and finish immediately with a die.
Read the file and ensure the records you read from the log have the correct userID structure: uppercase ST or TE followed by 4 digits only. Then the records must have a semicolon and a positive number (MBDownloaded).
Assume there will be one record only for each userID.
Any records that are not in this format must be copied to a new file called Errors.txt. Do not try to process them.
For each valid log record, use the userID as the key to a hash table of personal information provided.
The hash table has the structure of userID as the key and Name and Mastercard number separated by a colon as the value.

userID => Name:Credit card number

Use the information from the log record and the hash table to produce a bill for each user as follows. (The bill will take the form of messages to the system console).
Charges are 1 cent per megabyte for teachers and 0.1 cent for students.

Name : Fred Bloggs
UserID : ST1123
Mastercard number: 1234567890123457
MB downloaded: 720
Charge: $0.72

omar   

Posted at 12:55am on Thursday, August 28th, 2008

please send it to my email account : omargh84@hotmail.com

Josh   

Posted at 1:40am on Monday, September 1st, 2008

Hi, the question is simple and shows that I am a newbie.
"How to open files > 2 GB?"
I have a script that tries opening a file and if the file is > 2GB in size, it it skipping the part of code without showing any error and proceding with remaining...
What is the exact format of open() function that I need here?

karthick   

Posted at 12:33am on Tuesday, September 16th, 2008

i gotta assignment such that i have to sort the file contents of a file say data.txt and i need to create a another file data1.txt which should have the sorted contents of data.txt..can any body help.....

karthick   

Posted at 12:34am on Tuesday, September 16th, 2008

sorry the above program has to be done in perl

joe bloggs   

Posted at 4:38pm on Tuesday, September 16th, 2008

stop cheating CIT lol

karthick   

Posted at 12:43am on Friday, September 19th, 2008

What do you mean joe...........CIT????

Anuj   

Posted at 2:22am on Sunday, September 21st, 2008

How to store the contents of an aray into a file and then reading the values from that file

Please help me pout on this !!!

karthick   

Posted at 8:56pm on Sunday, September 21st, 2008

my @lines = ----nothing but a file handle
foreach $line (@lines}
{
print $line;
}
by this u wil be able to store the contents of the file in the array called @lines and you can proceed further

karthick   

Posted at 8:58pm on Sunday, September 21st, 2008

in that previous post
my @lines= ---a file handle

srinivas   

Posted at 12:10am on Monday, October 6th, 2008

Hi, i want to capture ip address & host names in a text file & put those hostnames & ipaddress to a new file. please help me out

Anonymous   

Posted at 12:12am on Monday, October 6th, 2008

eg: i have to huge lines in my text file containing host names & ip address along with other details so i want to take only ip address & host names in that file & put those into a new file. please send it to my id srinirelq@gmail.com

Hi   

Posted at 3:47pm on Thursday, October 9th, 2008

I am trying to write a perl CGI script that opens a file for writing. When I run it online however it does not recognise the path name ~ cannot find the file to write. My file is in the same folder as my cgi script.
Can someone tell me the likely problem?

Shakthi   

Posted at 8:56pm on Friday, October 10th, 2008

How to write a file in a path which has space in it Like: C:perl filefilenamefile.txt

Shakthi   

Posted at 8:58pm on Friday, October 10th, 2008

How to write a file in a path which has space in it Like: C://perl file//filename//file.txt

Nancy   

Posted at 10:20am on Monday, October 20th, 2008

I have a text file with name oxygen.txt
this file contains a list of all the files that came as a results of a find command.
Now I want to process each file in this oxygen.txt and look for grep -i MSDigital
And collect all those results for each file in another text file.

Can you please tell me how to write a script for this.

Thanks

oge   

Posted at 9:22am on Monday, October 27th, 2008

i want to know everything about file handling:basic concepts.


thanks

surya   

Posted at 12:53am on Tuesday, November 11th, 2008

Can anyone tell me how to read a file in perl having junk charaters . I have only one junk character which is repeated many times in the file. While i'm reading and printing the file , it is displaying till the 1st occurence of that junk character.

kopu   

Posted at 2:28am on Saturday, November 15th, 2008

hi surya ... you must open the file in binary mode into one variable ... then there is no mather how many junk chars are in the file ... after that if you wana you can split the variable to an array and proceed it like a TXT file ... or you can remove the any junk chars if they are usless and split it at the n ...

Mustafa   

Posted at 4:59pm on Monday, December 22nd, 2008

Hi Guys,
I need big help.
I'd like to find a string and print the bits corresponding to the mentioned string. PLEASE PLEASE HELP!!!
A part of my perl script is:
open (IN,"$inputfile") || die "Cannot find input file $inputfile n";
$pnum1 = 0;
while(my $line = ){
chomp( $line );
if ($line =~ /^s*(INPUT)(.*)(UART)(w*)(s*)(.*)/i){
if ($v1 eq "") {
if ($pnum1 == 0){
$v1 = $3;
print "uart{$3$4";
$pNum1=$3+$4;
$pNum1 = $pNum1 + 1;
}
else{
$pNum1=","+$3+$4;
$pNum1 = $pNum1 + 1;
}
}
else {
print ",$3$4";
$pNum1 = $pNum1 + 1;
print OUT ",$3$4";
}
}

else {
if( ($v1 ne "") && ($uart_done==0) ) {
print "}; ";
print "n$pNum1n";
$uart_done=1;
$v1 = "";
}
}
part of the bsd.txt file that I'm manipulating is this:
INPUT (1) (1) UART0_RXD ;
INPUT (1) (2) UART1_RXD ;

TP_START
"XX0XX1XXXXXXXXXXXXXX1X11XXXXXLXXXX";
"XX1X01XXXXXXXXXXXXXX1X11XXXXXLXXXX";

Mustafa   

Posted at 5:03pm on Monday, December 22nd, 2008

I forgot to mention that in the input file bsd.txt the first two bits on each line belongs to the UART pins that I want to print. Of course, the script should be smart enough to get the bits from anywhere in the vector lines.

guna   

Posted at 9:51pm on Tuesday, December 30th, 2008

how to flush the previous data in the flat file after it is created by using append mode?

Anonymous   

Posted at 6:04am on Monday, January 12th, 2009

Posted at 5:03pm on Monday, December 22nd, 2008

I forgot to mention that in the input file bsd.txt the first two bits on each line belongs to the UART pins that I want to print. Of course, the script should be smart enough to get the bits from anywhere in the vector lines.

Posted at 5:03pm on Monday, December 22nd, 2008

I forgot to mention that in the input file bsd.txt the first two bits on each line belongs to the UART pins that I want to print. Of course, the script should be smart enough to get the bits from anywhere in the vector lines.

Posted at 5:03pm on Monday, December 22nd, 2008

I forgot to mention that in the input file bsd.txt the first two bits on each line belongs to the UART pins that I want to print. Of course, the script should be smart enough to get the bits from anywhere in the vector lines.

Posted at 5:03pm on Monday, December 22nd, 2008

I forgot to mention that in the input file bsd.txt the first two bits on each line belongs to the UART pins that I want to print. Of course, the script should be smart enough to get the bits from anywhere in the vector lines.

Posted at 5:03pm on Monday, December 22nd, 2008

I forgot to mention that in the input file bsd.txt the first two bits on each line belongs to the UART pins that I want to print. Of course, the script should be smart enough to get the bits from anywhere in the vector lines.

Posted at 5:03pm on Monday, December 22nd, 2008

I forgot to mention that in the input file bsd.txt the first two bits on each line belongs to the UART pins that I want to print. Of course, the script should be smart enough to get the bits from anywhere in the vector lines.

Posted at 5:03pm on Monday, December 22nd, 2008

I forgot to mention that in the input file bsd.txt the first two bits on each line belongs to the UART pins that I want to print. Of course, the script should be smart enough to get the bits from anywhere in the vector lines.

Posted at 5:03pm on Monday, December 22nd, 2008

I forgot to mention that in the input file bsd.txt the first two bits on each line belongs to the UART pins that I want to print. Of course, the script should be smart enough to get the bits from anywhere in the vector lines.

Posted at 5:03pm on Monday, December 22nd, 2008

I forgot to mention that in the input file bsd.txt the first two bits on each line belongs to the UART pins that I want to print. Of course, the script should be smart enough to get the bits from anywhere in the vector lines.

Posted at 5:03pm on Monday, December 22nd, 2008

I forgot to mention that in the input file bsd.txt the first two bits on each line belongs to the UART pins that I want to print. Of course, the script should be smart enough to get the bits from anywhere in the vector lines.

Ritika   

Posted at 6:21am on Thursday, January 15th, 2009

Hi,
I need to write a script to accept value from UI in a text box and write it in a file. Please help me with the same

Co   

Posted at 3:13pm on Sunday, January 18th, 2009

Hi
I have been trying to write a script that will take a 'pcl' file in and write it out to another file exactly the same. it seems that it proccesses the new line characters so the outfile does not mirror the input file. I cant find a solution to this so help would be great.

Ash   

Posted at 10:36pm on Sunday, January 18th, 2009

hi...this is my 1st post in this site.
I need to open a log file created and replace some words witrh other and also add some more content to the same log file and then close it.The thing is i want to read the file from the last line.ie the latest program run will be at last lines of logs.Kindly help me out.

Dana   

Posted at 1:01pm on Wednesday, January 21st, 2009

I am trying to read from a file and i would like a specific lines in my txt file that start with > so i can't get it to work can some help.
here is the sample code that i have so far.
@raw_data =();

$data_file="data.txt";
open(DAT, $data_file) || die("Could not open file!");

print @raw_data;

@raw_data=;
close(DAT);

Daxesh   

Posted at 2:29am on Friday, January 30th, 2009

I want to append two files. some 20 lines header and 2 line footer is same in both files. I want to appear the header and footer once in the merged file. Can anyone help me?

shunan   

Posted at 3:19am on Thursday, February 5th, 2009

hey..i've some sort of files .xcd files...(may be normal .txt files) i want to convert the files into html and display it...give me some idea to do this..i need Perl script to run this..help me out..please..!!

Naiya   

Posted at 11:39pm on Tuesday, February 17th, 2009

hello
I have got a text file with 9846 lines and I want to split this input file in batches of 100 into multiple output files . I can read the all the lines and put it in the array but how do I split it into multiples of 100 and store it in output files with different names file1.txt, file2.txt....etc...It should stop creating when End of file. OS:Windows. Can anyone please help me.
Can any

needhelp   

Posted at 6:56am on Saturday, February 21st, 2009

Dear all,

need your help, please help me.
I have 11 files stored in a directory (same format) and I want to add the content of each file to another. I have managed so far to open the files and read them, but I need to index them (I guess) if I want to make operations between files... how?

#!/usr/bin/perl

# open the central value
$file0="central.dat";
open (FD0, $file0) || die "cannot open file: $file0n";

# open the directory which stores my 11 files
opendir (DIR, "diag.up") or die "$!";
while (my $file = readdir(DIR)) {
next if ($file eq '.' || $file eq '..');
# open the files in the directory to get the content
open (my $FH, "diag.up/$file") or print "$!n";
# get inside..
while (my $line0 = ) {
$line=;
@args=split ' ', $line;
@args0=split ' ', $line0;
printf(" %.10f %.10f %.10f %.14f %.16f n ", $args[0], $args0[1], $args[1], ($args[1]- $args0[1]), ($args[1]- $args0[1])**2)

}
close $FH;
printf ("n");
}
closedir DIR;
close $FD0;

but this is not what I want, I want to be able to add the columns of each file to another one.. HELP!

sincerely yours..

anon   

Posted at 1:39pm on Sunday, March 1st, 2009

Can I use the open command to open an mp3? If so, how do I do it?

ravi kiran   

Posted at 5:10am on Thursday, March 12th, 2009

i have doubt with perltk hw can i link an external perl script to get executed on clicking an widget like button and the output be dispalyed in an pop up message window?i am actually new to perltk so would request you help me in detail
thanking you
ravi kiran

b_arg   

Posted at 4:17am on Wednesday, March 18th, 2009

Help me,

How to search a line starting with a string "my_string" and ending with ";" and put a text before the line in a file.

Example

my_string line ;

OUTPUT :

SOME TEXT GOES HERE
my_string line ;

Anonymous   

Posted at 7:52am on Wednesday, March 18th, 2009

Write a Perl module (called Util) that does the following,
Given a list of numbers, can estimate the following statistics:
- max
- min
- average
- median
- frequency count of each element
- outputs data to file

You should write a separate perl program call usingutil.pl that uses the above module
in the following manner,

use Util;

Util:: add(1); // use this method to add numbers 1 to 10
m = Util:: max(); // find max and print it
m = Util:: min(); // find min and print it
m = Util:: max(); // find max and print it
m = Util:: median(); // find median and print it
m = Util:: output(filename1); // send current list to a file

Util::del(1) // delete all the odd numbers
m = Util:: max(); // find max and print it
m = Util:: min(); // find min and print it
m = Util:: max(); // find max and print it
m = Util:: median(); // find median and print it
m = Util:: output(filename2); // send current list to a file

Util::add() // add random numbers between 1 and 10 several times
Util::freq() // list how many times each number is part of current state
Util::outputfreq(filename3) // output freq to a file

Lucy   

Posted at 11:42am on Saturday, March 21st, 2009

Thank you for the resources. Keep up the good work!.
I am from Kosovo and now study English, please tell me right I wrote the following sentence: "The round trip airfare from madison, wis."

With love 8-), Lucy.

Anonymous   

Posted at 7:20am on Monday, March 23rd, 2009

Hi b_arg,
Try this
1. Read all lines to @arr i.e @arr=;

then do pattern match

forecah(@arr)
{
if($arr[i] =~ /(^my_string.*[;]$)/){
$arr[i]="SOME TEXT GOES HERE n $1";
}

}

please give a try and let me know if any problems.

-Sridhar

Anurag   

Posted at 8:33pm on Monday, March 23rd, 2009

Hi guys,
I am searching the codes in which i have to one suffix tree for each string and then uses the common pattern to search against each suffix tree.
I have the algorithm:
1 set number of characters to be processed ws = 8000
(note: we assume 8000 characters are processed at one time)
2 compute length of longest common pattern (overlap size).
3 for each sequence, Si, in database do
4 set overlap string Os to empty
5 while not end of sequence Si do
6 set Stmp = |Os| + ws characters of Si
7 construct a suffix tree, ST, for the subsequence Stmp
8 use multiple patterns search against the suffix tree ST
9 record the search result
10 determine the content of overlap string Os
11 update position for next ws characters from Si
12 end while
13 end for

mike....   

Posted at 2:14am on Tuesday, March 24th, 2009

hey guyx.
i got a huge file, and need to extract data and print it out as html..how will i do this...i just need the logic to do this...

XaN   

Posted at 5:11pm on Monday, April 27th, 2009

Awesome mate really helped me out alot =)

mk   

Posted at 6:32am on Saturday, May 9th, 2009

nice bt how i can creat afile to get out but of array

manish   

Posted at 5:02am on Monday, May 25th, 2009

How to read n number of line sfrom a file in perl in one go rather than just one?

Robert   

Posted at 4:49pm on Friday, May 29th, 2009

Hi, I'm new to perl. I've a tab delimited text file with 50 Columns. Top row contains header. From this file I want to seprate records to three other files like
Output file1: col1,col2,col5
Output file2: col1,col2,col4,col6
Output file3: col1,col2,col9.

Please help me to do the task.
Thanks in advence.

Sandeep   

Posted at 3:08am on Thursday, June 4th, 2009

sub processingLineCheck(){

open (ID, ">>process/$file.idx") or die $!;
flock (ID, 2);
my $line_number;
while(){
$line_number = $_;
}
#flock (ID, 8);
#close ID;
printf "lineeeeeeeeeeeeeeeeeeeee ".$line_number."/n";
my $nextline = $line_number+1;
print "This is the ".$nextline." next line ".$line_number."n";
##track the bug
open (X, ">>track/$track") or die $!;
print X $nextline."n";
close X;
##track the bug

my $line = $allDataIndex[$line_number];#line_with_index(*FILE, *INDEX, $nextline);
print "Here is the URL".$line;
if($line && $line_number >= 0)
{
#open (IDX, ">process/$file.idx") or die $!;
#flock (IDX, 2);
print ID $nextline;
flock (ID, 8);
close ID;
}
else
{
#halt the process

return 0;
}

if($line){
return $line;
}else{
#send halt signal to parent
return 0;
}
}

#####################CODE#################
here it is my code
i am opening the file in write mode and incrementing a counter and writing back the incremented value back to the file. But not working when i open the file in lock mode(exclusive). Actually it is not reading the content from the file.

gebrecherkos hailay   

Posted at 11:57am on Sunday, June 21st, 2009

this is very interesting!!!!!!!!!!!!

Rags   

Posted at 8:10am on Tuesday, July 7th, 2009

Hi, I want to read a many file (say a1.txt to a99.txt)and want to write first two lines of each opened file to another file.

-Means I want to copy first two lines of all files from a1.txt to a99.txt to another single file.(appending each line one after the other)

anybody please help

newuser   

Posted at 9:48am on Monday, August 3rd, 2009

Hi....
I have perl script whr I use a openssl client to perform some ssl operation after which it asks for a passphrase im not sure how to automate this passphrase in my script without me having to give the passphrase evrytim... Any suggestions guys?

chandrappa   

Posted at 12:07am on Tuesday, August 11th, 2009

Hi,
I am very new to perl. Please help.
Read multiple files from same directory

#!/usr/bin/perl

opendir DIR, "D:/Production/Aug/11-08-09/export test/DataHD/IN" || die "Cannot opendir IN $!";
while ( $filename = readdir(DIR) ) {
if($filename=~/.*.xml/){
open IN, "D:/Production/Aug/11-08-09/export test/DataHD/IN/$filename";
open OUT,">>D:/Production/Aug/11-08-09/export test/DataHD/OUT/all.txt";

@Array = ;
$Array[$i] = ~s/"", ""//g;

while(){ chomp ($_);

$length = @Array;
$i=0;
while ($i

Von   

Posted at 1:31pm on Monday, August 17th, 2009

Good morning. The dead might as well try to speak to the living as the old to the young. Help me! Looking for sites on: About benefit cosmetics. I found only this - where to buy benefit cosmetics. Posted by ifb presents links a la mode dramatis personae june am. Please know that we will research each of the issues this problem has surfaced, with the product and with customer service, and work to get each issue fixed. Thanks for the help :cool:, Von from Pakistan.

Trini   

Posted at 12:39am on Thursday, August 20th, 2009

Good morning. The more things a man is ashamed of, the more respectable he is.
I am from Somalia and also now'm speaking English, give please true I wrote the following sentence: "The cult following benefit has is no joke."

THX :-(, Trini.

Halbert   

Posted at 12:28pm on Sunday, September 6th, 2009

How are you. The creative is the place where no one else has ever been. You have to leave the city of your comfort and go into the wilderness of your intuition. What you'll discover will be wonderful. What you'll discover will be yourself. Help me! Can not find sites on the: Gel nails maintenance. I found only this - gel nail colors. He would retain any purpose of policy still though some are also crosslinkages. When there is a nipple, the horse could be employed before or after the added electric edge. :o Thanks in advance. Halbert from Tanzania.

jk   

Posted at 5:56am on Wednesday, September 16th, 2009

Cool tutorials but the perl installation file. havidworld@yahoo.co.nz

Tommy   

Posted at 8:56pm on Wednesday, September 23rd, 2009

Hi guys. When all is said and done, the weather and love are the two elements about which one can never be sure.
I am from Bosnia and now teach English, give true I wrote the following sentence: "You might have a dollar that has deposited typically, but fully you stay the business conjunction is economic for some different shares."

Regards :-D Tommy.

paripurna   

Posted at 3:29am on Monday, October 19th, 2009

good

Boobalan   

Posted at 6:12pm on Wednesday, November 4th, 2009

what is a ARGV in filehandling?

Raghavan   

Posted at 11:03am on Wednesday, November 11th, 2009

I have 2 files, a.txt and b.txt. They both are in different locations. b.txt has a long list of data which I do not want to lose. a.txt is generated by running a script. Now I want to append last few lines of a.txt to b.txt by keeping all the data in b.txt intact. Pl.suggest a way ASAP.

Dunadan   

Posted at 1:09pm on Friday, December 11th, 2009

I don't know if it has been said, but if you don't close FILE and then open another with same handle name, FILE will now contain data of both files.

Thulasi   

Posted at 8:44am on Thursday, December 17th, 2009

Hi,
Just now am learning perl to do my work..i have large amount of data.each file contain id,indivual chromos, startin postion ,ending postion,no.of pvalu...etc
each file datas are same but in different way,i need to analys these datas and to print the result the chromos which have sme pvalue

Hasini   

Posted at 11:55pm on Wednesday, January 6th, 2010

I need to create file based on input xml.
For Example
Input file: 785.xml


1235
create new file


1236
create new file


1237
create new file



Need output in 1235.xml, 1236.xml and 1237.xml
Is it possible create like this, plz help me?

heba   

Posted at 6:33am on Thursday, January 7th, 2010

iwant the code perl which check if the word is a hash key

kumarD   

Posted at 11:18am on Thursday, January 7th, 2010

Hi, I need to write a script to automate the following task sequence. Please help.

Step 1: Take as input a list of paired values -- each pair consisting of an file pathname (p) and a http URL (u).

Step 2: For each pair, do the following:
- Open, using Notepad, a specific file (say, named refresh.html).
- In the file, find "destination" and replace with the value of "u".
- Save the file at the pathname indicated by "p".

Antho   

Posted at 5:16am on Monday, January 11th, 2010

Hi I was wondering could anyone help me.
I have a tab-delimited file: file.txt with 7 entries per row
ie
data0 tab data1 tab data2 tab..... carriage return.
what I want to do is open this file and read it in. Then create an ordered list (array) of the column containing data0 data1... data 6.
But the important thing is that all the data on row 1 is connected so I need them to stay in the same order when i get them into the seperate arrays. That way I reference a line with @data1[i] @data2[i] etc

Any suggestions?

Snoops   

Posted at 4:27pm on Tuesday, January 12th, 2010

Great Tutorial and great help from many posters below.

I am a complete newbie and trying to do the following.

$> adduser.pl userId modelUserId filename.txt

I want to write a script that does following:

opens filename.txt
repeat
searches for modelUserId
copies line where modelUserId is on
pastes line underneath
Replaces modelUserId with userId
until end of file
saves file as filename.new


Any help really appreciated.
Thank you

K   

Posted at 12:56am on Monday, January 18th, 2010

I need your help. This is the flow that I created but I have no idea to code.

- We have folder "A".
- The text files will be put into folder A.
- I have to create Perl script in order to edit the text file by.
- searching .job file in folder A
- checking the name of .job file (Ex: 90098_3.job)
- collecting the number that follow _ (in this case, we have to collect "3")
- opening .job file
- finding " FileVersion=2 "
- replace with " FileVersion= X" , X is the number that we collected.(in this case, it should be " FileVersion= 3")
- save file
- move it to folder B
- folder "A" has to be monitored all the time, if there is the new file, it has to be processed


I've created some script. just a little part. (I've never used Perl before)
$file = ;

open (FILE,"$file") or die "Can't open $file: $!n";

for ( @lines ) {
s/FileVersion=2/$1FileVersion=3/;
print;
}
close STDOUT;

K   

Posted at 12:57am on Monday, January 18th, 2010

I need your help. This is the flow that I created but I have no idea to code.

- We have folder "A".
- The text files will be put into folder A.
- I have to create Perl script in order to edit the text file by.
- searching .job file in folder A
- checking the name of .job file (Ex: 90098_3.job)
- collecting the number that follow _ (in this case, we have to collect "3")
- opening .job file
- finding " FileVersion=2 "
- replace with " FileVersion= X" , X is the number that we collected.(in this case, it should be " FileVersion= 3")
- save file
- move it to folder B
- folder "A" has to be monitored all the time, if there is the new file, it has to be processed


I've created some script. just a little part. (I've never used Perl before)
$file = ;

open (FILE,"$file") or die "Can't open $file: $!n";

for ( @lines ) {
s/FileVersion=2/$1FileVersion=3/;
print;
}
close STDOUT;

Anonymous   

Posted at 7:35am on Monday, January 25th, 2010

how to get the common data from three files using perl

kala   

Posted at 1:45am on Thursday, January 28th, 2010

please send a program taking a file from user and searching a word in c
mail id t.kala_vizag@yahoo.com

alex   

Posted at 8:25am on Thursday, January 28th, 2010

Whoever wrote this in 2007 is a complete charlatan that should not be allowed to ever write or not to mention "help" other people.

The proper way to work with files is using FileHandle module.

ghjhgjhgj   

Posted at 5:30am on Tuesday, February 2nd, 2010

ugloooyuoy

Sidra Nisar   

Posted at 1:48am on Friday, February 5th, 2010

First we made a text file by the name text.txt and the contents were
Sidra|38|BE
Hira|48|BE
Shagufta|50|BE
Then we wrote the following script
open(DAT, "text.txt");
$data_file=" text.txt ";
open(DAT, $data_file);
@raw_data=;
close(DAT);
foreach $student (@raw_data)
{
chomp($student);
($name,$roll_no,$class)=split(/|/,$student);
print "The student $name bearing roll number $roll_no is in class $class";
print "n";
}
We tried the same with another file by the name text.dat holding the same data but it did not work either.

Deep   

Posted at 11:24pm on Sunday, February 7th, 2010

Hi,

I have a flow but i am finding it very difficult to code. please confirm. Ports are treated as files in perl, right.
the following needs to be done:
-a port say com6 needs to be opened
-a command is written in that port
-the response to that command is captured
normal read and write operations not working for the port.

akshara   

Posted at 3:11pm on Monday, February 8th, 2010

please help me....i need a perl script to compare columns from two files. i need to compare first column of the file1 with second column of file 2.also i need to compare the 2nd column of file1 with 3rd column of file2. after that i need to get a new file which contains the rows which are present in file1 but not in file2

Anonymous   

Posted at 10:43pm on Tuesday, February 16th, 2010

Kumaresan:
Fundamentals of PERL is very simply and useful. WE want more Explanations.Thanks

Selva   

Posted at 11:09pm on Friday, February 26th, 2010

how to find and remove the files from such directory

Srinivas   

Posted at 11:10am on Tuesday, March 9th, 2010

Hi Everybody,

I am in need of perl code to extract the data of text file into arrays by matching specific content in text file.

For Ex: Text file consists of data in 2 columns as below

23 1
245 2
67 1
556 3

need to put first column data in an array from row which contains second column as 1 after space.

Regards,
Srinivas

No name   

Posted at 10:54pm on Monday, March 15th, 2010

Srinivas, try this:


open (file, "

No name   

Posted at 10:56pm on Monday, March 15th, 2010

Srinivas, try this:


open (file, "

No name   

Posted at 10:58pm on Monday, March 15th, 2010

Srinivas, I tried answering this twice, but I can't seem to do it without the browser thinking the perl code is html, for some bizarre reason, and I can't fix it. I'm sorry, but if you want me to answer your question, send me an email at

codefun64@gmail.com

Kyle   

Posted at 10:45am on Monday, April 5th, 2010

Hello, how do I show how many lines a file has?

Bigben   

Posted at 2:11am on Monday, April 19th, 2010

Im trying to:

read the contents of /etc/syslog.conf and print out every line that contains /var/log

This is what I have that is not working:
open (DAT, "/etc/syslog.conf") || die "couldn't open the file!";
my @lines = ( | find /var/log);
print "$my @linesn";
close (DAT);

Can anyone help me fix this?
Ben

mani   

Posted at 11:06pm on Friday, April 23rd, 2010

nice

Justin   

Posted at 1:48am on Wednesday, April 28th, 2010

what would be the script to execute this program?
Enter your filename:etc/justin/test.txt
What do you want to do?
1.Read
2.Write
3.Append

Praseed   

Posted at 7:42am on Wednesday, May 5th, 2010

I have a requirement to split the records in a single file into multiple files based on a column value. The records containing particular column value should be written to different files. Is there any way in perl to do that ? Please advice

saeed   

Posted at 4:17am on Monday, May 17th, 2010

hi guys who can help and do project
project description
open a file "data.txt" and read data from this file (this data colud be integer or real ). the program should itself calculate the size of data (i.e. it should itself when the files end) .then the program should compute the following
1 size of data
2 mean
3 median
4 mode
5 variance
6 standard devation
7 miimum value in the data
8 maxmum value in the data
9 frequency of miimum value in the data
10 frequency of maxmum value in the data
11 data elemen(s) with highest frequncy
12 data elemen(s) with lowest frequncy

your program sholud out put these result on the screen as well in a file " result.txt"

this is my e-mail address ples who can do it an send it to me
r0o7r0o7y@hotmail.com

kaki   

Posted at 4:36am on Thursday, May 20th, 2010

I want to how to open a wav format file,cut it between a certain time range..this operation is performed on 2-3 wav file and paste these pieces into another wav file??
can ne one tell how??
plz reply urgent

Zav   

Posted at 11:10am on Monday, June 14th, 2010

Hey guys,
Im very new to perl and I have a simple task that i'm sure practically anyone could answer. I'm trying to look for certain words in a file and just take whole line where it finds that certain word. Example
* *
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
cccccccccccccccccccccccccccccccccccccc
this is the line i want
ddddddddddddddddddddddddddddddd
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee

...how would I do this? and what if i had about 200 similar files and just wanted the same lines taken out every time, then placed in a seperate file?
Someone please help!

weatherlight   

Posted at 6:18am on Friday, July 30th, 2010

Hi,

Please help.. I'm lost in this part of the code...
I just want to count how many "error" and "exception" word are there in a certain file.

Thanks in advance!...^_____^

open(INFILE,"$filename") or die "Can't open $filename!nCheck file permission or check if existing.n";
#print("$filename");
while()
{
if ($_ =~ /($error)|($exception)/)
{
$activeCount += &countChar($error,$_);
$notactiveCount += &countChar($exception,$_);
}

}

sameer   

Posted at 11:19pm on Sunday, August 1st, 2010

Thanq for your information

kalees   

Posted at 5:00am on Monday, August 2nd, 2010

i want to open the image file ......which location i give ,it may local host address or copied image url of any other website

Chandu   

Posted at 6:30am on Friday, August 13th, 2010

#!usr/bin/perl
use warnings;
use strict;
my $str = "chandu";

open FILE, ">test.pl" or die $!;
print FILE "#!/usr/bin/perl","n";
print FILE "print ",'"',$str,'"',";";
close FILE;

It will create new prel script..

jamal   

Posted at 8:41pm on Sunday, August 22nd, 2010

Write a program to capture all phone numbers in the given text file

Puradappa   

Posted at 11:49am on Tuesday, August 24th, 2010

Please write script
Attached file is the duration testcase profile.



In the attached file, each line corresponds to a file path and there is a percentage assigned to it.



Ex:

/fw/test/S_SUBSYSTEMS/duration/Misc/Anteater/Copy/BFT_012CopyLtrSimplex.xmlrexec=0.0208333333



Now, you have to write a script to get the percentages for each file and the script should inform the number of times the same percentage has repeated.



Say 0.0208333333 is assigned to 3 files. Then the script should return the same.



Example output (this is not actual values):

1 file(s) reside in the 0.0000920000 group.

15 file(s) reside in the 0.0050920000 group.

Puru   

Posted at 11:54am on Tuesday, August 24th, 2010

Her is attached sheet for last
### Target List type profile ###
############
### COPY ###
############
/fw/test/S_SUBSYSTEMS/duration/Misc/Anteater/Copy/BFT_012CopyLtrSimplex.xmlrexec=0.0208333333
/fw/test/S_SUBSYSTEMS/duration/Misc/Anteater/Copy/BFT_014Copy4Up.xmlrexec=0.0208333333
/fw/test/S_SUBSYSTEMS/duration/Misc/Anteater/Copy/BFT_015CopyNUp.xmlrexec=0.0208333333
/fw/test/S_SUBSYSTEMS/duration/Misc/Anteater/Copy/BFT_016CopyScaleUp.xmlrexec=0.0208333333
/fw/test/S_SUBSYSTEMS/duration/Misc/Anteater/Copy/BFT_017CopyScaleDn.xmlrexec=0.0208333333
/fw/test/S_SUBSYSTEMS/duration/Misc/Anteater/Copy/BFT_019CopyJobMode.xmlrexec=0.0208333333
/fw/test/S_SUBSYSTEMS/duration/Misc/Anteater/Copy/BFT_020CopyTextMode.xmlrexec=0.0208333333
/fw/test/S_SUBSYSTEMS/duration/Misc/Anteater/Copy/BFT_021CopyPhotoMode.xmlrexec=0.0208333333
/fw/test/S_SUBSYSTEMS/duration/Misc/Anteater/Copy/BFT_08BCopyBookModeFB.xmlrexec=0.0208333333
/fw/test/S_SUBSYSTEMS/duration/Misc/Anteater/Copy/BFT_18CopyJobCancel.xmlrexec=0.0208333333
/fw/test/S_SUBSYSTEMS/duration/Misc/Anteater/Copy/BFT_26CopyFBDuplex.xmlrexec=0.0208333333
/fw/test/S_SUBSYSTEMS/duration/Misc/Anteater/Copy/BFT_30Copy2Up.xmlrexec=0.0208333333
################
### Embedded ###
################
/fw/test/S_SUBSYSTEMS/duration/Misc/Anteater/DigitalSend/BFT_DS001EmbeddedEmail.xmlrexec=0.0450000000
###############
### Service ###
###############
/fw/test/S_SUBSYSTEMS/duration/Misc/Anteater/DigitalSend/BFT_DS001ServiceEmail.xmlrexec=0.0150000000
/fw/test/S_SUBSYSTEMS/duration/Misc/Anteater/DigitalSend/BFT_DS001ServiceSecureEmail.xmlrexec=0.0150000000
/fw/test/S_SUBSYSTEMS/duration/DigitalSend/DSMPLogGet.tcl=0.0150000000
#######################
### Service Folder ###
#######################
/fw/test/S_SUBSYSTEMS/duration/Misc/Anteater/DigitalSend/BFT_DS001ServiceFolder.xmlrexec=0.0300000000

Mike Hayes (UK)   

Posted at 11:59am on Wednesday, September 8th, 2010

Hello, Can anyone help me do a small program for me?

Program Requirements :-
Write a program that will take path of a directory (containing multiple files) as input
and print the average time to open and read the files as output. The files are to be read in
blocks of 64 KB.

Anonymous   

Posted at 10:31pm on Tuesday, September 28th, 2010

this is my sample code to open a single file of .txt..here..
--->


my problem now is..i want to open another .txt file that is inside the folder..pls do help me..thanks

Anonymous   

Posted at 9:42am on Thursday, October 28th, 2010

Not very helpful. I'm trying to figure out
"$cfg->read($args->{c})"

Vijay   

Posted at 5:22am on Wednesday, November 3rd, 2010

Need some more examples..

csk   

Posted at 5:58pm on Friday, November 19th, 2010

Hi,

I just come across a open command which used by some one..i couldn't understand what exactly it means, could any one give a brief explanation about this. Here is the command :

"open( P4INFO, '-|', $::p4, '-Zproxyto=master', 'info' )"

Thanks,

sravani   

Posted at 12:38pm on Monday, November 29th, 2010

hi,
I need to develope a perl program to read a "c" file and print all blocked comments.
sravanisimhadri@yahoo.co.in

ev   

Posted at 2:59pm on Tuesday, December 14th, 2010

thanks a mill this helped to clear some of the syntax

miss patil   

Posted at 10:31pm on Tuesday, December 28th, 2010

please add newly searched file handelling & data structure progamming

Anonymous   

Posted at 6:17am on Wednesday, December 29th, 2010

Hi,
I'd like to split a swift file. The file look like:
{kqshdkjshd
qsdmkqmsldkqmskdq
sdmqlksdm}${sdfsdfs
sdfsdfsdfs
sdfsdfsdsdfsd}

I'd like to split with perl this file into to n files (here 2 files):
file1:
{kqshdkjshd
qsdmkqmsldkqmskdq
sdmqlksdm}

the second file
file 2:
{sdfsdfs
sdfsdfsdfs
sdfsdfsdsdfsd}

thank you for help.

Franois   

Posted at 10:06am on Wednesday, December 29th, 2010

I've gff file : gi|78|gb|TT4879.1|TT4689
gi|78|gb|TT4879.1|TT4689
gi|78|gb|TT4879.1|TT4689
gi|78|gb|TT4879.1|TT4690 etc.. - it's my first column. I want to find the same name into my file but I don't now how?

Franois   

Posted at 10:07am on Wednesday, December 29th, 2010

I've gff file : gi|78|gb|TT4879.1|TT4689
gi|78|gb|TT4879.1|TT4689
gi|78|gb|TT4879.1|TT4689
gi|78|gb|TT4879.1|TT4690 etc.. - it's my first column. I want to find the same name into my file but I don't now how?

Mr J.   

Posted at 8:19am on Saturday, January 8th, 2011

can you send me some complete programs in this particular guide. i need help for my final defend. thank you..

a   

Posted at 12:31am on Tuesday, January 18th, 2011

How to read the output file character by character?

kg   

Posted at 12:44am on Saturday, January 22nd, 2011

hi,
i have written perl script for network traffic capture.i want perl script which will transfer the output of this perl script displayed in the command prompt to a word document periodically.

David   

Posted at 2:45pm on Thursday, January 27th, 2011

I want to add to the end of a line for a file that has the /usr/X11R6/bin/X in it. the /usr/X11R6/bin/X is not at the end of each line. I need to add "-nolisten tcp" to the end of each line containing the the /usr/X11R6/bin/X string

Hifz   

Posted at 12:58am on Thursday, February 10th, 2011

Hi All, I need help on PERL SCRIPTING..
I have a file with .sca extention.. Please help me with a perl script to open this .sca file an read the contents of with or list the files in it..

For your info I can view the contents of this fiel using winrar or winzip,, please give a script or alternative for this but in PERL.

Regards,
Hifz..

uma   

Posted at 1:12am on Monday, February 14th, 2011

good one

toufiq   

Posted at 4:13am on Friday, February 18th, 2011

really helful....

Rob Kinyon   

Posted at 12:39pm on Friday, February 18th, 2011

Why are you promulgating the FILE notion. Use scalar filehandles.

open my $fh, '

britantyo   

Posted at 8:53am on Tuesday, February 22nd, 2011

my shell script try to run perl script that contain file handler. it works fine when i run the perl script, but it fail when i run it from shell script. do you have any idea why this happen

B   

Posted at 1:00pm on Monday, April 11th, 2011

Need some help...
I have an input file that I need to convert to a different format to load to a Oracle table. We have an old system that takes a file from another system and manipulates it (via COBOL) creating an output file with the same data but in a different format. What I need is help with taking that same input file and doing what the COBOL program does but in PERL. I can not find anything about taking a file and writing to another changing the way the output file looks from the input file. We need it this way so the interface program can run the output file to the database table. Any help would be greatly appreciated.

Aza D. Oberman   

Posted at 6:37am on Thursday, April 14th, 2011

Really should address uploading using the Perl "read()" function because the "read()" function would let you limit the size of the file uploaded.

Naveen Kumar   

Posted at 3:57am on Friday, April 22nd, 2011

#Simple Script to open a file and print contents
open(DIR,"D:/PERL/smtp1.pl") || die ("Failed");
@DIR1=;
foreach $x (@DIR1)
{
print "$x";
}

Jimmy   

Posted at 4:49pm on Sunday, May 1st, 2011

Hi Just new in perl and my first assignment is to create a script that will read the latest log. Our log format is output_counter_date.log (output0012_20110411.log). Once the latest log has been identified, script will read the file and look for specific strings like 'unable to open businessclass' or 'unable to process transactions' or ' error in processing steps'. Once any of the strings found, it will send an email notification to the target receipients. I have done this script in UNIX script. How to do this in perl? I really appreciate it if you can help me. I know if I will do a research it will take me longer.

ghdstraightener01   

Posted at 2:00am on Wednesday, May 4th, 2011

Thanks for this site, it is really good. If I want to read several files such as c_1, c_2, c_3 etc in the same Ghd Straighteners sales
GHD Black Straighteners

richard   

Posted at 2:43am on Tuesday, May 10th, 2011

Any idea ?
I got a log with several lines with a date in it - i want to split the log in new logs with the name of the date e.g. log_20110510 - no prob so far.
But - my solution is to read the date from the origin log, open the new file with an anonymous filehandle, print the stuff in it and close the filehandle.
Is it possible to check, if the correct filehandle for the date exists, so i don't have to open and close it in every line ?
I tried to but i think my problem is - i can't print in a filehandle like this:
print $var "$line";#$var is a string and it doesn't work ??

Joyelle   

Posted at 10:38pm on Tuesday, May 10th, 2011

Hey, subtle must be your mdilde name. Great post!

thomas   

Posted at 12:18am on Wednesday, May 11th, 2011

how to insert lines to an existing file between two lines. Is there any way?

tlaznpwjxx   

Posted at 7:28pm on Wednesday, May 11th, 2011

vuvcNS fpxgnqkrkvqy

phqqygcsvcf   

Posted at 8:38pm on Friday, May 13th, 2011

yef3zQ ddvcwjdzjkxm

Anand   

Posted at 1:06am on Tuesday, May 17th, 2011

its the suitable answer but i want how can we get the output of program which is not having any code.can you give right answer?

Reospetty   

Posted at 4:15am on Wednesday, May 18th, 2011

Local Phone Numbers in 90 Countries

Virtual Phone Number For French Company

Prices
New York, USA
Set up - 30$, monthly fee- 12$
Los Angeles, USA
Set up - 30$, monthly fee- 12$
Tokyo, Japan
Set up - 50$, monthly fee- 30$
Berlin, Germany
Set up - 50$, monthly fee- 20$
Paris, France
Set up - 50$, monthly fee- 20$
Moscow, Russia
Set up - free, monthly fee- 50$
Lagos, Nigeria
Set up - 50$, monthly fee- 30$
Buenos Aires, Argentina
Set up - 50$, monthly fee- 26$
Mexico City, Mexico
Set up - 50$, monthly fee- 32$
London, UK
Set up - 30$, monthly fee- 12$
6500+ cities are available in 90 countries!
Voip 3Cx

Virtual local phone number is like a usual telephone number. It is a service to forward incoming calls. The incoming calls to virtual number are automatically forwarded to another landline or cell phone number of that city or country which the client chooses. For example, if you buy local virtual number in New York (212) XXX-XXXX and forward calls to your landline (mobile) phone number in London (Tokyo, Berlin, Beijing, Shanghai, Paris, Mexico, Istanbul, Moscow, etc.) the client will think that you are situated in New York. Or if you live in Canada and your family, relatives and friends live in the UK you can buy a VoIP DID virtual number in the UK and divert incoming phone calls to your Canadian number. The cost of international calls will become significantly cheaper. You can also forward calls from your local number to Skype and SIP.
Continent Telecom provides local phone numbers in 90 countries of the world, more then 6500 cities. View the list of available countries and local virtual numbers prices.

International Virtual Local Phone Numbers

Take Virtual Number In The United Kingdom

Continent Telecom provides local virtual phone numbers of all continents: Africa, Europe, Asia, Australia/Oceania, North America, South America and even Antarctica!


North America: Canada, Costa Rica, Dominican Rep, El Salvador, Guatemala, Jamaica, Mexico, Panama, USA - 1850+ cities
South America: Argentina, Brazil, Chile, Colombia, Peru, Venezuela
Europe: Austria, Belgium, Bulgaria, Croatia, Cyprus, Czech Republic, Denmark, Estonia, Finland, France, Georgia, Germany, Greece, Hungary, Iceland, Ireland, Italy, Latvia, Lithuania, Luxembourg, Malta, Netherlands, Norway, Poland, Portugal, Romania, Russia, Slovakia, Slovenia, Spain, Sweden, Switzerland, Ukraine, UK
Asia: Bahrain, China, Hong Kong (HK), Iran, Israel, Japan, Jordan, Kazakhstan, North Korea, Malaysia, Singapore, South Korea, Thailand, Turkey, Vietnam
Africa: Algeria, Angola, Congo, the Democratic Republic, Cote d'Ivore, Guinea-Bissau, Kenya, Madagascar, Nigeria, Sierra Leone, Somalia, South Africa
Australia and Oceania: Australia, New Ze

Reospetty   

Posted at 4:15am on Wednesday, May 18th, 2011

Local Phone Numbers in 90 Countries

Virtual Phone Number For French Company

Prices
New York, USA
Set up - 30$, monthly fee- 12$
Los Angeles, USA
Set up - 30$, monthly fee- 12$
Tokyo, Japan
Set up - 50$, monthly fee- 30$
Berlin, Germany
Set up - 50$, monthly fee- 20$
Paris, France
Set up - 50$, monthly fee- 20$
Moscow, Russia
Set up - free, monthly fee- 50$
Lagos, Nigeria
Set up - 50$, monthly fee- 30$
Buenos Aires, Argentina
Set up - 50$, monthly fee- 26$
Mexico City, Mexico
Set up - 50$, monthly fee- 32$
London, UK
Set up - 30$, monthly fee- 12$
6500+ cities are available in 90 countries!
Voip 3Cx

Virtual local phone number is like a usual telephone number. It is a service to forward incoming calls. The incoming calls to virtual number are automatically forwarded to another landline or cell phone number of that city or country which the client chooses. For example, if you buy local virtual number in New York (212) XXX-XXXX and forward calls to your landline (mobile) phone number in London (Tokyo, Berlin, Beijing, Shanghai, Paris, Mexico, Istanbul, Moscow, etc.) the client will think that you are situated in New York. Or if you live in Canada and your family, relatives and friends live in the UK you can buy a VoIP DID virtual number in the UK and divert incoming phone calls to your Canadian number. The cost of international calls will become significantly cheaper. You can also forward calls from your local number to Skype and SIP.
Continent Telecom provides local phone numbers in 90 countries of the world, more then 6500 cities. View the list of available countries and local virtual numbers prices.

International Virtual Local Phone Numbers

Take Virtual Number In The United Kingdom

Con

smith   

Posted at 1:20pm on Wednesday, June 1st, 2011

plz tell me the solution...i hav a html code that accepts input from user n call a perl file to perform action on it..and aftr running the perl program send input back to html form..
so could anyone plz tell me how a perl code accept the input which is return on html form n send back output dere at that form/block only

smith   

Posted at 1:25pm on Wednesday, June 1st, 2011

sry there are sme mistakes in previous question.....
plz tell me the solution...i hav a html code that accepts input from user n call a perl file to perform action on it..and aftr running the perl program send output back to html form..
so could anyone plz tell me how a perl code accept the input which is written on html form n send back output dere at that form/block only

WonToo3For   

Posted at 6:15am on Wednesday, June 8th, 2011

I'm trying to write a script that prompts the user for a list of names and then searches a specific file for the fields associated with the names and then sends those fields to another file.
Could someone please help. Thank you very much in advance. :)

veeru   

Posted at 12:01am on Monday, July 18th, 2011

nice

minkesh   

Posted at 7:09am on Friday, July 29th, 2011

hey m new at c so can u tell me why file handling is important learn?

chakras_2011   

Posted at 7:01am on Tuesday, August 2nd, 2011

Hello

I have a copy of a file in a Linux system, I want a script (Perl) which will check if this file is modified, if not, no further actions needed. but if yes, then copy it to a folder "DDMMYYYY".

How can I define the logic for this script.

Any help is appreciated

Regards
Suvajit

asdasd   

Posted at 9:38am on Friday, August 19th, 2011

sadasasdadasd

santosh   

Posted at 8:00pm on Saturday, August 20th, 2011

Hi Could any one suggest How could I open a file in server and do get filter out certain data in client machine where the script is running.

thanks in advance
ssr

Nirvana   

Posted at 12:09pm on Sunday, August 21st, 2011

Guys plzz help me.. i want to fetch an html file my program and den wann parse. i ve written parser.. now how to fetch the page by giving url.

Nirvana   

Posted at 12:10pm on Sunday, August 21st, 2011

Guys plzz help me.. i want to fetch an html file my program and den wann parse. i ve written parser.. now how to fetch the page by giving url.

Marvin   

Posted at 5:57pm on Saturday, August 27th, 2011

So how would I try and get input from a user using STDIN and have it write to a file... I'm looking through all the tutorials with no luck...

supraja   

Posted at 2:12am on Tuesday, September 6th, 2011

can any one tell how to write the program for collecting the similar kind of files and placed in one folder

jsfsafa   

Posted at 12:00pm on Wednesday, September 7th, 2011

afdsafsaf

Babu   

Posted at 3:25am on Thursday, September 22nd, 2011

good...
what i expected was there...

sheela suraj   

Posted at 10:05pm on Tuesday, September 27th, 2011

dont hav any other work......get lost

sheela suraj   

Posted at 10:08pm on Tuesday, September 27th, 2011

hey girls i love u a lot....come to our college....we will rock.......:):):P:D

GladysHodges   

Posted at 10:15pm on Tuesday, September 27th, 2011

That is great that we can receive the loan and it opens up new possibilities.

EugeniaGeorge23   

Posted at 9:52am on Tuesday, October 11th, 2011

Some time ago, I needed to buy a good car for my business but I didn't earn enough cash and couldn't order something. Thank heaven my friend suggested to get the loan from reliable creditors. Therefore, I acted so and was happy with my student loan.

Anonymous   

Posted at 1:52am on Thursday, October 13th, 2011

hello, I have 2 sql (a.sql, b.sql) files which contains few DDL and DML statements like create index, crete table, alter table and I have put those sql files in a temp directory. Now I need a perl script which will count of occurance of create table and create index statements in both files and wil give me result like below:

a.sql
create index=3 times
create table=5 times

b.sql
create index=8 times
create table=9 times

Can someone please help? we just need to pass location of directory not file name

tommys   

Posted at 12:59pm on Monday, October 24th, 2011

The open, close, print and read commands will allow you to perform most common file operations. However, much more is possible. Apart from opening files you may open

Samantha26Franco   

Posted at 4:24am on Thursday, October 27th, 2011

All people deserve good life time and business loans or student loan would make it much better. Just because people's freedom relies on money.

soneat   

Posted at 7:31pm on Thursday, October 27th, 2011

I don't understand how to use it!

saravanan.r   

Posted at 10:15pm on Wednesday, November 9th, 2011

hi, when i open bmp file it asks for open with option, how to resolve this issue

mewJeamsmex   

Posted at 11:37pm on Tuesday, November 29th, 2011

On February Twelve,2011,Ugglebo Professional clogs filed suit with Deckers Outdoor Corp using allegations for unfair competitiveness,deceptive trade practices along with reverse uncertainty based on Deckers' standby and call time UGG signature for blocks the and boots and shoes. In the agree with Ugglebo alleges which usually uggs cheap is a universal term understanding that through "aggressive going to court,coincidence,as well as advertising,Offender has with success converted "ugg" from a generic phrase for sheepskin boots around australia into a brand for boots in the United States. What is more,Defendant has now extended the trademark a number of non-boot footwear things such as,one example is clogs,house and moccasins,and also non-sheepskin." Ugglebo type clogs had been manufactured given that 1965.

During a signature infringement in addition to trade attire case,a plain term defense was dropped by a Dutch court. La Cheapa distributed ugg boots you are using Internet site with the Netherlands,conveying them in its online site as "100% traditional Ugg Aussie boots!!!Inch uggs canada with "UGG badge on the heel" in boxes nearly identical to Deckers appearance. Ruling simply Deckers with bills awarded in opposition to La Cheapa,that officer what individuals heard the outcome stated it can't establish mainly because fact that "ugg" is considered a generic title in the Benelux,good opinion of just one or more agencies in Australia.

Truly,the v

alaa   

Posted at 6:54am on Thursday, December 1st, 2011

alaa zohny

Richard Still (Oakbox)   

Posted at 4:13am on Thursday, December 15th, 2011

For READING files, I now depend almost exclusively on Slurp;

use Perl6::Slurp;
my $document = slurp "/file/location/file.txt";

Read the documentation of this super useful module because it puts everything on one line, the documentation is extensive, and it handles not only the read, but in most cases the parsing of the file into an array of lines for you.

nmike   

Posted at 8:16am on Friday, January 6th, 2012

good

Anonymous   

Posted at 9:39pm on Wednesday, January 11th, 2012

Please can any body help me ou in this scenario--I have two folders-folder 1 & folder 2...folder 1 contains some subfolders and files & folder 2 also contains some subfodlers and files...now i need to remove the files from folder1 which are not present in folder2 in this syncng but i should not get the changes to my data only the files should be removed and no updations on the data should occur..require a perl script please help me out----Sruthi Reddy

vish   

Posted at 4:53am on Monday, January 16th, 2012

cool. it works

satish   

Posted at 2:27am on Tuesday, January 17th, 2012

please make it very simple for undurstanding what is this i didnt understood the way of expressing this notes is very bad u made it difficult nonsense

satish   

Posted at 2:28am on Tuesday, January 17th, 2012

please make it very simple for undurstanding what is this i didnt understood the way of expressing this notes is very bad u made it difficult nonsense

satish   

Posted at 2:30am on Tuesday, January 17th, 2012

please make it very simple for undurstanding what is this i didnt understood the way of expressing this notes is very bad u made it difficult nonsense simple banao nahi to band karo kaisebhi likhte ho

Gaurav Nishaan   

Posted at 5:16am on Tuesday, January 31st, 2012

nothing

Ajay   

Posted at 8:15am on Monday, February 13th, 2012

Can anyone help with this and that..
so, 1). It helps to choose a girls name. Perl geeks are almost virgins..
2). You are asking for help, so suk it up, your frustration.
3). Money rewards.
4). Good questions, at least the English part of it. why would i waste my time trying to understand your blabber/question.
5). Be precise. The people answering your questions are not as dumb as you.
6). Try Google, internet is not only 'facebook' .
7). Every document has a audience and a subject to address, dont say, 'x' is not covered, when topic itself was 'y'.
8). Dont do perl, thinking its easy. Its not.
9). Change jobs or learn to google, copy, paste. Remember that too takes common sense.
10). Get some education.

5455555555555555555555555   

Posted at 12:30am on Friday, March 2nd, 2012

744552

dee   

Posted at 11:15am on Friday, March 9th, 2012

nice!

dee   

Posted at 11:22am on Friday, March 9th, 2012

nice!

swetha   

Posted at 9:29pm on Wednesday, March 14th, 2012

hi

How i will get filename into text file using perl,
Please help me

Ajit Gunge   

Posted at 2:48am on Thursday, March 15th, 2012

Can I know a program in perl that access a windows file.How do I mention the file path etc I need an working example.Can you please tell me how can I do this?

Thanks,
Ajit

Peter   

Posted at 11:33pm on Thursday, March 15th, 2012

I am trying to open a txt file after using the MIME parser
am trying to open it using the above command and i cant, any ideas guys?

if($type eq 'txt/plain')
{
print FILE "processing: ".$bh->{MB_Path}."n";


$csv = Text::CSV->new();
$processed = 0;


open CSVFILE, "{MB_Path}";



while ()


$line = $_;
if($line =~ /^$/)
....

Cupidvogel   

Posted at 6:04am on Friday, March 23rd, 2012

Really cool tutorial.

Billigfluege Gutschein   

Posted at 2:05pm on Sunday, March 25th, 2012

Weekend Story,shall surprise set shut need to pay general travel purpose offer report tear dog force settlement bone enemy speech united effect wall like smile mind victory wait main open obtain firm effect address firm period design black solution man achievement can contribution path top labour consist sure economic adult regular this need change official access reference music cultural out huge organise to as firm shake respond adult prison promise something target some initial out chance century people date criminal serious passage pretty soldier size order conclusion clearly together advise plus

gururaj   

Posted at 3:02am on Friday, April 20th, 2012

This program is completely wrong

gururaj   

Posted at 3:02am on Friday, April 20th, 2012

This program is completely wrong

Anonymous   

Posted at 7:44am on Saturday, April 21st, 2012

suhana


In filehandling...
I want to compare name and password..
i have to store name & password in a variable in a program..
and also in file...i also have store
name and password in a variable...
i want to compare both....
How we can do this through filehandling???

Anonymous   

Posted at 7:48am on Saturday, April 21st, 2012

how we can save information in file through file handling in c#

Anonymous   

Posted at 9:11am on Monday, April 30th, 2012

I cannot find the problem in my code.

if ($entry){
open LOG, ">>$logname" or die $!;
print LOG "$timestamp$entryn";
#say $timestamp.$entry;
close(LOG);
}

Or

if ($entry){
open LOG, ">>" , $logname" or die $!;
print LOG "$timestamp$entryn";
#say $timestamp.$entry;
close(LOG);
}

Or

if ($entry){
open my $LOGGER, ">>$logname" or die $!;
print $LOGGER "$timestamp$entryn";
#say $timestamp.$entry;
close($LOGGER);
}

And several other variations. I tried everything you have on this page. I have googled my error. It is breaking on the open, not on the print function.

"Inappropriate I/O control operation" I always get that, but it is writing to the log. It is also reporting to the user that the I/O is inappropriate. How can I fix this?

Chris   

Posted at 9:54am on Friday, May 11th, 2012

Hello

inhamsheitelm   

Posted at 4:24am on Saturday, May 19th, 2012

The actual Devon coast option is suitable throughout the fro

ramesh   

Posted at 7:23pm on Tuesday, May 22nd, 2012

it is very nice

karthick   

Posted at 4:42am on Thursday, June 7th, 2012

good

Soyclereger   

Posted at 1:23am on Thursday, June 21st, 2012

Секс подростков историй рассказы БЕСПЛАТНЫЕ ПОРНО ЭРОТИЧЕСКИ скачать торрент читерскую cs Однажды сидела рядом, Смотрела ему в глаза. В душе так наболело Спросила я - Любишь меня?Однажды сидела рядом, Смотрела ему в глаза. В душе так наболело... Спросила я - Любишь меня? И п%

matski   

Posted at 9:36pm on Saturday, June 30th, 2012

I'm trying to get the character per line. How can I get this coz I'm trying to make a symbol table.. any1 can help?

matski   

Posted at 9:38pm on Saturday, June 30th, 2012

I'm trying to get the character per line. How can I get this coz I'm trying to make a symbol table.. any1 can help? Thank you

gueroulourece   

Posted at 6:02pm on Thursday, July 5th, 2012

На мобильном телефоне Niko позвоните по этим номерам и нужные чит коды активируются!!! 482-555-0100 - здоровье и оружие 362-555-0150 - з%3

geetanjalee   

Posted at 1:37am on Monday, July 9th, 2012

very brief notes

Smearistame   

Posted at 4:32pm on Monday, July 16th, 2012

- есть немало предприятий в городе Москва, которым также часто бывает необходима срочная компьютерная помощь. На таких предприятиях, на компьютерах может быть установлено специализированное ПО и дополнительные hardware-модули, разработанные специально под требования предприятий. В случае краха таких систем может встать работа некоторых подразделений предприятия. Мы в срочном порядке оказываем скорую компьютерную помощь таким предприятиям, восстанавливая работоспособность в максимально возможные короткие сроки. Easy file undelete crack Главное правило ремонта компьютерной техники – обращаться за помощью только к опытным специалистам. Именно поэтому, если вы увидели объявление «Компьютерная помощь Домодедово» или «Починим компьютеры Домодедово», не стоит сразу же звонить по указанному номеру телефона. Следует понимать, что компьютерная техника является достаточно сложным видом оборудования. И если приступить к ремонту без наличия специальных знаний, можно только усугубить ситуацию. Нередко мы сталкиваемся и с другой проблемой – относя компьютеры в Домодедово

Ashwin   

Posted at 9:34pm on Wednesday, August 8th, 2012

I have a CSV file given below:

TranID,Date,AcNo,Type,Amount,ChequeNo,DDNo,Bank,Branch
132520,01-01-2011,51321342,Dr,5000,,,,
132524,01-01-2011,51321342,Dr,1000,,4126123,SB,Ashoknagar
132538,08-01-2011,51321342,Cr,1620,192101,,,
132548,17-01-2011,51321342,Cr,3500,192102,,,
132519,01-01-2011,55212341,Dr,2000,142514,,SBM,Hampankatte
132523,01-01-2011,55212341,Cr,500,192121,,,
132529,02-01-2011,55212341,Dr,5000,131211,,SB,Ashoknagar
132539,09-01-2011,55212341,Cr,500,192122,,,
132541,10-01-2011,55212341,Cr,2000,192123,,,
132525,02-01-2011,55212342,Dr,5000,,,,
132533,04-01-2011,55212342,Cr,2100,192201,,,
132526,02-01-2011,55212343,Dr,3000,126200,,ICICI,Hampankatte
132531,03-01-2011,55212343,Cr,500,192221,,,
132537,07-01-2011,55212343,Dr,5456,135123,,CB,Kankanady
132544,15-01-2011,55212343,Cr,3500,192222,,,
132546,15-01-2011,55212343,Cr,1342,192223,,,
132527,02-01-2011,55212344,Dr,5000,127821,,SB,MGRoad
132536,06-01-2011,55212344,Cr,1500,192251,,,
132528,02-01-2011,55212345,Dr,2000,162423,,CB,MGRoad
132530,03-01-2011,55212345,Cr,1000,192271,,,
132542,11-01-2011,55212345,Dr,3500,,4251234,ICICI,Hampankatte
132543,14-01-2011,55212345,Cr,1500,192272,,,
132521,01-01-2011,55212346,Dr,6000,125324,,CB,Kankanady
132532,03-01-2011,55212346,Cr,1000,192341,,,
132547,16-01-2011,55212346,Dr,2300,,,,
132522,01-01-2011,55212415,Dr,1200,162341,,SBI,Hampankatte
132534,05-01-2011,55212415,Dr,5000,162450,,SB,Kuloor
132535,06-01-2011,55212415,Cr,2000,192361,,,
132540,09-01-2011,55212415,Dr,2000,,4521349,CB,MGRoad
132545,15-01-2011,55212415,Cr,1245,192362,,,

Question is:
Read data from 'banktran.csv'.Calculate total amount deposited by cheque, dd and by cash for each account.
I am supposed to use only hash. Without using parse functions, how to solve? Please help.

Levia   

Posted at 7:53am on Tuesday, August 21st, 2012

2011 年 11 月 1 日 - 下午 12:29 5F Iran (ISLAMIC Republic Of) Opera Mini 9.64 Windows XPIt is truly a great and useful piece of inoofmatirn. I am glad that you just shared this useful info with us. Please stay us informed like this. Thanks for sharing.

kkicbbnc   

Posted at 9:41pm on Tuesday, August 21st, 2012

C0PN1s bnxnajadcpsk

hiixmlqe   

Posted at 4:12am on Friday, August 24th, 2012

FH0CWT xboxfgzgvvhw

Anonymous   

Posted at 5:33am on Tuesday, September 11th, 2012

THis is helpful

Thnaks
Murthy's

ram   

Posted at 8:10pm on Friday, November 9th, 2012

hi ,
iam trying to wrte aperl script which reads from afile and writes into a diffferent file.
basically my input file loks like this
112233445566778899aabbccddeeff....(tens of lakhs)
my output file should be
11
22
33
44
55
66
77
the input file has a single line with lakhs of characters and so when i use @variable to store an entire linw into the array it says out of memory at the command line.
so i moved to read function which reads acharacter by character and writes into the output file.but here i see only few characters are wriiten but not all



any help ..ill be much oblized.
thnaks
ram

Anastasialvl   

Posted at 2:30pm on Sunday, December 16th, 2012

cc radio thompson candy philip kotler principles of marketing navigator 6 jensen tv panerai replica watches pc ma

Candanceasx   

Posted at 7:37pm on Sunday, December 16th, 2012

ge webcam panniers ellen goodman hollandaise bose

sapphire   

Posted at 12:10am on Thursday, February 14th, 2013

Short and to the point .i like it .

raju   

Posted at 3:00am on Wednesday, March 6th, 2013

how can i create,write,append the data into MS-dos files using perl in windows machines?
please tell the solution

necmi   

Posted at 6:37pm on Saturday, March 23rd, 2013

F*CK YOU AND ALL OF YOUR COMMENT SHOWING SYSTEM AND BLA BLA, F*CK OFF

Anonymous   

Posted at 10:54pm on Monday, March 25th, 2013

jvuyhjqwertyuk mnbvg

goku   

Posted at 10:56pm on Monday, July 1st, 2013

shazam

dharshini   

Posted at 12:49am on Thursday, August 29th, 2013

hi whats meant by die in the perl

dharshini   

Posted at 12:50am on Thursday, August 29th, 2013

hi whats meant by die in the perl

dha   

Posted at 12:51am on Thursday, August 29th, 2013

hi whats meant by die in the perl

Ravi Orchu   

Posted at 1:15am on Tuesday, September 3rd, 2013

Please tell me how to open the .txt document through perl programming.....

Ravi Orchu   

Posted at 1:16am on Tuesday, September 3rd, 2013

Please tell me how to open the .txt document through perl programming.....

andrew lilley   

Posted at 8:45am on Tuesday, September 3rd, 2013

Very useful.
In xp I used liberty basic and I am looking for an easy language for macbook. Perl seems to be the answer as I am having difficulty installing a C compiler for apple .
Your articles are welcome.

veeru   

Posted at 1:00am on Wednesday, January 8th, 2014

We are not getting to copying the first file to another file.

and we have to no how to generate one XLS using Perl
Let me now plz..............

veeru   

Posted at 1:00am on Wednesday, January 8th, 2014

We are not getting to copying the first file to another file.

and we have to no how to generate one XLS using Perl
Let me now plz..............

hi   

Posted at 9:53pm on Friday, February 21st, 2014

deepak
hi

mixalis   

Posted at 5:55pm on Wednesday, March 26th, 2014

HEllo, can i use open but instead of using a fixed filename, use a string i've got as an input? And how is that done?

Gregory Lawson   

Posted at 7:11am on Wednesday, June 4th, 2014

ICC Mortgage And financial Services, Is a sincere and certified private Loan company approved by the Government, we give out international and local loans to all countries in the world,Amount given out $2,500 to $100,000,000 Dollars, Euro and Pounds.
We offer loans with a dependable guarantee to all of our clients. Our loan interest rates are very low and affordable with a negotiable duration.
Available now
MORTGAGE, PERSONAL, TRAVEL, STUDENT, EXPANSION OF BUSINESS AND NEW UNSECURED, SECURE, CONSOLIDATE
AND MORE
Available now..
Apply for a loan today with your loan amount and duration, Its Easy and fast to get. 4% interest rates and monthly installment payments.
{gregorylawson.icc@gmail.com}

Regards
Gregory Lawson
(646) 580-4839

asdfsfda   

Posted at 11:24am on Monday, June 23rd, 2014

asdfasdfasdf

Guru   

Posted at 3:26am on Friday, July 4th, 2014

Good material

Sheida   

Posted at 4:52pm on Thursday, July 17th, 2014

I have a code in C. and to put it simply gives me the Average volume (V) of the system based on the fix defined pressure(P=1). now I want to get different volumes by increasing the pressure! But I don't wanna do it manually. I want to calculate the V in 50 Pressures.
I know that its possible to do it using Perl. I was told that I can use a Perl script to change the pressure and save the data(V) based on each P.
Can I get any help about this? :(

Cheers

@abhy   

Posted at 4:25am on Tuesday, October 28th, 2014

How to write data from multiple .csv file into single .csv file?

@abhy   

Posted at 4:26am on Tuesday, October 28th, 2014

How to write data from multiple .csv file into single .csv file?

Vignesh   

Posted at 7:04pm on Wednesday, November 26th, 2014

How can I simultaneously assign 2 file handlers to the same file in a single statement?

Comments to date: 282.

Like it? Share it!

Hosted Perlfect Search(beta)

New
Don't have the time or the expertise to install and maintain Perlfect Search? Then our freehosted Pelrfect Search service is for you!

Suggested Reading

Order your copy of Programming Perl now! Programming Perl covers all you need to know about Perl file handling.