[22647] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4868 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 21 00:05:51 2003

Date: Sun, 20 Apr 2003 21:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 20 Apr 2003     Volume: 10 Number: 4868

Today's topics:
        Beginners question - directions please... <no_spam@no.spam.org.invalid>
        Bitwise Operators with Strings and the example in Progr (Phil McMillan)
        Bitwise Operators with Strings and the example in Progr (Phil McMillan)
    Re: Bitwise Operators with Strings and the example in P <bwalton@rochester.rr.com>
        Copying files efficiently (Felix)
    Re: Copying files efficiently <jurgenex@hotmail.com>
    Re: design considerations for using DB_File tie hashes  (dan baker)
    Re: Help needed understanding bitwise operations <tim@vegeta.ath.cx>
    Re: Help needed understanding bitwise operations <tim@vegeta.ath.cx>
    Re: HTTP::Headers - getting request headers <iain@bigpond.nospam.com>
        Matching multiple lines <ccsc3618@bigpond.net.au>
        Net::Ftp and the use of the FTP user command (Trevor Hales)
        Newbie Help searching for a ^ character ... <dlaw001@yahoonospam.co.uk>
        Passing objects <mail@annuna.com>
    Re: Passing objects <knuteNOSPAMPLEASE@trinityproject.org>
    Re: Passing objects <bwalton@rochester.rr.com>
    Re: Passing objects <jkeen@concentric.net>
    Re: Perl & Office <anthony@nospam.safferconsulting.com>
    Re: Perl source install over redhat rpm <knuteNOSPAMPLEASE@trinityproject.org>
    Re: PerlScript, handbook <knuteNOSPAMPLEASE@trinityproject.org>
    Re: PerlScript, handbook <s.lepolozec@wanadoo.fr>
    Re: Please help with HTML::Mason configuration/installa <randy@theoryx5.uwinnipeg.ca>
        Problem with paths in RedHat 8.0 <cwesterh@wanadoo.nl>
    Re: Problem with paths in RedHat 8.0 <rereidy@indra.com>
    Re: Q.  Basic Perl Tutorial ? (for a not-so-bright newb <knuteNOSPAMPLEASE@trinityproject.org>
        Q. Does ActivePerl for Windows require Apache to be ins (Jim)
    Re: Q. Does ActivePerl for Windows require Apache to be <dorward@yahoo.com>
    Re: Q. Does ActivePerl for Windows require Apache to be (Jim Jones)
    Re: Q. Does ActivePerl for Windows require Apache to be (Tad McClellan)
    Re: Q. Does ActivePerl for Windows require Apache to be <jurgenex@hotmail.com>
    Re: Recusively search directory... <jaspax@u.washington.edu>
    Re: Recusively search directory... (Tad McClellan)
        regexp match problem <m9l3@interchange.ubc.ca>
    Re: regexp match problem <tony_curtis32@yahoo.com>
    Re: Trouble with LWP <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 21 Apr 2003 10:14:08 +1000
From: "Tony" <no_spam@no.spam.org.invalid>
Subject: Beginners question - directions please...
Message-Id: <pan.2003.04.21.00.14.08.546063@no.spam.org.invalid>



Hi Guys,

Got a special little project.  I have a specific config file in the format
listed at the  end of this post.

I am looking for some pointers to how the following can be acheived:

I need to read the file into a perl program and process it.

The idea is that the perl program will be started, read in the file
and on the specified week day, at the specified time, start sending the
listed files to an output device, one after the other.  Each file name
is followed by a single digit which denotes the number of times
the file is processed by the output device (Controlled by an
external program) with 1 being = once, 2-9 being = 2 - 9 times
and 0 being infinite (10000 times).

The processing of the files is done by the external program and
perl does not need to deal with the multiple play times specified
after each file name (The external program does this and gives an
exit code when done).
I could set the file to play once always and let perl do the repeats
as needed.

When the last file on a given start time is playing multiple times
(Looping),  the next time (On the same output device) should result
in the looping being aborted and a new set of files being played etc.

I have done some work like getting the day of the week from
the RTC and ensuring that it is in large caps.  I also know how to
get the files sent to the external program with the appropriate switches
to be able to process the files.

My biggest perolem is that I do not know how to get from the
given file format to an array with a suitable format that can be
run, something like:

MON 0 02:00 (/some/path/file.name_1 1, /some/path/file.name_2 1, etc)
MON 1 12:00 (/some/path/file.name1 1, /some/path/file.name_2 1, etc)
TUE 0 15:00 (/some/path/file.name1 1, /some/path/file.name_2 1, etc)

Maybe this is the wrong approach....

It may be better to scan the entire file in a loop matching against the
day of the week, then picking up the output device number, then matching
the play time and finally grabbing the files that follow - I don't know.

Any suggestions.

Please note that I am new to all this but have read a lot on perl,
various tutorials and FAQ's...(Have I started something to big...?)

Best regards

Tony

Begin file format.
======================
MON       # The day of the week to take action...
0         # The output device to use...0 in this case
02:00     # The time to process the listed files     
12:00     # The next time to process the listed files
[...more times, one per line...]     # There may be up to 24 times
/some/path/file.name_1 1     # The first file to send to device 0,
/some/path/file.name_2 2     # The second file to device 0
/some/path/file.name_3 0     # The 3rd file to device 0
[...more files, there may be up to 10 or so...]
MON     # The day of the week to take action...
1        # The output device to use...1 in this case
05:00
16:00
[...several times, one per line...]
/some/path/other_file_1.name 1
/some/path/_other_file_2.name 2
/some/path/other_file_3.name 0
TUE
0
02:00
12:00
[...several times, one per line...]
/some/path/new_file_1.name 1
/some/path/new_file_2.name 2
/some/path/new_file_3.name 0
WED
0
13:00
[...continues like this for the whole week...]


-- 
------------------------------------------------------------
I can be contacted here: anthony_w  at  bigpond  dot  com
(No spam mail here please)
------------------------------------------------------------



------------------------------

Date: 20 Apr 2003 13:20:35 -0700
From: pamcmillan50@hotmail.com (Phil McMillan)
Subject: Bitwise Operators with Strings and the example in Programming Perl (3rd Edition)
Message-Id: <87172142.0304201220.1b346b90@posting.google.com>

Hello,

I am having some trouble understanding an example in the O'Reilly book
Programming Perl, 3rd edition, page 102...

the example is for finding out if any byte in the resultant string
came out to be non-zero when doing bitwise operations on two strings.

The solution is shown as:

if ( ("fred" & "\1\2\3\4") =~ /[^\0]/ ) { ... }

I am having trouble understanding what "\1\2\3\4" means in this case. 
They do not match any of what "man perlop" says are the acceptable
escapes...

           \033        octal char      (ESC)
           \x1b        hex char        (ESC)
           \x{263a}    wide hex char   (SMILEY)
           \c[         control char    (ESC)
           \N{name}    named char

In fact, to me these look like backreferences, which doesn't make much
sense as we are not in a regular expression.

So my question is, does this look like a bug in the book, or does \1
have some significance as a character escape when used in a string.

Regards
Phil


------------------------------

Date: 20 Apr 2003 13:29:36 -0700
From: pamcmillan50@hotmail.com (Phil McMillan)
Subject: Bitwise Operators with Strings and the example in Programming Perl (3rd Edition)
Message-Id: <87172142.0304201229.317cb16c@posting.google.com>

Hello,

I am having some trouble understanding an example in the O'Reilly book
Programming Perl, 3rd edition, page 102...

the example is for finding out if any byte in the resultant string
came out to be non-zero when doing bitwise operations on two strings.

The solution is shown as:

if ( ("fred" & "\1\2\3\4") =~ /[^\0]/ ) { ... }

I am having trouble understanding what "\1\2\3\4" means in this case. 
They do not match any of what "man perlop" says are the acceptable
escapes...

           \033        octal char      (ESC)
           \x1b        hex char        (ESC)
           \x{263a}    wide hex char   (SMILEY)
           \c[         control char    (ESC)
           \N{name}    named char

In fact, to me these look like backreferences, which doesn't make much
sense as we are not in a regular expression.

So my question is, does this look like a bug in the book, or does \1
have some significance as a character escape when used in a string.

Regards
Phil


------------------------------

Date: Sun, 20 Apr 2003 21:57:01 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Bitwise Operators with Strings and the example in Programming Perl (3rd Edition)
Message-Id: <3EA31797.2010609@rochester.rr.com>

Phil McMillan wrote:

 ...
> if ( ("fred" & "\1\2\3\4") =~ /[^\0]/ ) { ... }
> 
> I am having trouble understanding what "\1\2\3\4" means in this case. 


In quote interpolation, \n, \nn, or \nnn (where n is an octal digit) is 
a character with the specified octal code.  So "\033" and "\33" are, for 
example, the same thing.  It is perhaps conventional to include the 
leading zero to assist with the human-readable aspect of it.

Note that this differs from the interpretation of integers in Perl 
source code outside quoted strings.  For example, print 033; is 
different than print 33;.  Things can get tricky with stuff like print 
033.33; or print 033.033, too.  Bug?  No, not really.  Documented? 
Maybe.  Where? I can't find it right off.


 ...


> Phil
> 

-- 
Bob Walton



------------------------------

Date: 20 Apr 2003 20:04:22 -0700
From: josspowell@paradise.net.nz (Felix)
Subject: Copying files efficiently
Message-Id: <536f59c6.0304201904.42db8fc4@posting.google.com>

Hello all.  I'm currently writing my first real Perl program, which
will automatically back up folders that change frequently and need to
be backed up regularly.  I compared my copying code with Ctrl-C and
Ctrl-V in Windows.  In one case, my program took approx 1min, 50secs
to copy a folder, while Windows took 1min, 15secs.  Can I make my
program faster here?  Here is the code:

for (@source) {
    
  open IN, "$source/$_" or die $!;
  open OUT, "> $target/$_" or die $!;
  binmode IN; binmode OUT;
  print "Currently copying $_\n";
  while (<IN>) {

    print OUT $_;
     
  }

}

@source is an array of file names to be copied, $source is the source
folder, $target the target folder.  I tried reading the entire file at
once, and then writing, but this used much too much memory, and was
not much faster, at all.  Any help would be appreciated.

Cheers, Joss.


------------------------------

Date: Mon, 21 Apr 2003 03:12:58 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Copying files efficiently
Message-Id: <_kJoa.11168$yO5.9009@nwrddc02.gnilink.net>

Felix wrote:
> Hello all.  I'm currently writing my first real Perl program, which
> will automatically back up folders that change frequently and need to
> be backed up regularly.  I compared my copying code with Ctrl-C and
> Ctrl-V in Windows.  In one case, my program took approx 1min, 50secs
> to copy a folder, while Windows took 1min, 15secs.  Can I make my
> program faster here?  Here is the code:
>
[Hand-rolled code for read-then-write snipped]

> @source is an array of file names to be copied, $source is the source
> folder, $target the target folder.  I tried reading the entire file at
> once, and then writing, but this used much too much memory, and was
> not much faster, at all.  Any help would be appreciated.

Of course your code is sloooowww. Why do you want to read the data into an
internal data structure and even analyse it for line breaks?

You are not doing anything with the content of the file, so just use
File::Copy and your code should be way faster.

jue




------------------------------

Date: 20 Apr 2003 20:50:11 -0700
From: botfood@yahoo.com (dan baker)
Subject: Re: design considerations for using DB_File tie hashes ???
Message-Id: <13685ef8.0304201950.77fe13c8@posting.google.com>

Norbert Schmidt <me@privacy.net> wrote in message news:<1kxsv8mcci0v$.z1chksotqcia$.dlg@40tude.net>...
> Hello Dan,
> 
> > hi folks... I'm in the preliminary stages of designing a membership
> > management system ...
--------
> If most access will be reading quasi static data, then it could be a good
> idea to create ordinary HTML pages whenever some data is uploaded or build
> some caching machanism into the CGI that first checks if it could use an
> already formatted page.
--------------------------
agreed. most of the profile management system won't usually be hit
except as new members sign up, or change data for their address or
preferences. I am planning on "hiding" email addresses behind a lookup
for members to mail members so that it would be hard to grab all the
members for spamming. I would expect that this would be the heaviest
use, and i was thinking about creating a separate table with just the
"handle" and the email to keep the file as compact as possible.



> The solution-also to the locking problem-was to write a simple dedicated
> deamon that is the single authority for this DB file and keeps it open all
> the time. This deamon can also be written in Perl. IPC (I tried several
> ways) works best via TCP/IP (even on Windows). For the client side (CGI)
> you can write some simple TIE that hides the details of the IPC behind a
> hash. (It's really easy: see perltie!) 
-------
you lost me on this one.... I've never had to write a persistant
daemon of any kind, and I'm not even sure it would be allowed on my
shared-server hosted domain. Can you expand on this, or give a link to
an example/tutorial?


 
> > - access speed for maybe up to 100k-500k records.
> 
> That much data for each record?
---------
no.... I am guessing maybe a max of 500k members to manage. data could
easily be broken up into several different tables grouped logically be
expected usage.



> 
> 
> > - portability of application source and (hopefully) datafiles between
> > *nix and win32 PC development platforms.
> 
> Source is no problem. The problem may be with the DB_File module. Last time
> I looked, that module isn't shipped with ActiveState Perl for Win32. You'ld
> have to get it yourself and compile it.
------
actually, I loaded it via the regular ppm install on my development PC
a while back, so I think I'm ok there.



> 
> 
> > - how "stable" is the tied hash going to be ?----
> Quite stable. Just don't allow two applictions write access at the same
> time ...
---
> > - does the DB_File version of tie handle all the flock-ing issues
> > behind the curtain? 
> 
> AFAIK: No.
----------------
hhhmm, this is somwhat concerning to me. I was hoping that when you
"tie" to the hask with the DB_FILE method it would automatically flock
or whatever the file. i dont know much about that stuff, and would
like to find a high-level explaination/tutorial on considerations
required for multi-thread activity such as a multi-user web-based
database.
-------
> It's better to use the deamon approach. Then the "locking" will be implicit
> by the way TCP/IP request are queued and processed with a single threaded
> server process.
> --------------------------------------------

PLEASE expand on your approach here!
I am wondering things like:
- how does the daemon get "started"?
- how does it get re-started if it gets killed?
- do you have an example?
- is there a simple test I can do to see if my host allows daemons?


Another very different approach I was considering, and perhaps you
have some insight on, would be to create a directory for each user,
and populate with various data files for each. Locking would be a
minimal problem as users would be writing only with their own files,
file opens would be fast with tiny files. However, I was unsure what
the upper limit of directories would be, or if there were some other
issues with that approach.

d


------------------------------

Date: 20 Apr 2003 12:19:44 -0700
From: Tim Hammerquist <tim@vegeta.ath.cx>
Subject: Re: Help needed understanding bitwise operations
Message-Id: <slrnba5sgj.1gj.tim@vegeta.ath.cx>

Dark Over Lord graced us by uttering:
> Now, assuming that I am right (I hope!) What about different
> lengths?
> 
> Example:
> 10110101
> 1010
> 
> Are they right aligned or left? And would I have to pad them
> with 0s?

First some background on number systems to get some perspective.
Even if you already know this, bear with me; you might end up
answering your own question. :)

The values of the bits in a binary octet 01110110 are:

    0      1      1      1     0     1     1     0
    |      |      |      |     |     |     |     |
 128*0 + 64*1 + 32*1 + 16*1 + 8*0 + 4*1 + 2*1 + 1*0
    0  +  64  +  32  +  16  +  0  +  4  +  2  +  0  =  118

Just like the value of the digits in the decimal 118 are:

       1      1     8
       |      |     |
    100*1 + 10*1 + 1*8
     100  +  10  +  8  = 118

And just like the values of hexadecimal (base 16) 0x76 are:

      7     6
      |     |
    16*7 + 1*6
     112 +  6  = 118

So, they all really work just like decimal numbers, only with a
base of 2 rather than 10.

So, if you were asked to add the decimal numbers 200, 50, and 5,
would you stack them up like this?

    80
    6

Probably not, because the columns of equal relative value are not
lined up.  Likewise in binary, it makes little sense to
AND/OR/etc bits of different relative value.

If we put this in the context of file operations, it makes even
less sense.  The sysopen() function uses constants such as
O_WRONLY, O_RDWR, O_CREAT and O_APPEND.  These are #defined in my
system's header files (converted from the octal) as 1, 2, 64, and
1024, respectively.  First, let's convert these to binary:

             Base 10            Base 2
    O_WRONLY       1              0001
    O_RDWR         2              0010
    O_CREAT       64         0100 0000
    O_APPEND    1024    0100 0000 0000

These are bitwise flags which are OR'd together and the resulting
value is passed on to the function.  For
simplicity's sake, let's just find the call to open a file for
writing.  If the file already exists, we'll clobber its contents.
If it doesn't, we'll create it first.  The flags we'd use are:
O_RDWR and O_CREAT.  So our call looks something like this:

    sysopen(FH, $path, O_WRONLY | O_CREAT) or die $!;

Here we take the values of O_WRONLY and O_CREAT, perform a
bitwise OR on them, and pass the result as the third argument to
sysopen().  If these were left-aligned, the operation would look
like this:

      1000000
    | 1
      -------
      1000000

This doesn't make sense; we've lost all sign of O_WRONLY.  Try:

      1000000
    |       1
      -------
      1000001

or if you're so inclined:

      0100 0000
    | 0000 0001
      ---------
      0100 0001

Thus, the decimal value 65 (0x41) is actually passed to the
function, where it's eventually AND'd by the same O_* values to
determine whether these bits were set.

I could have simply said "right-aligned, pad with zeros as
desired", but I thought I'd explain why it works this way as
well.  :)

HTH
Tim Hammerquist
-- 
If circles were squares, this would be an accurate value of pi.
    -- Joe Schaefer in comp.lang.perl.misc


------------------------------

Date: 20 Apr 2003 12:29:27 -0700
From: Tim Hammerquist <tim@vegeta.ath.cx>
Subject: Re: Help needed understanding bitwise operations
Message-Id: <slrnba5t2q.1gj.tim@vegeta.ath.cx>

Tim Hammerquist made a digital faux pas:
> So, if you were asked to add the decimal numbers 200, 50, and
> 5, would you stack them up like this?
> 
>     80
>     6

Probably not, because 255 has little to do with 86.

That should have been:
> So, if you were asked to add the decimal numbers 80 and 6 would
> you stack them up like this?
> 
>     80
>     6

Apologies.

Tim Hammerquist
-- 
Sorry - when I booted up this morning, the 'use English' in
one of my init files failed. Am trying to compensate with
'abuse Caffeine' before rebooting.
    -- David Cantrell


------------------------------

Date: Mon, 21 Apr 2003 12:42:15 +0930
From: Iain <iain@bigpond.nospam.com>
Subject: Re: HTTP::Headers - getting request headers
Message-Id: <u9Joa.18940$1s1.289547@newsfeeds.bigpond.com>

David Efflandt wrote:
> On Thu, 17 Apr 2003 11:23:27 +0930, Iain <iain@pcorp.nospam.com.au> wrote:
> 
>>I want to get some (any would do for now!) request headers, ie sent by 
>>the client to the server.  I'm using HTTP::Headers as follows, but I 
>>think I'm doing something wrong:
> 
> 
> I am a little confused what you are attempting to do.  HTTP::Headers
> appears to be for setting request headers (for HTTP client use), which you
> are attempting to read when you have never set them.  Maybe you are
> actually attempting to use it on a web server to read request headers from
> a browser.  I do not think it is designed for that (normal web servers do
> not necessarily pass on full HTTP request header, just certain variables
> in the environment).

I suspected as much!  I am trying to do just that: read request headers 
(on server side) sent from a browser.  Some header information is passed 
to the environment, such as user agent and referrer, but others aren't. 
  Do you know of anything to do what I want to do?  Maybe mod_perl?

> If you want to see what an actual HTTP request looks like, write a little
> Perl server that listens on port 80 (perldoc perlipc) and reports anything
> it receives from the socket up until the first empty line.  Then print
> something back to the socket that looks like a normal server response with
> something simple, so the browser does not hang waiting for a response (or
> if that is too difficult, just hit the stop button on browser once it has
> sent its request).

I've done this already, so I know all the chatter, but getting it into 
the script is the problem.  Surely there is a way.  Any ideas?

Many thanks,
Iain



------------------------------

Date: Mon, 21 Apr 2003 01:55:34 GMT
From: "rjh" <ccsc3618@bigpond.net.au>
Subject: Matching multiple lines
Message-Id: <qcIoa.3876$8K2.31788@news-server.bigpond.net.au>

Hi,

Im writing a perl script that keeps a database of snipets of information
that i want to be able to retrieve.

my file would look like this after a few posts via the script/


24-2-2002
-----------
hello world
this is me
for another time
-----------
28-4-2002
-----------
hi,
this is another multi line piece of input.
-----------
So the format is ,   timestamp, separator, data.
What i want to be able to do is search my database using a flag ie :
myscript.pl -g hello.
This would then match any entry in the file with the word "hello"

Im trying to search the file for the ---------- delimiter and then read the
data into an array,  then search the
array for a match and then print out the array. My current solution doesnt
work very well.
Has anyone attempted anything similar to this ??

$separator = "---------------";
OpenFile($filename);
        while (<FILEHANDLE>) {
                chomp;
                m/\A$separator$/g;
                unless ($_ eq $separator )
                {
                        @w = m/\G.*/g;
                }
        foreach (@w) { print $_;}


Cheers.






------------------------------

Date: Mon, 21 Apr 2003 03:55:16 GMT
From: tfhales@iname.com (Trevor Hales)
Subject: Net::Ftp and the use of the FTP user command
Message-Id: <3ea36b3c.2424192@news.ozemail.com.au>

Behold a list of the problem I am attempting to solve using Perl...

Please find attached an ftp session show how you can
login again as a user...
ftp
Connected to
220 tigger FTP server (...) ready.
Name (:thales): anonymous
331 Guest login ok, send ident as password.
Password:
230 Guest login ok, access restrictions apply.
ftp> user
(username)
331 Password required for
Password:
230 User logged in.
ftp> ls -tl
200 PORT command successful.
 ...............
221 bytes received in 0.24 seconds (0.90 Kbytes/s)
ftp>


Any guidance / help you can provide re this issue
would be very much
appreciated.
cheers
trevor


------------------------------

Date: Mon, 21 Apr 2003 02:03:30 +0100
From: "Newbie" <dlaw001@yahoonospam.co.uk>
Subject: Newbie Help searching for a ^ character ...
Message-Id: <9zHoa.60$Fd1.253149@newsfep2-gui.server.ntli.net>

Hi

Its 2 am on a sunday mourning and I'm not thinking as straight
as I should be .and I can't seem to find my "perl book" ...
What I'm trying to is search a string to see if contains a '^' if so skip
that line and continue reading in the remainder of the lines

ie if the $Line  is ^FT2000 it skips while FT2000 is ok

 if( !( $Line = ?????????? ) ) {
   /* Line does not contain any ^ characters...*/
  .
  .
 }

Any help or pointers would be greatly appreciated...

Thanks
David
ps remove the nospam from my email address...




------------------------------

Date: Sun, 20 Apr 2003 19:11:17 -0500
From: Joe Creaney <mail@annuna.com>
Subject: Passing objects
Message-Id: <3EA33725.6040001@annuna.com>

I am writing a program usng objects written like this:
sub new {
	my ($name, $x, $y, $lv, $xp, $hp, $mhp, $wpn, $armor) = @_;
         my $player = {
		name  => $name,
		x     => $x,
		y     => $y,
		lv    => $lv,
		xp    => $xp,
		hp    => $hp,
		mhp   => $mhp,
		wpn   => $wpn,
		arm   => $armor
		};

          bless $player;
          return $player;
}


$play = new (Bla bla);

They work fine when I send them up to a subroutine but run into problems 
  when I pass them from that routine to another it seems like the values 
don't go with the objects.  Any advice?



------------------------------

Date: Mon, 21 Apr 2003 00:55:18 GMT
From: "Knute Snortum" <knuteNOSPAMPLEASE@trinityproject.org>
Subject: Re: Passing objects
Message-Id: <WjHoa.2771$Df4.3@nwrddc03.gnilink.net>

I may be wrong (I'm still new to OO) but I think $player needs to be global,
that is, declared outside the subroutine.  If you're using strict you will
have use vars to stop warnings about them.

    package Something;

    use strict;
    use vars qw/$player/;

    %player = ();

    sub new {...

Hopefully someone will verify or clarify this.

--
-- Knute Snortum
"Sure, I drink six 8-ounce glasses of water a day.  I just like my water
hot and filtered through ground coffee beans."


"Joe Creaney" <mail@annuna.com> wrote in message
news:3EA33725.6040001@annuna.com...
> I am writing a program usng objects written like this:
> sub new {
> my ($name, $x, $y, $lv, $xp, $hp, $mhp, $wpn, $armor) = @_;
>          my $player = {
> name  => $name,
> x     => $x,
> y     => $y,
> lv    => $lv,
> xp    => $xp,
> hp    => $hp,
> mhp   => $mhp,
> wpn   => $wpn,
> arm   => $armor
> };
>
>           bless $player;
>           return $player;
> }
>
>
> $play = new (Bla bla);
>
> They work fine when I send them up to a subroutine but run into problems
>   when I pass them from that routine to another it seems like the values
> don't go with the objects.  Any advice?
>




------------------------------

Date: Mon, 21 Apr 2003 01:24:34 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Passing objects
Message-Id: <3EA34839.8060709@rochester.rr.com>

Joe Creaney wrote:

> I am writing a program usng objects written like this:
> sub new {
>     my ($name, $x, $y, $lv, $xp, $hp, $mhp, $wpn, $armor) = @_;
>         my $player = {
>         name  => $name,
>         x     => $x,
>         y     => $y,
>         lv    => $lv,
>         xp    => $xp,
>         hp    => $hp,
>         mhp   => $mhp,
>         wpn   => $wpn,
>         arm   => $armor
>         };
> 
>          bless $player;
>          return $player;
> }
> 
> 
> $play = new (Bla bla);
> 
> They work fine when I send them up to a subroutine but run into problems 
>  when I pass them from that routine to another it seems like the values 
> don't go with the objects.  Any advice?
> 

Well, it seems to work fine for me when I pass one of your objects 
through a couple of subs.  Here is example code (yours verbatim except a 
fix to make it pass use strict; , the addition of a couple of package 
statements to make it a touch more realistic, and some test code and subs:

use Data::Dumper;
use strict;
use warnings;
use diagnostics;
package junk;
sub new {
     my ($name, $x, $y, $lv, $xp, $hp, $mhp, $wpn, $armor) = @_;
         my $player = {
         name  => $name,
         x     => $x,
         y     => $y,
         lv    => $lv,
         xp    => $xp,
         hp    => $hp,
         mhp   => $mhp,
         wpn   => $wpn,
         arm   => $armor
         };

          bless $player;
          return $player;
}

package main;
my $play = junk::new (qw(name x y lv xp hp mhp wpn armor));
two($play);

sub two{
	my $p=shift;
	print Dumper($p);
	three($p);
}

sub three{
	my $p=shift;
	print Dumper($p);
}

-- 
Bob Walton



------------------------------

Date: 21 Apr 2003 01:50:18 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: Passing objects
Message-Id: <b7vioq$mhr@dispatch.concentric.net>


"Joe Creaney" <mail@annuna.com> wrote in message
news:3EA33725.6040001@annuna.com...
> I am writing a program usng objects written like this:
> sub new {
> my ($name, $x, $y, $lv, $xp, $hp, $mhp, $wpn, $armor) = @_;
>          my $player = {
[snip definition of hash]
> };
>
>           bless $player;
>           return $player;
> }
> $play = new (Bla bla);
>

What class are you blessing $player into?

Cf.:  perldoc perltoot  # sections 'class interface' and 'planning for the
future: better constructors'




------------------------------

Date: Sun, 20 Apr 2003 13:19:58 -0500
From: "Anthony Saffer" <anthony@nospam.safferconsulting.com>
Subject: Re: Perl & Office
Message-Id: <3ea2e512_1@nntp2.nac.net>


"Stéphane Lepolozec" <s.lepolozec@wanadoo.fr> wrote in message
news:b7u18b$o8l$1@news-reader13.wanadoo.fr...
> Hello,
>
> I seek to create a small utility of documentation allowing to
> know the title, the author and the key words associated documents
> Word, Excel... (Office of Microsoft). These values are accessible
> from file > properties > summary in the various Office
> documents.
> Can one reach these values starting from Perl: I tested
> starting from WIN32::OLE without success.
>
> Thank you for any help:)

IIRC, there is a module on CPAN specifically for parsing Office documents.
Go to http://search.cpan.org and search for it. I think I did a search for
'office' when I found it. Good luck.

Anthony




------------------------------

Date: Mon, 21 Apr 2003 00:33:16 GMT
From: "Knute Snortum" <knuteNOSPAMPLEASE@trinityproject.org>
Subject: Re: Perl source install over redhat rpm
Message-Id: <g%Goa.2768$Df4.183@nwrddc03.gnilink.net>



"Eddy" <eddy@NOSPAMaxa.it> wrote in message
news:b7s9nv$th3$1@lacerta.tiscalinet.it...
> On my RH 6.2 I have tryed to upgrade Perl to 5.8 with source version
>
> It seems that the lib directories have mixed together  with the old rpm
> version from redhat:
>
> /usr/local/lib/perl5/5.8.0/
>
> and
>
> /usr/lib/perl5/5.00503/
> /usr/lib/perl5/site_perl/5.005/i386-linux/
>
> perl -V says:
> @INC:
>     /usr/local/lib/perl5/5.8.0/i686-linux
>     /usr/local/lib/perl5/5.8.0
>     /usr/local/lib/perl5/site_perl/5.8.0/i686-linux
>     /usr/local/lib/perl5/site_perl/5.8.0
>     /usr/local/lib/perl5/site_perl
>
> I have found also that I have multiple copies of perllocal.pod -->
>
> [root@www /]# locate perllocal.pod
> /usr/lib/perl5/5.00503/i386-linux/perllocal.pod
> /usr/lib/perl5/site_perl/5.005/i386-linux/perllocal.pod
> /usr/local/lib/perl5/5.8.0/i686-linux/perllocal.pod
> /usr/local/lib/perl5/site_perl/5.8.0/i686-linux/perllocal.pod
>
> How can I "clean up" everything?
> "rpm -e perl " fails because everything depends on perl,
> if i delete the old /usr/lib/perl5/ some redhat programs stop working,
> please help

The old libraries aren't removed.  What you're describing looks normal to
me.  What specific problems are you having?




------------------------------

Date: Mon, 21 Apr 2003 00:40:35 GMT
From: "Knute Snortum" <knuteNOSPAMPLEASE@trinityproject.org>
Subject: Re: PerlScript, handbook
Message-Id: <76Hoa.2770$Df4.790@nwrddc03.gnilink.net>

http://www.wellho.net/book/0-471-38314-7.html

Found by going to google.com and typing "perlscript book".

--
-- Knute Snortum
"Sure, I drink six 8-ounce glasses of water a day.  I just like my water
hot and filtered through ground coffee beans."


"Stéphane Lepolozec" <s.lepolozec@wanadoo.fr> wrote in message
news:b7u3gc$d8q$1@news-reader13.wanadoo.fr...
> Hello,
>
> I found many references to the use of PerlScript in a Web page,
> and even of the examples, but any handbook of the language which seems
> differed from Perl. Where can one find one of them?
>
> Thank you.
>
>




------------------------------

Date: Mon, 21 Apr 2003 04:03:12 +0200
From: "Stéphane Lepolozec" <s.lepolozec@wanadoo.fr>
Subject: Re: PerlScript, handbook
Message-Id: <b7vjh4$21l$1@news-reader12.wanadoo.fr>

"Knute Snortum" <knuteNOSPAMPLEASE@trinityproject.org> a écrit dans le
message de news: 76Hoa.2770$Df4.790@nwrddc03.gnilink.net...
> http://www.wellho.net/book/0-471-38314-7.html
> Found by going to google.com and typing "perlscript book".

Thank you very much, I thought of it but I did not find anything...
I badly wrote : I seek a free documentation HTML or pdf or TXT or DOC or...
on the Web ;-)
Another idea?




------------------------------

Date: Sun, 20 Apr 2003 16:57:59 -0500
From: "Randy Kobes" <randy@theoryx5.uwinnipeg.ca>
Subject: Re: Please help with HTML::Mason configuration/installation !
Message-Id: <HJEoa.2486$pd6.7171@news1.mts.net>

"Boris Pelakh" <pelakh@yahoo.com> wrote in message
 news:44ec9ada.0304200842.49578078@posting.google.com...
> I am trying to re-install a complete site on a new server. The site was
> written using HTML::Mason by a third party, which is no longer reachable.
> The server is running RedHat 8/Apache 2.0.40 with mod_perl support.
> After installing most of the module requested by the Makefile.PL from
> the Mason bundle, I still get 'need Apache::Request'. That is part of
> libapreq, which requires some parts from mod_perl (Apache/src.pm, etc).
> And that requires the Apache source. Now, I pulled and built the source
> for 2.0.45 (most recent release), but I am very confused as to what my
> next steps should be.
>
> Somehow, I should be able to build mod_perl, pointing it to my new 2.0.45
> Apache sources, then build libapreq, and then complete Mason. However,
> the mod_perl install only wants Apache 1.x.

Apache::Request (part of the libapreq package) hasn't been ported
yet to Apache 2 / mod_perl 2. You'll have to specify 'CGI' for
'args_method' in your Apache mason handler. The mason site,
particularly the mailing list archives, contains some discussion on
this.

best regards,
randy kobes





------------------------------

Date: Sun, 20 Apr 2003 23:46:37 +0200
From: "Cecil Westerhoff" <cwesterh@wanadoo.nl>
Subject: Problem with paths in RedHat 8.0
Message-Id: <pan.2003.04.20.21.46.37.48417@wanadoo.nl>

In the past I worked with SuSE. But my new hardware has problems with 
SuSE, so I am using RedHat 8.0 now. But now I can not use 
  perl -MCPANPLUS -eshelll
It looks like the Paths are not correctly set in RedHat 8.0.
Anyone an idea what I need to do?



------------------------------

Date: Sun, 20 Apr 2003 17:18:47 -0600
From: Ron Reidy <rereidy@indra.com>
Subject: Re: Problem with paths in RedHat 8.0
Message-Id: <3EA32AD7.5080403@indra.com>

What does "...it lokks like Paths are not correctly set ..." mean?  How 
about posting the output of:

1.  perl -v
2.  perl -MCPLANPLUS -e '0'

And telling us what you are expecting, what you are getting, etc.

--
Ron Reidy
Oracle DBA

Cecil Westerhoff wrote:
> In the past I worked with SuSE. But my new hardware has problems with 
> SuSE, so I am using RedHat 8.0 now. But now I can not use 
>   perl -MCPANPLUS -eshelll
> It looks like the Paths are not correctly set in RedHat 8.0.
> Anyone an idea what I need to do?
> 



------------------------------

Date: Mon, 21 Apr 2003 00:36:26 GMT
From: "Knute Snortum" <knuteNOSPAMPLEASE@trinityproject.org>
Subject: Re: Q.  Basic Perl Tutorial ? (for a not-so-bright newbie)
Message-Id: <e2Hoa.2769$Df4.1671@nwrddc03.gnilink.net>

http://www.oreilly.com/catalog/lperl3/

--
-- Knute Snortum
"Sure, I drink six 8-ounce glasses of water a day.  I just like my water
hot and filtered through ground coffee beans."


"Jim" <harley.davidsno@mailcity.com> wrote in message
news:3ea00459.412284@nntp.ix.netcom.com...
> Hi.
>
> I want to get into Perl. It seems no matter what book I pick up these
> days, on whatever subject, that it is written for people who already
> know the subject.
>
> What I want to do is is use Perl to make my own:
> Page counters and Message boards (with the reply option).
> Or at least to copy them, and place them where they need to be and
> then to link to properly link to them, from my own web pages.
>
> Can you recommend a study source which gives me the not only the basic
> Perl commands/usage, but also does an excellent job illustrating the
> big picture?
>
> I have the Internet web host I've always used, which doesn't allow
> Perl or CGI. BUt I understand there are sites out there which I can
> sign up with, which do allow it.
>
> One question for now:  If I want to use my own written Perl script,
> can I have it on a separate site and simply link to it, or does the
> CGI-BIN, and so on need to be on the same server as my own pages ?
>
> Thanks,
>
> Jim




------------------------------

Date: Sun, 20 Apr 2003 19:53:38 GMT
From: harley.davidsno@mailcity.com (Jim)
Subject: Q. Does ActivePerl for Windows require Apache to be installed ?
Message-Id: <3ea2fa90.288466@nntp.ix.netcom.com>

Can anyone help?
Thanks,
Jim


------------------------------

Date: Sun, 20 Apr 2003 21:33:34 +0100
From: David Dorward <dorward@yahoo.com>
Subject: Re: Q. Does ActivePerl for Windows require Apache to be installed ?
Message-Id: <b7v0c0$jne$2$8300dec7@news.demon.co.uk>

Jim wrote:

> Can anyone help?

With what?

Oh, for some reason you didn't bother putting your question in the body of
the message.

> Does ActivePerl for Windows require Apache to be installed ?

No, it doesn't.

-- 
David Dorward                                   http://david.us-lot.org/
"You cannot rewrite history, not one line."
                                      - The Doctor (Dr. Who: The Aztecs)


------------------------------

Date: Sun, 20 Apr 2003 17:42:48 GMT
From: harley.davidson@mailcity.com (Jim Jones)
Subject: Re: Q. Does ActivePerl for Windows require Apache to be installed ?
Message-Id: <3ea2dbe8.10365104@nntp.ix.netcom.com>

On Sun, 20 Apr 2003 21:33:34 +0100, David Dorward <dorward@yahoo.com>
wrote:

>Jim wrote:
>
>> Can anyone help?
>
>With what?
>
>Oh, for some reason you didn't bother putting your question in the body of
>the message.
>
>> Does ActivePerl for Windows require Apache to be installed ?
>
>No, it doesn't.

Thank you very much for your help. I sure wish that the ActiveState
site mentioned that little fact which has had me confused all day.
I sure am glad for these types of groups.
>
>-- 
>David Dorward                                   http://david.us-lot.org/
>"You cannot rewrite history, not one line."
>                                      - The Doctor (Dr. Who: The Aztecs)



------------------------------

Date: Sun, 20 Apr 2003 18:45:31 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Q. Does ActivePerl for Windows require Apache to be installed ?
Message-Id: <slrnba6c8r.lgm.tadmc@magna.augustmail.com>

Jim <harley.davidsno@mailcity.com> wrote:

> Subject: Q. Does ActivePerl for Windows require Apache to be installed ?


No.


Perl is not CGI.

CGI is not Perl.

You only need a web server if you want to do web stuff.

You can do plenty of non-web stuff with Perl, no need for a web server.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Mon, 21 Apr 2003 02:49:45 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Q. Does ActivePerl for Windows require Apache to be installed ?
Message-Id: <d%Ioa.11163$yO5.2497@nwrddc02.gnilink.net>

Jim wrote:
[Does ActivePerl for Windows require Apache to be installed ?]
> Can anyone help?

Of course not.
Why would you possibly think it would?

jue




------------------------------

Date: Sun, 20 Apr 2003 14:17:16 -0700
From: JS Bangs <jaspax@u.washington.edu>
Subject: Re: Recusively search directory...
Message-Id: <Pine.A41.4.53.0304201411540.106582@dante18.u.washington.edu>

Kasp sikyal:

> Is there a way to specify a filter for the file to be searched?
> For eg *.txt, *.html ?

Yes, quite easily. Following the example given by an earlier poster:

#!perl
use warnings;
use strict;
use File::Find;

my @dirs = qw(dir1 /dir2/foo dir3/bar);
find \&wanted, @dirs;

sub wanted
{
 return if not -f; # Only returns regular files
 return unless /\.txt$/ # Only allows files that end in .txt
 print "$File::Find::name\n";
 # Do something else here . . .
}
# End example

Any filters or conditions you want to put on the file should be given in
the &wanted subroutine. You can use a regex on the filename (as here), or
test filesize, or anything you want. Check the CPAN docs or perl POD's for
more explicit information on using File::Find.



Jesse S. Bangs jaspax@u.washington.edu
http://students.washington.edu/jaspax/
http://students.washington.edu/jaspax/blog

Jesus asked them, "Who do you say that I am?"

And they answered, "You are the eschatological manifestation of the ground
of our being, the kerygma in which we find the ultimate meaning of our
interpersonal relationship."

And Jesus said, "What?"


------------------------------

Date: Sun, 20 Apr 2003 15:17:06 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Recusively search directory...
Message-Id: <slrnba6022.ktj.tadmc@magna.augustmail.com>

Kasp <kasp@epatra.com> wrote:

> Is there a way to specify a filter for the file to be searched?
> For eg *.txt, *.html ?


Yes, but you did not quote the code, so we cannot show you
how to modify the code...


Here is Helgi's code:

> sub wanted
> {
>  return if not -f;


   return unless /\.(txt|html)$/; # process only .txt and .html files


>  print "$File::Find::name\n";
> }



-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Sun, 20 Apr 2003 11:51:32 -0700
From: "Rong" <m9l3@interchange.ubc.ca>
Subject: regexp match problem
Message-Id: <1050864679.147700@texada.ugrad.cs.ubc.ca>

Maybe I have a little misunderstanding about regular expresson.
I just wonder why /.[^w].?/ can match "two".
It seems that I have specified the second character not to be w.




------------------------------

Date: Sun, 20 Apr 2003 14:02:54 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: regexp match problem
Message-Id: <87k7dpf0v5.fsf@limey.hpcc.uh.edu>

>> On Sun, 20 Apr 2003 11:51:32 -0700,
>> "Rong" <m9l3@interchange.ubc.ca> said:

> Maybe I have a little misunderstanding about regular
> expresson.  I just wonder why /.[^w].?/ can match "two".
> It seems that I have specified the second character not
> to be w.

You haven't anchored the regexp.  Therefore it can match
anywhere in the input space:

    .    -> 'w'
    [^w] -> 'o'
    .?   -> <empty>

/^.[^w].?/ on the other hand (with the initial caret),
would force the pattern to start at the beginning of the
input space.

hth
t


------------------------------

Date: Sun, 20 Apr 2003 21:32:38 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Trouble with LWP
Message-Id: <3EA311DF.2020406@rochester.rr.com>

Kasp wrote:

 ...
> Here is the code:
> 
> use LWP::Simple;
>  getstore('http://www.perl.com/graphics/ora_logo.gif','ora_logo.gif');
> 
> When I run this code, it gives me error:
 ...


It works fine if you specify a URL that actually exists, like perhaps:

    http://www.perl.com/images/75-logo.jpg

If you tested the return code from getstore, you would be informed of 
such failures.  I tested your code on AS Perl 5.8.0 build 805 on Windoze 
98SE.
-- 
Bob Walton



------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 4868
***************************************


home help back first fref pref prev next nref lref last post