05-03-2011
Perl Help - Assigning variables to text file contents
I am looking to create a perl script which will take numbers from a simple text file, convert them from decimal to hex, and then rewrite those values in the file or create a new file with the hex numbers(whichever's easier).
My text document for example would be something as simple as
1312
4646
4231
3566
1341
2331
I know how to use sprintf, but I don't know how to make the function convert an entire file. I can only get it to convert one number that I input by myself. Does anyone know how to do this? Any help would be appreciated
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
okay, down below is the script. i have 32 words put into 32 variables and i want perl to print all those 32 variables into one text document, each word under another in the text file. the text files called times.txt Sorry about the length of the script
print " VToshiba ... (2 Replies)
Discussion started by: perleo
2 Replies
2. Shell Programming and Scripting
Hi,
I'm trying to assign the permissions, owner and group of a file to seperate variables, but using
ls -l filename | awk '{print $1 "\t" $3 "\t" $4}'
gives the owner as tom.ja instead of tom.james
Is there any way to expand it so i get the full name, or is there an easier way to get them... (5 Replies)
Discussion started by: olimiles
5 Replies
3. UNIX for Dummies Questions & Answers
Hi,
I need to place a number located in a text file in a variable so I can perform if/then comparison. How would I go about doing this? Using A=awk '{print $2}' maintenance_date.tmp does not seem to work.
Thanks (1 Reply)
Discussion started by: mojoman
1 Replies
4. Shell Programming and Scripting
I have a txt file
output.txt
Freq = 1900
L = 159I want to assign the values to a variable so that i can further use it in some other script.
like
F=1900
Len=159
etc
i tried doing something with awk but dosent work
F=$(awk 'BEGIN {}/Freq/ {split ($2,a);depth=a};printf "%d\t,... (2 Replies)
Discussion started by: shashi792
2 Replies
5. UNIX for Dummies Questions & Answers
Okay, I've made threads on extracting fields and comparing strings in separate files in .csv's. I've written the following code with intentions of learning more.
I just want this one question answered: How can I assign fields from a file(comma separated) to variables?
My goal is to check... (0 Replies)
Discussion started by: chickeneaterguy
0 Replies
6. Shell Programming and Scripting
Hi! This might be a simple thing, but I'm struggling to assign values to variables from the file.
I've the following values stored in the file.. It consists of only two rows..
10
20
I want to assign the first row value to variable "n1" and the second row value to variable "n2"..
That is ... (3 Replies)
Discussion started by: abk07
3 Replies
7. Shell Programming and Scripting
Hi,
I need to read two values,startdate and enddate from a param file and then write this value to another param file(global) under a specific workflow name.Here in global param file there is may workflow names, hence we need to check for the right one and then add the data below it.
Any... (5 Replies)
Discussion started by: angel12345
5 Replies
8. Shell Programming and Scripting
I have a file that has four values on each line and I'd like to give each column a variable name and then use those values in each step of a loop. In bash, I believe you could use a while loop to do this or possibly a cat command, but I am super new to programming and I'm having trouble decoding... (2 Replies)
Discussion started by: ccorder22
2 Replies
9. Shell Programming and Scripting
I wrote a simply perl that searched a file for a particualr value and if it found it, rite it and the next three lines to a file. Now I have been asked to check those next three lines for a different value and only write those lines if it finds the second value.
I was thinking the best way to... (1 Reply)
Discussion started by: billprice13
1 Replies
10. Shell Programming and Scripting
So first: Sorry if the title is confusing...
I have a script I'm writing with a file with several names in it (some other info - but it's not really pertinent...) - I want to be allow the user to delete certain records, but I ran into a problem I'm not sure how to go about fixing.
If I were... (6 Replies)
Discussion started by: sabster
6 Replies
LEARN ABOUT DEBIAN
graphics::color::rgb
Graphics::Color::RGB(3pm) User Contributed Perl Documentation Graphics::Color::RGB(3pm)
NAME
Graphics::Color::RGB - RGB color model
VERSION
version 0.29
SYNOPSIS
use Graphics::Color::RGB;
my $color = Graphics::Color::RGB->new({
red => 1,
blue => .31,
green => .25,
});
DESCRIPTION
Graphics::Color::RGB represents a Color in the sRGB color space. Individual color channels are expressed as decimal values from 0 to 1, 0
being a lack of that color (or opaque in the case of alpha) and 1 being full color (or transparent in the case of alpha). If no options
are provided then new instance of RGB are opaque white, (that is equivalent to red => 1, green => 1, blue => 1, alpha => 1).
Convenience methods are supplied to convert to various string values.
ATTRIBUTES
red
r
Set/Get the red component of this Color. Aliased to 'r' as well.
green
g
Set/Get the green component of this Color. Aliased to 'g' as well.
blue
b
Set/Get the blue component of this Color. Aliased to 'b' as well.
alpha
a
Set/Get the alpha component of this Color. Aliased to 'a' as well.
name
Get the name of this color. Only valid if the color was created by name.
METHODS
as_string
Get a string version of this Color in the form of RED,GREEN,BLUE,ALPHA
as_integer_string
Return an integer formatted value for this color. This format is suitable for CSS RGBA values.
as_css_hex
Return a hex formatted value with a prepended '#' for use in CSS and HTML.
as_hex_string ( [$prepend] )
Return a hex formatted value for this color. The output ignores the alpha channel because, per the W3C, there is no hexadecimal notiation
for an RGBA value. Optionally allows you to include a string that will be prepended. This is a common way to add the "#".
as_percent_string
Return a percent formatted value for this color. This format is suitable for CSS RGBA values.
as_array
Get the RGB values as an array.
as_array_with_alpha
Get the RGBA values as an array
equal_to
Compares this color to the provided one. Returns 1 if true, else 0;
not_equal_to
The opposite of equal_to.
from_color_library ($color_id)
Attempts to retrieve the specified color-id using Color::Library. The result is then converted into a Graphics::Color::RGB object.
from_hex_string($hex)
Attempts to create a Graphics::Color::RGB object from a hex string. Works with or without the leading # and with either 3 or 6 character
hex strings.
to_hsl
Creates this RGB color in HSL space. Returns a Graphics::Color::HSL object.
to_hsv
Creates this RGB color in HSV space. Returns a Graphics::Color::HSV object.
AUTHOR
Cory G Watson <gphat@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Cold Hard Code, LLC.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
perl v5.12.4 2011-08-11 Graphics::Color::RGB(3pm)