Sponsored Content
Full Discussion: File processing on perl
Top Forums Shell Programming and Scripting File processing on perl Post 302087512 by natesan81 on Friday 1st of September 2006 11:25:28 PM
Old 09-02-2006
MySQL Code

testfile.txt :

About Apple
Apple is a fruit
I like Apple Juice


Code

open(INFILE,"./testfile.txt")||die ("Cannot open testfile.txt");
open(OUTFILE,">./orange.txt")||die ("Cannot open orange.txt");
while($str=<INFILE>)
{
$str =~ s/Apple/Orange/g;
print OUTFILE $str;
}
close(INFILE);
close(OUTFILE);

Orange.txt


About Orange
Orange is a fruit
I like Orange Juice
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

perl script for file processing

Aim: To scan a file and ignore all characters that has an ASCII value from 0 to 31 and 127 to 255 and accept only those characters having an ASCII between 32 and 126. Script: #!/usr/local/bin/perl $filename = "$ARGV"; if (-e $filename) { open(OUT, "${filename}") || die "can't... (10 Replies)
Discussion started by: SEEHTAS
10 Replies

2. Shell Programming and Scripting

awk, perl Script for processing a single line text file

I need a script to process a huge single line text file: The sample of the text is: "forward_inline_item": "Inline", "options_region_Australia": "Australia", "server_event_err_msg": "There was an error attempting to save", "Token": "Yes", "family": "Family","pwd_login_tab": "Enter Your... (1 Reply)
Discussion started by: hmsadiq
1 Replies

3. Shell Programming and Scripting

Simple Script needed for Processing CSV file perl

I am new to perl, and need a script to pull a CSV file, strip out 2 leading columns, and 2 ending columns, and resave the file in a new location. The file is basic and has less than 10,000 records. Secondly, can I schedule perl scripts to run daily? Can someone provide the basic script to... (1 Reply)
Discussion started by: cobbjob
1 Replies

4. Shell Programming and Scripting

Processing a file in perl

Qspace ABC Queue doCol: true Queue order: fifo Queue setCol: red Queue order: fifo Qspace XYZ Queue getCol: true Queue order: fifo I need to append every line in this file with Qspace & Queue, so that final o/p shall look like this, Qspace: ABC Queue: doCol Qspace: ABC Queue: doCol... (2 Replies)
Discussion started by: deo_kaustubh
2 Replies

5. Shell Programming and Scripting

Perl file processing

I have an input array like : "SVR1" GRP="EVT_BOX06B" SRID=100 MIN=2 "SVR1" GRP="EVT_BOX06B" SRID=200 MIN=1 "SVR2" GRP="ADM_BOX06B" SRID=100 MIN=1 "SVR1" GRP="EVT_BOX88B" SRID=100 MIN=2 "SVR1" GRP="EVT_BOX88B" SRID=200 MIN=1... (4 Replies)
Discussion started by: deo_kaustubh
4 Replies

6. UNIX for Advanced & Expert Users

perl text file processing using hash

Hi Experts, I have this requirement to process large files (200MB+).Format of files is like: recordstart val1 1 val2 2 val3 4 recordstart val1 5 val2 6 val3 1 val4 1 recordstart val1 ... (4 Replies)
Discussion started by: mtomar
4 Replies

7. Programming

help me with perl script xml processing

Hi everyone, I have Xml files in a folder, I need to extract some attribute values form xml files and store in a hash. My xml file look like this. <?xml version="1.0" encoding="UTF-8"?> <Servicelist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"... (0 Replies)
Discussion started by: pavani reddy
0 Replies

8. Shell Programming and Scripting

perl problem in processing excel file

Dear all, I got a perl script to write some data into an excel file using Spreadsheet::ParseExcel::SaveParser. After that I find all formulas in the excel file are gone. Does any body encounter this problem or have any work around? (2 Replies)
Discussion started by: eldonlck
2 Replies

9. Shell Programming and Scripting

PARALLEL PROCESSING IN PERL

HI All, I have scenerio where I need to call sub modules through for loop for (i=0; i<30 ;i++) { .. .. .. subroutine 1; subroutine 2; } I want this to be run in parallel process1 { ... ... subroutine 1; subroutine 2; (0 Replies)
Discussion started by: gvk25
0 Replies

10. Programming

awk processing / Shell Script Processing to remove columns text file

Hello, I extracted a list of files in a directory with the command ls . However this is not my computer, so the ls functionality has been revamped so that it gives the filesizes in front like this : This is the output of ls command : I stored the output in a file filelist 1.1M... (5 Replies)
Discussion started by: ajayram
5 Replies
Crypt::CipherSaber(3pm) 				User Contributed Perl Documentation				   Crypt::CipherSaber(3pm)

NAME
Crypt::CipherSaber - Perl module implementing CipherSaber encryption. SYNOPSIS
use Crypt::CipherSaber; my $cs = Crypt::CipherSaber->new('my pathetic secret key'); my $coded = $cs->encrypt('Here is a secret message for you'); my $decoded = $cs->decrypt($coded); # encrypt from and to a file open(INFILE, 'secretletter.txt') or die "Can't open infile: $!"; open(OUTFILE, '>secretletter.cs1') or die "Can't open outfile: $!"; binmode(INFILE); binmode(OUTFILE); $cs->fh_crypt(*INFILE, *OUTFILE, 1); # decrypt from and to a file open(INFILE, 'secretletter.cs1') or die "Can't open infile: $!"; open(OUTFILE, '>secretletter.txt') or die "Can't open outfile: $!"; binmode(INFILE); binmode(OUTFILE); $cs->fh_crypt(*INFILE, *OUTFILE); DESCRIPTION
The Crypt::CipherSaber module implements CipherSaber encryption, described at http://ciphersaber.gurus.com. It is simple, fairly speedy, and relatively secure algorithm based on RC4. Encryption and decryption are done based on a secret key, which must be shared with all intended recipients of a message. METHODS
new($key, $N) Initialize a new Crypt::CipherSaber object. $key, the key used to encrypt or to decrypt messages is required. $N is optional. If provided and greater than one, it will implement CipherSaber-2 encryption (slightly slower but more secure). If not specified, or equal to 1, the module defaults to CipherSaber-1 encryption. $N must be a positive integer greater than one. encrypt($message) Encrypt a message. This uses the key stored in the current Crypt::CipherSaber object. It will generate a 10-byte random IV (Initial- ization Vector) automatically, as defined in the RC4 specification. This returns a string containing the encrypted message. Note that the encrypted message may contain unprintable characters, as it uses the extended ASCII character set (valid numbers 0 through 255). decrypt($message) Decrypt a message. For the curious, the first ten bytes of an encrypted message are the IV, so this must strip it off first. This returns a string containing the decrypted message. The decrypted message may also contain unprintable characters, as the CipherSaber encryption scheme can handle binary files with fair ease. If this is important to you, be sure to treat the results correctly. crypt($iv, $message) If you wish to generate the IV with a more cryptographically secure random string (at least compared to Perl's builtin rand() func- tion), you may do so separately, passing it to this method directly. The IV must be a ten-byte string consisting of characters from the extended ASCII set. This is generally only useful for encryption, although you may extract the first ten characters of an encrypted message and pass them in yourself. You might as well call decrypt(), though. The more random the IV, the stronger the encryption tends to be. On some operating systems, you can read from /dev/random. Other approaches are the Math::TrulyRandom module, or compressing a file, removing the headers, and compressing it again. fh_crypt(*INPUT, *OUTPUT, ($iv)) For the sake of efficiency, Crypt::CipherSaber can now operate on filehandles. It's not super brilliant, but it's relatively fast and sane. Pass in a reference to the input file handle and the output filehandle. If your platform needs to use "binmode()", this is your responsibility. It is also your responsibility to close the files. You may also pass in an optional third parameter, an IV. There are three possibilities here. If you pass no IV, "fh_crypt()" will pull the first ten bytes from *INPUT and use that as an IV. This corresponds to decryption. If you pass in an IV of your own (gener- ally ten digits, but more than one digits as the code is now), it will use your own IV when encrypting the file. If you pass in the value '1', it will generate a new, random IV for you. This corresponds to an encryption. COPYRIGHT AND LICENSE
Copyright (C) 2000 - 2001 chromatic This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. AUTHOR
chromatic <chromatic@wgz.org> thanks to jlp for testing, moral support, and never fearing the icky details and to the fine folks at http://perlmonks.org Additional thanks to Olivier Salaun and the Sympa project (http://www.sympa.org) for testing. SEE ALSO
the CipherSaber home page at http://ciphersaber.gurus.com perl(1), rand(). perl v5.8.4 2002-05-25 Crypt::CipherSaber(3pm)
All times are GMT -4. The time now is 06:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy