Sponsored Content
Full Discussion: Reading a File
Top Forums UNIX for Dummies Questions & Answers Reading a File Post 302124935 by oop on Tuesday 3rd of July 2007 08:55:07 AM
Old 07-03-2007
Network Reading a File again

Hi

I submitted a request earlier asking how to read a file with text and number and counts the number of bin 1's (ie. number 1's) in the file.

Messaage to anbu23, this is not homework, I usually work with Object Oriented Programming (Java) and I have never used perl before. I have a program from another person who has since left the company and I want to add a few extra functions to it.

If anyone can help me, I'd appreciate it, I need to somehow read the file, disregard the text and count the number of 1's in the file.

Cheers
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Reading file names from a file and executing the relative file from shell script

Hi How can i dynamically read files names from a list file and execute them from a single shell script. Please help its urgent Thanks in Advance (4 Replies)
Discussion started by: anushilrai
4 Replies

2. UNIX for Advanced & Expert Users

Reading a file and sending mail based on content of the file

Hi Gurus, I am having an requirement. i have to read a list file which contains file names and send mail to different users based on the files in the list file. eg. if file a.txt exists then send a mail to a@a.com simillary for b.txt,c.txt etc. Thanks for your help, Nimu (6 Replies)
Discussion started by: nimu1979
6 Replies

3. UNIX for Dummies Questions & Answers

Reading from a file(passing the file as input parameter)

hi I have a shell script say primary.sh . There is a file called params my scenario is primary.sh should read all the values and echo it for example i should pass like $primary.sh params output would be Abc ... (2 Replies)
Discussion started by: ssuresh1999
2 Replies

4. Shell Programming and Scripting

Searching for Log / Bad file and Reading and writing to a flat file

Need to develop a unix shell script for the below requirement and I need your assistance: 1) search for file.log and file.bad file in a directory and read them 2) pull out "Load_Start_Time", "Data_File_Name", "Error_Type" from log file 4) concatinate each row from bad file as... (3 Replies)
Discussion started by: mlpathir
3 Replies

5. Shell Programming and Scripting

fatal: cannot open file `TNAME' for reading (No such file or directory)

Hi, I am running this command through a shell script and getting the error mentioned in the subject line: testing.awk -f x.txt TNAME My testing.awk file contains something like ++++++++++++++++++ #!/usr/bin/awk -f BEGIN{ TAB_NAME="INSERT_ONE_" ARGV ; } if ( $1=="JAM_ONE" &&... (1 Reply)
Discussion started by: kunwar
1 Replies

6. Shell Programming and Scripting

Reading UNIX commands from file and redirecting output to a file

Hi All I have written the following script: #!/bin/ksh while read cmdline do echo `$cmdline` pid="$cmdline" done<commands.txt =========== commands.txt contains: ps -ef | grep abc | grep xyz |awk '{print $2}; My objective is to store the o/p of the command in a variable and do... (8 Replies)
Discussion started by: rahulparo
8 Replies

7. UNIX for Dummies Questions & Answers

Reading XML file and print the values in the text file using Linux shell script

hi guys, i want help... Reding XML file and print the values into the text file using linux shell script file as per below xml file <sequence> <Filename>aldorzum.doc</Filename> <DivisionCode>US</DivisionCode> <ContentType>Template</ContentType> <ProductCode>VIMZIM</ProductCode> </sequence>... (1 Reply)
Discussion started by: sravanreddy
1 Replies

8. UNIX for Dummies Questions & Answers

Reading Xml file and print the values into the text file in columnwise?

hi guys, i want help... Reding XML file and print the values into the text file using linux shell script file as per below xml file <sequence> <Filename>aldorzum.doc</Filename> <DivisionCode>US</DivisionCode> <ContentType>Template</ContentType> <ProductCode>VIMZIM</ProductCode> </sequence>... (4 Replies)
Discussion started by: sravanreddy
4 Replies

9. Shell Programming and Scripting

ksh Script, Reading A File, Grepping A File Contents In Another File

So I'm stumped. First... APOLOGIES... my work is offline in an office that has zero internet connectivity, as required by our client. If need be, I could print out my script attempts and retype them here. But on the off chance... here goes. I have a text file (file_source) of terms, each line... (3 Replies)
Discussion started by: Brusimm
3 Replies
Kakasi(3pm)						User Contributed Perl Documentation					       Kakasi(3pm)

NAME
Text::Kakasi - perl frontend to kakasi SYNOPSIS
use Text::Kakasi; # functional $res = Text::Kakasi::getopt_argv('-JJ', '-c', '-w'); $str = Text::Kakasi::do_kakasi($japanese_text); # object-oriented $obj = Text::Kakasi->new('-JJ', '-c', '-w'); $str = $obj->get($japanese_text); DESCRIPTION
This module provides interface to kakasi (kanji kana simple inverter). kakasi is a set of programs and libraries which does what Japanese input methods do in reverse order. You feed Japanese and kakasi converts it to phonetic representation thereof. kakasi can also be used to tokenizing Japanese text. To find more about kakasi, see <http://kakasi.namazu.org/> . Text::Kakasi now features both functional and object-oriented APIs. functional APIs are 100% compatible with ver. 1.05. But to take advantage of "Perl 5.8 Features", you should use OOP APIs instead. See Text::Kakasi::JP for the Japanese version of this document. Functional APIs Note "Text::Kakasi::" is omitted. Text::Kakasi does not export these functions by default. You can import these function as follows; use Text::Kakasi qw/getopt_argv do_kakasi/; $err = getopt_argv($arg1, $arg2, ...) initializes kakasi with options options are the same as "kakasi" command. Here is the summery as of kakasi 2.3.4. -a[jE] -j[aE] -g[ajE] -k[ajKH] -E[aj] -K[ajkH] -H[ajkK] -J[ajkKH] -i{oldjis,newjis,dec,euc,sjis} -o{oldjis,newjis,dec,euc,sjis} -r{hepburn,kunrei} -p -s -f -c"chars" [jisyo1, jisyo2,,,] Character Sets: a: ascii j: jisroman g: graphic k: kana (j,k defined in jisx0201) E: kigou K: katakana H: hiragana J: kanji (E,K,H,J defined in jisx0208) Options: -i: input coding system -o: output coding system -r: romaji conversion system -p: list all readings (with -J option) -s: insert separate characters (with -J option) -f: furigana mode (with -J option) -c: skip chars within jukugo (with -J option: default TAB CR LF BLANK) -C: romaji Capitalize (with -Ja or -Jj option) -U: romaji Upcase (with -Ja or -Jj option) -u: call fflush() after 1 character output -w: wakatigaki mode Returns 0 on success and nonzero on failure. Unlike version 1.x where you have to start the first argument with "kakasi", you can omit that in version 2.x (adding "kakasi" does not harm so compatibility is preserved). $result_str = do_kakasi($str) apply kakasi to $str and returns result. If anything goes wrong it return "undef". close_kanwadic() closes dictionary files which are implicitly opened. This function is for backward compatibity only and you should never have to use this function today. Object-Oriented APIs As of 2.0, Text::Kakasi also offers OOP APIs. $k = Text::Kakasi->new($args ...) Constructs object. When argument is fed, it is the same as "Text::Kakasi->new->set($args ...)" $k->set($args ...) OOP interface to "getopt_argv". my $k = Text::Kakasi->new; $k->set('-w'); # Text::Kakasi::getopt_argv('-w'); Unlike "getopt_argv()" which returns the status, "set" returns the object itself so you can go like this; my $tokenized = $k->set('-w')->get($raw_japanese); To get the status of "$k->set", use "$k->error". See also "Perl 5.8 Features". $k->error returns the status of last method. $result = $k->get($raw_japanese); OOP interface to "do_kakasi". The following codes are equivalent. # Functional getopt_argv('-w'); $result = do_kakasi($raw_japanese); # OOP $k->set('-w')->get($raw_japanese); Perl 5.8 Features Perl 5.8 introduces Encode module which transcodes various encodings. This module takes advantage of this feature but to keep backward compatibility with version 1.x, This feature is enabled only when you use OOP interface (version 1.x only provided functional APIs). On Perl 5.8 and up, "-iencoding" and "-oencoding"are handled by Encode module so you can use encodings Kakasi does not suppport such as utf8. In other words, $result = $k->set(qw/-iutf8 -outf8 -w/)->get($utf8); Is analogous to: $euc = encode('eucjp' => $utf8); getopt_argv('-w'); $tmp = do_kakasi($euc); $result = decode('eucjp' => $tmp); When you specify "-outf8", "$k->get" will return the string with utf8 flag on. You can suppress this feature by setting $Text::Kakasi::HAS_ENCODE to 0 in which case this feature is not used. SEE ALSO
kakasi(1), <http://kakasi.namazu.org/>,Encode,perlunicode COPYRIGHT
(C) 1998, 1999, 2000 NOKUBI Takatsugu <knok@daionet.gr.jp> (C) 2003 Dan Kogai <dankogai@dan.co.jp> There is no warranty for this free software. Anyone can modify and/or redistribute this module under GNU GENERAL PUBLIC LICENSE. See COPYING file that is included in the archive for more details. perl v5.14.2 2003-05-26 Kakasi(3pm)
All times are GMT -4. The time now is 01:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy