in reply to Concatenation of scaler reference
Either I'm missing something important... or you're going waaaay out of your way to achieve this:
which prints "Scan, $MaxScanId: 45" But since the reasonable suspicion is the first alternative above, could you tell us where I'm going wrong. The intent of your reference to "a reference" just isn't working its way to the space between my ears, since I can't see a reason for using a reference to achieve what you say you were "looking for."#!/usr/bin/env perl use Modern::Perl; # 943467 my $MaxScanId = 45; my $a = "Scan"; print "$a, \$MaxScanId: $MaxScanId";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Concatenation of scaler reference
by Largins (Acolyte) on Dec 14, 2011 at 05:02 UTC | |
well, let me see if I can clarify what I am trying to do:
Once these values are loaded, the remainder of the XML is parsed and the values
Hope this clarifies the purpose of my madness. | [reply] [d/l] [select] |
by cdarke (Prior) on Dec 14, 2011 at 08:40 UTC | |
You can create variable names dynamically in Perl, but it is very rairly justified. Off topic, but I notice that you are using eq for comparing numerics. eq is for string comparisons, better to use == instead. BTW, your supplied code will not compile, you use strict (which is good) but many of your variables are not declared using my. | [reply] [d/l] [select] |
by Marshall (Canon) on Dec 14, 2011 at 13:05 UTC | |
The DB will keep track of the primary key which is an integer and will auto increment it so that every "name" will have a unique id number. Does that help? Update: I not quite sure what this "box" this is. I could be that just one table will be all that you need.
For some DB's, like SQLite, the varchar(X), the X is just a "hint" and the actual data can be much larger. It is ok for name to appear more than once because it is not the primary key. There is another step to index the database according to more than the primary key - so perhaps that you can search for "name" efficiently. I don't think that you are "stupid"..on the contrary for 30 days you have gotten quite far along! | [reply] [d/l] [select] |
by Largins (Acolyte) on Dec 14, 2011 at 13:30 UTC | |
Thank you for the very useful pointers. They will be used | [reply] |
by Largins (Acolyte) on Dec 15, 2011 at 16:26 UTC | |
I went ahead and made changes based on your suggestions. Here is what I now have. Box, bookleafplate and other tables not seen need to be separat tables for normalization purposes, for example, a (book in this case) may have come from a box labeled 'Skowhegan Me No 345' and may or may not have a bookleafplate ( fronts piece image ). I have one table which contains all of the unique information, and then id's to tables where duplication may occur, thus the need for the last_insert_id call. I spent many years using Sybase, Oracle and other relational databases, but not within perl until now. I like SQLite because all I have to worry about is one file which makes for easy (physical) portability. I did use perl for a while shortly after it emerged in the 80's while working on a CAD/CAM software project, but only now have become serious about it. | [reply] [d/l] |