[7561] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1187 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 16 17:07:55 1997

Date: Thu, 16 Oct 97 14:00:24 -0700
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, 16 Oct 1997     Volume: 8 Number: 1187

Today's topics:
     Re: Any plans for Min and Max operators? (Colin Kuskie)
     Re: Any plans for Min and Max operators? <rootbeer@teleport.com>
     Re: ARGV question <rootbeer@teleport.com>
     Compiling perl on Unixware 1.0 <prems@lucent.com>
     Re: Constants (Mike Stok)
     Re: Difference between local and my with typeglobs (Charles DeRykus)
     Escape sequences w/back-tick (`) <ssmith@nine.com>
     Extracting an email address or URL's from a string? <bjorn@realitynet.com>
     Re: Extracting an email address or URL's from a string? <usenet-tag@qz.little-neck.ny.us>
     Re: File creation in macPerl (brian d foy)
     File locking problems in Perl 4.036 (Andrew Jonathan Tei)
     Global Search and Replace Question (Drake Cleary)
     Re: Global Search and Replace Question (Tad McClellan)
     Looking for a function like the VB-funktion ASC("A") <Marion@netway.at>
     Microsoft Mail <aaron@soltec.net>
     Re: PERL : diff utility for NT (Scott McMahan)
     Q: how do I search a particular URL w/out var expansion (Ramon M. Felciano)
     Re: Q: how do I search a particular URL w/out var expan <felciano@smi.stanford.edu>
     Q: Perl Distribution? <marilyn.loomis@kla-tencor.com>
     Scope of LABELs <mgregory@asc.sps.mot.com>
     setting UID/GID (Gerben Wierda)
     Something like an "IN" test (Gord Russell)
     Re: Something like an "IN" test (brian d foy)
     Re: Something like an "IN" test <dgwilson@gte.net>
     Re: Something like an "IN" test (Tad McClellan)
     Re: Something like an "IN" test (Mike Stok)
     Re: statics or const in perl ? <rootbeer@teleport.com>
     Re: sybperl/oraperl (John D Groenveld)
     Web Programmer Wanted <b~johnston@rocketmail.com>
     Why am I running out of memory? (Joseph Scott Stuart)
     Win32, problem opening dir (Eric)
     windows question:  $foo to the clipboard, is it possibl <htaylor@nospam.mit.edu>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 16 Oct 1997 11:32:14 -0700
From: colink@latticesemi.com (Colin Kuskie)
Subject: Re: Any plans for Min and Max operators?
Message-Id: <625mje$nfj@sarek.latticesemi.com>

In article <Pine.GSO.3.96.971016082410.20497O-100000@usertest.teleport.com>,
Tom Phoenix  <rootbeer@teleport.com> wrote:
>If anyone makes some, they should accept lists (not just two values). What
>should they do when given undef? (I'd say, treat it like zero, but return
>it if it is then the min or max.) 
>
>In any case, I'd say you should put them in a module, rather than making
>them builtins. When you've finished it and uploaded it to CPAN, announce
>it on c.l.p.announce! :-) 

It's already done!  Check out the Statistics::Descriptive.  Now,
granted, you also get a lot more than you expected, like most of
all the other statistics functions that you ever wanted (and a
few that you didn't) but it saves having to re-invent the
wheel.

Colin Kuskie
colink@latticesemi.com


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

Date: Thu, 16 Oct 1997 13:15:52 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Paul Moore <Paul.Moore@uk.origin-it.com>
Subject: Re: Any plans for Min and Max operators?
Message-Id: <Pine.GSO.3.96.971016131214.20497i-100000@usertest.teleport.com>

On Thu, 16 Oct 1997, Paul Moore wrote:

> You also need variations which use lt and gt (string comparison)
> instead of < and > (numeric comparison). 

I've never seen a real-world situation which needed those. But, OTOH, it
would be nice to have a definable order, a la sort(). (Note that with
this, you wouldn't need two subs, so we could call it 'extreme' or some
such.)

   sub min { extreme { $a < $b } @_ }
   sub max { extreme { $a > $b } @_ }

-- 
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: Thu, 16 Oct 1997 13:10:40 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Alan <ahecker@interport.net>
Subject: Re: ARGV question
Message-Id: <Pine.GSO.3.96.971016130705.20497h-100000@usertest.teleport.com>

On Wed, 15 Oct 1997, Alan wrote:

> $count = 1;
> $len = @ARGV;
> until ($count == $len) {
>       open (IN, $ARGV[$count]);

Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check of the return value after opening a
file.

>       #do some operations here
>       close (IN);
>       $count++;
> }
> 
> Should the open statement work correctly or not? And if not, 1) what
> will make it work the way I need it to--namely, opening the args from
> the command line, in order--and 2) why doesn't mine work?

You started the count at one instead of zero. But check out the diamond
operator in a while loop; it may do what you need.

    while (<>) { ... }

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: 16 Oct 1997 19:07:41 GMT
From: "Prem" <prems@lucent.com>
Subject: Compiling perl on Unixware 1.0
Message-Id: <01bcda66$4dac7b40$54bc1187@hoprem.ho.lucent.com>

I compiled Perl 5.004_01 on unixware 1.0  - success
but fails test for readdir (i already have csh as undef), filecache

and lstat

help please
prem



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

Date: 16 Oct 1997 19:43:48 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Constants
Message-Id: <625qpk$b21@news-central.tiac.net>

In article <Pine.GSO.3.96.971015140837.13645V-100000@usertest.teleport.com>,
Tom Phoenix  <rootbeer@teleport.com> wrote:
>On 14 Oct 1997, Matthew Cravit wrote:
>
>>     sub NUMERIC_CONSTANT { 27.3; }
>
>>     $foo += NUMERIC_CONSTANT;
>
>Unfortunately...
>
>     $bar = NUMERIC_CONSTANT + 3;
>
>     print "$bar\n";

But this can be cleared up using prototypes e.g.

$ perl -de 1

Loading DB routines from perl5db.pl version 1.01
Emacs support available.

Enter h or `h h' for help.

main::(-e:1):   1
  DB<1> sub NUMERIC_CONSTANT () { 27.3; }

  DB<2> $bar = NUMERIC_CONSTANT + 3

  DB<3> print $bar
30.3

perl can tell that

  print sqrt 4, 9

is print sqrt (4), 9 'cos it knows that sqrt takes a single argument at
most.  Using the const pragma does communicate your intent better...

On my system this:

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

use Benchmark;
use constant C1 => 27.3;
use vars qw/$C2/;

*C2 = \27.3;
sub C3 () {27.3}


timethese (1000000, {
           'constant' => '$x = C1 + 4;',
           'glob'     => '$x = $C2 + 4;',
           'sub'      => '$x = C3 + 4;',
          });
__END__

says

Benchmark: timing 1000000 iterations of constant, glob, sub...
  constant:  2 secs ( 2.55 usr  0.00 sys =  2.55 cpu)
      glob:  5 secs ( 4.62 usr  0.00 sys =  4.62 cpu)
       sub:  2 secs ( 2.53 usr  0.00 sys =  2.53 cpu)

(that's perl 5.004_04..., your mileage may vary.)

Hope this helps,

Mike
-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: Thu, 16 Oct 1997 18:10:06 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Difference between local and my with typeglobs
Message-Id: <EI5p4v.1s0@bcstec.ca.boeing.com>

In article <624ou7$qnh$1@esmeralda.zdv.Uni-Mainz.DE>,
J%org Knappen <knappen@iphcip1.Physik.Uni-Mainz.DE> wrote:
 > 
 > I just stumbled over the following:
 > 
 > #! /usr/local/bin/perl
 > 
 > sub sprod{
 >  local (*x,*y)=@_;  # in this line, local works, but my causes an error
 >  my ($sum)=0;
 >  my $final=min(scalar(@x),scalar(@y));
 >  my $i=0;
 >  while($i<$final){
 >   $sum = $sum+$x[$i]*$y[$i];
 >   $i++;}
 >  return $sum;}
 > 
 > The error message is:
 > 
 > [knappen@micky] sprod.pl
 > Can't declare ref-to-glob cast in my at ./sprod.pl line 4, near ")="
 > 
 > 
 > I have read the descriptions of local and my in the blue camel book,
 > but didn't see why this behaviour occurs.
 > 
 > The installed perl version is:

 
Typeglobs are symbol table pointers and are global 
in scope.  "my" variables aren't in the symbol table
at all and are handled by a special stack known only
to the enclosing block or subroutine. 

"local" variables wilL work because they're also global,
i.e. symbol table entries, that just preserve and then
restore any previous value of the "localized" variable  
when the subroutine or block terminates. 

There are some wonderful explanations in Sriram's  
"Advanced Perl Programming" if you want to know 
more. See Chapter 3:  "Typeglobs and Symbol Tables"
for instance.

Regards,
--
Charles DeRykus


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

Date: 16 Oct 1997 19:27:36 GMT
From: Steve Smith <ssmith@nine.com>
Subject: Escape sequences w/back-tick (`)
Message-Id: <625pr8$9ti@news-central.tiac.net>



-- 
mailto:ssmith@nine.com


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

Date: Thu, 16 Oct 1997 11:52:12 -0700
From: Bjorn Lindstrom <bjorn@realitynet.com>
Subject: Extracting an email address or URL's from a string?
Message-Id: <Pine.BSF.3.96.971016114145.7324A-100000@shell5.ba.best.com>

Hi,

I am working on a program to process a mailfile, and change the lines that
have email addresses and URL's to HTML references.

I want to basically take any email address, and wrap a URL around it, such
as reading in 'blah blah address@domain.com blah blah' and writing out 
'blah blah <A HREF="mailto:address@domain.com">address.domain.com</A> blah
blah'.

I pulled and installed Mailtools from CPAN, but can't figure out how to
use it to do this.

In addition, I want to take a URL (which could appear anywhere) and
convert it from:

'blah blah blah http://www.domain.com/page blah blah blah'

to:

'blah blah blah 
<A HREF="http://www.domain.com/page">http://www.domain.com/page</A> 
blah blah blah'

(keeping it all on the original line of course ...)

Any advice would be very much appreciated!

Yours truly,

Bjorn Lindstrom

http://www.realitynet.com/bnk

bjorn@realitynet.com (home)
b45klin@ptss.com (work)
Heartagold@aol.com (AOL)




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

Date: 16 Oct 1997 20:51:49 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: Extracting an email address or URL's from a string?
Message-Id: <eli$9710161616@qz.little-neck.ny.us>

Bjorn Lindstrom  <bjorn@realitynet.com> wrote:
> I am working on a program to process a mailfile, and change the lines that
> have email addresses and URL's to HTML references.

This is a complex task. Is http://example.url/foo a URL? Does
"In <Pine.BSF.3.96.971016114145.7324A-100000@shell5.ba.best.com>,
Bjorn Lindstrom  <bjorn@realitynet.com> wrote:" have an email
address in it? Need we deal with <"echo request"@qz.little-neck.ny.us>,
which is an address with a space in it?

> I want to basically take any email address, and wrap a URL around it, such
> as reading in 'blah blah address@domain.com blah blah' and writing out 
> 'blah blah <A HREF="mailto:address@domain.com">address.domain.com</A> blah
> blah'.

Distinguishing email addresses (mailto: scheme) and message-IDs
(news: scheme) will be very difficult. I have seen people attempt
to send mail to my message-IDs, so I know people writing address
harvesters have these problems.

	# Encapsulated addresses
	s! <([^>]+@[\w.]+)>	# fails for lots of valid addresses, but...
	 !<A HREF="mailto:$1">&lt;$1&gt;&gt;</A>!x;

> I pulled and installed Mailtools from CPAN, but can't figure out how to
> use it to do this.

I've only used that for parsing addresses, myself.

> In addition, I want to take a URL (which could appear anywhere) and
> convert it from:
> 'blah blah blah http://www.domain.com/page blah blah blah'
> to: 'blah blah blah 
> <A HREF="http://www.domain.com/page">http://www.domain.com/page</A> 
> blah blah blah'

This is probably easier than the email address problem.

	s!
	  <(url:)	# RFC 1738(?) encapsulation -- easiest case

	   ( [^>]+ )	# grab the URL

	  >		# end encapsulation
	 !
	  ( $pre = $1, $urlliteral=$2, $urlfixed=$2,	# variables

	    $urlfixed =~ s/ (?: -\s+ | \s+ ) //x,	# unfold

	    qq,<A HREF="$urlfixed">&lt;$pre$urlliteral&gt;</A>, # replace
	  )
	 !gix;		# /i case insensitive; /x extended format

> (keeping it all on the original line of course ...)

Why? Is it in a <PRE></PRE> container?

If I was feeling ambitious, I'd have written those for non-encapsulated
cases by using lots more capturing parens with ?s and testing for
define'dness. This whole task is quite difficult because humans tend
not to type in nice easy ways to parse. You should -- in particular --
be careful about excluding [,.?">] from the end of the URLs but allow
them in the middle.

Elijah
------
always RFC1738 encapsulates urls


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

Date: Thu, 16 Oct 1997 19:17:08 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: File creation in macPerl
Message-Id: <comdog-1610971917080001@netnews.worldnet.att.net>

In article <3446372D.827DF939@harvard.edu>, chris_braiotta@harvard.edu wrote:


> How does one
>     a) create folders in macperl
>     b) write files to specific folders
> 
> This is all quite easy in UNIX based perl, but I'm at a loss in macPerl.

it works the same way in MacPerl

#!/usr/bin/perl

#remember that the directory separator is a colon
$dir = 'doppelbrian:Desktop Folder:Dead Horse';

#Macs know nothing of modes, so use undef
mkdir $dir, undef
     or die "Could not make folder: $!";

open FILE, "> $dir:glue.txt"
     or die "$!\n";

print FILE 'yadda yadda yadda';

close FILE;

__END__

-- 
brian d foy                                 <http://computerdog.com>
#!/usr/bin/perl
$_=q|osyrNewkecnaYhe.mlorsePptMskurj|;s;[NY.PM]; ;g;local$\=
qq$\n$;@pm=split//;while($NY=pop @pm){$pm.=$NY;$ny.=pop @pm}
$pm=join'',reverse($ny,$pm);open(NY,'>&STDOUT');print NY $pm


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

Date: 16 Oct 1997 12:47:06 -0700
From: atei@galaxy.csc.calpoly.edu (Andrew Jonathan Tei)
Subject: File locking problems in Perl 4.036
Message-Id: <625qvq$gv4@galaxy.csc.calpoly.edu>

I've been trying for a week now to fix some perl routines that we wrote
to make system administration routines a little simpler.  We wrote 
wrappers to facilitate file locking and unlocking.  They were working 
fine until we moved from AIX to HPUX. Now file locking seems to be 
completely broken.  We have already changed flock to fcntl and that 
doesn't work.  I've consulted the proper sections of the perl faq and I 
still don't have anything, and I've been monitoring the group but 
everything is around perl 5.  I need a solution that would work on HPUX 
10.20 with perl 4.036. 

I'm including the library routine where the lock and unlock are, a test 
perl script that I've been running, and the result of the test.


--------------<locking.pl - holds library routines>--------------------
######################################################################
# Script : locking.pl                                                #

  # general.pl contains many HP wide variables so that they do not need
  #  to be hard coded in all of the HP administration scripts
  require "general.pl";
  require "fcntl.ph";
  
  #
  # Global variables:
  #
  $F_SETLK = "6";
  $F_WRLCK{L_TYPE} = "02";
  $F_WRLCK{L_START} = 0;
  $F_WRLCK{L_LEN} = 0;
  $F_UNLCK = "03";
  
  ##########################################################################
  # routine: lock
  #
  # purpose: Lock a file using a lockfile as a flag
  # passed : $file - FILEHANDLE!!!!!!  to lock (not filename)
  ##########################################################################
  sub lock {
    local($file) = @_;

    ($result = fcntl($file, 6, 02))  || ($result = -1);
    if ($result = -1) {
      print STDERR "$0: Error locking file - $result\n";
    }
    return ($result);
  }
  
  ##########################################################################
  # routine: unlock
  #
  # purpose: Unlock a file using a lockfile as a flag
  # passed : $file - FILEHANDLE!!!!!!  to lock (not filename)
  ##########################################################################
  sub unlock {
    local($file) = @_;
    local($result);
  
    ($result = fcntl($file, $F_SETLK, $F_UNLCK)) || ($result = -1);
    if (!$result) {
      print STDERR "$0: Error unlocking file - $result\n";
    }
    return ($result);
  } # end unlock

}
1;


----------------<TEST SCRIPT>---------------------
#!/usr/local/bin/perl

require "locking.pl";

open (TEST, ">> testing.file") || die "Can't open testing.file $!\n";

$ret_val = &lock(TEST);
print "Return Value for lock: $ret_val\n";

sleep 2;
$ret_val = &unlock(TEST);
print "Return Value for unlock: $ret_val\n";

close (TEST);

-----------------<RESULTS>------------------------
 ./testing.locking3.pl: Error locking file - -1
Return Value for lock: -1
Return Value for unlock: -1

Andrew Tei                         *  email: atei@galaxy.csc.calpoly.edu
Computer Science Senior            *  web : http://www.calpoly.edu/~darkjedi
Righteous Dragon -==(UDIC)==-      *  Ultima Dragons Internet Chapter
Cal Poly, San Luis Obispo          *  Also known as The Dark Jedi
-- 
Andrew Tei                         *  email: atei@galaxy.csc.calpoly.edu
Computer Science Senior            *  web : http://www.calpoly.edu/~darkjedi
Righteous Dragon -==(UDIC)==-      *  Ultima Dragons Internet Chapter
Cal Poly, San Luis Obispo          *  Also known as The Dark Jedi


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

Date: Thu, 16 Oct 1997 18:20:58 GMT
From: killbell@peterboro.net (Drake Cleary)
Subject: Global Search and Replace Question
Message-Id: <34465a4a.12102284@news.peterboro.net>

I'm trying to do a search and replace for my whole web site with the
following....

perl -p0777i -e 's/ - \d Home Pages/\<\!-- 0 --\>/gm;' `find . -name
'*.html' -print`

It works fine up to a certain number of files.... then unix gives an
error...

Is there any command that will work regardless of the number of
files???

Thanks.


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

Date: Thu, 16 Oct 1997 14:18:03 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Global Search and Replace Question
Message-Id: <b9p526.o5i.ln@localhost>

Drake Cleary (killbell@peterboro.net) wrote:

: It works fine up to a certain number of files.... then unix gives an
: error...


I'm holding my forehead against the monitor...

 ...

 ...


Nope. It's just not coming through.

What error message does unix give you?

Knowing the symptoms is often helpful when attempting a diagnosis  ;-)


(try 'man xargs' OR change shells to one that doesn't barf on
 long argument lists (such as tcsh) OR use the File::Find module 
 and don't even use the shell)


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


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

Date: Thu, 16 Oct 1997 22:14:12 +0100
From: Christian Putz <Marion@netway.at>
Subject: Looking for a function like the VB-funktion ASC("A")
Message-Id: <344683A4.9EB3AC30@netway.at>


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

Hy!

I need for a perlscript a function like one I know from Visual Basic.

Testnumber = Asc("A") ........................... the result is  65.


Thank You for everyone who helps me.
Christian

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

<HTML>
Hy!

<P>I need for a perlscript a function like one I know from <B>Visual Basic</B>.

<P>Testnumber = Asc("A") ........................... the result is&nbsp;<B>
65</B>.
<BR>&nbsp;

<P>Thank You for everyone who helps me.
<BR>Christian</HTML>

--------------DCF1CBFEA140B823B4D4B520--



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

Date: 16 Oct 1997 20:56:09 GMT
From: "Aaron" <aaron@soltec.net>
Subject: Microsoft Mail
Message-Id: <01bcda75$2a0daf60$b5910a9f@aurora.cna.com>

Has anyone ever written any scripts to write mail message to microsoft
mail?




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

Date: 16 Oct 1997 18:40:02 GMT
From: scott@lighthouse.softbase.com (Scott McMahan)
Subject: Re: PERL : diff utility for NT
Message-Id: <625n22$ovk$1@mainsrv.main.nc.us>

Bryan OConnell (bryan_oconnell@ins.com) wrote:
: I need a good UNIX-like diff utility for completing "diff -c" (unix
: equiv) on text files from within a PERL script on a Windows NT 4.0 box.

: Any suggestions?

The Cygnus GNU utilities port to Win32 is your best bet. Various
other diff clones exist (including some graphical ones), but
their compatibility with the UNIX version would be suspect.

Scott



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

Date: Thu, 16 Oct 1997 11:27:01 -0800
From: felciano@smi.stanford.edu (Ramon M. Felciano)
Subject: Q: how do I search a particular URL w/out var expansion?
Message-Id: <felciano-1610971127020001@smi-mac-146.stanford.edu>


Hello --

I am trying to do URL substitution in an HTML file and am running into
problems with Perl's variable expansion. I want to replace all HREF
instances of $oldURL with $newURL in a given web page. Thus, the search
pattern includes a variable ($oldURL) and certain constant elements to
match the HREF tag. The problem is that $oldURL may contain special regex
characters which get expanded during the search (e.g. a questionmark if
the url points to a CGI). The \Q option allows me to "turn off" these
special characters but it applies to the whole pattern, not just the
variables in the pattern. If I ignore special characters, I cannot
flexibly match the HREF reference. 

In the example below, only patterns 2 and 5 match. Pattern 2 is
unacceptable because it would match URLs outside of HREF tags, and pattern
5 is unacceptable because it doesn't match variable whitespace in the HREF
tag (as patterns 3 and 4 do).

$html = "<A HREF=\"http://www.bozo.com/mycgi?alpha\">my link</A>.";
$oldURL = "http://www.bozo.com/mycgi?alpha";

if ($html =~ m/$oldURL/si) { print "Pattern 1 matched.\n"; } else { print
"Pattern 1 not matched.\n"; }
if ($html =~ m/\Q$oldURL/si) { print "Pattern 2 matched.\n"; } else {
print "Pattern 2 not matched.\n"; }
if ($html =~ m/(HREF\s*=\s*)("?)$oldURL(#?[^"]*)("?)(.*)>/si) { print
"Pattern 3 matched.\n"; } else { print "Pattern 3 not matched.\n"; }
if ($html =~ m/\Q<A HREF\s*=\s*"$oldURL"\s*>/si) { print "Pattern 4
matched.\n"; } else { print "Pattern 4 not matched.\n"; }
if ($html =~ m/\Q<A HREF="$oldURL">/si) { print "Pattern 5 matched.\n"; }
else { print "Pattern 5 not matched.\n"; }

The only solution I can think of is to escape out regex special characters
in $oldURL before I do the pattern match. Is there a simple way to do
this? Or can someone else point me to a better solution?

Thanks very much -- I checked the FAQ and couldn't find the answer there.

Ramon


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

Date: Thu, 16 Oct 1997 12:45:42 -0700
From: "Ramon M. Felciano" <felciano@smi.stanford.edu>
Subject: Re: Q: how do I search a particular URL w/out var expansion?
Message-Id: <34466EE6.90B33917@smi.stanford.edu>

Hello all --

I love the net -- 1 hour, 1 answer :). It looks like I can control which
parts of a search pattern have quotemeta on using \Q _and_ \E. So my
problem is solved by using the following regular expression:

$html =~ m/<A HREF\s*=\s*"\Q$oldURL\E"\s*>/si

Thanks very much to "Andrew Johnson" <ajohnson@gpu.srv.ualberta.ca> for
the quick response. I will write to the Perl FAQ maintainer to suggest
including this factoid in the next FAQ release.

Ramon


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

Date: Thu, 16 Oct 1997 13:48:00 -0700
From: Marilyn Loomis <marilyn.loomis@kla-tencor.com>
Subject: Q: Perl Distribution?
Message-Id: <34467D80.621F@kla-tencor.com>

Is there a way to distribute my perl scripts to others without
installing Perl on their machines?

Thanks for any help,

Marilyn Loomis
marilyn.loomis@kla-tencor.com


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

Date: 15 Oct 1997 21:19:58 -0700
From: Martin Gregory <mgregory@asc.sps.mot.com>
Subject: Scope of LABELs
Message-Id: <r8k9fe8hld.fsf@asc.sps.mot.com>


Hi,

Is it documented anywhere what the scope of a LABEL identifier is?

In otherwords, where am I allowed to reuse a LABEL name again without
coming to grief?

I notice that perl parses this with no comment:


use strict;


sub sub1 
{
 LAB: 
  while(1){}
}

sub sub2
{
 LAB: 
  while(0){}
}


Thanks,

Martin.




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

Date: Thu, 16 Oct 1997 15:59:46 GMT
From: G.C.Th.Wierda@AWT.nl (Gerben Wierda)
Subject: setting UID/GID
Message-Id: <EI5J3M.GFw@AWT.NL>

I'd like to do things like setting effective or real user id for scripts 
running as root.

But, it seems I have setuid/setgid, but when I use them and afterwards do 
something like

system( "date > test.out");

the file test.out is owned not by the user I just uid-ed to.

And seteuid and friends are not part of perl, or should they be? They are not 
part of perl's man page or faq.

And I can use POSIX.pm, but here the set is incomplete too.

So, what is the scope on the possibilities of setting user and group id?

Thanks,

---
Gerben Wierda,

Stafmedewerker Adviesraad voor het Wetenschaps- en Technologiebeleid.
Staff member Advisory Council for Science and Technology Policy
Javastraat 42, 2585 AP, Den Haag/The Hague, The Netherlands
Tel (+31) 70 3639922	Fax (+31) 70 3608992
http://www.AWT.nl/prive/wierda/

The fox knows many things, but the hedgehog knows one big thing.

Random EFF quote:
"First of all, you have to make the distinction between the Internet
and some commercial service like AOL or Prodigy.  If you spend that
time and money building internets, you at the end of your labors
will own tangible assets: hardware, software, paid-for network
bandwidth, and human capital in the form of people who know how to
run same. Spending those dimes on Prodigy means that in the end you
will have rented someone else's assets and will have nothing
concrete in the end except for receipts for bills paid."
  - Edward Vielmetti of MSEN



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

Date: Thu, 16 Oct 1997 17:50:28 GMT
From: gord@oracle.utoronto.ca (Gord Russell)
Subject: Something like an "IN" test
Message-Id: <EI5o84.MLy@utcc.utoronto.ca>

I'm new to perl and I'd like to do at test something like:

if ($var IN ("A", "B", "C") {  }

but perl doesn't seem to have anything like an IN test.  I've
been trying to do the same sort of thing with pattern matching,
such as 

if ( m/$var/[A, B, C] )

and being unfamiliar with sed I've been fumbling about with all
sorts of (probably stupid) permutations of using patterns.  Any
advice out there would be appreciated - like if you live in
Toronto I'll buy ya a beer.

_____________________________________________________________________

Gord Russell				   
416 978 7031				   Office of Space Management
gord@space.osm.utoronto.ca		   	University of Toronto
http://www.osm.utoronto.ca				       Canada
finger for PGP key
_____________________________________________________________________



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

Date: Thu, 16 Oct 1997 19:07:02 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Something like an "IN" test
Message-Id: <comdog-1610971907020001@netnews.worldnet.att.net>

In article <EI5o84.MLy@utcc.utoronto.ca>, gord@oracle.utoronto.ca (Gord
Russell) wrote:

> I'm new to perl and I'd like to do at test something like:
> 
> if ($var IN ("A", "B", "C") {  }
> 
> but perl doesn't seem to have anything like an IN test.  

not sure what IN is supposed to do, but if you are looking for
$var to be either 'A', 'B', or 'C' then you can use

   if( $var =~ m/^ (A|B|C) $/x )

the match will be true is $var matches any of those (in this
case the match is exact since i've anchored the match to
that start and end of the string.

for larger things alternation gets to be rather unweildly
since perl might have to do a lot of work to find a match.
you might be better off doing something like:

   foreach( qw( A B C ) )
      {
      if ($var eq $_)
         {
         $match = 1;
         last;
         }
      }

good luck :)

-- 
brian d foy                                 <http://computerdog.com>
#!/usr/bin/perl
$_=q|osyrNewkecnaYhe.mlorsePptMskurj|;s;[NY.PM]; ;g;local$\=
qq$\n$;@pm=split//;while($NY=pop @pm){$pm.=$NY;$ny.=pop @pm}
$pm=join'',reverse($ny,$pm);open(NY,'>&STDOUT');print NY $pm


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

Date: 16 Oct 1997 18:40:07 GMT
From: Douglas Wilson <dgwilson@gte.net>
Subject: Re: Something like an "IN" test
Message-Id: <625n27$t0s$1@gte2.gte.net>

Gord Russell wrote:
> 
> I'm new to perl and I'd like to do at test something like:
> 
> if ($var IN ("A", "B", "C") {  }

look in perlfunc for the 'grep' function.

> and being unfamiliar with sed I've been fumbling about with all
> sorts of (probably stupid) permutations of using patterns.  Any
> advice out there would be appreciated - like if you live in
> Toronto I'll buy ya a beer.

I don't live there, but if I'm in town I'll collect.

Cheers,
Douglas Wilson


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

Date: Thu, 16 Oct 1997 14:28:19 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Something like an "IN" test
Message-Id: <jsp526.o5i.ln@localhost>

Gord Russell (gord@oracle.utoronto.ca) wrote:
: I'm new to perl and I'd like to do at test something like:

: if ($var IN ("A", "B", "C") {  }

: but perl doesn't seem to have anything like an IN test.  


Ah, but it does. We call it 'grep'   ;-)

   if ( grep $_ eq $var, ("A", "B", "C")) {


: Any
: advice out there would be appreciated - like if you live in
: Toronto I'll buy ya a beer.


I hope that holds should I ever visit Toronto  ;-)


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


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

Date: 16 Oct 1997 19:49:11 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Something like an "IN" test
Message-Id: <625r3n$bap@news-central.tiac.net>

In article <EI5o84.MLy@utcc.utoronto.ca>,
Gord Russell <gord@oracle.utoronto.ca> wrote:
>I'm new to perl and I'd like to do at test something like:
>
>if ($var IN ("A", "B", "C") {  }
>
>but perl doesn't seem to have anything like an IN test.  I've
>been trying to do the same sort of thing with pattern matching,
>such as 
>
>if ( m/$var/[A, B, C] )

  if (grep {$var eq $_} ("A", "B", "C")) {
    ...
  }

might be one way to do it, but if you have a long list it will carry on
doing the comparison even when a natch is found.  You might want to have a
peek at the FAQ (frequently asked questions) which should come with recent
perl distributions:

  perldoc perlfaq

gets the introduction, and failing that you can check out
http://www.perl.com/

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: Thu, 16 Oct 1997 13:21:15 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Andrew M. Langmead" <aml@world.std.com>
Subject: Re: statics or const in perl ?
Message-Id: <Pine.GSO.3.96.971016131746.20497j-100000@usertest.teleport.com>

On Thu, 16 Oct 1997, Andrew M. Langmead wrote:

> Unfortunately, because the problems with lists, they don't quite fit
> the original posters criteria.
> 
> use constant LIST => qw(a b c de f g);
> for(@_) {
>   tr/a-mn-zA-MN-Z/n-za-mN-ZA-M/;
> }
> 
> Silently ignores attempts to change the members of LIST and:

Sure, 'cause you never touched them! :-)

But you're right; a foreach loop doesn't notice all lists. This is error
free, too:

    for (qw/fred barney/) {
	tr/e/Z/;
    }

Someday, I hope, it will be caught by -w. Similarly with your other code,
which "fails to fail" for other lists, not just constants.

-- 
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: 16 Oct 1997 15:50:46 -0400
From: groenvel@cse.psu.edu (John D Groenveld)
Subject: Re: sybperl/oraperl
Message-Id: <625r6m$49d$1@tholian.cse.psu.edu>

In article <62072r$69u$1@news.interlog.com>,
Patrick Charles Perroud <pperroud@interlog.com> wrote:
>would allow me to access both RDBM's. I need to select from, and 
>update
>tables on both Oracle and Sybase at the same time.

If you have access to the libraries for Oracle and Sybase for your client,
you should be able to build the DBD::Sybase and DBD::Oracle drivers and use
the DBI module to access each data source.
DBI and DBD::* can be fetched from CPAN along with the latest perl5.
http://www.hermetica.com/technologia/DBI/ is helpful, as is
http://www.dejanews.com. An Oraperl emulation module exists for
DBI/DBD::Oracle, I dont know the status of Sybperl emulation.
John
groenvel@cse.psu.edu


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

Date: Thu, 16 Oct 1997 13:29:06 -0700
From: Drake International <b~johnston@rocketmail.com>
Subject: Web Programmer Wanted
Message-Id: <34467912.3A506718@rocketmail.com>

I am looking for a Web Programmer in Vancouver.
                C++, Java Script and Perl
                        3 Yrs exp.
Please e-mail b~johnston@rocketmail.com

Barry Johnston
IT Recruitment Consultant
Drake International



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

Date: 16 Oct 1997 16:55:44 GMT
From: nospam@ll.mit.edu (Joseph Scott Stuart)
Subject: Why am I running out of memory?
Message-Id: <NOSPAM.97Oct16125544@pickering.ll.mit.edu>


I have a perl program that stops with the message 'Out of memory!' and
I can't figure out why. Using ps, I found that the memory size grows to
dozens of megabytes pretty quickly.  I've narrowed down the problem to
a particular subroutine, and I've made a small sample program that
also eats memory.  If you see anything wrong, please let me know.

Here are my system specs:

% perl -v
This is perl, version 5.004_01

% uname -a
OSF1 herpolhode V3.2 148 alpha


And the program:

#!/usr/local/bin/perl

use diagnostics;
use POSIX qw(modf);

#Days into the year, referenced by month, where 01->Jan for
#regular years and leap years.
@days = ( 0, 0, 31, 59, 90, 120, 151, 181, 212, 
              243, 273, 304, 334, 365);
@ldays = ( 0, 0, 31, 60, 91, 121, 152, 182, 213, 
              244, 274, 305, 335, 366);

# this subroutine converts Modified Julian Date into year, month,
# and day (where day specifies the time as a fraction of the day)
# the stuff about leap years is in there because I'm planning to
# change it soon to work for years other than 1997.  If you have
# any comments about that, please let me know!
sub mjd2ymd {
    my $mjd = $_[0];

    #For 1996 the MJD = 50082 + DOY
    #For 1997 the MJD = 50448 + DOY
    if ( ($mjd < 50449) || ($mjd > 50448 + 365) ){
	warn "Error MJD not in 1997\n";
    }
    $y = 1997;
    $mjd = $mjd - 50448;

    # split fractional and integral parts
    ($dayfrac, $dayint) = modf($mjd);

    use integer;

    # decide if it is a leap year
    if ( (($y%4 == 0) && ( $y%100 != 0)) || ($y%400 == 0)){
	$msize = \@ldays;
    } else {
	$msize = \@days;
    }

    # find the month number
    for($m = 2; $dayint > $$msize[$m]; $m++){;}
    $m--;

    # subtract off the days up to the beginning of the month
    # to get the day of the month
    $dayint -= $$msize[$m];

    no integer;

    # add back the fractional part of the time
    $d = $dayfrac + $dayint;

    return ($y, $m, $d);
}

$MJD=50460.23038;
for(;;){
	
    # genarate the MPC format time
    ($y, $m, $d) = &mjd2ymd($MJD);
    print "$y\t$y\t$d\n";
}

-- 
Scott Stuart
stuart at ll mit edu



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

Date: Thu, 16 Oct 1997 18:13:05 GMT
From: eric@intiman.org_nospam (Eric)
Subject: Win32, problem opening dir
Message-Id: <344657c8.2932067@intXnt>

OK, I'm missing something.  I'm new to using Perl, but I didn't think doing
things with directories would give problems!

Here is what I have been trying:

chdir ("E:\PROGS\PMAIL\MAIL") || die ("Didn't cd to
e:\\progs\\pmail\\mail\n");
unless (opendir (PMAILDIR, "e:\progs\pmail\mail")) {
	if (!(-e "e:\progs\pmail\mail")) {
		die ("Directory e:\\progs\\pmail\\mail doesn't exist\n");
	} elsif (!((-r "e:\progs\pmail\mail") && (-w
"e:\progs\pmail\mail")))  {
		die ("You are not allowed to read and write to directory
e:\\progs\\pmail\\ \n");
	} else {
		die ("Directory e:\\progs\\pmail\\mail exists, but can't be
opened\n");
	}
}

As you all can see, I've been trying to find the problem.  Perl doesn't even
think any directories exist!  I have tried other directories also and no go.

What am I missing?

Thanks!

eric@intiman.org_nospam
Eric Kylstra
Computer Coordinator
Intiman Theatre

I have the nospam on the end of my email address for the obvious reason.
Remove it to email me directly.


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

Date: Thu, 16 Oct 1997 14:48:26 -0400
From: "Hank" <htaylor@nospam.mit.edu>
Subject: windows question:  $foo to the clipboard, is it possible in a perl script?
Message-Id: <625ngf$lu8@senator-bedfellow.MIT.EDU>

has anyone ever tried to stick a scalar ($foo) into the windows clipboard?
is this possible in a perl script using ole?

thanks,

hank taylor




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

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

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