Programming :: Converting MB/TB To GB In Perl?

Jan 30, 2010

I am taking an input from the user for free and Used capacity in a disk. I wish to convert Input entered in MBTB to GB and this is how i am doing it.

Code:

<some code>
print "Enter Total disk space";
$tot = <STDIN>;
convert($tot);

[code]...

how do i pass the value of conv[0] after conversion back to $tot or $use such that they contain only value which is in GB?

View 3 Replies


ADVERTISEMENT

Programming :: Converting Perl Script To Python?

Jul 21, 2011

#!/usr/bin/perl
print "Input File Name: ";
$filename = <>;
$filename =~ s/s+$//;mkdir "$filename";

[code]....

View 3 Replies View Related

Debian :: Perl Script - Converting Unicode To ASCII?

May 7, 2010

I'm trying to write a Perl script that will convert text to ASCII. I'm particularly interested in converting files created with MS Windows, so I used Notepad to create a few test files.

I have had some success with the following script:
[[ Script Deleted -- see subsequent posts ]]

After coming back /home/ to Debian, I used file to examine the file types:
$ file ansi.txt unicode_big-endian.txt unicode.txt utf8.txt
ansi.txt: ASCII text, with CRLF line terminators
unicode_big-endian.txt: Big-endian UTF-16 Unicode character data, with CRLF line terminators
unicode.txt: Little-endian UTF-16 Unicode character data, with CRLF, CR line terminators
utf8.txt: UTF-8 Unicode (with BOM) text, with CRLF line terminators

After running:
$ uni2ascii.pl -i ansi.txt -c ASCII -o new_ansi.txt
$ uni2ascii.pl -i unicode_big-endian.txt -c utf16 -o new_unicode_big-endian.txt
$ uni2ascii.pl -i unicode.txt -c utf16 -o new_unicode.txt
$ uni2ascii.pl -i utf8.txt -c utf8 -o new_utf8.txt

Everything appears good:
$ file new_ansi.txt new_unicode_big-endian.txt new_unicode.txt new_utf8.txt
new_ansi.txt: ASCII text
new_unicode_big-endian.txt: ASCII text
new_unicode.txt: ASCII text
new_utf8.txt: ASCII text

But the "little-endian file" does not convert properly:
$ md5sum new_ansi.txt new_unicode_big-endian.txt new_unicode.txt new_utf8.txt
c4def7932bc151b9e786b6ca1299162c new_ansi.txt
c4def7932bc151b9e786b6ca1299162c new_unicode_big-endian.txt
5b62a013dced4f2c2c0af45ea6388c1e new_unicode.txt
c4def7932bc151b9e786b6ca1299162c new_utf8.txt

When I use cat to print the new_unicode.txt file in an Emacs terminal, a ^@ appears on the last (empty) line. When I open the new_unicode.txt with KWrite, a warning message tells me that the file is a "binary" and "saving it will result in a corrupt file."

View 14 Replies View Related

Programming :: Error When Converting C To C++?

Jan 22, 2011

I'm working on a project where I am converting a C file to C++. I have worked out 99% of the errors but there is still one lingering one that I cant seem to figure out. I get the following error when compiling with g++

Code:
mscp.cpp:749: error: invalid conversion from const void* to move
mscp.cpp:750: error: invalid conversion from const void* to move

[code]...

View 5 Replies View Related

Programming :: Converting ODT File To PDF Using PHP

Apr 3, 2011

My problem is to convert an odt file to pdf using php. I wrote an article in odt and I'd want to download it in pdf from my site. I know "fpdf", but it doesn't convert from odt. Someone says to convert from odt to html then to pdf... but some others says NO! Well, do you know a way? (may be also different from odt to pdf, e.g. from latex to pdf).

View 12 Replies View Related

Programming :: Converting C Code To Assembly

May 17, 2011

I've been converting some C code to assembly for my homework; it was going well but I'm having trouble with a for loop for hours. I could not understand where is the problem and decided to ask. I'm posting the part where I'm having trouble of my C-code and assembly-code; every other part of codes act same and the variable values are same. I'm waiting this two codes to act same, but they don't.

Code:
mov ebx, [result]
mov eax, [i]
mov ecx, [ebx+eax]
mov [j], ecx
mov [ebx+eax], byte '.'

_loop:
mov ebx, [result]
mov eax, [i]
inc eax
mov cl, [ebx+eax]
cmp cl, 'Z'
je _continue

mov ebx,[result]
mov eax,[i]
inc eax
mov ecx, [ebx+eax]
mov [k], ecx
mov ebx, [result]
mov eax, [i]
inc eax
mov ecx, [j]
mov [ebx+eax], ecx
mov ecx, [k]
mov [j], ecx
inc dword [i]
jmp _loop

_continue:
Code:
j=result[i];
result[i]='.';
for(;result[i+1]!='Z';i++){
k=result[i+1];
result[i+1]=j;
j=k;
}

View 10 Replies View Related

Programming :: Converting Bash Script Into PHP?

Jul 5, 2011

I wrote the following as our developers won't do it for us! The rest of my programming is in PHP, any ideas on how I can get this into php?I'm in the middle of writing a reminder system which involves importing the customer data and sending out reminder emails.All the script below does is download the current report $FILEIN, compare field number 6 ($DATA) with the date($DATE), if there is a match, it checks each line in the prescription_skus.csv to see if there is a match with field number 1 in the current report. It then outputs the entire line to $FILEOUT

Code:
TODAY=`date +"%Y-%m-%d"`
FILEIN="export-"$TODAY".csv"

[code]...

View 7 Replies View Related

Programming :: GMP And Converting Mpz_t To Char?

Jul 16, 2011

I'm writing the Diffie-Hellman key exchange system using GMP to handle big integers. For the most part, everything works. I can convert the string to mpz_t, set up the keys and everything, and encrypt it fine. Its the decrypting I'm having issues with. What I'm using is mpz_xor() for both. To encrypt I'm doing mpz_xor(buffer, mpz_of_text, secret_key), and to decrypt I'm doing mpz_xor(buffer, mpz_of_cipher, secret_key).

For one character, it semi-works...it'll decrypt it fine, but it'll return it as it's ASCII value (i.e.: if I encrypt "A", it'll decrypt it as 65). Which, I can easily just do sprintf(decrypted_buffer, "%c", 65) for example and be fine. But, when I'm sending text bigger than one character, the encryption for AB gives me something like 1061043 after running the decrypting xor on it.

Has anyone ever done this before or can point me in some directions? Perhaps other algorithms to try? I know XOR isn't the most secure encryption method to use, but at the time I wasn't sure what else to use. I'm really just having a hard time trying to convert a mpz_t to a character string. I've looked at mpz_get_str() and it works before running encryption (i.e.: using mpz_set_str() to create a mpz of a string, then calling mpz_get_str() to change it back). Maybe my XOR method is wrong? Here's the code I'm using:

Code:

/**
* str2mpz()
* b The current buffer of text to convert [in]
* m The mpz_t variable to store converted text [out]

[code]....

View 9 Replies View Related

Programming :: Converting C Code To C++ Causes An Type Error?

Mar 25, 2010

I'm a C / assembler programmer so am not use to C++, which I need to use. Basically I'm using my own versions of memcpy, but for long and int rather than char. It's for fast graphics. So I have a char array which I copy to another array. But I copy as either longs or ints, much faster. for example

Code:
void * fastmemcpysprite (void *destaddr, void const *srcaddr, size_t len)
{

[code]...

View 3 Replies View Related

Programming :: Converting Vector Of Bytes To String C++

Mar 4, 2011

I have a vector of octets that needs to be converted to a std string. I'm currently doing it this way:

Code:
stringstream ss;
for (unsigned int i=0; i < data.size(); i++
{
ss << data[i];
}
string s_data = ss.str();

This works, but is there any better way to do it?

View 2 Replies View Related

Programming :: Socket Programming In Module Perl

Jul 21, 2010

Where is the perl module for programming with sockets?

View 4 Replies View Related

Programming :: Converting String Sequence Of 1's And 0's Into Their Hexa Sequences

Apr 27, 2011

I have to write a code that converts a sequence of 1's and 0's(block) into their equivalent hexa number and copying to another array(byte). but this sequence is not always of length 8 and you are required to send strlen(sequence)%8 bits back into the string. So i've written down this code and it works well with the sample input but fails in the real program.

Code:
int Convert_encode( char * block,unsigned char * byte)
{
int len,iter,i,j,k,sum;
char * temp=(char *)malloc(4*sizeof(char));
len=strlen(block)/8;

[code]....

View 7 Replies View Related

Programming :: Converting YYYYMMDD To Date In Bash Script?

Aug 2, 2010

I need to convert strings in the format YYYYMMDD to dates so I can perform date arithmetic.

View 4 Replies View Related

Programming :: Converting Date Format In A Comma Separated Field?

Apr 9, 2010

I am in the process of learning some scripting, however I am running into a roadblock in specifying a certain time format in the array. Ideally I would like to use Here are the lines of text that I am interrogating:

1123,3/25/2010,00:14 Thu,33229
1124,3/26/2010,13:30 Fri,33230
1125,3/27/2010,04:49 Sat,33231

[code]...

View 2 Replies View Related

Programming :: Converting Epoch In A File Name To Human Readable Date/time?

May 5, 2011

I have log files that everyday are downloaded from my webserver in the format: Code: samplesite.com.xxxxxxxxxxx.gz xxxxxxxxxx is a 10 digit epoch time. I am trying to figure out a way in batch to:

1. find all of exisiting files containing the pattern (after the first run it will only be one a day)
2. Isolate the epoch string
3. convert the epoch string to human readable date/time
4. rename the original file as samplesite.com.mmddYYYY.gz

View 2 Replies View Related

Programming :: Cannot Install Perl / Tk

May 9, 2010

I just downloaded Tk-804.028 and try to install it (according to the README.linux) but I get:

> perl Makefile.PL
/opt/ActivePerl-5.10/bin/perl-static is installed in /opt/ActivePerl-5.10/lib okay
PPM for perl5.010001
Test Compiling config/perlrx.c
Test Compiling config/pmop.c
Test Compiling config/pregcomp2.c

[code]...

View 5 Replies View Related

Programming :: Perl Tutorial To Use?

May 18, 2011

Any recommendations on what Perl tutorial to use?

View 1 Replies View Related

Programming :: How To Get Perl Qt4 Working

Jul 24, 2010

I really would like Perl Qt4 bindings. The best I could find is this:[URL]The problem is that the sources would not compile, and the RPMs are for 32-bit machines.Is there really no such thing as good Perl Qt4 bindings?

View 8 Replies View Related

Programming :: MP3 - Tag And Perl Script

Mar 27, 2011

I am a newbie on linux and just searching everything about perl scripting and modules nearly 3-4 days. I need a perl script but one of not easy to find on searching google. Okay now I need a perl script which create or recreate (edit) id3 tags (artist, comment, album, year, cover) of mp3 files stored on my linux centos server. I installed MP3::Tag version 1.13 pearl module to my server. I Searched tutorials about how to use it, finally I get through reading id3 tag of mp3 file but not achieve to modify it or create a new id3tag.

These are the details:
I have a mp3 file called 1.mp3 this script will process that '1.mp3' file read its id3tag if there is one, than modify or create id3tag for it by my fix artist name for example:
'1.mp3' files id3 tag details are like this
Artist: Dj xx
Year:2010
Title:yyyyy
Comment:eerwer
Cover: x.jpg

Now via this perl script which uses MP3::TAG I will change it's
artist as YYY
Title:ttt
Comment:cool
Cover:t.jpg
these are gonna be my fixed values. I mean all '1.mp3' file will have same artist based on script value.

The reason of this script is I will share Dj podcasts on my server and Dj's would have upload their mp3's which has got different id3 tags and cover pics. etc. I want to create more organized podcasts of them by the way I would trigger this perl script via Cronjob.

View 14 Replies View Related

Programming :: How To Generate MD5 / Sha-1 With Perl

Mar 31, 2010

How can I generate a md5 or sha-1 code with perl?

View 2 Replies View Related

Programming :: Perl - Interpreter For Fib Numbers

Apr 1, 2010

As some of you know that I am new to this forum. I have another problem that I got stuck on. I have this file called "Fib.rbb" and my instructor told us to write an interpreter program by using Fib.rbb.

"You are to write an interpreter in Perl for Rongs Basic Basic (RBB) as explained in class. The BNF description for RBB and a test file called Fib.rbb are part of the RBB.zip file which is available in the Course Documents folder on blackboard. If you call your interpreter myIntp.pl, you would execute the program via perl myIntp.pl Fib.rbb

Code: Print "A few Fibonacci numbers:"

View 3 Replies View Related

Programming :: Unable To Find The Perl

Mar 9, 2011

Just installed Fedora 14. I wanted to try "Hello World" with perl. But where is it?

Code: [user]@user bin]$ ls

View 1 Replies View Related

Programming :: Perl From USB Pen To Run On Both Linux And Windows

May 23, 2011

Im somewhat new at perl and was wondering if there was a way to run a perl script or tool made from perl, from a USB pen that would work both on Linux and on Windows?

View 1 Replies View Related

Programming :: 404 Not Found With Perl/cgi Script

Jan 16, 2010

I writed my home.html page in /var/www with following form:

Quote:

<form action="/cgi-bin/login.cgi" method="get" class="form-font">
<label>Already you registered?</label><br/><hr/><br/>
<fieldset><br/>
<legend>Insert your account</legend>
Email: <input type="text" name="email"/><br/><br/>

[Code].....

View 2 Replies View Related

Programming :: Add Folder To Perl Path?

Jun 8, 2010

I'm the server guy which is why I don't know this, but were staging a new webserver and we use some custom perl scripts and as were moving the site over for testing, apache is blowing a perl error;Can't locate web.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.10.0 /usr/local/share/perl/5.10.0 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl .) at /home/mcp/htdocs/cgi-bin/newgraph.gif line 11.,Now I can copy that file local, but there are a bunch of things, so the question is how do you globally add a folder to the perl search path

View 1 Replies View Related

Programming :: Adding Mod-Perl And Using Apache ASP?

Sep 16, 2010

I have a debian lenny machine that I am trying to add mod_perl to and use apache asp on. I have had a range of failures on it. Is ther a way I can build apache2 with mod_perl in it? Instead of separate. Apache2 is built with some modules built in by default, how can I make mod_perl one of them?

View 1 Replies View Related

Programming :: Comparing Two Files In Perl ?

Oct 9, 2009

I would like to ask opinion from perl experts.

I want to compare 2 files and show the differences in a text file.

For example, if i open File A an B in notepad

File A:

File B:

Quote:

line3 is missing in File B

So if I did a File compare (line by line), the differences will be in line3, line4, line5, line 6.

But I dont want it to be like that.

I want it to be like this

Quote:

Can Text:: Diff able to perform the work.

View 1 Replies View Related

Programming :: Date Listing In Perl?

Jun 1, 2010

Using given program , i am able to print current date but is is possible to print last n no. of date. For example i want to print last three date staring from today. so o/p should be like

2010-06-02
2010-06-01
2010-05-31
Code:
my $myTimeStamp = "";
sub _timestamp
{

[Code]...

View 1 Replies View Related

Programming :: Download Files Using Perl?

Jul 24, 2010

How do I download a file to a specified location on disk in Perl?I tried doing a few web searches but suprisingly couldn't find anything.

View 4 Replies View Related

Programming :: Exception Handling In Perl?

May 12, 2010

I writed Quote:

#!/usr/bin/perl -w
use Error qw(:try);
try {

[code]....

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved