Programming :: Store Executable Code In The Value Part Of A Hash?

May 28, 2010

I was reading about Ruby code blocks, but it's all a bit hazy.My questions:1. Can you store executable code in the value part of a hash (err...associative array)2. If you did, how would you call the code?3. If you executed this stored code, would it be possible when doing soto pass in an object to the code that it could use?

View 1 Replies


ADVERTISEMENT

Programming :: Perl - Store And Access An Array In A Hash Of Hashes?

Jul 7, 2010

I am in need of some syntax help. I'm trying to figure out how to store and retrieve an array out of a hash of hashes. For this example, I'm trying to access the city list for a particular state for a particular country. I understand I could do a join and split on the hash key to combine Country and State, but trying to keep things separated.The code I have gets in all the information for the Countries, and states, and gets the list of cities together, no problem. I store all the city names in an array, then make an anonymous pointer to the array for the hash, like this - $MY_CITIES{$COUNTRY}{$STATE} = [@CITIES]I believe that syntax is correct, or is it? What I'd like to do is I need to cycle through every hash to find if a city exists or not. If it exists in 3 states, then it should print 3 times. Here is the code block to search -

Code:
for $COUNTRY (@LIST_OF_COUNTRIES) {
for $STATE ( keys %MY_CITIES{$COUNTRY){$STATE} ) {

[code]...

View 4 Replies View Related

Programming :: Run A Part Of Code On Exit In A Shell Script?

May 14, 2010

How do i run a part of code on exit in a shell script?Suppose i have four echo statements like the following:

echo "Stmt 1"
echo "Stmt 2"
....some code goes here...

[code]...

View 2 Replies View Related

Ubuntu :: Make A Executable File Part Of The System Path?

Sep 1, 2010

Morning all , not sure how to put this. I have a .sh executable script I use for video encoding. I want the system to be able to see it no matter where in which folder I am. I want to be able to execute that script in terminal in any folder. How can I make it part of the system path. ? Don't know if my wording is right but I think you guys know what I mean.

View 9 Replies View Related

General :: Error Cannot Find Disk At [hash-code - Looks Like 0ace5f When Booting OpenSUSE 11.2 GNOME-LIVE (64bit)?

Jan 29, 2010

I am in the process of re-DL-ing the ISO as the checksums didn't match.

Mind you, that was with a shell extension in Win-Lose. Who knows.

Anyway:

I have the ISO (that I had previously) on a USB courtesy of UNetBootIn. All appears well until, quite quickly, I receive an error after the loading process which goes something like:

Code:
Error: cannot find disk at [hash-code - looks like 0ace5f etc etc, is about 12 char's in length.]Something very similar (but not same error I think) happened when I tried to do the same with my OpenSolaris or Fedora install. I.e., gets as far as the very beginning of the loader and then: bork.

At least one of them said "will reboot in 120 secs". Saves me the trouble!

View 2 Replies View Related

Ubuntu :: Code: /tmp/sXRap_kD.zip.part Could Not Be Saved

Dec 14, 2010

I've tried downloading xmind from their site as well as source forge and I keep getting this error message...

Code:
/tmp/sXRap_kD.zip.part could not be saved, because the source file could not be read.

Try again later, or contact the server administrator.How do I get this software and is this a problem on my end? I tried a few mirrors as well.[URL]..

View 1 Replies View Related

General :: Converting C Code Into Command Line Executable?

Sep 1, 2010

I thought this question's best category would be in the newbie sectionBasically I have a C code, (for simplicity is only prints a few lines), called printx.c that I would like to convert into a binary file so whenever I have to type "printx" in the command line it would execute the programofcourse gcc will give me a binary file if I do a "gcc printx.c", but even the output file (e.g. print.outwould have to be executed following manner./print.outI only ask, because I notice programs like mailx (which is written in C) is a binary file that could be run in this manner (at least that's what I notice on my ubuntu distro)

View 3 Replies View Related

Programming :: Custom Delimiter For Hash In Perl?

Jan 6, 2010

Can I have a custom delimiter for hash in perl?

View 4 Replies View Related

Programming :: Get Number Of Elements In A Hash Of Arrays?

Dec 10, 2008

I have something like this:

$arr_hash{'produce'}{'veggies'}[0] = Broccoli
$arr_hash{'produce'}{'veggies'}[1] = Cauliflower
$arr_hash{'produce'}{'veggies'}[2] = Carrots

[code]...

View 2 Replies View Related

Programming :: Make A Hash Of Objects In Perl?

Aug 31, 2010

I am trying to make a hash of objects in perl (long story.) I have a package containing the main hash and all the subroutines necessary to work with it. My "new" subroutine used to add an object to the hash goes like this:

Code:
$tmpdir="/tmp";
$subdir="/AutoScript";

[code]...

View 14 Replies View Related

Programming :: Sort Hash Of Hashes By Value In Perl?

Dec 1, 2010

I have a hash of hashes and I need to sort this by value and write to a javascript array file..Currently I am using the following

foreach my $key(sort { keys %{$trans{$a}} <=> keys %{$trans{$b}}} keys %transmission)
{
foreach my $role(sort {$trans{$key}{$a} cmp $trans{$key}{$b}} keys %{$trans{$key}})

[code]...

View 2 Replies View Related

Programming :: Association Lists Are Faster Than Hash Tables?

Jun 13, 2011

I'm writing an interpreter and it used simple association lists for mapping varaible names to their values. Here's the code:

Code:

#include "assoc_array.hpp"
#include <string.h>
using namespace LANG_NAMESPACE;

[code]....

I thought that I would replace it with a hash table to increase performance. Note that I decided to store linked lists in the buckets instead of the actual values, in case the hash function outputs the same index for multiple variable names:

Code:

#include "hash_table.hpp"
#include "assoc_array.hpp"
#include <string.h>

[code]....

It runs in about 0.333 seconds on my machine. Since I'm using git version control, I decided to bring back the old version that used association lists. To my amazement, it ran 3 times faster, completing in 0.116 seconds! Is my hash table implementaion really that bad, or is this a really poor benchmark (and real-world code actually will be faster using the hash table)?

View 7 Replies View Related

Programming :: Replace A Hash In A Shadow File Not Using Passwd?

Aug 5, 2010

What is the easiest way to replace a hash in a shadow file for one particular user, not using passwd, and when the current password is unknown?

View 3 Replies View Related

Programming :: Selenium Java Code Into Equivalent Php Code?

Mar 30, 2011

I need to rewrite the selenium java code into its equivalent php code.

View 5 Replies View Related

General :: Where Does ITunes Store Its Stuff - Copy Its Data Store To An External Drive

Dec 8, 2009

I have two students whose windows laptops are riddled with malware and not working properly. They want me to help them install Linux (which we use in school), but they are concerned about their iTunes.

Having avoided iPods as "defective by design", I know nothing about iTunes whatsoever. However I remember reading about DRM locking and such problems that have me concerned that I won't be able to do it.

Where does iTunes store its stuff?

Can I copy its data store to an external drive, and then into a linux home?

Then will it work on wine, or can another manager (rhythmbox etc) access the itunes data?

Alternatively, if I partition the drive and install linux, can rythmbox/wine/something access itunes data on the win partition?

Supposing they are buying music through iTunes, what will happen to that account?

Finally, one of them has an iphone. Does that work with linux?

Ironic that an apple application is blocking migration away from windows.

View 9 Replies View Related

Programming :: Store The Results In An Array?

Apr 13, 2010

i have a loop which produces new value everytime it runs. i want to store the results in an array. how can i do dat??

loop is like:
a=0
declare v
while ((....))
do
v[$a]="$r"
let a=a+1
done

while doing this it is not treating v as array but as variable and it is overriding the value and old value is lost..i am using bash shell version 3.00.15

View 5 Replies View Related

Programming :: Store A Command In A Variable?

Jan 28, 2010

Code:

ls Again the command can be stored in a variable and then executed. Like

Code:

var=ls
&var

The above two codes are the same. The problem occurs when we try to pipeline it. Consider the following problem:

Code:

ls | grep *

works fine...but when we try to store it in a variable and run the command there is an error.

Code:

var="ls|grep *"
$var

how to store this kind of commands in a variable?

View 11 Replies View Related

Programming :: Store H.264 File On Avi Container?

Mar 4, 2010

i m trying to store h.264 in avi container using ffmpeg....is it possible using ffmpeg.i m using v4l to capture a image and compressed in to h.264, how i can store it in avi container,any programming example,header format for avi container,and what other information required to store in a container.

View 14 Replies View Related

Programming :: Store A Packet In Buffer?

May 19, 2010

writing a code in C program for debugging error and sendingror messagein routingprotocols. please answer with code

View 2 Replies View Related

Programming :: Cutting Last Part Of URL?

Dec 1, 2010

website.com/john/doe/index.htmlI need to cut that to say:website.com/john/doe/I am getting really close using sed, but I just can't get the syntax quite right.

View 2 Replies View Related

Programming :: Store The Data In Program In A Map Of Priority_queues?

Jul 30, 2011

I am trying to store the data in my program in a map of priority_queues an I am having a bit of trouble doing it. basically I am storing activities (ie watching tv, eating dinner, playing ping-pong, etc) and I want these event grouped by the day that they happened on.
my first thought was to use a multimap where the key is the date, and the value is the activity, however I would like to keep the activities in a specific order. I have tried to find the proper syntax for this but have frustratingly come up empty. Even google provided little assistance.

View 9 Replies View Related

Programming :: Cannot Capture - No At End Of File Store It And Print It Using Sed And Awk

Nov 25, 2008

How to write a shell script the would search for a phone no using at the end text file using sed or awk and store it in a varaible or print it.

The text file is in this form

The first line may take any form but the last line will always be Firstname Lastname:KEN:+254456789

I would like to seach for the Phone and store it in a variable and print it.

The phone no will alway be preceeded by ":+"

View 10 Replies View Related

Programming :: Store Pictures In A MySQL Database In PHP

Apr 29, 2010

How do I do this? I wish to store the pictures via a "Browse" button on the webpage, and later display them on a particular page on the site.

View 2 Replies View Related

Programming :: Store Output Of Command With Pipes?

Jan 20, 2011

I need to find one RUNNING word in latest created logs.
and as soon as i will get RUNNING WORD , i have to execute another Unix Command.

I wrote following script code...

View 3 Replies View Related

Programming :: How To Store Video Files In NAS Server

Apr 13, 2009

I am working in DM355 board. CPU is armv5t. I am asked to record the video thats coming from camera using rtsp. I can record the video file in avi format on /opt directory on dm355 target board. Now I have to store this avi file in nas server. My nas server ip is 192.168.1.250. Linux pc,DM355 target board and NAS server on same network. How to write the program to store avi files from DM355 to NAS server.

View 2 Replies View Related

Programming :: Store 2 , 4 Tree In A Single Array?

Oct 30, 2010

I am working on an structure program and i have to represent a 2,4 tree in a class in Java using single int array and make the insert and delete functions .

View 1 Replies View Related

Programming :: Store Data Before The System Hibernates?

Mar 24, 2011

I have a requirment where I have to store some data before the system goes to hibernate.
How the kernel intimates to the application when it goes to hibernate. Is there any event or a signal that kernel posts to all applications?

View 4 Replies View Related

Programming :: Unable To Pull And Store Certificates?

Dec 21, 2009

I have to pull certificate from multiple computers which are on network and store it in a single fie or each file belong to a particular computer.I am using certutil -store to import the certificate.

View 4 Replies View Related

Programming :: Read And Store Key In A Perl Script?

Sep 22, 2010

I have a webpage (jps) that produce a key. How i read and store this key in a perl script.

View 1 Replies View Related

Programming :: Hashing The Components Of An Tcp Session To Assign/locate The Session In A Hash Table Bucket?

Nov 10, 2010

I have a very bad attempt at hashing the components of an tcp session to assign/locate the session in a hash table bucket. I am pretty sure that it has a very high collision rate and when there are a very large number of tcp sessions my application is having to search a long linked list to find the session within the bucket.

All the hashing functions I have found take a single string input where I need to input several integers and hash them into a single result. My guess is that any real hashing function is going to produce better results than what I am currently doing.

[Code]...

View 2 Replies View Related







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