[7635] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1261 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Nov 2 12:07:12 1997

Date: Sun, 2 Nov 97 09:00:23 -0800
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, 2 Nov 1997     Volume: 8 Number: 1261

Today's topics:
     Re: "Modulus zero" error weirdness? (Tushar Samant)
     Re: again -- multi-line minimal match text replacement <rootbeer@teleport.com>
     Re: Annoying syntax Q ... <rootbeer@teleport.com>
     Re: Annoying syntax Q ... (Tad McClellan)
     Re: Bug in Perl 5 'chr' <rootbeer@teleport.com>
     Re: BUG in WinPerl; OK in Unix Perl (Tye McQueen)
     Re: Children only inherit redirects if use system "perl (Tye McQueen)
     Re: Displaying Atomic Clock time?? <rootbeer@teleport.com>
     Re: form to return answers? <rootbeer@teleport.com>
     Free for alls submission script <webmaster@dmedia.net>
     Re: How to send keystrokes from Perl to Win95 app (Tye McQueen)
     Re: Memory problems - how can I fix? <rootbeer@teleport.com>
     Re: Newbie needs some help ... PLEASE! (Tad McClellan)
     Re: Novell and CGI <rootbeer@teleport.com>
     Re: Perl for NT and ARGV parameters (Tye McQueen)
     Problems with unshift  and @LoL <Koos_Pol@bigfoot.com>
     Re: Regex: finding the n'th pattern in a string. Global <rootbeer@teleport.com>
     Re: transpose file <rootbeer@teleport.com>
     Re: Warning when starting perl. What is it ? <jhi@alpha.hut.fi>
     Re: What to do with Bitwise operators? <Steinar.Kleven@ahs.hist.no>
     Re: What to do with Bitwise operators? (Tad McClellan)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 2 Nov 1997 10:20:24 -0600
From: scribble@shoga.wwa.com (Tushar Samant)
Subject: Re: "Modulus zero" error weirdness?
Message-Id: <63i988$mtm@shoga.wwa.com>

ahecker@interport.net writes:
>devise a divison problem that isn't too complicated. I don't qant for
>example, to have someone figure out 95 / 8. So, I needed a method to
>ensure that the numbers that are divided are whole numbers & there's no
>remainder to fiddle with.

Then generate integers to start with, and multiply them:

	($first, $second) = (1 + int rand $level, 1 + int rand $level);
	$second *= $first;



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

Date: Sun, 2 Nov 1997 08:11:29 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Dave Kaufman <davidk@nospam.cnct.com>
Subject: Re: again -- multi-line minimal match text replacement
Message-Id: <Pine.GSO.3.96.971102081032.7851L-100000@usertest.teleport.com>

On Sat, 1 Nov 1997, Dave Kaufman wrote:

> s/(STARTSTRING.*ENDSTRING)?/replace string/s;  #should match startstring up
> to the FIRST endstring

I think you want the pattern to be this, instead.

    STARTSTRING.*?ENDSTRING

Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Sun, 2 Nov 1997 08:09:26 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: "Richard G. Roberto" <robertor@typhoon.co.jp>
Subject: Re: Annoying syntax Q ...
Message-Id: <Pine.GSO.3.96.971102075248.7851K-100000@usertest.teleport.com>

On Sat, 1 Nov 1997, Richard G. Roberto wrote:

> Why do so many perl modules, etc. use qw(list) instead of (list)?  E.g.
> isn't @subs=qw(FirstSub SecondSub ThirdSub) the same as
> @subs=(FirstSub,SecondSub,ThirdSub) ? 

Actually, there's a big difference. Consider this:

    @months = 	(jan, feb, mar, apr, may, jun,
		 jul, aug, sep, oct, nov, dec);

Do you see the subtle bug? (I'll leave this as a puzzle for the benefit of
the readers who like puzzles. If the answer isn't obvious after printing
"@months\n", look for the appropriate entry in the perlfunc manpage.)

This is why "use strict qw(subs)" was developed - because barewords may
mean either the obvious string or a keyword or a sub. And new keywords and
subs may be added at a later date! So, instead of saying

    @subs = (FirstSub,SecondSub,ThirdSub);		# Bad

Under that stricture, you have to say something like this:

    @subs = ("FirstSub", "SecondSub", "ThirdSub");

But nobody liked typing all those commas and quote marks. So the qw//
syntax was added to Perl, allowing you to write this simpler form.

    @subs = qw{ FirstSub SecondSub ThirdSub };

So now for the other question: Why did I write "use strict qw(subs)" 
above instead of "use strict 'subs'", since the second accomplishes the
same thing? The reason is that it's become a tradition to write parameters
to modules using qw// syntax because items may be added and deleted from
that syntax more easily. So, it's actually more convenient to use qw//
whenever you expect to be adding barewords to the list, or deleting them
from it. 

    use someModule qw/ FirstSub /;

Now, if we need SecondSub and ThirdSub, they are easy to add. 

Have fun with it!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Sun, 2 Nov 1997 09:37:34 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Annoying syntax Q ...
Message-Id: <un6i36.rt5.ln@localhost>

Richard G. Roberto (robertor@typhoon.co.jp) wrote:
: I just checked the FAQ and this isn't in there.  I've looked
: everywhere I could think of (camel book, FAQ, perl.com) but
: I can't find an answer to this question.  

Thank you, everyone on the newsgroup appreciates that.


But I don't see "man pages" in your list there.

These are the *.pod files that are included with the perl distribution.

They are the *first* place you should look, even before the FAQ or Camel.
(they include the FAQ too, starting at v5.004)


'perlop' and 'perldata' have parts germane to your question. See below.


: Forgive me if this
: seems silly, but what's the difference between using qw and
: not using it?  

You don't really have an "Annoying syntax Q" here. 

You have a "Don't understand the different *semantics* (ie. 'meaning')" 
question  ;-)

ie. They mean different things. They arrive in the same place with
    your particular examples, but they get there via different routes  ;-)
    There are plenty of ways where they lead to different places, as
    Aaron showed in his followup.


: The camel book suggests its just another way
: to specify a list without list delimters.  

That's pretty much it then. However, finding out what Perl folks mean
when they say LIST will explain what is meant by the NON-qw() part of
your example.

>From the 'perldata' man page:

---------------------------
=head2 List value constructors

List values are denoted by separating individual values by commas
(and enclosing the list in parentheses where precedence requires it):

    (LIST)
 ...
---------------------------

So, (FirstSub,SecondSub,ThirdSub) is one of these 'list values'.
     ^^^^^^^^ ^^^^^^^^^ ^^^^^^^^

Those are 'barewords'. Perl will complain about those if you 

   use strict;    # which you should use on nearly every script...

(unless they are the names of subroutines that perl can find the
 declaration for)



perl must come up with a 'value' for each comma-separated element
in the list.

if (an element is a bareword)
   if (the word is the name of a subroutine)
      value = return value from *calling* the subroutine
   else
      value = bareword interpreted as a string
      also issue a warning if use strict is in effect


: If that's the
: case, why bother?  

Because they *mean* different things.

At this point, we know what one of them means (value is either a string
or the return value from some subroutine).


: Why do so many perl modules, etc. use
: qw(list) instead of (list)?  E.g. isn't 
: @subs=qw(FirstSub SecondSub ThirdSub) the same as
: @subs=(FirstSub,SecondSub,ThirdSub) ?

Let's find out what the other one means.

>From the 'perlop' man page:

---------------------------
=item qw/STRING/

Returns a list of the words extracted out of STRING, using embedded
whitespace as the word delimiters.  It is exactly equivalent to

    split(' ', q/STRING/);
 ...
---------------------------

So, qw(FirstSub SecondSub ThirdSub) also returns a LIST, but it
determines what values to put in the list differently than
the non-qw() example.

   split(' ', 'FirstSub SecondSub ThirdSub'); # equivalent to example
                                              # no subroutines get called...

[
  Note that the parenthesis mean different things in your examples.

  qw(FirstSub SecondSub ThirdSub) here they are simply string delimiters.
  qw/FirstSub SecondSub ThirdSub/
  qw{FirstSub SecondSub ThirdSub}

  are all equivalent ways of getting the same semantics, by using
  alternate string delimiters.


  (FirstSub,SecondSub,ThirdSub) here they are a 'list value constructor'
]


: And what's the use of having just @subs=qw(oneSub) instead

@subs gets a list of subroutine _names_


: of @sub=oneSub or @sub=(oneSub) ?

@sub gets whatever is returned from a *call* (execution) of the named
subroutine (not what we want for your particular examples where
they are indeed subroutine names in the module)


: Again, sorry for the relatively stupind question since this
: neither fixes nor breaks anything I'm writing.  I'm just
                ^^^^^^^^^^

Gak! You should 'use strict' on production scripts.

Really.

Eat those "vegetables" because they are Good For You   ;-)


: really curious.  I feel like the rest of the world knows
: what's up with this, but I'm still in the dark.


This question pulls together several disparate parts of perl's
syntax and the semantics associated with that syntax.

I don't think a simple check of one place in the docs could explain
all of that...


: Enlightenment is welcome ;)

Hope you got some ;-)


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: Sun, 2 Nov 1997 08:37:43 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Ulrich Ludwig <100675.2064@CompuServe.COM>
Subject: Re: Bug in Perl 5 'chr'
Message-Id: <Pine.GSO.3.96.971102082923.7851O-100000@usertest.teleport.com>

On Fri, 31 Oct 1997, Ulrich Ludwig wrote:

> there seems to be abug in GNU Perl 5.0004 for WIN@*# 32.
> The 'chr'-function is not implemented, 

(You must mean 5.004, right?) It's really not implemented? I don't have a
Win32 machine handy, but that's an amazingly obvious bug. (It's even
tested for in t/op/ord.t, so I don't see how the porters could have missed
it.) Does this give an error from the command line? (Maybe it does because
I've forgotten something about Win32 shell quoting... :-) 

    perl -e "print map(chr, 0x4f, 0x4b), $/" 

Well, if it's really a bug, file a bug report as described in the docs
which should have come with your distribution. Thanks!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: 2 Nov 1997 01:00:19 -0600
From: tyde@medtrodnet.cdom (Tye McQueen)
Subject: Re: BUG in WinPerl; OK in Unix Perl
Message-Id: <63h8e3$l5g@fiinix.metronet.com>

Pierre Fortin <pfortin@cisco.com> writes:
) There is a bug in WinPerl wherein a file which contains 0x1A can't be
) read past that point...

No, same thing happens in C and with "COPY".  Not a Perl problem.
Just use binmode(FILE_HANDLE) before your read/write from/to the
file the first time.  binmode() should work under Unix as well
and is needed for other non-Unix environments as well.
--
Tye McQueen    Nothing is obvious unless you are overlooking something
         http://www.metronet.com/~tye/ (scripts, links, nothing fancy)
       Remove d's from address to reply (sorry for the inconvenience).


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

Date: 2 Nov 1997 01:16:05 -0600
From: tyde@medtrodnet.cdom (Tye McQueen)
Subject: Re: Children only inherit redirects if use system "perl": should be NT FAQ!
Message-Id: <63h9bl$nuh@fiinix.metronet.com>

Dan Harkless <dan_oct97@unitech.com> writes:
) 
) I guess what should be a FAQ is that you can't expect output redirection
) to work properly with versions of the standard Perl distribution built
) under Windows. The ActiveWare port, on the other hand, works properly.

So, with the ActiveWare port, does this work:

    scriptname.pl <input >output

I thought it didn't.
--
Tye McQueen    Nothing is obvious unless you are overlooking something
         http://www.metronet.com/~tye/ (scripts, links, nothing fancy)
       Remove d's from address to reply (sorry for the inconvenience).


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

Date: Sun, 2 Nov 1997 08:41:50 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Brett <moggy@lisp.com.au>
Subject: Re: Displaying Atomic Clock time??
Message-Id: <Pine.GSO.3.96.971102083814.7851P-100000@usertest.teleport.com>

On 31 Oct 1997, Brett wrote:

> The reason I ask this is because of a page I am creating which needs the
> viewers to see the same time (ie, not what you're computer is set to). 
> This is primarily for online auctions, so that when an auction is about to
> close in say 10 mins, the client knows that it IS 10 mins and not 20 mins
> away from closing.

You can always calculate the difference in times and simply say "At the
time this page was generated (Sun Nov  2 16:39:24 1997 UCT) the auction
will close in approximately 20 minutes." There are several (some would say
too many) date modules available on CPAN, although the standard functions
listed in the perlfunc manpage may suffice for your needs. Good luck! 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Sun, 2 Nov 1997 08:43:41 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Rick <ricklarson@pacificcoast.net>
Subject: Re: form to return answers?
Message-Id: <Pine.GSO.3.96.971102084229.7851Q-100000@usertest.teleport.com>

On 2 Nov 1997, Rick wrote:

> Need to get a start for a form that will returm answers to math
> questions. ie: user will enter a few numbers.....form or whatever
> returns a value.

That's easy to do in Perl. You may use the CGI.pm module to make it easier
to write. Good luck with it!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Sun, 02 Nov 1997 14:28:08 +0200
From: Aitor <webmaster@dmedia.net>
Subject: Free for alls submission script
Message-Id: <345C71D9.4E8C9CE0@dmedia.net>

Hi,

Is there any free or shareware script to submit a page to various free for all pages?

Or suggestions about how may I program it? (not expert in perl)

I want the script only for FFA pages not needed for directories or search engines.

Any idea?


Thanx in advance.

Aitor


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

Date: 2 Nov 1997 01:08:23 -0600
From: tyde@medtrodnet.cdom (Tye McQueen)
Subject: Re: How to send keystrokes from Perl to Win95 app
Message-Id: <63h8t7$mbh@fiinix.metronet.com>

) >On 27 Oct 1997, L. Dwynn Lafleur wrote:
) >> Is it possible to send keystrokes from a running Perl script to a Win95
) >> application that the script has opened?  For example, from a Perl
) >> script, can I open Notepad and then issue a command in the script to
) >> insert a text string into the Notepad document? 

It can be easy, but only if it is a "console" application.

I _have_ done it quite a bit for other things, like Notepad.
It isn't really in a state that is ready for the world, yet.
But I do have "fakey.pl" that lets you fake keystrokes to
windows applications.

It requires just a couple of routines via an *.xs module, which I
plan to make available nicely via a Win32API::Message module.  In
the mean time, I use a quick-and-dirty Win32::Misc module that
just has poor access to just the few routines I need.

If you are in a desparate hurry, and willing to figure it out
yourself, then I can give you a copy.  But don't ask if you won't
be able to deal with it yourself.
--
Tye McQueen    Nothing is obvious unless you are overlooking something
         http://www.metronet.com/~tye/ (scripts, links, nothing fancy)
       Remove d's from address to reply (sorry for the inconvenience).


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

Date: Sun, 2 Nov 1997 08:29:08 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: "M.J.T. Guy" <mjtg@cus.cam.ac.uk>
Subject: Re: Memory problems - how can I fix?
Message-Id: <Pine.GSO.3.96.971102081441.7851N-100000@usertest.teleport.com>

On 1 Nov 1997, M.J.T. Guy wrote:

> i)   each element of the 1..100000 array is taking nearly 100 bytes.
>      I know Perl is prodigal with memory, but this seems excessive.

Patches are welcome. :-)

Actually, on the to-do list is the plan to change the implementation of
'for (1..100_000)' to not generate the list. 

> ii)  With the foreach, the test took 28 secs on my aging system.   The
>      for version took 38 secs.    Conventional wisdom seems to have it
>      that the C-style for is the fastest form of loop, but it appears
>      not to be true here.

Well, the conventional wisdom is based upon the fact that malloc'ing the
memory needed to hold the 100_000-element list can take a sizeable amount
of time. But once the list is generated, it seems that it may be faster to
iterate over it than to use a C-style three-part for loop. 

Nevertheless, the C-style loop should probably be optimized internally if
it's taking that long. Patches are welcome. :-) 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Sun, 2 Nov 1997 10:26:12 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Newbie needs some help ... PLEASE!
Message-Id: <4j9i36.r26.ln@localhost>

Richard Bermudez (ghostcat@brokersys.com) wrote:
: First, a bit of background is in order: my linux server (2.0.29) was
: configured by my ISP, who no longer has time to provide me with support.
                            ^^^^^^^^^^^^^^^^^^

 ... and therefore no longer collects fees from you, right?

(if not, I'd just go find a different ISP  ;-)


[ snip description of server setup ]

: So, I downloaded Perl5.004_04 (which I discovered by reading this group)
: and went through the install procedure. I'm assuming it went correctly
: since I saw no errors during the process. However, I know next to
: nothing about linux administration and I hadn't worked on a UNIX system
: in 8 years (and that as a C programmer and not as a sysadmin) prior to
: attempting to fix this myself, so the miniscule amount I know I've
: picked up in just the past few days.


If you "saw no errors" then it probably really did go right.


: On to my problem: I get the following message when I try to run any Perl
: script from a command prompt:

:     Illegal character \015 (carriage return) at brochure.pl line 14.
:     (Maybe you didn't strip carriage returns after a network transfer?)


The perldiag man page (included with the perl distribution) describes
the messages that perl might issue. You should always look them up
there if you don't know immediately what they mean.


-------------------
=item Illegal character %s (carriage return)

(F) A carriage return character was found in the input.  This is an
error, and not a warning, because carriage return characters can break
multi-line strings, including here documents (e.g., C<print E<lt>E<lt>EOF;>).

Under Unix, this error is usually caused by executing Perl code --
either the main program, a module, or an eval'd string -- that was
transferred over a network connection from a non-Unix system without
properly converting the text file format.

Under systems that use something other than '\n' to delimit lines of
text, this error can also be caused by reading Perl code from a file
handle that is in binary mode (as set by the C<binmode> operator).

In either case, the Perl code in question will probably need to be
converted with something like C<s/\x0D\x0A?/\n/g> before it can be
executed.
-------------------



: I get that, using both 5.004_01 and _04 on scripts that previously ran
: just fine 


The fact that they ran just fine might have been an accident. 

You have a potential bug that newer versions of perl know to recognize
(and mention, and even refuse to continue compilation).


: from a command line using the older 5.001 version (which I
: still have, even though it suffers from the problems mentioned at the
: top of this post).

: Naturally, in the process of trying to fix one problem I've obviously
: created another. I suspect I've done something wrong in the Q&A during
  ^^^^^^^^^^^^^^^

It was already there. You have just "exposed another" that was there
all along...


: install, or have forgotten to specify something in a config file
: somewhere. But I'm clueless as to what's wrong, where, why, much less
: how to fix it.


Somewhere along the line, you probably ftp'ed stuff between a MS box
and a Unix one in binary mode. If you ftp in ASCII mode, it will convert
line endings for you.

To fix the ones you have, just do what the perldiag man page suggests:

  s/\x0D\x0A?/\n/g;

on each file. (might want to use the -i and -p switches, documented in
                the perlrun man page)


: Will someone please take a bit of pity on this poor, ignorant fellow and
: help remove the veil of ignorance under which I suffer?  :)


So, the good news is that your installation of 5.004 is (likely) not 
the problem, it just exposes a potential problem that you didn't 
even know about.


: Any help is appreciated. Thanks.

Hope that did!


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: Sun, 2 Nov 1997 08:14:13 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Jim Fuhring <jfuhring@platinum.com>
Subject: Re: Novell and CGI
Message-Id: <Pine.GSO.3.96.971102081333.7851M-100000@usertest.teleport.com>

On Fri, 31 Oct 1997, Jim Fuhring wrote:

> Does anyone know how to set up a Novell Web Server?

I'm sure somebody does - and that person is probably ready to answer your
questions, if you ask them in a newsgroup about webservers. :-)  Good
luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: 2 Nov 1997 01:14:05 -0600
From: tyde@medtrodnet.cdom (Tye McQueen)
Subject: Re: Perl for NT and ARGV parameters
Message-Id: <63h97t$nd6@fiinix.metronet.com>

) Mark Nielsen wrote in article <6384bn$r56$1@auto.med.ohio-state.edu>...
) >I usually Execute a perl script in a batch file or command like
) >perl MyPerlScripts.pl $Argv1 $Argv2
) >
) >It always works for me.

"Allen Evenson" <ase@seanet.com> writes:
) while I do this too I have run up against a problem. Suppose your using
) the standard
) 
) @rem =3D '--*-Perl-*--
) @echo off
) perl -x -S %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
) goto endofperl
) @rem ';
) #!perl -w
) #line 8
) 
) generated by pl2bat.bat script supplied with win/dos perl distributions.
) 
) if you supply less than 9 arguments and want to pipe or redirect output.
) the msdos "shell" (if you can call it that) sucks up the redirection
) and/or piping and sends them to the perl interpreter.

Have you tried:

    perl -x -S %0 %*

It seems to work better under Windows NT but I don't know if it
work prior to that.
--
Tye McQueen    Nothing is obvious unless you are overlooking something
         http://www.metronet.com/~tye/ (scripts, links, nothing fancy)
       Remove d's from address to reply (sorry for the inconvenience).


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

Date: Sun, 02 Nov 1997 11:37:45 -0100
From: Koos Pol <Koos_Pol@bigfoot.com>
Subject: Problems with unshift  and @LoL
Message-Id: <345C7419.729@bigfoot.com>

(quotes and punctutation removed for simplicity)

I have some problems with unshift-ing an array, as I have the array
reference but not the array itself:

@LoL  = ( [a,b,c] , [1,2,3] , [yes,no,maybe] )
$aref = $LoL->[0]

If I pass $aref to a function, how can I unshift the array -[a,b,c]- ?
If I unshift($aref,(0,0,0,0)) I get a warning for using an array element
i.s.o an array.
In other words, how do I get from $aref to the full array ?


Koos Pol
Koos_Pol@bigfoot.com


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

Date: Sun, 2 Nov 1997 07:51:39 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: gtuckerkellogg@genetics.com
Subject: Re: Regex: finding the n'th pattern in a string. Global matching using while and foreach
Message-Id: <Pine.GSO.3.96.971102074839.7851J-100000@usertest.teleport.com>

On Fri, 31 Oct 1997 gtuckerkellogg@genetics.com wrote:

> but when I paste the *exact* code into a CGI script,

Perl (and the regular expression engine) don't know or care whether your
script is a CGI script. My guess is that your server is running a
different version of Perl than you are. (Examine $] to find out.) If
that's not it, my next guess is that one of the two binaries is
miscompiled, or somehow you have different data in one or the other. If
you're convinced that none of these can be the case, and if you're running
the most recent version of Perl, use perlbug to file a bug report. Thanks!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Sun, 2 Nov 1997 08:44:55 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: chk@rrz.Uni-Koeln.DE
Subject: Re: transpose file
Message-Id: <Pine.GSO.3.96.971102084402.7851R-100000@usertest.teleport.com>

On Sun, 2 Nov 1997 chk@rrz.Uni-Koeln.DE wrote:

> what would be the most memory-efficient
> way to read each row from one file and write
> these rows as the columns of an output file?

Probably it would be most memory-efficient to read and write them one item
at a time, but that may be terribly slow. :-)

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: 02 Nov 1997 16:50:42 +0200
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: Warning when starting perl. What is it ?
Message-Id: <oeeyb37fiyl.fsf@alpha.hut.fi>


PBUhauck@t-online.de (Uwe Hauck) writes:

> 
>     Everytime I start perl on my account i get the following error
> message:
> warning:setlocale(LC_TYPE,"") failed.
> warning: LC_ALL = "(null)", LC_TYPE = "(null)", LANG = "De_DE.ASCII",
> warning: falling back to the "C" local.
> 
> How can I get rid of that. It disturbs some pages on my Web Server wich
> is administrated
> by another department in our company. Asked the sysop of the system but
> he has no idea.

Getting rid of it is possible but do you really want that?  It means
that Perl is trying to tell you that you have a system configuration
problem: your locale environment is somehow broken.  Your LANG is set
but when Perl tries to believe you, it cannot.  The perllocale man
page tells the whole story, for example why this warning happens and
how to silence this warning.

-- 
$jhi++; # http://www.iki.fi/~jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen


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

Date: Sun, 02 Nov 1997 17:58:18 +0100
From: Steinar Kleven <Steinar.Kleven@ahs.hist.no>
To: tmalloy@boley.escape.com
Subject: Re: What to do with Bitwise operators?
Message-Id: <345CB12A.86BA8083@ahs.hist.no>

Hi

If you don't need then you can ignore them or?.

Bitwise operators are often used with numbers as flags.
ex:
A object can be in sveral 'states'. Just one, 2 or 5 or ...
Then you can set this number to mask the bits for the state
in question.
For a 16 bit number you can have 16 states or ANY combination
of the states. You can figure out the total number of combinations
yourself. 

tmalloy@boley.escape.com wrote:
> 
> Hi.  First, I am beginner just learning perl.  Can someone provide
>  an explaination of the practical use of bitwise operators.
>  ( &, |, ^, ~, <<,>>)


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

Date: Sun, 2 Nov 1997 10:03:38 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: What to do with Bitwise operators?
Message-Id: <q88i36.816.ln@localhost>

tmalloy@boley.escape.com wrote:
: Hi.  First, I am beginner just learning perl.  Can someone provide
:  an explaination of the practical use of bitwise operators.
:  ( &, |, ^, ~, <<,>>)
: Please note that I am not asking for an explaination of what the operators
:  do.  I can read.  
        ^^^^^^^^^^

Most excellent! 

You can probably figure out most of how to use Perl effectively then.

[ just a poke at the 'read the docs for me' type of article that often
  makes it way here. Not a poke at you  ;-)
]


: It is just difficult for me to envision any practical
:  use for them. In what situation might I need to use them  They must have
:  some utility.  I just don't see it. I would like to understand.

OK. So the question here is really "when is a bit string an appropriate
data structure to use?"  ??

It depends  ;-)

Usually when you are either 
   1) manipulating binary data, or
   2) storing a bunch of Boolean (true/false) values


: Perhaps I could be referred to some example code. 


Sure, here are a couple of semi-common uses:

1)
If you want to get the return value from a program called via system(),
you need to shift system()'s return value by eight bits (same as divide
by 256 decimal):

   $return_value = system("cat foobar") >> 8;

2)
Many Unixy things have switches whose state is determined by a single
bit (so in decimal, they are all powers of two)

You can use the bitwise operators to combine the individual switches
into a composite bit vector:

For flock(), LOCK_EX (exclusive lock) is often 10 (2 decimal), and
             LOCK_NB (non blocking) is often 100 (4 decimal)

if you wanted to get a non-blocking exclusive lock, you would use:

   LOCK_EX | LOCK_NB

to get a 00000110 bit vector for the OPERATION argument to flock()


:  Thank you for any assistance.

Hope that helped!


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 1261
**************************************

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