[18036] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 196 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 1 21:06:17 2001

Date: Thu, 1 Feb 2001 18:05:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <981079512-v10-i196@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 1 Feb 2001     Volume: 10 Number: 196

Today's topics:
        DBM Help (Beginner Question) freedive@my-deja.com
    Re: Fish v Fishing lessons - again! (was: Installing an <jdf@pobox.com>
    Re: Fish v Fishing lessons - again! (was: Installing an <comdog@panix.com>
    Re: getting a match within a string? (Garry Williams)
    Re: how to split *gz file <chrisw@dynamite.com.au>
        I have the weirdest problem !!! (die, and exit don't wo pape_98@my-deja.com
    Re: Include bug in HTML::Template 2.2 (Damian James)
        Q:  Activestate and Fork() <loy_x@yahoo.com>
    Re: Q:  Activestate and Fork() <jdf@pobox.com>
    Re: question about sort <mischief@velma.motion.net>
    Re: race condition or lock problem <jdf@pobox.com>
    Re: race condition or lock problem <johnm@acadiacom.net>
    Re: race condition or lock problem <jdf@pobox.com>
        redirection problem <b0l4549@cs.tamu.edu>
    Re: redirection problem <johnm@acadiacom.net>
        replace a matched string cleng1@my-deja.com
        Running shell comands from Perl? <gdaniell@wt.com.au>
    Re: Running shell comands from Perl? <jck1@seed.net.tw>
    Re: Running shell comands from Perl? <jdf@pobox.com>
    Re: stupid eval tricks (Damian James)
    Re: Thank you!- Re: sort: how do I ignore a specific wo <bart.lateur@skynet.be>
        use strict  + .lib <jhall@ifxonline.com>
    Re: use strict  + .lib <jdf@pobox.com>
    Re: Using global var in subroutine <wyzelli@yahoo.com>
        Viewing the html code <vm1@ece.msstate.edu>
    Re: Viewing the html code (Abigail)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 02 Feb 2001 00:35:56 GMT
From: freedive@my-deja.com
Subject: DBM Help (Beginner Question)
Message-Id: <95cvdc$ns7$1@nnrp1.deja.com>

Hi,

   I've just compiled the Perl v5.6.0 in my machine.
   The executable is in /usr/bin.
   I am getting "No dbm on this machine at line 8" message
   when trying to run the code below :

   Could anyone tell me how to trouble-shoot this ?? Is DBM
   a seperate part of Perl ?? Am I missing certain kinds of link ?
   How can I find DBM ??

Thanks for your help in advance,


Bill



#!/usr/bin/perl -w
# use strict;

dbmopen(%lict, "licount", 0644) || die "Can not DBM licount $!";

foreach $cnt (keys %lict) {
         print "$cnt $lict{$cnt}\n";
      }

dbmclose(%lict);


Sent via Deja.com
http://www.deja.com/


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

Date: 01 Feb 2001 20:13:28 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Fish v Fishing lessons - again! (was: Installing and using modules when you're not root?)
Message-Id: <hf2dopjb.fsf@pobox.com>

brian d foy <comdog@panix.com> writes:

>     http://www.perldoc.com

Very nice! Might you make available a distribution of the thing for
local mirroring?

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Thu, 01 Feb 2001 20:20:28 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: Fish v Fishing lessons - again! (was: Installing and using modules when you're not root?)
Message-Id: <comdog-F43910.20202801022001@news.panix.com>

In article <hf2dopjb.fsf@pobox.com>, Jonathan Feinberg <jdf@pobox.com> 
wrote:

> brian d foy <comdog@panix.com> writes:
> 
> >     http://www.perldoc.com
> 
> Very nice! Might you make available a distribution of the thing for
> local mirroring?

ask Carlos. :)

-- 
brian d foy <comdog@panix.com>



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

Date: Fri, 02 Feb 2001 00:19:59 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: getting a match within a string?
Message-Id: <P2ne6.374$Sn3.14235@eagle.america.net>

On Thu, 01 Feb 2001 17:16:47 GMT, alazarev1981@my-deja.com
<alazarev1981@my-deja.com> wrote:
>I need to create a new file, the name of which is a pattern found in a
>line from another file that already exists.
>Here's my code (doesn't work):
>
>#!/usr/local/bin/perl -w

Good.  Warnings enabled.  

Better: 

 use strict;

>my(@xmlFileArray);
>
>open(XMLFILE, "<blah.xml");


Always check the result of opening a file.  

 open(XMLFILE, "<blah.xml") || die "can't open `blah.xml': $!;


>$i=0;
>while(<XMLFILE>) {
>  $xmlFileArray[$i] = $_;
>  $i++;
>}
>close(XMLFILE);


Not sure why you go to the trouble of counting the lines in the file.
Perl will do that for you and put the number in the $. variable.  See
the perlvar manual page for details.  

I'm also not sure why you load each line into an array.  Why not just
include the following processing in the same loop and skip saving
each line into another array?  

Of course, I get the feeling that you have not shown all of the code
for your particular program, so you may have good reasons.  


>open(XMLFILE, "<blah.xml");
>foreach(@xmlFileArray) {
>  if($_ =~ /  <Member number="\d{4}-\d{3}" status="\w+">$/) {
>    ############
>    # i need to make a new file with a name that matches
>    # the \d{4}-\d{3} pattern in the if condition above
>    ############
>    $newXMLFileName = m/\d{4}-\d{3}/;


Then I suggest that you rewrite the if statement to capture just that
bit.  Also, the default for a match operator is to do the match in the
$_ variable, so you can omit the binding operator altogether: 

   if (/  <Member number="(\d{4}-\d{3})" status="\w+">$/) {
       $newXMLFileName = $1;


>    print "$newXMLFileName\n"; # prints the number 1???!!!
>  }
>}
>close(XMLFILE);


Hmm.  Didn't that file just get closed?  :-)  


>I've read my perl books and looked at perldoc and perl.com and I can't
>find the answer?! Any help is appreciated.


Okay, you need to review the perlop and perlre manual pages.  Use
capturing parentheses to "remember" the parts of a regular expression
and use the truth of the match to know if it actually happened.  In
your code, the match simply returns the number 1 because you didn't
ask for any capturing to be done and you assigned the result of the
match to a scalar.  

-- 
Garry Williams


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

Date: Fri, 2 Feb 2001 11:15:38 +1100
From: "Chris W" <chrisw@dynamite.com.au>
Subject: Re: how to split *gz file
Message-Id: <50ne6.23$bi2.5153@news0.optus.net.au>

"Peter Sundstrom" <peter.sundstrom@eds.com> wrote in message
news:95cm20$nlk$1@hermes.nz.eds.com...
> What's wrong with the split command?

It doesn't produce n gzip files each containing some of the files from the
original, each useful on its own.

Of course, that doesn't make this any more a Perl question.





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

Date: Fri, 02 Feb 2001 00:19:13 GMT
From: pape_98@my-deja.com
Subject: I have the weirdest problem !!! (die, and exit don't work)
Message-Id: <95cudq$n5u$1@nnrp1.deja.com>

Hello,
I have an if statement written below, and when it finds the variable
$name, the script is supposed to print some stuff out, and then die.
But for some reason it doesn't. It actually excecutes the commands
written after the else. This is what i don't understand.
I have asked co-workers to look at this, and they tell me that it
shouls work. So now i'm left pondering why it doesn't work.
Do any of you guys see something wrong with what I have written???

Thanks,
Pape

This is what the script looks like:

# Opens the file animal and stores contents into an array.
open (file, "/applications/apache/cgi-bin/animal-schedule-
list/animal1.txt");
@lines = <file>;
close (file);

# If the name that was imputed is already in the list, then the program
exits.
for ($i=0; $i <= $#lines; $i++) {
 if ($lines[$i] =~ s/$email/$email/){
    print header(), start_html("USER ALREADY EXISTS");
    print "<center> The user $name is already in the list<br>";
    print end_html;
    }
 if ($lines[$i] =~ s/$email/$email/){
    die ;
    exit(0);
    print "i still c u <br>";
    }
 else{

# Otherwise, it opens the file for writing and prints the updated array.
    open (file, ">/applications/apache/cgi-bin/animal-schedule-
list/animal1.txt");
    print file @lines;
    print file "$name,$email\n";
    close (file);
    }
}


Sent via Deja.com
http://www.deja.com/


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

Date: 1 Feb 2001 23:53:19 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: Include bug in HTML::Template 2.2
Message-Id: <slrn97jtnr.mcu.damian@puma.qimr.edu.au>

Thus spake James Taylor on Thu, 1 Feb 2001 03:38:20 +0000:
>A few days ago I posted the following article, but it had no comment
>from anyone. Is this because I have chosen the wrong group for this
>question, or have I unknowingly upset the group and been killfiled?
>
>In article <ant3104210b0fNdQ@oakseed.demon.co.uk>, James Taylor
><URL:mailto:james@NOSPAM.demon.co.uk> wrote:
>>
>> I think I've found a bug in HTML::Template ...
>> ...
>> I have double checked that the syntax of the templates I am using are
>> correct, and that the file named in the TMPL_INCLUDE is present in the
>> correct place. Please could someone tell me if I'm doing something
>> fundamentally wrong, or whether this is a genuine bug in
>> HTML::Template. Thank you.
>
>I hope someone out there can help. Thanks again.
>

It's probably worth pointing out that there's an HTML::Template mailing
list that is the canonical place to post questions, bug reports, etc. Sam
tends to be quite responsive to questions sent to the list -- though I've
never seen him post here, or in clp.mod* (a quick deja search confirms
this). Anyway, to subscribe, send mail to:

	htmltmpl-subscribe@lists.vm.com

HTH

Cheers,
Damian
-- 
$;=ord$%,$:=$;-ord q,.,,$_=q 13346:3366:3276:3326:3386:546:566:966:3396:3376:1.
q 73386:546:;96:3326:3336:3386:3266:3236:3366:546::26:3236:3366:32:6:546:32667.
q,:;96:;;6:3296:3236:3366:326:56,,s,.,ord($&)-$:-$;;,eg,s,$;,q;q;;chr$&-$:;,eg,
eval eval;               #requires 5.6.0 ## my first attempt at one of these...


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

Date: Thu, 01 Feb 2001 16:50:23 -0800
From: news <loy_x@yahoo.com>
Subject: Q:  Activestate and Fork()
Message-Id: <3A7A044F.7CE0AE87@yahoo.com>

I have Activestate 6.5.0.620 on WIN2K and I have no fork...  And I need
fork. I've read everything I can find in the documentation and
online...and the two solutions I found were

a) rebuild activestate manually and configure for fork emulation.

But I couldn't compile the cpan source('latest') with either dmake or
nmake.

b) use cygwin

I prefer this solution, but i'm having problems install DBD::ODBC... the
makefile generates errors about not being able to communicate with the
odbc driver manager.

At this point i'm going in circles i've read everything available via
google or deja at least 3 times.



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

Date: 01 Feb 2001 20:45:22 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Q:  Activestate and Fork()
Message-Id: <4rydoo25.fsf@pobox.com>

news <loy_x@yahoo.com> writes:

> I have Activestate 6.5.0.620 on WIN2K and I have no fork...
                     ^^^
             You mean 5.6, right?

Well, I have build 623 on Win2K, and I seem to have fork().  Here's
directory listings the hard way on my box:

  $pid = fork;
  (print("Parent exiting.\n"), exit) if $pid;
  die "fork: $!\n" unless defined $pid;
  exec('dir');

Upgrade your distro.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Thu, 01 Feb 2001 23:39:06 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: question about sort
Message-Id: <t7jssqjqalodc7@corp.supernews.com>

Michael Carman <mjcarman@home.com> wrote:
> Chris Stith wrote:
>> 
>> Michael Carman <mjcarman@home.com> wrote:
>> 
>>> @a = sort {$a->{NAME} cmp $b->{NAME} ||
>>>            $a->{AGE}  <=> $b->{AGE}    } @a;
>> 
>> Much more simple than my original kludged response in another portion
>> of the thread. It doesn't use references like mine does either, which

[snip]

> My response was just a standard sortsub. There are fancier techniques
> designed to speed up large, complicated sorts (Schwartzian Transform,
> Guttman-Rosler Transform) but those are complete overkill here.

> Maybe we can call yours the "Rubilator Sort." :) And even if you did
> take the long way around, the important thing is that it worked. We'll
> smooth the rough edges later.

Mine certainly was the long way around. On some level, you're right, and
as long as it works, it's good enough. On another level, I've been
programming Perl for a few years and should know better. Of course, the
quality of the code I write here is determined by outside factors such as
the time spent on programming that actually goes into a project and makes
my boss money. I'd looked at the problem more seriously if it were for
my own code, and I should apologize for making a quick and dirty post
that's so non-optimal, even if it does work. I'm sorry to anyone lead
to use my Rube Goldberg-style code. 
  
>> I really do need to brush up on a few things. I should have had this in
>> mind myself.

> Remember Larry's goal for Perl: "Simple things should be simple, and
> hard things should be possible." Sorting should be simple, and it is.
> When something that should be easy starts looking hard, you're probably
> on the wrong path. That's when it's time to do a sanity check and look
> at the docs.

What I did didn't look hard to me. It just looked more obvious at the
time because I've been working on lots of projects lately with references
and few with sorting. As Larry says, a project in Perl is correct if it
produces the required result before your boss fires you (I'm paraphrasing
here, because http://www.perl.com updated since I read that earlier).

> In this case, the sort manpage has numerous examples, and there are two
> FAQs with 'sort' in their title.

I read docs often and thouroughly. I just haven't had to sort anything
more complex than an array in a long time. I use hashes often, but I don't
care much about the order of them in another structure (unless that's a
disk file, in which case I'm probably doing things line-by-line and
naturally preserving the previous line order).

I've been reading some things today by Mark Jason Dominus about people
programming Perl as if it was a low-level or mid-level language, even
though it provides many high-level tools. I've really been guilty of
that, especially in my previous post in this thread. I'm one of those
people who writes another language in Perl syntax ;)

All in all, I guess I proved that TMTOWTDI, even if some are ugly and
round-about.

Chris

-- 
Christopher E. Stith

For the pleasure of others, please adhere to the following
rules when visiting your park:
    No swimming.  No fishing.  No flying kites.  No frisbees.
    No audio equipment. Stay off grass.  No pets. No running.



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

Date: 01 Feb 2001 20:31:51 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: race condition or lock problem
Message-Id: <d7d1oooo.fsf@pobox.com>

"John Michael" <johnm@acadiacom.net> writes:

> However, the script will still send several emails.  I am getting
> the impression that a race condition is occuring, because the LOCK
> file is not preventing multiple occurances of the script from
> running.

Why is the script running concurrantly?  Don't you start and stop the
script yourself?  If the script is run automatically, is it not
possible that one script runs after the other has exited, so there is
no lock?

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: 02 Feb 2001 01:37:17 GMT
From: "John Michael" <johnm@acadiacom.net>
Subject: Re: race condition or lock problem
Message-Id: <95d30d$3e1@dispatch.concentric.net>

The script is run buy an apache errordoc handler

ErrorDocument 401 /cgi-bin/myscript.pl
Therefore,  a bot script running on another server can make a lot of request
in just few seconds.
JM


"Jonathan Feinberg" <jdf@pobox.com> wrote in message
news:d7d1oooo.fsf@pobox.com...
> "John Michael" <johnm@acadiacom.net> writes:
>
> > However, the script will still send several emails.  I am getting
> > the impression that a race condition is occuring, because the LOCK
> > file is not preventing multiple occurances of the script from
> > running.
>
> Why is the script running concurrantly?  Don't you start and stop the
> script yourself?  If the script is run automatically, is it not
> possible that one script runs after the other has exited, so there is
> no lock?
>
> --
> Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
> http://pobox.com/~jdf




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

Date: 01 Feb 2001 20:46:19 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: race condition or lock problem
Message-Id: <zog5n9g4.fsf@pobox.com>

"John Michael" <johnm@acadiacom.net> writes:

> The script is run buy an apache errordoc handler
> 
> ErrorDocument 401 /cgi-bin/myscript.pl
> Therefore,  a bot script running on another server can make a lot of request
> in just few seconds.

Well, so one script is finished by the time another starts up, so why
shouldn't they both send an email?

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Thu, 1 Feb 2001 17:52:52 -0600
From: Bin - Lu <b0l4549@cs.tamu.edu>
Subject: redirection problem
Message-Id: <Pine.SOL.4.10.10102011745410.4741-100000@robert>

Hi,

I have the following code:

print "Set-Cookie: token=$token; domain=.what.com; expires=Tuesday"; 
$link="http://www.blah.com";
print "Location: $link\n\n";
exit;  

The redirection doesn't work. But when I remove the set cookie line, the
redirection works. (the set-cookie is working fine)

What's the problem? Since I have to use both the cookie and redirection
and their order in the code can't change, what can I do? I'd appreciate
any clue!

Bin



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

Date: 02 Feb 2001 00:25:17 GMT
From: "John Michael" <johnm@acadiacom.net>
Subject: Re: redirection problem
Message-Id: <95cupd$3e1@dispatch.concentric.net>

It has to do with the fact that both of them are went in the header.

A  "\n\n" tells the browser that the header is ended.

You can actually print the Location header fist, but you have to use only 1
\n.

Try this:

use CGI qw(:standard);   #import the cgi.pm routines for setting cookie
 $cookie = cookie(
            -name=>'token',
            -value=>$token,
            -path=>'/',
            -expires=>'+3d'                            #in 3 days
);

print "Location: $image\n";
print header(-cookie=>[$cookie]);
print "\n\n";                        #tells bowser that header is done.

exit;

Cya
John Michael
http://realtimescripts.com






"Bin - Lu" <b0l4549@cs.tamu.edu> wrote in message
news:Pine.SOL.4.10.10102011745410.4741-100000@robert...
> Hi,
>
> I have the following code:
>
> print "Set-Cookie: token=$token; domain=.what.com; expires=Tuesday";
> $link="http://www.blah.com";
> print "Location: $link\n\n";
> exit;
>
> The redirection doesn't work. But when I remove the set cookie line, the
> redirection works. (the set-cookie is working fine)
>
> What's the problem? Since I have to use both the cookie and redirection
> and their order in the code can't change, what can I do? I'd appreciate
> any clue!
>
> Bin
>




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

Date: Fri, 02 Feb 2001 00:55:31 GMT
From: cleng1@my-deja.com
Subject: replace a matched string
Message-Id: <95d0hv$oss$1@nnrp1.deja.com>

I have a string like this:
book_yellow, book_green, book_red

after I did
s/(book_.*)/$1_buff/g;

my output should be like
book_yellow_buff, book_green_buff, book_red_buff

How come my output is like
book_yellow, book_green, book_red_buff

How to fix, so I can replace all string? intead one?

thanks,


Sent via Deja.com
http://www.deja.com/


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

Date: Fri, 02 Feb 2001 07:59:00 +0800
From: Graham Daniell <gdaniell@wt.com.au>
Subject: Running shell comands from Perl?
Message-Id: <3A79F844.307481FC@wt.com.au>

How can I run a shell command from Perl?

What I want to do is run "/sbin/ifconfig ppp0' and test what is
returned, to see whether ppp0 is running.

Something like:

# test ppp0
if ( "sbin/ifconfig ppp0" )
    do ...
fi
#

Thanks,
Graham Daniell
gdaniell@wt.com.au




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

Date: Fri, 2 Feb 2001 09:12:11 +0800
From: "jck1" <jck1@seed.net.tw>
Subject: Re: Running shell comands from Perl?
Message-Id: <95d236$g2a@netnews.hinet.net>

I often use the "system" to do shell command

Graham Daniell <gdaniell@wt.com.au> wrote in message
news:3A79F844.307481FC@wt.com.au...
> How can I run a shell command from Perl?
>
> What I want to do is run "/sbin/ifconfig ppp0' and test what is
> returned, to see whether ppp0 is running.
>
> Something like:
>
> # test ppp0
> if ( "sbin/ifconfig ppp0" )
>     do ...
> fi
> #
>
> Thanks,
> Graham Daniell
> gdaniell@wt.com.au
>
>




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

Date: 01 Feb 2001 20:40:04 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Running shell comands from Perl?
Message-Id: <8znpooaz.fsf@pobox.com>

Graham Daniell <gdaniell@wt.com.au> writes:

> How can I run a shell command from Perl?

If you wish to examine the output of another process from within a
Perl program you may either use the qx// construction, as documented
in perlop and perlipc, or you may use the open() function with the "|"
pseudo-file-mode, as documented in perlfunc and perlipc.

For example

  my $process_list = qx/ps/;
  my $directory_listing = `ls -l`;

  open(DU, 'du -ks |') || die "Can't fork: $!\n";
  while (<DU>) {
     # process the next line of du output
  }
  close (DU) || die "bad du: $!\n";

So, that's perlipc, perlop, and perlfunc for you, plus perlfaq8.  Go.
  
-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: 2 Feb 2001 01:48:24 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: stupid eval tricks
Message-Id: <slrn97k4fk.mcu.damian@puma.qimr.edu.au>

Thus spake Weston Cann on Thu, 01 Feb 2001 21:12:33 GMT:
>
>1) read a file into a string
>2) scan that string for any perl variables that exist
>   in the current block
>3) replace those variables with their values
>
>...
>Are they cooler or do they have any advantage over the way I've presented?
>

You might like to check out MJD's Text::Template module.  If the file is HTML, 
you might be interested in Sam Tregar's HTML::Template module. Both are on
CPAN, and will do what you ask for, plus some other things you might like.

If the names and the files are not complex, you could try using some sort
of simple token rather than a variable name in the file, and keep a hash
with keys that match the tokens (instead of a bunch or vars). I like HTML
comment syntax for this, but YMMV:

eg:

%cat test
#!/usr/local/bin/perl -w
use strict;

my $file_contents;
{ local $/ = undef; $file_contents = <> }
my %vars = ( VAR1 => 'value', VAR2 => 'value' );
$file_contents =~ s/<--!$_-->/$vars{$_}/g for keys %vars;
print $file_contents;
__END__

%cat data
this is a test:
var1 = <--!VAR1-->
var2 = <--!VAR2-->
end of test.

%./test data
this is a test:
var1 = value1
var2 = value2
end of test.

Of course, when you need to add variables, you add them to the hash, and
the for loop grabs them.

HTH

Cheer,
Damian
-- 
$;=ord$%,$:=$;-ord q,.,,$_=q 13346:3366:3276:3326:3386:546:566:966:3396:3376:1.
q 73386:546:;96:3326:3336:3386:3266:3236:3366:546::26:3236:3366:32:6:546:32667.
q,:;96:;;6:3296:3236:3366:326:56,,s,.,ord($&)-$:-$;;,eg,s,$;,q;q;;chr$&-$:;,eg,
eval eval;               #requires 5.6.0 ## my first attempt at one of these...


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

Date: Fri, 02 Feb 2001 00:11:43 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Thank you!- Re: sort: how do I ignore a specific word?
Message-Id: <thuj7toil3uh2i4p36e39n1j08o3m3na2m@4ax.com>

Cyclops wrote:

>Gwyn, I
>will look into your suggestions of hashes and Gutman-Rossler/Schwartzian
>Transform as a way to improve sorting speed (you can tell I'm not computer
>science by my lack of knowledge about those two sorting algorithms

Not really. Both Gutman-Rosler and Schwartzian Transform are very much
perl oriented mechanisms (although in principle, they could be used in
other languages). In fact, those 3 people are / used to be regulars in
this newsgroup.

-- 
	Bart.


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

Date: Fri, 02 Feb 2001 01:09:29 GMT
From: "John Hall" <jhall@ifxonline.com>
Subject: use strict  + .lib
Message-Id: <dNne6.22586$E6.668012@news1.rdc1.sdca.home.com>

I am modifying  a GPL script, and updating the cookie transactions it
includes to work with modern browsers.

The original script uses "strict" and I suppose I will keep it that way, to
my understanding it is a security measure.

What I don't understand, is, now that when I want to use a "cookie.lib" :

require './cookie.lib';

I can't use some of the functions in that library because of strict.

I have been trying for hours to learn how to declare something like %Cookies
or that %Cookies is valid and belongs to cookie.lib but I don't know how to
do it. If I declare it like "my %Cookies" then it breaks the cookie
functions.

p.115 of "Perl In a Nutshell" describes a "package declaration" that sounds
like what I need, "package namespace" - but I can't figure out how to make
it work, if in fact it's what I want to do.

For now i'll push on without strict, but I do want to know how to solev the
problem. Many thanks.




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

Date: 01 Feb 2001 21:00:10 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: use strict  + .lib
Message-Id: <vgqtn8t1.fsf@pobox.com>

"John Hall" <jhall@ifxonline.com> writes:

> The original script uses "strict" and I suppose I will keep it that
> way, to my understanding it is a security measure.

It's more a software-engineering disciplinary measure.  It forces you
to be deliberate about names.

The documentation for the precise meaning and usage of the "strict"
pragma is available via

   $ perldoc strict

There's also a justification for using strict in perldsc.

> I have been trying for hours to learn how to declare something like
> %Cookies or that %Cookies is valid and belongs to cookie.lib but I
> don't know how to do it. If I declare it like "my %Cookies" then it
> breaks the cookie functions.

The short answer is to not rely on "cookie.lib" (by the way, .lib is a
mighty peculiar file extension for a Perl library).  Better you should
use the standard module

  use CGI::Cookie;

which provides methods to parse and generate cookies.

The longer answer is that you'll have to learn about packages, as you
surmised from reading the "Nutshell" book.  Read about packages in
perlmod, perltoot, perlsub, and of course perlfunc.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Fri, 2 Feb 2001 09:14:59 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Using global var in subroutine
Message-Id: <rome6.18$G%5.4053@vic.nntp.telstra.net>

"Steve Yates" <steve@teamITS.com> wrote in message
news:t7j0d1krdt6gda@corp.supernews.com...
> <dtbaker_dejanews@my-deja.com> wrote in message
> news:95arjb$rd3$1@nnrp1.deja.com...
> > take a close look at wherever $userCode is defined and make sure:
> > - it is not inside another sub
>
>     Sigh...isn't it amazing how you can look at code for hours and not
see
> the simple stuff?  The var IS set within a sub, and not declared
beforehand.
> The wild thing was that this program was used for a long time this
way.  Did
> older Perl versions make all vars global by chance?

Happens

>     If I simply declare $userCode == "" at the beginning of the script
that
> will force it to be global right?

Yes, though you would probably be better off declaring it just before it
is used, outside the sub.  The other alternative is to declare the
variable as part of the main package, by

$main::userCode = 'whatever';

within the sub and it will still be global.  You can also work with
packages this way.

Some useful info on scoping is at:

http://perl.plover.com/FAQs/Namespaces.html

Wyzelli
--
push@x,$_ for(a..z);push@x,' ';
@z='092018192600131419070417261504171126070002100417'=~/(..)/g;
foreach $y(@z){$_.=$x[$y]}y/jp/JP/;print;




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

Date: Thu, 1 Feb 2001 17:39:42 -0600
From: Vishwanath Mantha <vm1@ece.msstate.edu>
Subject: Viewing the html code
Message-Id: <Pine.SOL.4.10.10102011738430.3467-100000@leto.ece.msstate.edu>


How do I view the html code for a URL in perl.

-Mantha



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

Date: 2 Feb 2001 00:17:54 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Viewing the html code
Message-Id: <slrn97jv5i.ibn.abigail@tsathoggua.rlyeh.net>

Vishwanath Mantha (vm1@ece.msstate.edu) wrote on MMDCCXI September
MCMXCIII in <URL:news:Pine.SOL.4.10.10102011738430.3467-100000@leto.ece.msstate.edu>:
`' 
`' How do I view the html code for a URL in perl.


What on earth do you mean? URLs don't have HTML code. A URL might
point to a resource that is of text/html; is that what you mean?

And what do you mean with viewing in perl? You view with your eyes,
usually sitting in a room. I could imagine viewing with a program
that is written in Perl, but that seems like a strange request,
wouldn't a program written in Ada or PL/1 work as well?

Maybe if you explain what you want to do someone can help you. Of 
course, first be sure it ain't in the FAQ, the manual, recently asked
and answered here, or have a ready to use module on CPAN.


Abigail
-- 
perl -weprint\<\<EOT\; -eJust -eanother -ePerl -eHacker -eEOT


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

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 V10 Issue 196
**************************************


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