using perl references from subroutine

2008-08-18 Thread Noah
Hi there, I have a routine returning a perl reference and I am trying to figure out how to properly use the hash tables in the main section of my perl proggie. --- from the main program my $templateConfiguation = &readConfigTemplate($templateConfigFilename, $sortedTemplateConfigFilename);

Re: code references - how to

2008-06-11 Thread Dermot
2008/6/11 Rob Dixon <[EMAIL PROTECTED]>: > Dermot wrote: >> Hi All, ..snip >> So how do you create a code reference in this context, should I create >> a code reference or use something else and what should I be test the >> hash values for? >> Thanx in advance. >> Dp. >> >> >> >> #!/usr/bin/perl

Re: code references - how to

2008-06-10 Thread Rob Dixon
Dermot wrote: > Hi All, > > I was have to create a script to search and find files. The files will > end in 'a.txt', 'b.txt', 'c.txt', so a record could have 123a.txt, > 123b.txt, 123c.txt. > > There may be lots of ways to achieve my goal but I got curious about > how to create a structure that,

Re: code references - how to

2008-06-10 Thread Jenda Krynicky
;; > foreach my $l (qw/a b c j/) { > if ($_->{$l}) { You never called the referenced subroutine. To do that you have to use if ($_->{$l}->()) { or if (&{$_->{$l}}) { The $_->{$l} is the reference and references are always true. Jenda = [EMAIL PR

Re: code references - how to

2008-06-10 Thread John W. Krahn
Dermot wrote: Hi All, Hello, I was have to create a script to search and find files. The files will end in 'a.txt', 'b.txt', 'c.txt', so a record could have 123a.txt, 123b.txt, 123c.txt. There may be lots of ways to achieve my goal but I got curious about how to create a structure that, for

code references - how to

2008-06-10 Thread Dermot
Hi All, I was have to create a script to search and find files. The files will end in 'a.txt', 'b.txt', 'c.txt', so a record could have 123a.txt, 123b.txt, 123c.txt. There may be lots of ways to achieve my goal but I got curious about how to create a structure that, for each record would store th

RE: references to complex data structures

2008-01-15 Thread Kevin Viel
> -Original Message- > From: Rob Dixon [mailto:[EMAIL PROTECTED] > Sent: Monday, January 14, 2008 8:59 PM > To: beginners@perl.org > Cc: Kevin Viel > Subject: Re: references to complex data structures > > Kevin Viel wrote: > > Consider the following anony

Re: references to complex data structures

2008-01-14 Thread Rob Dixon
ter array is either ${$a}[0] (which can be written $$a[0] without ambiguity) or $a->[0] These are references to the first inner array, which can also be indexed in either way. So we have four ways of reaching the first element of the first inner array: ${${$a}[0]}[0] ${$a}[0]->

Re: references to complex data structures

2008-01-14 Thread Gunnar Hjalmarsson
it: print "${$a}[ 0 ][ 0 ]\n" ; Should I not need two pairs of bracers? $a is a reference to the anonymous array. The elements of the anonymous arrays are references to anonymous arrays, correct? The following seems to achieve this result: print "${${$a}[ 0 ]}[ 0 ]\n" ; W

references to complex data structures

2008-01-14 Thread Kevin Viel
$a}[ 0 ][ 0 ]\n" ; Should I not need two pairs of bracers? $a is a reference to the anonymous array. The elements of the anonymous arrays are references to anonymous arrays, correct? The following seems to achieve this result: print "${${$a}[ 0 ]}[ 0 ]\n" ; Is the outmost pair o

Re: printing elements of an arrays of references

2007-10-18 Thread Paul Lalli
x], "\n"; > > > > } > } To dereference a reference, you enclose the reference in { } and prepend the appropriate sigil ($ for scalar, @ for array, % for hash) for my $heading (@{$AoA[0]}) { print "$heading\t"; } print "\n"; or more simply print join(&qu

Re: printing elements of an arrays of references

2007-10-18 Thread Chas. Owens
On 10/18/07, Pedro Soto <[EMAIL PROTECTED]> wrote: > Dear all, > I am trying to make a matrix out of a file (row-columns) using perl. In > particular I would like to print the first row of an array of arrays which > contains the headings of the file. > I tried to do it but I can't print it. If used

Re: printing elements of an arrays of references

2007-10-18 Thread Matthew Whipple
Pedro Soto wrote: > Dear all, > I am trying to make a matrix out of a file (row-columns) using perl. In > particular I would like to print the first row of an array of arrays which > contains the headings of the file. > I tried to do it but I can't print it. If used $AoA[0], I get the reference > t

printing elements of an arrays of references

2007-10-18 Thread Pedro Soto
Dear all, I am trying to make a matrix out of a file (row-columns) using perl. In particular I would like to print the first row of an array of arrays which contains the headings of the file. I tried to do it but I can't print it. If used $AoA[0], I get the reference to the array.How can I deferenc

Re: subroutine references

2007-08-27 Thread Jenda Krynicky
From: "Mr. Shawn H. Corey" <[EMAIL PROTECTED]> > Dr.Ruud wrote: > >> Why do people who write these books have exercises of little > >> practical value? > > > > An exercise needs to be educational. > > I have worked in programming for 25 years and during that time I have > never use a closure an

Re: subroutine references

2007-08-27 Thread Jenda Krynicky
} > }, > sub { return @found_items } > ) > } If you do it this way there is no point in returning the subroutine references in the first place. You are using global variables here (even though you declare them with my). You can'

Re: subroutine references

2007-08-27 Thread Peter Scott
On Sun, 26 Aug 2007 13:04:48 -0400, Mr. Shawn H. Corey wrote: > I have worked in programming for 25 years and during that time I have > never use a closure and have never seen one used. Boggle. I don't think any program I write these days doesn't have one. They're the most convenient way of re

Re: subroutine references

2007-08-26 Thread Chas Owens
On 8/26/07, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote: > Dr.Ruud wrote: > >> Why do people who write these books have exercises of little > >> practical value? > > > > An exercise needs to be educational. > > I have worked in programming for 25 years and during that time I have never > use a >

Re: subroutine references

2007-08-26 Thread brian d foy
In article <[EMAIL PROTECTED]>, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote: > Chris wrote: > > I'm working on yet another exercise from Intermediate Perl. I've been > > given a script that searches for files that fall between a two > > timestamps. > Why do people who write these books have e

Re: subroutine references

2007-08-26 Thread Rob Dixon
Mr. Shawn H. Corey wrote: Dr.Ruud wrote: Why do people who write these books have exercises of little practical value? An exercise needs to be educational. I have worked in programming for 25 years and during that time I have never use a closure and have never seen one used. I may be har

Re: subroutine references

2007-08-26 Thread Randal L. Schwartz
> "Shawn" == "Mr Shawn H Corey" <[EMAIL PROTECTED]> writes: Shawn> Oh, I get it. When I said 25 years, you thought that I meant 25 years Shawn> with Perl. No. Shawn> Sorry, about the confusion. No confusion. Shawn> I have programmed in many different languages and have never seen a

Re: subroutine references

2007-08-26 Thread Mr. Shawn H. Corey
Randal L. Schwartz wrote: "Shawn" == Shawn H Corey <[EMAIL PROTECTED]> writes: Shawn> Why do you include an insult with every thing you post? I don't think I do. I was only making fun of your claim, since you made the claim. Why did you include "25 years"? It just sets you up for a fall. :)

Re: subroutine references

2007-08-26 Thread Randal L. Schwartz
> "Shawn" == Shawn H Corey <[EMAIL PROTECTED]> writes: Shawn> Why do you include an insult with every thing you post? I don't think I do. I was only making fun of your claim, since you made the claim. Why did you include "25 years"? It just sets you up for a fall. :) Shawn> BTW, what lege

Re: subroutine references

2007-08-26 Thread Mr. Shawn H. Corey
Randal L. Schwartz wrote: Think of closures as "variables that hold behavior". Sure, maybe you've never needed that in your legendary 25 years in the industry, but I've used it *frequently* in my 30 years. :) Why do you include an insult with every thing you post? BTW, what legends do you ha

Re: subroutine references

2007-08-26 Thread Randal L. Schwartz
> ""Mr" == "Mr Shawn H Corey" <[EMAIL PROTECTED]> writes: Mr> Objects can do the same things as closures, which is store and hide data, Mr> but don't have this problem of having to keep in mind two phases of the Mr> same code. But objects have fixed code with variable data. Closures can have

Re: subroutine references

2007-08-26 Thread Mr. Shawn H. Corey
Dr.Ruud wrote: Why do people who write these books have exercises of little practical value? An exercise needs to be educational. I have worked in programming for 25 years and during that time I have never use a closure and have never seen one used. I may be harsh in my definitions but t

Re: subroutine references

2007-08-25 Thread Dr.Ruud
Chris schreef: > #!/usr/bin/perl -w Toss the -w, and insert a "use warnings;". > my ($start, $stop) = @_; > my @starting_directories = @_; This doesn't do what I think that you think it does. > my($sec, $min, $hour, $day, $mon, $yr, $dow) = localtime; Is the start/top related to today? What

Re: subroutine references

2007-08-25 Thread Chris
Ok, if anyone is interested, here is my answer: #!/usr/bin/perl -w # Testing code for Exercise 6-1. Your task is to write the sub # gather_mtime_between. use strict; use File::Find; use Time::Local; my ($start, $stop) = @_; my @starting_directories = @_; my @found_items; sub gather_mtime_betw

Re: subroutine references

2007-08-25 Thread Dr.Ruud
Shawn schreef: > Chris: >> I'm working on yet another exercise from Intermediate Perl. I've >> been given a script that searches for files that fall between a two >> timestamps. For the exercise, I am supposed to write the >> gather_mtime_between subrouti

Re: subroutine references

2007-08-25 Thread Mr. Shawn H. Corey
Mr. Shawn H. Corey wrote: Chris wrote: I'm working on yet another exercise from Intermediate Perl. I've been given a script that searches for files that fall between a two timestamps. For the exercise, I am supposed to write the gather_mtime_between subroutine that will return two

Re: subroutine references

2007-08-25 Thread Mr. Shawn H. Corey
Chris wrote: I'm working on yet another exercise from Intermediate Perl. I've been given a script that searches for files that fall between a two timestamps. For the exercise, I am supposed to write the gather_mtime_between subroutine that will return two references to two subrout

Re: subroutine references

2007-08-25 Thread Tom Phoenix
On 8/25/07, Chris <[EMAIL PROTECTED]> wrote: > if (my $start <= $timestamp <= my $stop){ Until Perl 6, you have to break down chain comparisons like this into separate comparisons, usually joined with 'and': if ($start <= $timestamp and $timestamp <= $stop) { ... } But the real problem

subroutine references

2007-08-25 Thread Chris
I'm working on yet another exercise from Intermediate Perl. I've been given a script that searches for files that fall between a two timestamps. For the exercise, I am supposed to write the gather_mtime_between subroutine that will return two references to two subroutines. One wil

Re: how to get references from imbricated capturing parenthesis ?

2007-07-02 Thread marin
Hi, Thanks a lot you for your solutions.. I'will study its :-) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: how to get references from imbricated capturing parenthesis ?

2007-07-02 Thread julien blitte
Hello, I'm transcoding 4 bytes hex data to an IPv4 address. Thanks a lot for your solution : It's works ;) Regards, 2007/6/30, Tom Phoenix <[EMAIL PROTECTED]>: On 6/29/07, marin <[EMAIL PROTECTED]> wrote: > I'm trying to get references from a simple r

Re: how to get references from imbricated capturing parenthesis ?

2007-06-29 Thread Dr.Ruud
marin schreef: > I'm trying to get references from a simple regular > exepression like this : > > "a40d7412" =~ /(([[:xdigit:]]{2})*)/; > print "$1: <$2><$3><$4><$5>\n"; > > This prints : > a40d7412: <12><>

Re: how to get references from imbricated capturing parenthesis ?

2007-06-29 Thread Tom Phoenix
On 6/29/07, marin <[EMAIL PROTECTED]> wrote: I'm trying to get references from a simple regular exepression like this : "a40d7412" =~ /(([[:xdigit:]]{2})*)/; print "$1: <$2><$3><$4><$5>\n"; How to get all references and not the la

how to get references from imbricated capturing parenthesis ?

2007-06-29 Thread marin
Hi everyone! I'm trying to get references from a simple regular exepression like this : "a40d7412" =~ /(([[:xdigit:]]{2})*)/; print "$1: <$2><$3><$4><$5>\n"; This prints : a40d7412: <12><><><> How to get all refere

Re: References inquiry

2007-05-10 Thread Tom Phoenix
On 5/10/07, Steve Finkelstein <[EMAIL PROTECTED]> wrote: I'm looking at some sample code from an opensource software package, and had a question on the the usage of '\' in the following: username => \ &common_name_validator There is an explicit space list between \ and &com

References inquiry

2007-05-10 Thread Steve Finkelstein
Hi all, I'm looking at some sample code from an opensource software package, and had a question on the the usage of '\' in the following: $auth_backends = { struct_validator => { sufficient => 1, driver => 'AuthStruct', username => \ &common

Re: improving my code: array of references

2007-04-28 Thread Randal L. Schwartz
>>>>> "Pierre" == Pierre Mariani <[EMAIL PROTECTED]> writes: Pierre> I want to run it on several variables. Pierre> I have the following code that: Pierre> - builds an array of references on the variables, Pierre> - calls the function on the content of

Re: improving my code: array of references

2007-04-27 Thread Pierre Mariani
On Fri, 2007-04-27 at 14:26 -0400, Matthew J. Avitable wrote: > Pierre, > >> Thank you, but I got it to work the way I wanted, thanks to Matthew and > >> Rob's posts: > >> > >> map { modify_variable(${$_}) } = \($var1, $var2, $var3); > >> > > To annotate to what Paul said - the above won't wo

Re: improving my code: array of references

2007-04-27 Thread Matthew J. Avitable
Pierre, Thank you, but I got it to work the way I wanted, thanks to Matthew and Rob's posts: map { modify_variable(${$_}) } = \($var1, $var2, $var3); To annotate to what Paul said - the above won't work. The block syntax of map is "map BLOCK LIST". Plus, it looks like you are going to

Re: improving my code: array of references

2007-04-27 Thread Paul Johnson
On Fri, Apr 27, 2007 at 09:54:37AM -0700, Pierre Mariani wrote: > Thank you, but I got it to work the way I wanted, thanks to Matthew and > Rob's posts: > > map { modify_variable(${$_}) } = \($var1, $var2, $var3); I think you'll find that syntax is incorrect. And map in void context is generall

Re: improving my code: array of references

2007-04-27 Thread Pierre Mariani
On Fri, 2007-04-27 at 12:45 -0400, Chas Owens wrote: > On 4/27/07, Pierre Mariani <[EMAIL PROTECTED]> wrote: > > On Fri, 2007-04-27 at 12:03 -0400, Chas Owens wrote: > > > On 4/27/07, Pierre Mariani <[EMAIL PROTECTED]> wrote: > > > snip > > > > > - modify_variable() doesn't appear to modify anythin

Re: improving my code: array of references

2007-04-27 Thread Chas Owens
On 4/27/07, Pierre Mariani <[EMAIL PROTECTED]> wrote: On Fri, 2007-04-27 at 12:03 -0400, Chas Owens wrote: > On 4/27/07, Pierre Mariani <[EMAIL PROTECTED]> wrote: > snip > > > - modify_variable() doesn't appear to modify anything, otherwise why > > > are you assigning its return value to the scal

Re: improving my code: array of references

2007-04-27 Thread Pierre Mariani
llowing must be true: > > my $foo = 5 > modify_variable($foo) > print "$foo\n"; #prints "6\n" > Yeah, that's exactly it. > > > > > > - Why are you using references? Are you sure you need to? > > > > > Please correct me if I a

Re: improving my code: array of references

2007-04-27 Thread Chas Owens
variable. I think the issue is what you mean by "modifies". In order to say that the modify_variable function modifies its input then something like the following must be true: my $foo = 5 modify_variable($foo) print "$foo\n"; #prints "6\n" > - Why are you

Re: improving my code: array of references

2007-04-27 Thread John W. Krahn
Pierre Mariani wrote: > Matthew and Rob, thank you for your replies. > >> - It's unclear whether you have a fixed set of variables to process. >> Is the list always the same? > > Yes, the list is always the same. > >> - Why are you usin

Re: improving my code: array of references

2007-04-27 Thread Pierre Mariani
Matthew and Rob, thank you for your replies. > - It's unclear whether you have a fixed set of variables to process. > Is > the list always the same? Yes, the list is always the same. > - Why are you using references? Are you sure you need to? > > - modify_variable() d

Re: improving my code: array of references

2007-04-26 Thread Rob Dixon
Pierre Mariani wrote: Hello everyone, I have a 'modify_variable' function that, well, modifies a variable. I want to run it on several variables. I have the following code that: - builds an array of references on the variables, - calls the function on the content of the reference,

Re: improving my code: array of references

2007-04-26 Thread Matthew J. Avitable
Hi Pierre, my @tmp = ( $var1, $var2, $var3 ); @tmp = map modify_variable, @tmp; which is better Conway (in Perl Best Practices) prefers the block form of map, since in his opinion, it's more readable. So you could rewrite it as: my @tmp = ( $var1, $var2, $var3 ); @tmp = map { modify_variab

Re: improving my code: array of references

2007-04-26 Thread Paul Johnson
On Thu, Apr 26, 2007 at 03:26:02PM -0700, Pierre Mariani wrote: > anyone know how to create an array of references? my @a = \($a, $b, $c); -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTEC

Re: improving my code: array of references

2007-04-26 Thread Pierre Mariani
gt; > - How do I improve my array definition? > > - How to I call the modify_variable function in a more elegant way? > > Perfect canidate for Map. Thanks for that. So now I have: my @tmp = ( $var1, $var2, $var3 ); @tmp = map modify_variable, @tmp; which is better. I don't thin

Re: improving my code: array of references

2007-04-26 Thread Rodrick Brown
Perfect canidate for Map. On 4/26/07, Pierre Mariani <[EMAIL PROTECTED]> wrote: Hello everyone, I have a 'modify_variable' function that, well, modifies a variable. I want to run it on several variables. I have the following code that: - builds an array of references

improving my code: array of references

2007-04-26 Thread Pierre Mariani
Hello everyone, I have a 'modify_variable' function that, well, modifies a variable. I want to run it on several variables. I have the following code that: - builds an array of references on the variables, - calls the function on the content of the reference, - set the content of the

Re: Create array of references

2006-06-12 Thread beginner
On 9 Jun 2006 at 11:55, Peter Cornelius wrote: > The problem you're having is that you're creating a new hash > reference in each of your if/elsif statements. I'm going to make > some assumptions about your data since I don't know anything about > it, but it looks like you want to group back/

Re: Create array of references

2006-06-09 Thread John W. Krahn
beginner wrote: > Hi, Hello, > I am trying to create an array of references but am getting stuck at > how/when to push the reference into the array > > Below is some sample data and a snip of what I have been trying. What > is happening is that the reference $times is getti

Re: Create array of references

2006-06-09 Thread Peter Cornelius
The problem you're having is that you're creating a new hash reference in each of your if/elsif statements. I'm going to make some assumptions about your data since I don't know anything about it, but it looks like you want to group back/home/out times by day. If that's what you want then

Re: Create array of references

2006-06-09 Thread Muma W.
beginner wrote: Hi, I am trying to create an array of references but am getting stuck at how/when to push the reference into the array [...] } elsif ($key =~ /j/ ) { $times = { out => $time}; Try this: $times->{out} = $time; [...] -- To unsubscr

Create array of references

2006-06-09 Thread beginner
Hi, I am trying to create an array of references but am getting stuck at how/when to push the reference into the array Below is some sample data and a snip of what I have been trying. What is happening is that the reference $times is getting pushed into the array before all the keys are

references header Was: Chomp method

2006-04-27 Thread Bjørge Solli
one of the following aproaches: 1. quote what you are answering, and replying beneath it. 2. set your email client to include a propper References-header, so you don't start a new thread each time you post to the list. Please consider this as a friendly reminder. -- Bjørge Solli -- To uns

Re: simple references question

2006-02-24 Thread Hans Meier (John Doe)
Bryan R Harris am Donnerstag, 23. Februar 2006 19.30: > Responding to your references to modules, we haven't used them because we > can't count on them being there. Obviously my problem, not yours. =) [...] There is no must to have them installed in default locations. You can i

Re: simple references question

2006-02-23 Thread Bryan R Harris
Responding to your references to modules, we haven't used them because we can't count on them being there. Obviously my problem, not yours. =) Thanks for the response. - Bryan > Hi Bryan > > It's a bit lengthy, but I hope it motivates you a bit to look aro

Re: simple references question

2006-02-23 Thread Hans Meier (John Doe)
Bryan Harris am Donnerstag, 23. Februar 2006 16.41: Hi Bryan It's a bit lengthy, but I hope it motivates you a bit to look around... > You mention larger projects, and I've heard about "reusable code"... Is > that generally done by copy/paste into the script you're working on? Code copied&pas

Re: simple references question

2006-02-23 Thread Bryan Harris
> > -Original Message- > From: Bryan Harris [mailto:[EMAIL PROTECTED] > Sent: Wednesday, February 22, 2006 6:47 PM > To: Beginners Perl > Subject: Re: simple references question > > > > Thanks! > > Regarding your "note", out of curiosit

RE: simple references question

2006-02-23 Thread Timothy Johnson
n Harris [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 22, 2006 6:47 PM To: Beginners Perl Subject: Re: simple references question Thanks! Regarding your "note", out of curiosity, how will it help a lot in the end? I've been scripting for almost 5 years now, and have produced

Re: simple references question

2006-02-22 Thread Hans Meier (John Doe)
Bryan Harris am Donnerstag, 23. Februar 2006 03.46: > Thanks! > > Regarding your "note", out of curiosity, how will it help a lot in the end? > I've been scripting for almost 5 years now, and have produced >100 scripts > that are used in data analysis work by ~15 people, and have never used "use >

Re: simple references question

2006-02-22 Thread Bryan Harris
; >my $g = shift; > >print $f[2], "\n"; > } > > ### > > > > > -Original Message- > From: Bryan R Harris [mailto:[EMAIL PROTECTED] > Sent: Wednesday, February 22, 2006 12:39 PM > To: Beginners Per

RE: simple references question

2006-02-22 Thread Timothy Johnson
hift; print $f[2], "\n"; } ### -Original Message- From: Bryan R Harris [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 22, 2006 12:39 PM To: Beginners Perl Subject: simple references question I'm trying to pass an array to a sub

RE: simple references question

2006-02-22 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Bryan R Harris wrote: > I'm trying to pass an array to a subroutine. I'd like the subroutine > to create "@f" from the "[EMAIL PROTECTED]" that I send it, but I can't seem > to > figure out the syntax. Is there a way to replace my "???f???" with > something to make it work? > >

simple references question

2006-02-22 Thread Bryan R Harris
I'm trying to pass an array to a subroutine. I'd like the subroutine to create "@f" from the "[EMAIL PROTECTED]" that I send it, but I can't seem to figure out the syntax. Is there a way to replace my "???f???" with something to make it work? ** @a = (1,2,

Re: taking references to functions

2005-12-21 Thread John Doe
utines > #by Rob Kinyon | Pages: 1, 2, 3, 4 > > # Adding and removing available subroutines is > # simpler than the if-elsif-else scenario, and > # this is much safer than the soft references scenario. > # Perl Cookbook 11.4 shows following example > > my %dispatch =

taking references to functions

2005-12-21 Thread John W. Burns
warnings; # reference_to_functions8.pl # Dispatch Tables # See Making Sense of Subroutines #by Rob Kinyon | Pages: 1, 2, 3, 4 # Adding and removing available subroutines is # simpler than the if-elsif-else scenario, and # this is much safer than the soft references scenario. # Perl Cookbo

Re: references

2005-11-24 Thread Eric Pretorious
On Thu, 2005-11-24 at 11:18 -0600, The Ghost wrote: > Is there a way I can know if a variable ($hash{someKey}) is an array > or an arrayref or hashref or scalar? > I could use eval, but I thought I remember there was some other > function for doing this. >From the third edition of "Programming

Re: references

2005-11-24 Thread John Doe
The Ghost am Donnerstag, 24. November 2005 18.18: > Is there a way I can know if a variable ($hash{someKey}) is an array > or an arrayref or hashref or scalar? > I could use eval, but I thought I remember there was some other > function for doing this. Yes, perldoc -f ref :-) greetings, joe --

references

2005-11-24 Thread The Ghost
Is there a way I can know if a variable ($hash{someKey}) is an array or an arrayref or hashref or scalar? I could use eval, but I thought I remember there was some other function for doing this. Ryan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECT

keep entity references while parsing with XML::Parser

2005-09-15 Thread Alois Heuboeck
Hi Perlers, I'm trying to do the following: 1- take an XML file 2- in one script, replace everything above Unicode #x7F (end of ASCII) with entity references (which can either have "special" names, like ä or be based on the Unicode nb. like ®) 3- then in another scrip

Re: References Question

2005-08-19 Thread Rex Rex
In Perl, my($array, @array, %array); open(ARRAY, ">file.txt"); opendir(ARRAY, "C:/DIR"); are all different. They are not the same. Thanks, Rex On 8/19/05, Dave Adams <[EMAIL PROTECTED]> wrote: > Dan, > > It appears the $apple->[2] and $apple[2] are not the same thing. > > > #!/usr/bin/perl -

Re: References Question

2005-08-19 Thread Jeff 'japhy' Pinyan
On Aug 19, Dave Adams said: In the code below, I thought $array[2] and $array->[2] were different but they give me the same result. Any explaination for this? my @array = (1,2,3); my $array [EMAIL PROTECTED]; print ref($array); print $array[2]; print $array->[2]; The constructs $this[2] and

Re: References Question

2005-08-19 Thread Dave Adams
Dan, It appears the $apple->[2] and $apple[2] are not the same thing. #!/usr/bin/perl -w use strict; my $apple = [4,5,6]; #example of a scalar representing an array print ref($apple) . $apple->[2] . "\n"; print ref($apple) . $apple[2] . "\n"; errror msg: Global symbol "@apple" requires expl

Re: References Question

2005-08-19 Thread Octavian Rasnita
ners perl" Sent: Friday, August 19, 2005 17:31 PM Subject: References Question In the code below, I thought $array[2] and $array->[2] were different but they give me the same result. Any explaination for this? my @array = (1,2,3); my $array [EMAIL PROTECTED]; print ref($array); p

References Question

2005-08-19 Thread Dave Adams
In the code below, I thought $array[2] and $array->[2] were different but they give me the same result. Any explaination for this? my @array = (1,2,3); my $array [EMAIL PROTECTED]; print ref($array); print $array[2]; print $array->[2]; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional

RE: References

2005-06-13 Thread Bob Showalter
radhika wrote: > > You could do it like this: > > > > while (@row = fetchrow_array()) { > >push @$perl, { > > TRADE_DATE => $row[0], > > TRADE_TIME => $row[1], > > FIRSTNAME => $row[2], > > LASTNAME=> $row[3], > >

RE: References

2005-06-13 Thread radhika
> > You could do it like this: > > while (@row = fetchrow_array()) { >push @$perl, { > TRADE_DATE => $row[0], > TRADE_TIME => $row[1], > FIRSTNAME => $row[2], > LASTNAME=> $row[3], > EXCHANGE=> $

RE: References

2005-06-13 Thread Bob Showalter
radhika wrote: > Hi, > > I am trying to create this data structure as below: > > $perl = [ > { > fname => 'Fred', > lname => 'Flintstone', > residence => 'Bedrock' > }, > { > fname => '

References

2005-06-13 Thread radhika
Hi, I am trying to create this data structure as below: $perl = [ { fname => 'Fred', lname => 'Flintstone', residence => 'Bedrock' }, { fname => 'Barney', lname

RE: sorting array full of hash references

2005-06-07 Thread Charles K. Clarkson
Jeremy Kister wrote: : I'm stumped on how to sort an array based on a hash refrences's : key in each element of my array. : : this is dumbed down code of what I have: : my @array; : while(my $row = $sth->fetchrow_arrayref){ : my %hash = (id => $row->[0], name => $row->

Re: sorting array full of hash references

2005-06-07 Thread Peter Rabbitson
On Tue, Jun 07, 2005 at 10:40:43PM -0400, Jeremy Kister wrote: > I'm stumped on how to sort an array based on a hash refrences's key in > each element of my array. > > this is dumbed down code of what I have: > my @array; > while(my $row = $sth->fetchrow_arrayref){ > my %hash = (id => $row->[0],

Re: sorting array full of hash references

2005-06-07 Thread John W. Krahn
Jeremy Kister wrote: I'm stumped on how to sort an array based on a hash refrences's key in each element of my array. this is dumbed down code of what I have: my @array; while(my $row = $sth->fetchrow_arrayref){ my %hash = (id => $row->[0], name => $row->[1]); push(@array, \%hash); } after th

sorting array full of hash references

2005-06-07 Thread Jeremy Kister
I'm stumped on how to sort an array based on a hash refrences's key in each element of my array. this is dumbed down code of what I have: my @array; while(my $row = $sth->fetchrow_arrayref){ my %hash = (id => $row->[0], name => $row->[1]); push(@array, \%hash); } after the while loop, I'm tryin

Re: CGIs & CSS - References

2005-04-30 Thread Chris Devers
"; if this works, then Apache is fine; if it doesn't, then your Apache is configured in a way that doesn't agree with what you're doing. (If you're serving your CGI scripts out of a ScriptAlias'ed directory rather than by file extension, then Apache will attempt

Re: CGIs & CSS - References

2005-04-30 Thread Mike Lesser
Current versions of CGI.pm should generate XHTML by default, iirc. Hmm. Does it include the doctype stuff and so forth? I seem to be getting along fine with print qq() today, but I figured CGI.pm would help with tables and links and so forth. I guess there's no need to settle on using just CGI.

Re: CGIs & CSS - References

2005-04-30 Thread Chris Devers
Whoops! Forgot to send this to the beginners-cgi list :-) Oh well... On Sat, 30 Apr 2005, Mike Lesser wrote: > (1) What's the contemporary way to print xhtml from my CGI? Should I > use CGI.pm, or something else? I currently just have a mess of print > commands. Current versions of CGI.pm sh

CGIs & CSS - References

2005-04-30 Thread Mike Lesser
a mess of print commands. (2) My stylesheets don't work with @import - Apache claims that it can't find the file. They _do_ work with a hard reference like http://localhost/the_stylesheet.css"; /> I've been advised that @import is the way to go, and either way I need rela

References and subroutine ?

2005-04-22 Thread Michael Gale
Hello, I have an array and I would like to pass it to a subroutine: &printlist([EMAIL PROTECTED]); sub printlist { my $array_ref = (shift); my $max; my $maxnew = @{$array_ref}; for(my $i=0;$i < $maxnew; $i++){ print "\t\t\t\t\t";

RE: References and subroutine ?

2005-04-22 Thread Charles K. Clarkson
Michael Gale wrote: : I am passing the reference of an to the subroutine, which using : (shift) assigns the first scaler to my scaler array_ref. So now : array_ref scaler is equal to the passed scaler allowing me to use : array_ref as a reference. : : Correct ? Ye

Re: pointers - references ??

2005-04-11 Thread Jay Savage
On Apr 11, 2005 4:20 AM, Brent Clark <[EMAIL PROTECTED]> wrote: > Hi all > > If anyone has the time and / or the will to help me understand. > > I know how to create / use references for perl. But would why would you > use it. > And I think more importantly when. >

Re: pointers - references ??

2005-04-11 Thread Jonathan Paton
> I know how to create / use references for perl. But would why would you > use it. Perl uses references for multidimensional/complex datastructures. Also used when doing OO in perl. > And I think more importantly when. Whenever appropriate. :) I probably make the greatest use of r

Re: pointers - references ??

2005-04-11 Thread John Doe
Am Montag, 11. April 2005 10.20 schrieb Brent Clark: > Hi all Hi Brent Here's my way to explain it from an "abstract" perspective more or less "outside" of the world of perl: [...] > I know how to create / use references for perl. But would why would y

<    1   2   3   4   5   >