|
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 I’ve 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 |
Comments to date: 144.