[10667] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4259 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 19 21:07:31 1998

Date: Thu, 19 Nov 98 18:00:24 -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           Thu, 19 Nov 1998     Volume: 8 Number: 4259

Today's topics:
    Re: Calling functions from a hash <bruce.w.mohler@saic.com>
    Re: Calling functions from a hash <bruce.w.mohler@saic.com>
    Re: Cutting down refering URL to 30 symbols? (Craig Berry)
    Re: get unixtime from year and yday (Martien Verbruggen)
        Help with curses (James S. White)
    Re: Help with curses (Erik)
    Re: HELP: how to prompt for input from command line? (Larry Rosler)
    Re: How do i trim a string in Perl?? (Martien Verbruggen)
    Re: How to access a file within a perl program <sasho@staff.mgu.bg>
    Re: How to access a file within a perl program (Tad McClellan)
    Re: how to execute (Martien Verbruggen)
    Re: How to solve this problem? mwwenzel@my-dejanews.com
    Re: How to solve this problem? (Tad McClellan)
    Re: installing ParseLex on NT <sgordon@kenan.com>
        manipulating the last few lines of file efficiently? <wangc@std.teradyne.com>
    Re: number of elements in an array (Matthew Bafford)
    Re: number of elements in an array (Craig Berry)
    Re: perl documentation date (Martien Verbruggen)
    Re: perl/win95 <mendrak@worldnet.att.net>
        Problems building DB_File 1.52 elvis@NOTGRACELANDclark.net
        Promote a TIEREF to hash.... <lordvorp@usa.net>
        Regex-ing an entire file: How to? <webmaster@topproducer.com>
    Re: Regex-ing an entire file: How to? (Erik)
    Re: Regex-ing an entire file: How to? (Tad McClellan)
    Re: Smarter Web Mailer (Martien Verbruggen)
    Re: Smarter Web Mailer <phenix@interpath.com>
    Re: Tracking Subroutines <dolezal@mrms.navy.mil>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Thu, 19 Nov 1998 15:31:11 -0800
From: Bruce Mohler <bruce.w.mohler@saic.com>
Subject: Re: Calling functions from a hash
Message-Id: <3654AA39.94BD0F9F@saic.com>

Brand Hilton wrote:

> In article <365463D0.B54F556C@saic.com>,
> Bruce Mohler  <bruce.w.mohler@saic.com> wrote:
> >   my $Response = &{$Category{$Subcategory}}($Subcategory);
>
>    my $Response = &{${$Category}{$Subcategory}}($Subcategory);
>
> But you're kinda scaring me with all those symbolic references.
>

So you think, maybe, I should put some comments in to lower the
anxiety level?  :-)

Actually, I do put narrative comments in my code to explain to those
following after (sometimes me) what I was intending to do...  I just
didn't include it in my examples.

By the way, your code works like a champ!

Thanks, Brand!!!

>
> --
>  _____
> |///  |   Brand Hilton  bhilton@adc.com
> |  ADC|   ADC Telecommunications, ATM Transport Division
> |_____|   Richardson, Texas

Bruce

--
Bruce W. Mohler                619-458-2675 (voice)
SAIC/ITS/Server Support        619-535-7806 (fax)
Sr UNIX system administrator   888-781-5697 (pager)
                               mailto:bruce.w.mohler@saic.com
Of course my password is the same as my pet's name.
My dog's name is Q47pY!3, but I change it every 90 days.




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

Date: Thu, 19 Nov 1998 15:33:10 -0800
From: Bruce Mohler <bruce.w.mohler@saic.com>
Subject: Re: Calling functions from a hash
Message-Id: <3654AAB6.3B43AD7@saic.com>

Brand Hilton wrote:

> In article <365463D0.B54F556C@saic.com>,
> Bruce Mohler  <bruce.w.mohler@saic.com> wrote:
> >   my $Response = &{$Category{$Subcategory}}($Subcategory);
>
>    my $Response = &{${$Category}{$Subcategory}}($Subcategory);
>
> But you're kinda scaring me with all those symbolic references.
>

In being "cute" I may have missed your point.  Is there a better way to
express what I'm trying to do?

Bruce

>
> --
>  _____
> |///  |   Brand Hilton  bhilton@adc.com
> |  ADC|   ADC Telecommunications, ATM Transport Division
> |_____|   Richardson, Texas

--
Bruce W. Mohler                619-458-2675 (voice)
SAIC/ITS/Server Support        619-535-7806 (fax)
Sr UNIX system administrator   888-781-5697 (pager)
                               mailto:bruce.w.mohler@saic.com
Of course my password is the same as my pet's name.
My dog's name is Q47pY!3, but I change it every 90 days.




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

Date: 19 Nov 1998 22:56:20 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Cutting down refering URL to 30 symbols?
Message-Id: <7327mk$69k$1@marina.cinenet.net>

VYTiS (vip@takas.lt) wrote:
: I have a problem when using $ENV{'HTTP_REFERER'}:
: Sometimes this URL is longer than 50 or even more symbols.
: And it messes up the page, so I'd like to ask if anyone would
: tell me how to notice when it's over 30 symbols and if it is,
: print only these first 30 symbols and "..."?
: 
: Like I have:
: http://www.yahoo.com/cgi-bin/search?perl+example+or+just+anything&20
: And I need:
: http://www.yahoo.com/cgi-bin/s...

  $url =~ s/(.{30}).+/$1.../;

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "Ripple in still water, when there is no pebble tossed,
       nor wind to blow..."


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

Date: Fri, 20 Nov 1998 01:43:37 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: get unixtime from year and yday
Message-Id: <dP352.107$RQ1.210@nsw.nnrp.telstra.net>

In article <7318vd$a4g$1@nnrp1.dejanews.com>,
	rengels@my-dejanews.com writes:
> Is there any simple way of getting the time in non leap year seconds from 1970
> if you only know:
> 
> year day
> year
> 
> and set seconds, hours, minutes to 0? Sort of like a slightly different
> "timegm"

Get the seconds since epoch for that year, with everything else set to
0 or 1 (using Time::Local::timelocal or timegm)

multiply the year day by the number of seconds per day, add that to
the result of the previous call, and you should have what you want.

use Time::Local;

# For the 153rd day in 1993
my $time = timegm(0,0,0,1,0,1993);
print scalar gmtime($time), "\n";

$time += 153 * 24 * 60 * 60;
print scalar gmtime($time), "\n";

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | We are born naked, wet and hungry. Then
Commercial Dynamics Pty. Ltd.       | things get worse.
NSW, Australia                      | 


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

Date: 19 Nov 1998 23:51:57 GMT
From: whitej4@vetmed.auburn.edu (James S. White)
Subject: Help with curses
Message-Id: <732aut$6n9$1@ultranews.duc.auburn.edu>

Does anyone know where I can find good documentation on the perl Curses module?
TIA!

--

 ---------------------------------------------------------------------------- 
| James S. White                              www.vetmed.auburn.edu/~whitej4 |
| Sys/Net Administrator                            whitej4@vetmed.auburn.edu |
| Auburn University College of Veterinary Medicine             (334)844-3705 |
 ---------------------------------------------------------------------------- 
The complete lack of evidence is the surest sign that the conspiracy is working.


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

Date: 20 Nov 1998 00:23:59 GMT
From: eln@cyberhighway.net (Erik)
Subject: Re: Help with curses
Message-Id: <732cqv$fnq$1@news.cyberhighway.net>

In article <732aut$6n9$1@ultranews.duc.auburn.edu>,
	whitej4@vetmed.auburn.edu (James S. White) writes:
> Does anyone know where I can find good documentation on the perl Curses module?
> TIA!

perldoc Curses?

-- 
Erik Nielsen, Cyberhighway Internet Services NOC
I think I'd like to see a Simpsons episode start up with Bart Simpson writing 
'I will not attempt to undermine the Usenet cabal'. 
             -- J.D. Falk in a.s.r.


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

Date: Thu, 19 Nov 1998 15:02:42 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: HELP: how to prompt for input from command line?
Message-Id: <MPG.10be437147b679cf989883@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <sarhfvvb9za.fsf@camel.fastserv.com> on 19 Nov 1998 17:20:41 
-0500, Uri Guttman <uri@fastengines.com> says...
> >>>>> "BH" == Brand Hilton <bhilton@tsg.adc.com> writes:
>   BH> print "Enter something -> ";
>   BH> $something = <>;
> 
> sorry brand, but you won't see that prompt. you have to turn on $| to
> make autoflushing on STDOUT work. by default it only flushes with print
> when there is a newline (line buffered).

Sorry, Uri.  I just tried this on HP-UX and on Windows NT, and it works 
fine.  I did not turn on $|.

This is from the ANSI/ISO C Standard (whose behavior governs Perl I/O), 
section 4.9.3 Files:

  Furthermore, characters are intended to be transmitted as a block
  to the host environment when a buffer is filled, ***when input is
  requested on an unbuffered stream,*** or when input is received on a
  line buffered stream that requires the transmission of characters
  from the host environment.  [Emphasis added.]

STDIN from a terminal is unbuffered, so STDOUT is flushed first.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 20 Nov 1998 00:37:34 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: How do i trim a string in Perl??
Message-Id: <iR252.82$RQ1.235@nsw.nnrp.telstra.net>

In article <731mp3$1ev2@roc344.ghc.org>,
	"Monty Taylor" <montyt@bestnet.com> writes:
> First of all, go buy a book, or read the docs, or take a class, or
> SOMETHING!
> 
> Second ...
> 
> ($string =~ s/^\s*//) =~ s/\s*$//;

For someone with so nasty an attitude, you post something with an
unexpected result:

Can't modify substitution in substitution at ./tt.pl line 7, near "s/\s*$//;"
Execution of ./tt.pl aborted due to compilation errors.

Maybe you should also read the documentation?

perlfaq4 does not for nothing suggest the following as the best
solution:

         $string =~ s/^\s+//;
         $string =~ s/\s+$//;

     Or more nicely written as:

         for ($string) {
             s/^\s+//;
             s/\s+$//;
         }

(Notice the + instead of the * as well?)

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | If it isn't broken, it doesn't have
Commercial Dynamics Pty. Ltd.       | enough features yet.
NSW, Australia                      | 


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

Date: Thu, 19 Nov 1998 07:34:34 +0200
From: Alexander Avtanski <sasho@staff.mgu.bg>
Subject: Re: How to access a file within a perl program
Message-Id: <3653ADE9.123B5E4C@staff.mgu.bg>


--------------0FE0E09EFC44162406B1DED5
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Christian Harms wrote:

> Murali Kanaga <mkanaga@hotmail.com> wrote:
> >
> > Greetings!
> >
> > I am new to Perl. I have to write a perl program which will search through
> > the /etc/group file. When I type a user name (jdoe), the script will go
> > through
> > /etc/group file & find out which group jode is in.
> >
> > In order to do this, how can I read the file /etc/group from my perl script.
> >
> > I would really apprecitae any idea or input on this.
> >
> > Thank you,
> > murali
>
> foreach $i (grep(/$user/,`cat /etc/group`))
> {
>    ($i,$u)=split(/::/,$i);
>    print "$i\n";
> }

There is a potential problem, when username which we look for is substring
of an existing username (for example, we are looking for "art" and there is
username such as "artpress"). So:

foreach $i (grep(/\W$user\W/,`cat ./group`)) ...

--
Alexander Avtanski
sasho@staff.mgu.bg



--------------0FE0E09EFC44162406B1DED5
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Christian Harms wrote:
<blockquote TYPE=CITE>Murali Kanaga &lt;mkanaga@hotmail.com> wrote:
<br>>
<br>> Greetings!
<br>>
<br>> I am new to Perl. I have to write a perl program which will search
through
<br>> the /etc/group file. When I type a user name (jdoe), the script will
go
<br>> through
<br>> /etc/group file &amp; find out which group jode is in.
<br>>
<br>> In order to do this, how can I read the file /etc/group from my perl
script.
<br>>
<br>> I would really apprecitae any idea or input on this.
<br>>
<br>> Thank you,
<br>> murali
<p>foreach $i (grep(/$user/,`cat /etc/group`))
<br>{
<br>&nbsp;&nbsp; ($i,$u)=split(/::/,$i);
<br>&nbsp;&nbsp; print "$i\n";
<br>}</blockquote>

<p><br>There is a potential problem, when username which we look for is
substring
<br>of an existing username (for example, we are looking for "art" and
there is
<br>username such as "artpress"). So:
<p>foreach $i (grep(/\W$user\W/,`cat ./group`)) ...
<pre>--
Alexander Avtanski
sasho@staff.mgu.bg</pre>
&nbsp;</html>

--------------0FE0E09EFC44162406B1DED5--



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

Date: Thu, 19 Nov 1998 19:54:21 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: How to access a file within a perl program
Message-Id: <d4i237.em3.ln@flash.net>

Alexander Avtanski (sasho@staff.mgu.bg) wrote:

: --------------0FE0E09EFC44162406B1DED5
: Content-Type: text/plain; charset=us-ascii
: Content-Transfer-Encoding: 7bit


   What is that strange stuff up there?

   Please do not do that.

   Usenet runs on plain text.


: Christian Harms wrote:

: > Murali Kanaga <mkanaga@hotmail.com> wrote:
: > >
: > > I am new to Perl. I have to write a perl program which will search through
: > > the /etc/group file. When I type a user name (jdoe), the script will go
: > > through
: > > /etc/group file & find out which group jode is in.

: > foreach $i (grep(/$user/,`cat /etc/group`))

: There is a potential problem, when username which we look for is substring
: of an existing username (for example, we are looking for "art" and there is
: username such as "artpress"). So:

: foreach $i (grep(/\W$user\W/,`cat ./group`)) ...


I think you meant /b instead of /W there...


: <!doctype html public "-//w3c//dtd html 4.0 transitional//en">

   Gak!

   HTML is for the World Wide Web.

   This is Usenet, not the WWW.

   Your "newsreader" is misconfigured.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Fri, 20 Nov 1998 01:46:53 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: how to execute
Message-Id: <hS352.108$RQ1.210@nsw.nnrp.telstra.net>


Please read the following information on how to choose a good subject
line: http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post


In article <731dua$12m$1@sun4000.casema.net>,
	"Casema" <ours@casema.net> writes:
> Hi Helping hands,

I doubt it.

> I made this tiny little script, called stats.pl which I want executed
> everytime someone requests a document.

from a HTML page.

This has absolutely nothing at all to do with perl, since the method
would be the same were your CGI application written in any other
language. You should therefore ask this question in a group that talks
about HTML, CGI, SSI, or web stuff in general, but not here.

Try one of the comp.infosystems.www.* groups.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | 
Commercial Dynamics Pty. Ltd.       | Curiouser and curiouser, said Alice.
NSW, Australia                      | 


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

Date: Thu, 19 Nov 1998 23:10:49 GMT
From: mwwenzel@my-dejanews.com
Subject: Re: How to solve this problem?
Message-Id: <7328ha$8e1$1@nnrp1.dejanews.com>

In article <Pine.GSO.4.02.9811161156570.20384-100000@aludra.usc.edu>,
  Nadeem Rana <nrana@aludra.usc.edu> wrote:
> I am trying to solve one problem where I have a text file containing the
> names of functions declarations. The syntax of the file is like this...
>
> 		funcA(
> 		int a,
> 		char b,
> 		dword c,
> 		objectA d
> 		)
>
> 		funcB(
> 		char t,
> 		int r,
> 		char y
> 		)
>
> 		funcA(
> 		if EVERYTHING is SAME over here as funcA upwards then dont
> select this function else select this function too!!
>
> 		)
>
> So im trying to remove redundancy by removing all those functions which
> have EXACTLY same signatures. How can I solve this problem in PERL?
>
> Thanks
> Nadeem
>
>

If you are using UNIX or have unix tools for your machine (if you don't
then get them and learn how to use them)...

I would use perl to reformat the defs to be on a single line.
Make sure the white space is the same in each one when you reformat.
Pipe the output to sort -u.
Then pipe the output of that into a perl script to reformat it to the
original format.

Hope this helps,
Mark Wenzel

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Thu, 19 Nov 1998 19:09:38 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: How to solve this problem?
Message-Id: <igf237.8d3.ln@flash.net>

Nadeem Rana (nrana@aludra.usc.edu) wrote:
: I am trying to solve one problem where I have a text file containing the
: names of functions declarations. The syntax of the file is like this...


: 		funcA(
: 		int a,
: 		char b,
: 		dword c,
: 		objectA d
: 		)

: 		funcB(
: 		char t,
: 		int r,
: 		char y
: 		)

: 		funcA(
: 		if EVERYTHING is SAME over here as funcA upwards then dont
                              ^^^^^^^
: select this function else select this function too!!


   You don't really define what that means.

   So I'll guess it means *identical*.

   Though I would think the below should be counted as the same.
   Choosing a different name for the formal parameters shouldn't
   matter...

      funcA(
      int w,
      char x,
      dword y,
      objectA z
      )

   If that is what you want, then you won't get it because you
   didn't ask for it  ;-)


   You also don't say if you require them to be in the same order
   as in the input...

   ... so you're not going to get that either  ;-)


: So im trying to remove redundancy by removing all those functions which
: have EXACTLY same signatures. How can I solve this problem in PERL?


-----------------------------------
#!/usr/bin/perl -w

{  local $/ = ''; # paragraph mode

   while (<DATA>) {
      $funcs{$_} = 1;  # value does not matter here, only the keys
   }
}

foreach (sort keys %funcs) {
   print;
}

__DATA__
funcA(
int a,
char b,
dword c,
objectA d
)

funcB(
char t,
int r,
char y
)



funcA(
int a,
char b,
dword c,
objectA d
)

funcA(
int a,
char b,
dword c,
objectA z
)
-----------------------------------

prints the first two and the last one.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Thu, 19 Nov 1998 18:13:19 -0500
From: Seth Gordon <sgordon@kenan.com>
To: Randy Kobes <randy@theory.uwinnipeg.ca>
Subject: Re: installing ParseLex on NT
Message-Id: <3654A60F.59D057F6@kenan.com>

[posted and emailed]

Thanks for the pointers -- nmake has been downloaded and installed correctly.

I had made one other mistake, which is worth describing here:

The ActiveState documentation said that if I wanted to make NT execute perl
scripts from the command line, I should type

SET PATHEXT=.pl;%PATHEXT%

I had, foolishly, opened up the "System" control panel, clicked on the
"Environment" tab, selected the PATHEXT line on the "User Variables" list, and
typed ".pl;%PATHEXT%" into the "Value" field ...

Since that GUI window didn't do any kind of variable interpolation, from then
on, the *only* commands that I could type unadorned from the command line were
Perl scripts.  That is, I could type "example" to run the script "example.pl",
or "perl.exe example.pl", but not "perl example.pl".

This is probably why I was getting the "Unable to find perl 5" error message
earlier; the script was expecting Windows to expand "perl" into "perl.exe", and
Windows wasn't cooperating, and so the script didn't find any executable file
named "perl".

Full speed ahead,
--
perl -le'$m="r 0rJaa.u0cksthe";$c=967150;s/$/substr$m,($i\
+=$c%2?4:1)%=16,1or$i-2?"no":"Perl h"/e while$c>>=1;print'
== seth gordon == sgordon@kenan.com == standard disclaimer ==
== documentation group, kenan systems corp., cambridge, ma ==




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

Date: Thu, 19 Nov 1998 16:42:10 -0800
From: Chen Wang <wangc@std.teradyne.com>
Subject: manipulating the last few lines of file efficiently?
Message-Id: <3654BAE1.1FA1A586@std.teradyne.com>

Hi, I have a perl script that produces a large text file (unknown in
length).
When I am done, I'd like to change the last 4 lines produced.  An
efficient
solution will be traversing backward from eof with the file handle
and modify the file accordingly.  But I don't see a clean function that
does
that. A couple of things I've tried:

1) read the FAQ, doesn't present efficient solutions
2) tried buffering 4 lines, but complicates old code

Anyone has suggestions?

-Chen






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

Date: Thu, 19 Nov 1998 18:02:15 -0500
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: number of elements in an array
Message-Id: <MPG.10be6d8095b9e24c989720@news.scescape.net>

In article <DS052.107$SD1.17458@news.shore.net>, Scratchie 
<upsetter@ziplink.net> pounded in the following:
=> 
=> Shawn Berg <sberg1@tampabay.rr.com> wrote:
=> 
=> :>Is there a Perl function that will return the number of elements in an
=> : array?
=> :>
=> 
=> 
=> : $count = scalar(@list);
=> 
=> or
=> 
=> $count = @list;
=> 
=> or
=> 
=> $count = $#list + 1
=> 

or

$count = $#list - $[ + 1;

if you have been (foolishly) messing with $[.

=> --Art

--Matthew


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

Date: 19 Nov 1998 23:03:47 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: number of elements in an array
Message-Id: <73284j$69k$2@marina.cinenet.net>

Shawn Berg (sberg1@tampabay.rr.com) wrote:
: >Is there a Perl function that will return the number of elements in an
: >array?
: 
: $count = scalar(@list);

True as written, but more verbose than is typically seen in Perl programs.
Using an array name in a 'scalar context' (such as assignment to a scalar)
will implicitly do the 'scalar' part.  Thus,

  $count = @list;

Or even just use @list where the number of items is needed:

  for ($itemIndex = 0; $itemIndex < @list; $itemIndex++)

HTH!

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "Ripple in still water, when there is no pebble tossed,
       nor wind to blow..."


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

Date: Fri, 20 Nov 1998 01:02:49 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: perl documentation date
Message-Id: <Zc352.90$RQ1.235@nsw.nnrp.telstra.net>

In article <36549cbb$0$12768@nntp1.ba.best.com>,
	"Xah" <xah@best.com> writes:
> Thanks to Greg Ward and Daniel Grisinger 
> 
> In article <731n00$3i5$2@news0-alterdial.uu.net>, 
>		gward@thrak.cnri.reston.va.us (Greg Ward) wrote:
>>If you're reading the online docs as man pages, check the bottom of
>>every page.
> 
> Ah I see. I missed that because I always use perldoc.

Hmm. On my system, perldoc also produces that line.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | 75% of the people make up 3/4 of the
Commercial Dynamics Pty. Ltd.       | population.
NSW, Australia                      | 


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

Date: 20 Nov 1998 00:16:11 GMT
From: Mark Carnes <mendrak@worldnet.att.net>
Subject: Re: perl/win95
Message-Id: <3654B3AC.B0B0BCB9@worldnet.att.net>



mila@stars.gsfc.nasa.gov wrote:

> Forrest,
>    You can type perl hello.pl on the DOS command line. Either go to
> the perl dir and type it from there. Or, if you have .pl associated with
> perl.exe, it should work from any dir.
>

I've installed perl and I can certainly type perl xyz.pl and it will work
but I can't just type xyz.pl.  What do I have to do to associate it?




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

Date: 19 Nov 1998 23:59:58 GMT
From: elvis@NOTGRACELANDclark.net
Subject: Problems building DB_File 1.52
Message-Id: <732bdu$aqj$1@clarknet.clark.net>

I have perl 5.004.04
Make DB_File 1.52 completes fine.  However when I run make test:

Makefile:736: warning: overriding commands for target `Makefile' Makefile:657: warning: ignoring
old commands for target `Makefile' PERL_DL_NONLAZY=1 /bin/perl -I./blib/arch -I./blib/lib
-I/usr/local/lib/perl5/sun4-solaris/5.00404 -I/ usr/local/lib/perl5 -e 'use Test::Harness
qw(&runtests $verbose); $verbose=0; runtests @ARGV;' t/*.t t/db-btree..........Can't load
'./blib/arch/auto/DB_File/DB_File.so' for module DB_File: ld.so.1: /bin /perl: fatal: relocation
error: file ./blib/arch/auto/DB_File/DB_File.so: symbol db_version: reference d symbol not found
at /usr/local/lib/perl5/sun4-solaris/5.00404/DynaLoader.pm line 166.
 at t/db-btree.t line 21 BEGIN failed--compilation aborted at t/db-btree.t line 21. dubious
        Test returned status 2 (wstat 512, 0x200)

I cannot make heads or tails of this error message.

Any ideas why I am getting relocation error?

Thanks.

Bill


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

Date: Thu, 19 Nov 1998 17:04:13 -0800
From: Lord Vorp <lordvorp@usa.net>
Subject: Promote a TIEREF to hash....
Message-Id: <3654C00D.3553@usa.net>

I've been wondering...

Suppose, just suppose, you have a tied object.  For example:

$t = new Tie::IxHash (foo => 'bar' , fuu => 'baz');

Is it possible to tie this OBJECT to a hash?  Something like:

tie %hash, $t;

or even better, suppose I wanted to pass my tied %hash by ref to a
function:

&my_func(\%hash)

Is there a way to promote it back to a tied hash?

sub my_func {
    my $ref = shift;
    print ref $ref, "\n";

    my %hash = %$ref;

    print Data::Dumper->Dump([\%hash], [qw/hash/]);
    print defined tied(%hash) ? 'Tied' : 'Not Tied', "\n";

}

Prints "Not Tied" at the end.

Now, of course, I could always call &myfunc(tied(%hash)), but then we
are back at the original question.

NE1?

L8r,
L V


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

Date: Thu, 19 Nov 1998 15:14:33 -0800
From: "Alistair Calder" <webmaster@topproducer.com>
Subject: Regex-ing an entire file: How to?
Message-Id: <7328o5$fa7$1@supernews.com>

I have looked through my Camel book and tried to find the answer in the
perldoc, but I am not exactly sure what to do here.  This might be a bit of
a newbie question, but hey, I'm a Perl newbie.

What I want to do is read a file, run some RE's on the entire thing and
write it back to the server.  I tried bringing it into @DATA and doing
something like this:

@DATA =~ s/Santa/Elves/;

but it gave me errors to do with substitutions being done under
scalar(@array).  I am confused and I can't figure out how to parse the
entire file all at once.

Should I just do it line for line with a

foreach $line(@DATA){ ...}

?


Thanks for any help,
Alistair




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

Date: 19 Nov 1998 23:31:35 GMT
From: eln@cyberhighway.net (Erik)
Subject: Re: Regex-ing an entire file: How to?
Message-Id: <7329on$dn6$1@news.cyberhighway.net>

[Posted and mailed]

In article <7328o5$fa7$1@supernews.com>,
	"Alistair Calder" <webmaster@topproducer.com> writes:
> What I want to do is read a file, run some RE's on the entire thing and
> write it back to the server.  I tried bringing it into @DATA and doing
> something like this:
> 
> @DATA =~ s/Santa/Elves/;

You're treating it as a scalar, and it's an array.  The s/// operator works
on scalars.  So, put all the data into a scalar.
Try something like:
$data = join "",@DATA;
$data =~ s/Santa/Elves/;

-- 
Erik Nielsen, Cyberhighway Internet Services NOC
That means I'll have to use $ans to suppress newlines now.
Life is ridiculous.
             -- Larry Wall in Configure from the perl distribution


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

Date: Thu, 19 Nov 1998 18:57:48 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Regex-ing an entire file: How to?
Message-Id: <cqe237.ma3.ln@flash.net>

Alistair Calder (webmaster@topproducer.com) wrote:

: What I want to do is read a file, run some RE's on the entire thing and
: write it back to the server.  I tried bringing it into @DATA and doing
: something like this:

: Should I just do it line for line with a

: foreach $line(@DATA){ ...}


How you should do it depends on what you need done  ;-)

-----

If the things to be replaced do not span across lines, then
you can process it line by line (and you don't need to put it
into an intermediate array):

while (<>) {
   s/Santa/Elves/g;  # need s///g if there might be more than one
                     # 'Santa' on a line
   print;
}

-----

If the things to be replaced do span lines, then it is easiest
to read the entire file into a single string (scalar). This
will be problematic if the file is large though:


{ local $/;   # localizing special variable changes is good
              # programming practice.
              # this makes the Input Record Separator be undef
              # instead of a newline. aka: slurp mode

  $_ = <>;    # slurp the *whole file* into $_
}

s/Santa\nClaus/Elves/g;  # multiline substitution, may also need
                         # s///ms but it depends on what it is
                         # that you need to replace
print;

-----

see also the -i switch in the 'perlrun' man page if you want
to do "in place edits".


also see also this frequently Asked Question from part 5:

   "How do I change one line in a file/
    delete a line in a file/
    insert a line in the middle of a file/
    append to the beginning of a file?"


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Fri, 20 Nov 1998 00:41:55 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Smarter Web Mailer
Message-Id: <nV252.85$RQ1.235@nsw.nnrp.telstra.net>

In article <3654168B.1C53AFEE@elsevier.nl>,
	Leon Brocard <l.brocard@elsevier.nl> writes:

> $txt =~ s|([^\"])(mailto:[a-z\-0-9._,]+@[a-z\-0-9.]+[a-z\-0-9])|$1<a href="$2"><tt>$2</tt></a>|igm;
> 
> Hmm. Betcha the above strings don't wrap around properly in the post.

Nope they don't :)

I always make sure that I use the x modifier on complex REs. That
makes it easier to comment them, and to maintain them if I come back 6
months later to have another look at them. It also makes it easier to
keep them inside of the 76 column limit :)

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Little girls, like butterflies, need no
Commercial Dynamics Pty. Ltd.       | excuse - Lazarus Long
NSW, Australia                      | 


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

Date: Thu, 19 Nov 1998 20:49:19 -0500
From: John Moreno <phenix@interpath.com>
Subject: Re: Smarter Web Mailer
Message-Id: <phenix-191119982049193527@roxboro0-022.dyn.interpath.net>

Leon Brocard <l.brocard@elsevier.nl> wrote:

> "I.J. Garlick" wrote:
> 
> > JTJ <jtjohnston@courrier.usherb.ca> writes:
> > > I am playing with a Web-Based E-mailer. How do I extract a web
> > > address in a block of text and replace it with a link:
> 
> > I am having a similar prob. I got this far
> > 
> >     s!(^|[^=])(\s*)(http://.*?)(\s+|/\W\s+)!$2<A HREF=$3>$3</A>$4!gs;
> 
> > However I suspect your just trying to improve that Web based email
> > client you where crowing about earlier :-) :-)
> 
> Well, in *my* Web-based email client[1] I use
> 
> $txt =~ s|(https?://[a-z\-0-9/~._,\#=;?&]+[a-z\-0-9/_])|<ahref="$1"><tt>$1</tt></a>|igm;
> $txt =~ s|([^/>])(www\.[a-z\-0-9/~._,\#=;?&]+\.[a-z\-0-9/_]+)|$1<ahref="http://$2"><tt>$2</tt></a>|igm;
> $txt =~ s|<a href="(.+?)&gt"><tt>(.+?)&gt</tt></a>;|<ahref="$1"><tt>$2</tt></a>&gt;|igm;
> $txt =~ s|(ftp://[a-z\-0-9/~._,]+[a-z\-0-9/_])|<ahref="$1"><tt>$1</tt></a>|igm;
> $txt =~ s|([a-z\-0-9._,]+\@[a-z.]+[a-z])|<ahref="mailto:$1"><tt>$1</tt></a>|igm;
> $txt =~ s|([^\"])(mailto:[a-z\-0-9._,]+@[a-z\-0-9.]+[a-z\-0-9])|$1<ahref="$2"><tt>$2</tt></a>|igm;
> 
> Hmm. Betcha the above strings don't wrap around properly in the post.

Easy enough to fix, but using the x modifier would have allowed you to
have it span multiple lines, you could have added some much needed
comments. 

-snip-

> --
> $monger{Amsterdam.pm}[0] # $laptop--

-- 
John Moreno

(Newsreaders recognize the signature by looking for the sigdash, which is a
line which consist solely of two dashes followed by a space)


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

Date: Thu, 19 Nov 1998 22:52:14 GMT
From: Tim Dolezal <dolezal@mrms.navy.mil>
Subject: Re: Tracking Subroutines
Message-Id: <3654A11E.BB7BF9FB@mrms.navy.mil>

Thank you,

	Exactly what I was looking for.

Tim


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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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 4259
**************************************

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