Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: using arrays insteaed of files

by davorg (Chancellor)
on Jul 11, 2003 at 16:04 UTC ( [id://273443]=note: print w/replies, xml ) Need Help??


in reply to using arrays insteaed of files

It depends what you want to go into $database.

$database = "@names"; # space separated list of names $database = @names; # number of elements in @names $database = \@names; # reference to @names $database = [@names]; # reference to a copy of @names
--
<http://www.dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

Replies are listed 'Best First'.
Re: Re: using arrays insteaed of files
by Anonymous Monk on Jul 11, 2003 at 16:09 UTC
    Thanks Dave This is what is in the test.dbf file. I think it is just a list. Tin Grig Lou Caero Karen Dnny Lo Fiadeiro Ben Mandig Luen Menoza
Re: Re: using arrays insteaed of files
by Anonymous Monk on Jul 11, 2003 at 16:12 UTC
    I think this is what I meantthe file looked like.

    Tin Grig
    Lou Caero
    Karen Dnny
    Lo Fiadeiro
    Ben Mandig
    Luen Menoza
Re: Re: using arrays insteaed of files
by Anonymous Monk on Jul 11, 2003 at 16:20 UTC
    I have tried all of the suggestions.
    $database = "@names"; # space separated list of names $database = @names; # number of elements in @names $database = \@names; # reference to @names $database = [@names]; # reference to a copy of @names
    But no data ever seems to be there.
      You say: "But no data ever seems to be there."

      What do you mean by "there"? All of the commands shown will put something into the variable $database if @names had something in it to begin with.

      The statement: my $database = "test.dbf"; looks like you were previously assigning a filename to $database. And that filename was then being passed to test(). Is that the case? If so, a routine expecting a filename is not going to do well if passed a string containing data instead.

      You seem to be at a beginning level so we will be much more able to help you if you tell us more specifically what you are doing and what you are asking for:

      • Where did you expect the data to be after you tried the statements above?
      • What did you do that convinced you that "no data ever seems to be there"?
      • In general: what are you *actually* doing (show us the code) and what are you seeing as a result?
      • What file are you refering to when you say "
      • What does the test() routine look like?
      • Did you have any success passing the value 'test.dbf' to the test() routine (before you tried setting $database to the array value)?

      NOTE: What often happens when you force yourself to *demonstrate* your problem to us instead of just reporting things like "it doesn't work" or "nothing was there" is that, in carefully laying out the specifics of your attempts you discover the solution for yourself. It's a good discipline.

      P.S. Good work on using "my". Is there a "use strict" at the top of your script also? And are you using warnings?

      ------------------------------------------------------------
      "Perl is a mess and that's good because the
      problem space is also a mess.
      " - Larry Wall

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://273443]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2025-03-27 03:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When you first encountered Perl, which feature amazed you the most?










    Results (69 votes). Check out past polls.

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.