[13684] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1094 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Oct 16 13:05:24 1999

Date: Sat, 16 Oct 1999 10:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <940093508-v9-i1094@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 16 Oct 1999     Volume: 9 Number: 1094

Today's topics:
        Adding modules from the resource kit <tekwiz@home.com>
    Re: and versus && <gellyfish@gellyfish.com>
        another pointless debate was[Re: and versus &&] <ltl@rgsun40.viasystems.com>
        Bad Ref <jimmy@blackhole-designs.com>
    Re: Convert time-date string to epox seconds, (Larry Rosler)
    Re: CSS / NETSCAPE -> Through PERL <ps1715@earthlink.net>
    Re: CSS / NETSCAPE -> Through PERL <ps1715@earthlink.net>
    Re: encoded CGI data <gellyfish@gellyfish.com>
    Re: GD-1.22 Windows build? <randy@theory.uwinnipeg.ca>
    Re: Help weird html with CGI.pm and Ispell.pm <gellyfish@gellyfish.com>
    Re: Help with extracting a portion of a string <pooka@cygnus.ucdavis.edu>
    Re: Help with extracting a portion of a string <flavell@mail.cern.ch>
        How can return a dir listing from a foreign FTP site? <mjh@me.com>
        isnīt there a newbies newsgroup? where? (basic question <r.freund@gmx.de>
    Re: Learn Perl Language (Brett W. McCoy)
        LWP and IP spoofing (David Stack)
    Re: Need help with seek/sysseek <dan@tuatha.sidhe.org>
        problem about fork <null@nomail.org>
    Re: problem about fork (Randal L. Schwartz)
    Re: qr operator the $_ <ltl@rgsun40.viasystems.com>
    Re: question on FORMAT (Randal L. Schwartz)
    Re: recursive delete (Randal L. Schwartz)
        shifting a hash <tom.kralidis@ccrs.nrcanDOTgc.ca>
        sleep in win32 ? <yhu@mail.nih.gov>
    Re: sleep in win32 ? (Larry Rosler)
    Re: sleep in win32 ? <ray@rlaj.com>
    Re: sleep in win32 ? <yhu@mail.nih.gov>
    Re: sleep in win32 ? <yhu@mail.nih.gov>
    Re: Substitute for Net::SSL? <dan@tuatha.sidhe.org>
    Re: Time in $time <gellyfish@gellyfish.com>
        TUTORIAL <golf@tfz.net>
    Re: Unix Utilities: Perl Versions (Larry Rosler)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sat, 16 Oct 1999 14:05:20 GMT
From: "Robert Young" <tekwiz@home.com>
Subject: Adding modules from the resource kit
Message-Id: <AC%N3.14524$gm.159735@news1.rdc2.on.home.com>

I have the version of Perl for SCO as destributed on their Skunkware CD. I
have loaded 'gcc' from it and loaded the 'DateCalc' code from theResource
Kit. I was able to compile the DateCalc code and it seemed to install OK.

When I try to run a short test script. I get a core dump. New at this sort
of thing, but would like to import this and many more of the modules.

Maybe my call is wrong. Can anyone shed any light. The code segment I used
is from the resource kit and follows:

use DateCalc qw(:all);
$F = leap(1999);
print "$F\n";





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

Date: 16 Oct 1999 10:58:55 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: and versus &&
Message-Id: <7u9lpf$31s$1@gellyfish.btinternet.com>

On 16 Oct 1999 02:05:01 GMT lt lindley wrote:
> R. McGillis <rmcgilli@popmail.ucsd.edu> wrote:
> :>I was taught that "and" is just a short cut for "&&" to improve
> :>readability, but otherwise interchangable.
> 
> The standard example is:
> 
> open(FH,"somefile") || die "failed open somefile: $!";
> open FH, "somefile" or die "failed open somefile: $!";
> 
> Look in the table for the precedence of "," vs "||" vs "or", and then
> you may get a clue about why the parens are required in the first
> example, but not required in the second.
> 
> Frankly, I think it is one of those times where "there are too
> many ways to do it."  

'or' was introduced much later than '||' - it would generally be considered
a 'bad thing' to simply change the precedence of an operator and given
that in some circumstances where it might be used the precedence of '||'
is too high a new lower precedence operator is required lest a lot of
programs get broken.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


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

Date: 16 Oct 1999 16:11:32 GMT
From: lt lindley <ltl@rgsun40.viasystems.com>
Subject: another pointless debate was[Re: and versus &&]
Message-Id: <7ua83k$fl2$1@rguxd.viasystems.com>

Jonathan Stowe <gellyfish@gellyfish.com> wrote:
:>On 16 Oct 1999 02:05:01 GMT lt lindley wrote:
:>> Frankly, I think it is one of those times where "there are too
:>> many ways to do it."  

:>'or' was introduced much later than '||' - it would generally be considered
:>a 'bad thing' to simply change the precedence of an operator and given
:>that in some circumstances where it might be used the precedence of '||'
:>is too high a new lower precedence operator is required lest a lot of
:>programs get broken.

Oh, puuu-lease, Johnathan.  I said nothing about changing the
precedence of an existing operator.  And I can't think of
any situation where or/and is required.  Are there really
any places where you cannot control the precedence with parens?

I like having them available.  They let me write prettier code (for
some definitions of pretty).  But I can do without them quite
easily.  

Is there really any argument for them other than taste and style?
(Not that taste and style aren't perfectly good arguments.)

-- 
// Lee.Lindley   /// I used to think that being right was everything.
// @bigfoot.com  ///  Then I matured into the realization that getting
////////////////////   along was more important.  Except on usenet.


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

Date: Sat, 16 Oct 1999 16:39:36 GMT
From: Jimmy Humphrey <jimmy@blackhole-designs.com>
Subject: Bad Ref
Message-Id: <3808AB43.B5C7990@blackhole-designs.com>

Hi,

I am noticing that some people on aol browsers cause my cgi scripts to
crash on when I check for their $ENV{'HTTP_REFERER'} to make sure they
are coming from the right place, and not trying to me off. Do some
browsers not support $ENV{'HTTP_REFERER'} ? Is there another direct way
around it to tell where they are coming from?

Thanks,

Jimmy
-- 
Jimmy Humphrey <jimmy@blackhole-designs.com>
Web Designer - Black Hole Designs - http://www.blackhole-designs.com


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

Date: Sat, 16 Oct 1999 08:41:45 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Convert time-date string to epox seconds,
Message-Id: <MPG.12723c89e192c54f98a0a3@nntp.hpl.hp.com>

In article <6nEIOHWcK3SOh=xUg1VUFRasKPat@4ax.com> on Sat, 16 Oct 1999 
11:40:34 GMT, Marcel Grunauer <marcel.grunauer@lovely.net> says...
> On Sat, 16 Oct 1999 12:59:14 +0200, Mark Bakker <mark@compumix.com>
> wrote:
> > Does anyone know a simple way to convert a date-time string (YYYY-MM-SS
> > HH:MM:SS) to epox seconds?
> 
> Time::Local has what you need:
> 
> #!/usr/bin/perl -w
> 
> use strict;
> use Time::Local;
> 
> my $t = '1999-10-16 13:39:20';
> my ($year, $month, $day, $hour, $min, $sec) =
> 	($t =~ /^(\d{4})-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)/);
> print timelocal($sec,$min,$hour,$day,$month,$year);

Oops.

  print timelocal($sec, $min, $hour, $day, $month - 1, $year - 1900);

A good way to test this is to feed the result back to scalar 
localtime().  Too bad you didn't do that.

Surprisingly, it still works with '1999' instead of '99', which must be 
due to some juju in the timelocal() module.  It is specified to take the 
same arguments as the first six elements of the list of values that 
localtime() produces.

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


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

Date: Sat, 16 Oct 1999 11:16:44 -0500
From: "RLD" <ps1715@earthlink.net>
Subject: Re: CSS / NETSCAPE -> Through PERL
Message-Id: <7ua5tt$onn$1@ash.prod.itd.earthlink.net>

******** STOP *********

I figured it out... for those wanting to know the solution...

I had to place all of the <div> tags that contained id's pointing to css
styles within <div> tags that pointed to no style information... very
strange, but I'm new to this DHTML stuff.

Thanks everyone for your help.

Randall
****************************
RLD <ps1715@earthlink.net> wrote in message news:...
> I appreciate your help... however... none of this solves the problem...
>
> You will notice that the same exact code works in Netscape if you load the
> file directly...
>
> http://www.scriptsites.com/helpdesk/template.htm
>
> However when you load the file using CGI / Perl output ... it doesn't...
> although the styles and javascript has not changed....
>
> http://scriptsites.com/cgi-bin/helpdesk/helpd.pl
>
> It works in both instances with IE, but Netscape does not seem to handle
it
> when it is output from a perl script.
>
> Any ideas?
>
> Randall
>
>
> Thomas <thomas@firstpoint.se> wrote in message
> news:7u8g49$4b$1@zingo.tninet.se...
> > hi,
> >
> > 1.if you are linking to external JS / CSS sources like;
> > <SCRIPT SRC="js.pl"> or <style src="css.pl">
> > you MUST make sure the correct headers are being sent along.
> > IE mostly recognizes things by the file-extensions or its inline origin.
> > but Netsape on the other hand *correctly*
> > does it from the content-type header.
> >
> > with PERL, start your output session by telling STDOUT;
> > print "Content-Type: application/x-javascript\n\n";
> > or;
> > print "Content-Type: text/css\n\n";
> >
> > 2. Check your HTML syntax, IE allows sloppy coding, ehh, take no
> > offence...:))
> > while Netscape indeed does not, especially when it comes to
layer-content.
> >
> > ok, hope this helps...
> > thomas(at)firstpoint(dot)se
> > ---------------------------------------
> > RLD skrev i meddelandet <7u86mv$313$1@fir.prod.itd.earthlink.net>...
> > >Ran across a strange problem that maybe someone can give me some
> direction
> > >with...
> > >
> > >Created a template file that uses CSS and JavaScript.  The layers are
> > tables
> > >that are displayed depending on what button is clicked.  The template
> works
> > >fine when loaded in both Netscape and IE.  However... when I run my
Perl
> > >script which opens the template and then displays it... only IE
displays
> it
> > >correctly with full functionality.  Netscape on the other hand just
sits
> > >there, the calls to the JavaScript ing... seems to produce no output...
> it
> > >is not hiding the tables and making visible the one chosen.
> > >
> > >Is there something in the headers possibly that is not going over well
> with
> > >Netscape?  I've used JavaScript in this manner before, but never with
CSS
> > >... could there be a problem with styles not loading correctly when the
> > >output comes through a Perl script?  I'm stumped.
> > >Please help,
> > >Randall
> >
> >
> >
>
>





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

Date: Sat, 16 Oct 1999 11:09:31 -0500
From: "RLD" <ps1715@earthlink.net>
Subject: Re: CSS / NETSCAPE -> Through PERL
Message-Id: <7ua5gj$o2d$1@ash.prod.itd.earthlink.net>

I appreciate your help... however... none of this solves the problem...

You will notice that the same exact code works in Netscape if you load the
file directly...

http://www.scriptsites.com/helpdesk/template.htm

However when you load the file using CGI / Perl output ... it doesn't...
although the styles and javascript has not changed....

http://scriptsites.com/cgi-bin/helpdesk/helpd.pl

It works in both instances with IE, but Netscape does not seem to handle it
when it is output from a perl script.

Any ideas?

Randall


Thomas <thomas@firstpoint.se> wrote in message
news:7u8g49$4b$1@zingo.tninet.se...
> hi,
>
> 1.if you are linking to external JS / CSS sources like;
> <SCRIPT SRC="js.pl"> or <style src="css.pl">
> you MUST make sure the correct headers are being sent along.
> IE mostly recognizes things by the file-extensions or its inline origin.
> but Netsape on the other hand *correctly*
> does it from the content-type header.
>
> with PERL, start your output session by telling STDOUT;
> print "Content-Type: application/x-javascript\n\n";
> or;
> print "Content-Type: text/css\n\n";
>
> 2. Check your HTML syntax, IE allows sloppy coding, ehh, take no
> offence...:))
> while Netscape indeed does not, especially when it comes to layer-content.
>
> ok, hope this helps...
> thomas(at)firstpoint(dot)se
> ---------------------------------------
> RLD skrev i meddelandet <7u86mv$313$1@fir.prod.itd.earthlink.net>...
> >Ran across a strange problem that maybe someone can give me some
direction
> >with...
> >
> >Created a template file that uses CSS and JavaScript.  The layers are
> tables
> >that are displayed depending on what button is clicked.  The template
works
> >fine when loaded in both Netscape and IE.  However... when I run my Perl
> >script which opens the template and then displays it... only IE displays
it
> >correctly with full functionality.  Netscape on the other hand just sits
> >there, the calls to the JavaScript ing... seems to produce no output...
it
> >is not hiding the tables and making visible the one chosen.
> >
> >Is there something in the headers possibly that is not going over well
with
> >Netscape?  I've used JavaScript in this manner before, but never with CSS
> >... could there be a problem with styles not loading correctly when the
> >output comes through a Perl script?  I'm stumped.
> >Please help,
> >Randall
>
>
>





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

Date: 16 Oct 1999 10:23:20 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: encoded CGI data
Message-Id: <7u9jmo$2rv$1@gellyfish.btinternet.com>

On Fri, 15 Oct 1999 00:58:31 -0500 Clinton Carr wrote:
> What's an easy way to URL encode data to send via CGI Post?
> 

The module URI::Escape will do this (how can the b*tard guttman gets a
module name after him :)

Alternatively:

    $string =~ s/([^A-Za-z0-9])/sprintf("%%%02X",ord($1))/eg;

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


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

Date: Sat, 16 Oct 1999 10:15:50 -0500
From: "Randy Kobes" <randy@theory.uwinnipeg.ca>
Subject: Re: GD-1.22 Windows build?
Message-Id: <7ua4od$50i$1@canopus.cc.umanitoba.ca>


Steve Siegel <stevesny@ibm.net> wrote in
   message news:38081318.32698500@news1.ibm.net...
> Does anyone know of a GD-1.22 (with True Type fonts) complete windows
build?

Hi,
    If ActiveState's GD build doesn't include ttf support, search deja-news
for a recent thread on trying to build your own under Windows.

best regards,
Randy Kobes





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

Date: 16 Oct 1999 09:12:04 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Help weird html with CGI.pm and Ispell.pm
Message-Id: <7u9fh4$2pf$1@gellyfish.btinternet.com>

On Fri, 15 Oct 1999 17:43:53 GMT Scott Beck wrote:
> Do you happen to know of a more portable way to spell check?
> I know Ispell is not install on every computer.
> Maybe there is somthing I can install locally that would do it?
> 

The module Search::Dict is part of the Perl distribution - of course you
will have to do more work yourself:

#!/usr/bin/perl -w

use strict;
use Search::Dict;

my $file = '/usr/dict/words';

open(DICT,$file) || die "Cant open $file - $!\n";

while(<>)
{
  my $line_number = $.;
  chomp;
  
   foreach (split )
     {
       s/\W//g;
       next if /^\d/;        
       my $pos = look *DICT,$_,1,1;
       my $word = <DICT>;
       chomp $word;
       if (lc($_) ne lc($word))
         {
           print "line $line_number : $_  - guess $word \n";
         }
     }
}

On a platform that doesnt have spell or ispell you will have to get your
own word list - copy the /usr/dict/words from a platform that does.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


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

Date: Sat, 16 Oct 1999 16:24:57 GMT
From: Brandon <pooka@cygnus.ucdavis.edu>
Subject: Re: Help with extracting a portion of a string
Message-Id: <3808361B.3A94C195@cygnus.ucdavis.edu>

Abigail wrote:
> Pointless proof, as the text you are parsing isn't comments - it's HTML.
> And HTML cannot be described as a regular expression.
> 

I'm not _parsing_ anything; I'm merely extracting the comments. My
solution relies on pattern matching instead of trying to parse a grammer
(HTML in this case). The rest of the HTML can be eliminated or ignored,
so my language is not HTML, but HTMLcomment (for lack of another name).
Granted, this process takes slightly more computational power than just
a single regular expression can provide, but it's still not parsing.
This argument could get highly semantical around the definition of the
word "parser", but I think you can see the differentiation I'm making...
There is a parser, and there is a class of machines with computational
power enough to be capable of parsing, but not necessarily used for
parsing. The technique has limited scope in terms of language
processing, but scope nonetheless...


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

Date: Sat, 16 Oct 1999 18:36:51 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Help with extracting a portion of a string
Message-Id: <Pine.HPP.3.95a.991016183514.6256I-100000@hpplus01.cern.ch>

On Sat, 16 Oct 1999, Brandon wrote:

> I'm not _parsing_ anything; I'm merely extracting the comments. 

You obviously don't understand what you're saying.

> My
> solution relies on pattern matching instead of trying to parse a grammer
> (HTML in this case).

Then it can't work.

> The rest of the HTML can be eliminated or ignored,

Yes, it can: you do that by parsing it.



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

Date: Sat, 16 Oct 1999 17:24:15 -0700
From: "John" <mjh@me.com>
Subject: How can return a dir listing from a foreign FTP site?
Message-Id: <IJ1O3.17$cW.7078@news.enterprise.net>

I need a directory listing, and the ability to delete and upload/download,
to this FTP site.  I have access to the FTP server name, username and
password.  I know their are some modules, but is their a built in PERL 5
function to simply grep a dir structure.  This is for a remote access script
that I am developing.

Any help would be great.
John




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

Date: Sat, 16 Oct 1999 18:22:44 +0200
From: "Robert Freund" <r.freund@gmx.de>
Subject: isnīt there a newbies newsgroup? where? (basic questions)
Message-Id: <7ua8kb$f5u$1@rks1.urz.tu-dresden.de>






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

Date: Sat, 16 Oct 1999 14:03:07 GMT
From: bmccoy@foiservices.com (Brett W. McCoy)
Subject: Re: Learn Perl Language
Message-Id: <slrn80h1l1.863.bmccoy@moebius.foiservices.com>

Also Sprach Internet Explorer <12345@unbounded.com>:

>any web site good for me to learn perl language?

uh, www.perl.com?

-- 
Brett W. McCoy                             bmccoy@foiservices.com
Computer Operations Manager (Alpha Geek)   http://www.foiservices.com
FOI Services, Inc./DIOGENES                301-975-0110
---------------------------------------------------------------------------


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

Date: Sat, 16 Oct 1999 17:20:19 GMT
From: musicstack@hotmail.com (David Stack)
Subject: LWP and IP spoofing
Message-Id: <3808b30c.92569888@news.supernews.com>

Does anyone know a way to use LWP and have your IP address changed
each time a call is made?  (ie, IP spoofing)

I would be willing to pay money for a working solution.

Dave



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

Date: Sat, 16 Oct 1999 16:10:29 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Need help with seek/sysseek
Message-Id: <Vr1O3.1267$IZ5.20104@news.rdc1.ct.home.com>

Shawn Collenburg <greynite@mindspring.com> wrote:
> Could anyone tell me why the following program does not work? It fails
> on just about every PERL it's been tested on save one.

How exactly is it failing?

> open FILE,"+>>seektest1.txt";

You've opened this file wrong. You probably want +< which will open it
read/write without clobbering what's in there.

Also, IIRC many C libraries automatically seek to the end of a file opened
for append whenever you write to it, no matter where you were when you
tried the write. That might also be your problem.

					Dan


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

Date: 16 Oct 1999 14:59:01 GMT
From: null <null@nomail.org>
Subject: problem about fork
Message-Id: <7ua3rl$9s1$1@news2.nctu.edu.tw>


I have a problem about fork. If I have some jobs to do (say n jobs)
,and I hope to fork m processes (m<n) to do these jobs. When any one process
of these m processes finished , a new process is forked, until all
n jobs are done. That is , at any time , I have m processes to
do these jobs in parallel. Here is my program, but it forks more
than m processes....-_-

for($i=1,$i<=(n/m),$i++)
{$j=1;
       Fork_start:{ if($pid=fork())
                        {
                                $j++;
                                if(j<=m){redo Fork_start;}
                                waitpid($pid,0);
                        }
                        else
                        { #my job here}
                }
}


-- 
No Junk Mail


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

Date: 16 Oct 1999 09:33:54 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: problem about fork
Message-Id: <m1zoxjxo25.fsf@halfdome.holdit.com>

>>>>> "null" == null  <null@nomail.org> writes:

null> I have a problem about fork. If I have some jobs to do (say n jobs)
null> ,and I hope to fork m processes (m<n) to do these jobs. When any one process
null> of these m processes finished , a new process is forked, until all
null> n jobs are done. That is , at any time , I have m processes to
null> do these jobs in parallel. Here is my program, but it forks more
null> than m processes....-_-

null> for($i=1,$i<=(n/m),$i++)
null> {$j=1;
null>        Fork_start:{ if($pid=fork())
null>                         {
null>                                 $j++;
null>                                 if(j<=m){redo Fork_start;}
null>                                 waitpid($pid,0);
null>                         }
null>                         else
null>                         { #my job here}
null>                 }
null> }

Try this instead:

    my %kids;
    for (my $task = 1; $task <= $m; $task++) {
      while (keys %kids >= $n) { # must wait for previous
	my $died = wait;
	delete $kids{$died};
      }
      my $pid = fork;
      unless (defined $pid) {
	warn "waiting to fork: $!";
	sleep 1;
	redo;
      }
      if ($pid) { # parent
	$kids{$pid} = 1;
	next;
      } else { #child
	do_task($task);
	exit 0;
      }
    }
    while (keys %kids > 0) { # wait till they're all done
      my $died = wait;
      delete $kids{$died};
    }

I just hacked this out in a few minutes... might have missed something,
but this should be a lot closer than where you were going. :)

I should probably turn this into a magazine column.  Yeah, that's the
ticket.

print "Just another Perl hacker,"

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: 16 Oct 1999 15:15:41 GMT
From: lt lindley <ltl@rgsun40.viasystems.com>
Subject: Re: qr operator the $_
Message-Id: <7ua4qt$ep3$1@rguxd.viasystems.com>

Marcel Grunauer <marcel.grunauer@lovely.net> wrote:
[snip]
:>but it'd be nice if

:>	print "match" if $re;

:>would act on $_.

Well, the fact that $re is a scalar that is not 0 will always
return true in that context.

print "match" if /$re/;

will do what you want.  So will

print "match" if $_ =~ $re

:>But maybe I'm misunderstanding qr() (I've checked perlop).

:>	print $re

:>prints "(?-xism:\d)", so qr() just seems to construct a regex, but
:>somehow I thought there'd be more magic behind the scenes. Is that all
:>there is to qr() or am I missing something?

There is less magic than I thought when I first saw it too.  It is
mostly just a quoting operator.  If you think of it that way,
it will behave the way you expect most of the time.

Put 
use re 'debugcolor';
at the top of your program and more will become clear as you
experiment.


-- 
// Lee.Lindley   /// I used to think that being right was everything.
// @bigfoot.com  ///  Then I matured into the realization that getting
////////////////////   along was more important.  Except on usenet.


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

Date: 16 Oct 1999 08:09:22 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: question on FORMAT
Message-Id: <m1iu47e40t.fsf@halfdome.holdit.com>

>>>>> "dVoon" == dVoon  <dvoon@my-deja.com> writes:

dVoon> Consider the code below. How to output a report with each department
dVoon> grouped in one page? -Or how to page break each every new value in
dVoon> $dept? Please help.

dVoon> P/S: Please excuse my broken English.

dVoon> Regards,
dVoon> Daniel

dVoon> %table = (
dVoon>            100 => ['john', 'sales', 3200],
dVoon>            200 => ['alan', 'tech', 2200],
dVoon>            300 => ['susan', 'admin', 1200],
dVoon>            400 => ['mark', 'sales', 3500],
dVoon>            500 => ['elle', 'tech', 2300],
dVoon>            600 => ['lee', 'admin', 2500],
dVoon>            700 => ['alice', 'sales', 3500],
dVoon>            800 => ['lucas', 'tech', 4000],
dVoon>            900 => ['mcarthur', 'admin', 2000]
dVoon>          );

dVoon> foreach $id (sort {($table{$a}[1] cmp $table{$b}[1])||($a cmp $b)} keys
dVoon> %table) {

add:

        if ((my $thisdept = $table{$id}[1]) ne $prevdept) {
		$prevdept = $thisdept;
		$- = 0; # force pagebreak on next write
	}

dVoon> 	($name, $dept, $salary) = @{$table{$id}};
dVoon> 	write( STDOUT );
dVoon> }

dVoon> 	format STDOUT_TOP =
dVoon> @<<<<<
dVoon> $dept

dVoon> NAME        SALARY
dVoon> ----        ------
dVoon> .
dVoon> 	format STDOUT =
dVoon> @<<<<<<<    @####.##
dVoon> $name,      $salary
dVoon> .

print "Just another Perl hacker,"

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: 16 Oct 1999 07:46:43 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: recursive delete
Message-Id: <m1puyfe52k.fsf@halfdome.holdit.com>

>>>>> "Mike" == Mike Watkins <mwatkins@promotion4free.com> writes:

Mike> Hi there,
Mike> Try this little bit of code which I wrote for a script I'm creating.
Mike> $newdir is the directory which you want to delete, without the slash at the
Mike> end, and the $rmdir variable is the location to the "rmdir" function, which
Mike> on UNIX servers is usually located at "/bin/rmdir".  For Windows systems,
Mike> use just "rmdir".

[code deleted]

Or just use the built-in libraries:

    use File::Path;
    rmtree("/top/of/tree/to/delete", $verbose ? 1 : 0);

If you ever find yourself writing recursive directory things, please
stop.  There's already this function in the standard library, and the
more general File::Find that can do nearly anything.

print "Just another Perl hacker,"
-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Sat, 16 Oct 1999 10:04:22 -0400
From: Tom Kralidis <tom.kralidis@ccrs.nrcanDOTgc.ca>
Subject: shifting a hash
Message-Id: <380885E6.72A51D34@ccrs.nrcanDOTgc.ca>

Hi,

I've been working on script to correct data files.  The script does
corrections based on a hash:

key    value

33.44  444
55.69  741
88.88  777

The has gets created by a foreach loop, with:

push(@{ $errorList{$error} }, $pointID );

The has gets sorted so that the highest key's value is returned, then
used to zero weight the key's value in another file.  The above case
would return value 777, with the following code:

 foreach (reverse sort keys %errorList)
  {
    print "$_: @{$errorList{$_}}\n";
    $skew = $errorList{$_}->[0] if not defined $skew;
  }

The process has to be looped until an output file is created, or the
number of samples is less than 4.

For each iteration of this process, I would like to shift (delete the
first value) the has so that the script looks for a value that has not
been zero-weighted in the previous loop.  I have tried:

shift(@{ $errorList{$error} }, $pointID );

to remove the first key - value, and return the highest value's key that
has not been used by the loop, but no luck.

Does anyone have any advice on this?  Am I better useing a
multi-dimensional array?

Thanks alot

 ..Tom

-----------------------------------------------------------------------------------------
Tom Kralidis                                  Geo-Spatial Technologist 
Canada Centre for Remote Sensing              Tel: (613) 947-1828
588 Booth Street , Room 241                   Fax: (613) 947-1408
Ottawa , Ontario K1A 0Y7                     http://www.ccrs.nrcan.gc.ca
-----------------------------------------------------------------------------------------


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

Date: Sat, 16 Oct 1999 11:38:55 -0400
From: Ying Hu <yhu@mail.nih.gov>
Subject: sleep in win32 ?
Message-Id: <38089C0E.C33E1AEC@mail.nih.gov>

Hi:
Do you know if there is sleep function in win32?
Thanks!
Ying



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

Date: Sat, 16 Oct 1999 09:03:58 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: sleep in win32 ?
Message-Id: <MPG.127241c5ab52189b98a0a5@nntp.hpl.hp.com>

In article <38089C0E.C33E1AEC@mail.nih.gov> on Sat, 16 Oct 1999 11:38:55 
-0400, Ying Hu <yhu@mail.nih.gov> says...
> Do you know if there is sleep function in win32?

What happened when you tried it?

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


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

Date: Sat, 16 Oct 1999 11:13:35 -0400
From: Ray and Grace <ray@rlaj.com>
Subject: Re: sleep in win32 ?
Message-Id: <3808961F.7A390EDD@rlaj.com>

> Do you know if there is sleep function in win32?
>

yes.

sleep(5);   # 5 seconds sleep




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

Date: Sat, 16 Oct 1999 12:49:39 -0400
From: Ying Hu <yhu@mail.nih.gov>
Subject: Re: sleep in win32 ?
Message-Id: <3808ACA3.4F0BFE2D@mail.nih.gov>

I want to get the result after the refresh such as the following:
<META HTTP-EQUIV="Refresh"
CONTENT="6;URL=http://www.aaa.com/bbb/bbbb.cgi?something1=string1&something2=string2">

Can I get the result after sleeping 6 second?


Larry Rosler wrote:

> In article <38089C0E.C33E1AEC@mail.nih.gov> on Sat, 16 Oct 1999 11:38:55
> -0400, Ying Hu <yhu@mail.nih.gov> says...
> > Do you know if there is sleep function in win32?
>
> What happened when you tried it?
>
> --
> (Just Another Larry) Rosler
> Hewlett-Packard Laboratories
> http://www.hpl.hp.com/personal/Larry_Rosler/
> lr@hpl.hp.com



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

Date: Sat, 16 Oct 1999 12:51:03 -0400
From: Ying Hu <yhu@mail.nih.gov>
Subject: Re: sleep in win32 ?
Message-Id: <3808ACF7.D4173CD7@mail.nih.gov>

sleep (5); == sleep 5; ?

Ray and Grace wrote:

> > Do you know if there is sleep function in win32?
> >
>
> yes.
>
> sleep(5);   # 5 seconds sleep



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

Date: Sat, 16 Oct 1999 16:05:06 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Substitute for Net::SSL?
Message-Id: <Sm1O3.1266$IZ5.20104@news.rdc1.ct.home.com>

Mike Watkins <mwatkins@promotion4free.com> wrote:
> Does anyone know anyway I can "easily" post form data to a remote SSL server
> without having to install any extra Perl modules?  For example, using the
> IO::Socket module?

You've got two choices here:

1) Use an existing SSL module
or
2) Write the SSL code yourself in perl

There may be code out there to do SSL entirely in perl (in which case you
could snag it, if the license permits, and embed it in your program) but I
doubt it.

I really don't think you want to be doing this in perl anyway, at least
not if there's any quantity of data involved. Perl really isn't the
language to be writing fast cryptographic software in. Besides, using an
existing module has the advantage that it's more likely to be correct, or
at least less wrong, as more folks have been abusing it.

				Dan


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

Date: 16 Oct 1999 10:29:50 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Time in $time
Message-Id: <7u9k2u$2s2$1@gellyfish.btinternet.com>

On 15 Oct 1999 13:45:35 -0400 Uri Guttman wrote:
>>>>>> "CB" == Craig Berry <cberry@cinenet.net> writes:
> 
>   CB>   my $timestr = strftime '%Y-%m-%d %H:%M:%S', localtime;
> 
> golf, anyone?
> 

The problem with that is that you Americans all start jumping on the green
before its all over ...

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


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

Date: Sat, 16 Oct 1999 12:17:13 -0400
From: "Jim" <golf@tfz.net>
Subject: TUTORIAL
Message-Id: <7ua8gq$oje$1@bgtnsc03.worldnet.att.net>

Where can I get a download a perl tutorial for windows. I am a beginner with
perl, but have other programming experience.

Jim




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

Date: Sat, 16 Oct 1999 08:52:02 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Unix Utilities: Perl Versions
Message-Id: <MPG.12723f00e317595f98a0a4@nntp.hpl.hp.com>

In article <7u9mn5$5hg$1@nnrp1.deja.com> on Sat, 16 Oct 1999 11:14:47 
GMT, bayinnaung@my-deja.com <bayinnaung@my-deja.com> says...
> I came across a page full of Unix utilities that
> had been rewritten in Perl about a week ago.

They were rewritten much more than a week ago.  :-)

> I believe the author was Tom Christiansen...
> and I cannot find it again...you'd think that there
> would be a lot of links to it...
> 
> Does anyone know where it is?

Very odd.  I couldn't find it by searching <URL:http://www.perl.com/>  
for 'PPT' or 'power tools'.  But Deja of this newsgroup with subject PPT 
and author Christiansen came up with the answer right away:

<URL:http://language.perl.com/ppt/>

You post from Deja; why not use it?

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


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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

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

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


------------------------------
End of Perl-Users Digest V9 Issue 1094
**************************************


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