Perl to parse text file [closed] - perl

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
here Im writing a perl program which to parse a file, it contians multiple line, in each line it has three fields: name, size in bytes and user.
any sample code to validates the file? for example, if I want to check if a given file through argument that it is validate file?

If this is a CSV file use a CSV parser
For eg.
http://perlmeme.org/tutorials/parsing_csv.html

Related

Importing data from file in MATLAB [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I want to import all data from ascii file exclude the first row that is a description. I can import all data correctly if that line missing. I've used imporData.
Edit:
I've resolved it just moving the file pointer ahead by one.
This is the code
FH = fopen(f_old,'rb');
firstRowString = fgetl(FH);
use
A = importdata(filename,delimiterIn,headerlinesIn)
This can load data from an ASCII file reading numeric data starting from line headerlinesIn+1 where delimiterIn is the column separator character, specified as a string. The default character is interpreted from the file. Use '\t' for tab.
http://www.mathworks.co.uk/help/matlab/ref/importdata.html#inputarg_headerlinesIn

Using Scala's worksheet, clarification needed [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
The following snippet compiles and runs fine
When using as part of worksheet, i see error
Why is this please?
It's probably just a bug/missing feature.
By the way, you could write joiner like the following code to get the same behaviour, and it also will avoid the worksheet problem.
def joiner(strings: List[String], separator: String = " ") =
strings.mkString(separator)

Coding of '\xa1' in Perl [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I want to process a txt file using perl. I have succeeded in using this perl code to process wikipedia txt file before, so it is correct. But when I run the perl code, there appears an error:
utf8 "\xA1" does not map to Unicode at xxx
I check the txt file. There is \xA1 characters in it. I tried to remove those "\xA1" with RegEx s/(\xa1)+//g; but failed.
So what is the problem and how can I solve this?
At last, I revise my code. I use
binmode( IN, ':stdio' );
instead of
binmode( IN, ':utf8' );
and it works.

creating hash table using perl [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I am trying to create hash table using perl. I have XML file as input and it contains information about diognostic tests and test description. Test number as a key and Test description as a value to the key. Then test number and string have the key -value relation.Help me to write perl script that stores description in one string and create hash table.please can help me because i am begginer to perl and i am reading but i am not able to implement.
<DATA>
<number>1</number>
<age>24</age>
<place>india</place>
<description></description>
</data>
That's pretty much what XML::Simple does. So just use that.

How can I use a Perl script to create the plain text file [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
How can use a Perl script to create the plain text file. Perl should generate (random 16 bit hex) input data.
If you are new to Perl take a look at http://learn.perl.org
Check out Open, hex, and sprintf.
open a file handle, then print to it.
In addition to the other advice, to generate a random value, use Perl's rand function.
The Perl documentation can also be queried at your command prompt. For example, to access the FAQ:
perldoc -q random