[11202] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4802 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 2 01:07:21 1999

Date: Mon, 1 Feb 99 22:00:20 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 1 Feb 1999     Volume: 8 Number: 4802

Today's topics:
        "use" - packages loaded at runtime or compile time? mizpoon@my-dejanews.com
    Re: "use" - packages loaded at runtime or compile time? (Alan Barclay)
    Re: "use" - packages loaded at runtime or compile time? (Bill Moseley)
    Re: "use" - packages loaded at runtime or compile time? (Martien Verbruggen)
        Anyone familar with CGI.pm internals? (Bill Moseley)
    Re: Anyone familar with CGI.pm internals? (brian d foy)
        Can't return outside a subroutine info@gadnet.com
    Re: Comments in Perl code (Alan Barclay)
    Re: Email script ..seems to be working.. anything overl (Ronald J Kimball)
    Re: Help needed with locking mkshanx@ust.hk
    Re: help please, trying to sort a multidimensional arra (Ronald J Kimball)
    Re: HELP!! How to delete files created by perl from tel (Ronald J Kimball)
    Re: HELP!! How to delete files created by perl from tel (Martien Verbruggen)
    Re: HELP!! How to delete files created by perl from tel (brian d foy)
    Re: local($_) - why not "my"? (Ronald J Kimball)
    Re: Newbie question <jcounts@voicenet.com>
    Re: Newbie question (Ronald J Kimball)
    Re: Perl 5.001 File Locking? (Ronald J Kimball)
    Re: Perl syntax ( URGENT ) (Martien Verbruggen)
        perl/tk slow dialog mapping?? (fwd) <wayne@crb-web.com>
        substituting keywords in a string (Jason Q.)
    Re: substituting keywords in a string <jcounts@voicenet.com>
    Re: substituting keywords in a string (Martien Verbruggen)
    Re: substituting keywords in a string (Jason Q.)
    Re: substituting keywords in a string <ebohlman@netcom.com>
    Re: The behaviour of split() - followup (Ronald J Kimball)
        Trouble compiling Perl 5.005_2 with Apache on FreeBSD 3 (Nick Tonkin)
    Re: Using Net <ebohlman@netcom.com>
        Using Perl to parse input from a url marc1859@my-dejanews.com
    Re: Using Perl to parse input from a url (brian d foy)
    Re: Using Perl to parse input from a url <ebohlman@netcom.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Tue, 02 Feb 1999 03:04:34 GMT
From: mizpoon@my-dejanews.com
Subject: "use" - packages loaded at runtime or compile time?
Message-Id: <795pvv$2hj$1@nnrp1.dejanews.com>

I need to use Date::Manip in one of my perl packages. As Date::Manip is a
large package, I only want it to get loaded when I need it, and not before. I
don't need it loaded at all times.

I was planning on wrapping the 'use Date::Manip' in a function.

Can someone tell me if this will ensure that the Date code will only get
loaded when this function is called? Or does the Perl interpreter whizz
through the code and load up all the use directives at compile time?

All I want to do, is take a date and find the next day from it. Maybe someone
can suggest a simpler way to do this that doesn't involve Date::Manip. It has
to be a standard perl package or command line program. I've looked at GNU
DATE, but it doesn't do what I want.

please cc all responses to pouneh@wired.com as I only browse these newsgroups.

cheers,

mizpoon

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


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

Date: 2 Feb 1999 04:03:20 GMT
From: gorilla@elaine.drink.com (Alan Barclay)
Subject: Re: "use" - packages loaded at runtime or compile time?
Message-Id: <917928189.124758@elaine.drink.com>

In article <795pvv$2hj$1@nnrp1.dejanews.com>,  <mizpoon@my-dejanews.com> wrote:
>I need to use Date::Manip in one of my perl packages. As Date::Manip is a
>large package, I only want it to get loaded when I need it, and not before. I
>don't need it loaded at all times.
>
>I was planning on wrapping the 'use Date::Manip' in a function.

use's are performed at compile time. 

>please cc all responses to pouneh@wired.com as I only browse these newsgroups.

Please read the newsgroup as I only browse your email.


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

Date: Mon, 1 Feb 1999 20:09:07 -0800
From: moseley@best.com (Bill Moseley)
Subject: Re: "use" - packages loaded at runtime or compile time?
Message-Id: <MPG.11201a425579e58a989697@nntp1.ba.best.com>

In article <795pvv$2hj$1@nnrp1.dejanews.com>, mizpoon@my-dejanews.com 
says...
> I need to use Date::Manip in one of my perl packages. As Date::Manip is a
> large package, I only want it to get loaded when I need it, and not before. I
> don't need it loaded at all times.

Take a read through your blue Camel book section on standard modules.

or perldoc autouse

    use autouse 'Date::Manip' => qw( ParseDate );




-- 
Bill Moseley mailto:moseley@best.com


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

Date: Tue, 02 Feb 1999 05:13:04 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: "use" - packages loaded at runtime or compile time?
Message-Id: <APvt2.129$wk3.8102@nsw.nnrp.telstra.net>

In article <795pvv$2hj$1@nnrp1.dejanews.com>,
	mizpoon@my-dejanews.com writes:

> I need to use Date::Manip in one of my perl packages. As Date::Manip
> is a large package, I only want it to get loaded when I need it, and
> not before. I don't need it loaded at all times.

A use is the same as a require, followed by a import, inside a BEGIN
block. (the documentation explains this: # perldoc -f use)
I think you need 'require'. # perldoc -f require

> please cc all responses to pouneh@wired.com 

No.

> as I only browse these newsgroups.

That is evident. You post a question which gets asked regularly. You
are missing a lot by not reading this group. 

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | The number of the beast is not 666. Its
Commercial Dynamics Pty. Ltd.       | number is 95, and it's awake.
NSW, Australia                      | 


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

Date: Mon, 1 Feb 1999 20:50:29 -0800
From: moseley@best.com (Bill Moseley)
Subject: Anyone familar with CGI.pm internals?
Message-Id: <MPG.112023f5271bb517989698@nntp1.ba.best.com>

I've got about a 1500 line script that seems to be working fine.  One odd 
thing is that when run from the command line I get

(offline mode: enter name=value pairs on standard input)

which is normal, but then I press ^Z or ^D (depending on where I'm 
running it) and then I get

(offline mode: enter name=value pairs on standard input)

again, a second time.

It's only happening with this one script, and on both my PC and on a unix 
machine.  No error messages are printing, and no messages are in the 
server logs.

Maybe it's no big deal, but I wonder what I'm doing (perhaps wrong) in my 
script to make CGI.pm print two of those messages.

Any ideas?

I'm running under -w and use strict;

(But -T reports:

 [Mon Feb  1 20:45:49 1999] ipreg.cgi: Insecure dependency in eval while
 running with -T switch at /usr/local/perl5.005/lib/5.005/CGI.pm line 614

But that's another issue.)

-- 
Bill Moseley mailto:moseley@best.com


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

Date: Tue, 02 Feb 1999 00:35:05 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Anyone familar with CGI.pm internals?
Message-Id: <comdog-ya02408000R0202990035050001@news.panix.com>

In article <MPG.112023f5271bb517989698@nntp1.ba.best.com>, moseley@best.com (Bill Moseley) posted:

> I've got about a 1500 line script that seems to be working fine.  One odd 
> thing is that when run from the command line I get
> 
> (offline mode: enter name=value pairs on standard input)
> 
> which is normal, but then I press ^Z or ^D (depending on where I'm 
> running it) and then I get
> 
> (offline mode: enter name=value pairs on standard input)
> 
> again, a second time.

do you happen to create two CGI objects in your script?  you'll 
get one of these promotes each time you call the CGI constructor
if you don't pass anything (like a saved state) to it.

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>


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

Date: Tue, 02 Feb 1999 10:25:03 GMT
From: info@gadnet.com
Subject: Can't return outside a subroutine
Message-Id: <36b6d200.5718298@news.newsguy.com>

What is wrong with this:

if ($ENV{'QUERY_STRING'} =~ /ID=([^\s&]*)&/)
{
	$thisuser = $1;
	&getad;
	&updateuser;
	return;
}

It comes up with error: Can't return outside a subroutine at line
(line number of 'retuurn'.

This works fine:

if ($ENV{'QUERY_STRING'} =~ /ID=([^\s&]*)&/)
{
	$thisuser = $1;
	&getad;
	&updateuser;
}

Why?




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

Date: 2 Feb 1999 03:57:59 GMT
From: gorilla@elaine.drink.com (Alan Barclay)
Subject: Re: Comments in Perl code
Message-Id: <917927869.714104@elaine.drink.com>

In article <795f1b$2gf@bgtnsc01.worldnet.att.net>,
Charles R. Thompson <design@raincloud-studios.com> wrote:
>I've often considered putting some timers in the front and back
>end of some scripts to see what I get. I'm sure you are probably
>right... it's human nature to be curious about the little
>things, ya know? :)

My estimates give about 10 ms per 1000 lines of comments. Hardly
worth worrying about in the slightest.



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

Date: Mon, 1 Feb 1999 23:51:32 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Email script ..seems to be working.. anything overlooked
Message-Id: <1dmkk8j.3lkqaz11a0tmnN@bay2-328.quincy.ziplink.net>

Quentin Compson <bcompson@yahoo.com> wrote:

> Thanks for you input
> 
> > The main thing you seem to have overlooked is the CGI.pm module.  This
> > module handles the reading of data, the parsing of arguments, and the
> > conversion of hex escapes.  It is strongly recommended that you 'use
> > CGI' in all your CGI scripts.
> > 
> 
> The book I was using to teach myself Perl never even mentions CGI.pm which
> means  A) it is old or B) it isn't a very good book
> copyright 1998

If this book is at all CGI-oriented, and it does not mention CGI.pm,
then I'm afraid it is not a very good book.

> I looked around and seem to have come to the conclusion that CGI.pm is sort
> of
> a way of making Perl object oriented.

Nope.  You can create a CGI object and call CGI methods in an
object-oriented way, or you can import the CGI methods and call them
directly in a functional way.  You can even mix both ways in the same
script.

> Anyway am I right in thinking that to use this you need to generate the
> form with
> perl as well as process it?

Nope.  You can do anything with CGI.pm that you can do without.  CGI.pm
just makes it much much easier to do CGI things.

> Can you process info sent from a normal HTML form?

Of course!  The browser can't tell whether the HTML was dynamically
generated or a static page anyway.  A form is a form is a form.

-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Tue, 02 Feb 1999 03:54:22 GMT
From: mkshanx@ust.hk
Subject: Re: Help needed with locking
Message-Id: <795stc$4p5$1@nnrp1.dejanews.com>

In article <77nv25$ln6$1@pegasus.csx.cam.ac.uk>,
  mjtg@cus.cam.ac.uk (M.J.T. Guy) wrote:
> >
> >So, with very few exceptions, close is good, flock(UN) is bad.
>
> Despite the above, that's still good advice, if only for compatibility
> with older Perls.


Thanks Mike, but I am still having a problem with flush()! I went to the page
http://language.perl.com/newdocs/pod/perlfunc/flock.html but when i include
the functions as specified there, it gives me an error:


_____________ERROR______________

":flock" is not exported by the Fcntl module at screenlast.cgi line 3
 at /usr/local/lib/perl5/Exporter.pm line 106
        Exporter::export called at /usr/local/lib/perl5/Exporter.pm line 136
        Exporter::import called at screenlast.cgi line 3
        main::BEGIN called at /usr/local/lib/perl5/Fcntl.pm line 0
        (eval) called at /usr/local/lib/perl5/Fcntl.pm line 0
Can't continue with import errors.
BEGIN failed--compilation aborted at screenlast.cgi line 3.

_______________/ERROR__________________


COuld it be that this page has old code? My code looks like this:

_______________CODE__________________

#!/usr/local/bin/perl
use CGI qw(:standard);
use Fcntl ':flock';     # import LOCK_* constants


&readparse;
$firsttime = $value[0];
$AllNecessaryVariables = join ' || ', "hello", $firsttime;


########### The file -- data.txt

open(MYFILE, ">>data.txt") or die "Please call the instructor: $!\n";

             lock();
             print MYFILE "$AllNecessaryVariables\n";
             unlock();
close(MYFILE);


################ THE FILE LOCKING AND UNLOCKING ROUTINES


    sub lock {
        flock(MYFILE,LOCK_EX);
                # and, in case someone appended
                # while we were waiting...
        seek(MYFILE, 0, 2);
    }

    sub unlock {
        flock(MYFILE,LOCK_UN);
    }


################THE HTML CONTENT TO BROWSER


print "Content-type:text/html\n\n";
print "Done";


##################readparse function for input from last screen

sub readparse {
read(STDIN,$user_string,$ENV{'CONTENT_LENGTH'});
if (length($ENV{'QUERY_STRING'})>0) {$user_string=$ENV{'QUERY_STRING'}};
$user_string =~ s/\+/ /g;
@name_value_pairs = split(/&/,$user_string);
foreach $name_value_pair (@name_value_pairs) {
        ($keyword,$value) = split(/=/,$name_value_pair);
        $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/ge;
        push(@value, "$value");
          $user_data{$keyword} = $value;
          if ($value=~/<!--\#exec/) {
                print "Content-type: text/html\n\nNo SSI permitted";
              exit;
          };
};
};


_____________________/CODE_________


Without the FLOCK the above program works like a charm. I guess they are using
Sun OS in the university (my ISPs!), and Perl 5.001. Is that a problem? Is it
that Perl 5.001 does not support flocking?

Well, I did man flock(), and it seems to recognize the command!

Thanks for your time,
Regards,
Shanx


_____________
IF you reply to this message, please cc to me at mkshanx@ust.hk too.
Thanks.

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


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

Date: Mon, 1 Feb 1999 23:51:33 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: help please, trying to sort a multidimensional array
Message-Id: <1dmkkjy.100m15hvc92a0N@bay2-328.quincy.ziplink.net>

23_skidoo <23_skidoo@geocities.com> wrote:

> eg, the script generates @newsarray such that:
> 
> $newsarray[0][0] = 15;
> $newsarray[1][0] = 12;
> $newsarray[2][0] = 8;
> 
> i allready have the numerical sort subroutine which i use elsewhere like
> this:
> 
> @killfile = sort numerically (@killfile);
> 
> sub numerically { $a <=> $b }
> 
> i'm just not sure how to carry that forward to sort the 2d array.

sub mysort { $a->[0] <=> $b->[0] }

Remember that when you sort @newsarray, the elements you are comparing
are array references.  So, you want to dereference the element to get
the array, and then get that array's first element.


> i did rtfaq, found this example but i don't understand the final line in
> it. i added comments stating what i thought was going on.

This example does something tricky; instead of sorting the elements of
the array, it sorts an array of indices.  Once those indices are sorted,
it uses an array slice to get the array in sorted order.

> @idx = ();  #clears the array @idx
> for (@data) {   #loops through each item in @data
>   ($item) = /\d+\s*(\S+)/; 
>             #defines a variable '$item' which is a number of non 
>             #whitespace characters located after 1 or more digits 
>             #and 0 or more whitespace characters

That's not quite it...
What you're missing from this example is the contents of @data.  You
can't create a sort routine without knowing what you're sorting...

In this case, @data looks something like this:

@data = (
  '76   bazzle_    +++',
  '123     FooBar   XyZ',
  '000    A+B-C      @1',
);

Now, let's say we wanted to sort these elements on the second column.
The first column is a string of digits.  The second column is a string
of non-whitespace characters.


So, the first thing to do is separate out the parts we want to compare:

  ($item) = /\d+\s*(\S+)/;

Now $item holds the second column in the current element.


>   push @idx, uc($item); 
>             #pushes an upper case version of $item into @idx

And we push $item onto a new array; uppercased, because we want to do a
case-insensitive comparison.


> }
> @sorted = @data[ sort { $idx[$a] cmp $idx[$b] } 0 .. $#idx ];
>       #i got a bit lost here.

There's a lot going on in this one line.  Let's look at it in parts...


  0 .. $#idx

This creates a list of numbers from 0 to $#idx.  In other words, it's a
list of all the indices of @idx.  (Keep in mind that @idx is the same
size as @data, because we pushed one $item for each element of @data.)


  sort { $idx[$a] cmp $idx[$b] } 0 .. $#idx

This sorts the numbers from 0 to the last index of @idx.  Now, since
we're sorting the list (0 .. $#idx), we don't want to compare $a and $b
directly.  Instead, we want to sort based on the items we stored in
@idx.  So, compare $idx[$a] and $idx[$b] instead.


  @data[ sort { $idx[$a] cmp $idx[$b] } 0 .. $#idx ];

Okay, remember that we sorted a list of indices.  The above expression
gives us all the elements of @data, but in a different order.  (Compare
that to $data[0], which is the first element of @data, and to
@data[0..$#data], which is all the elements.)  And what order are those
elements in?  Well, they're in the same order as the indices, which we
sorted by the second column.  So we have a list of the elements of
@data, sorted by the second column from each element.


  @sorted = @data[ sort { $idx[$a] cmp $idx[$b] } 0 .. $#idx ];

And, we assign that list to a new array, @sorted.  Ta da!


> i know that {$idx[$a] cmp $idx[$b]} is comparing ascii values just like
> {$idx[$a] <=> $idx[$b]} would be for a numerical sort but i'm not sure
> about the square brackets and the 0 .. $#idx at the end. can anyone help
> me out here?

The square brackets are for array indices; the 0 .. $#idx is a range.
Hope that helps!

-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Mon, 1 Feb 1999 23:51:35 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: HELP!! How to delete files created by perl from telnet!!
Message-Id: <1dmkloz.1w66aejb3zuz9N@bay2-328.quincy.ziplink.net>

MekaGames Staff <support@mekagames.com> wrote:

> My perl program created some files in a certain directory. However, I do
> not have ftp access to this directory, but I do have telnet directory. What
> command do I have to use to delete this files?

This is not a Perl question.

If it's a Unix system, try 'rm', which is short for remove.

-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Tue, 02 Feb 1999 05:09:33 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: HELP!! How to delete files created by perl from telnet!!
Message-Id: <hMvt2.126$wk3.8102@nsw.nnrp.telstra.net>

In article <01be4e55$80b6c180$ae89accf@default>,
	"MekaGames Staff" <support@mekagames.com> writes:
> My perl program created some files in a certain directory. However, I do
> not have ftp access to this directory, but I do have telnet directory. What
> command do I have to use to delete this files? Thanks for your help!

Huh? Are you sure that you can telnet there, but you can't ftp there?
That makes very little sense. Almost none.

Anyway, depending on what sort of OS that 'server' is running: use the
appropriate command to delete files.

For DOS-based stuff: del
For Unices: rm

To read how to use rm:

# man rm

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | A Freudian slip is when you say one
Commercial Dynamics Pty. Ltd.       | thing but mean your mother.
NSW, Australia                      | 


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

Date: Tue, 02 Feb 1999 00:37:14 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: HELP!! How to delete files created by perl from telnet!!
Message-Id: <comdog-ya02408000R0202990037140001@news.panix.com>

In article <1dmkloz.1w66aejb3zuz9N@bay2-328.quincy.ziplink.net>, rjk@linguist.dartmouth.edu (Ronald J Kimball) posted:

> MekaGames Staff <support@mekagames.com> wrote:
> 
> > My perl program created some files in a certain directory. However, I do
> > not have ftp access to this directory, but I do have telnet directory. What
> > command do I have to use to delete this files?
> 
> This is not a Perl question.
> 
> If it's a Unix system, try 'rm', which is short for remove.

or if he really wants to use Perl, he can use unlink().  and, as we
all know, the return value of unlink() is the number of files you will 
have to read from tape (not that i know this empirically ;).

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>


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

Date: Mon, 1 Feb 1999 23:51:36 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: local($_) - why not "my"?
Message-Id: <1dmkmb7.1imvig7azabkaN@bay2-328.quincy.ziplink.net>

Ala Qumsieh <aqumsieh@matrox.com> wrote:

>          my $pack::var;      # ERROR!  Illegal syntax
>          my $_;              # also illegal (currently)
> 
> 
> > Does "currently" mean that in some later version of perl this will
> > change?   Where is the difficulty?
> 
> I am not sure what the "currently" means here. But I would guess that
> that might have been legal code before. You see, lexical variables
> were only introduced in Perl 5 (IIRC). But, as far as I know, there
> are no plans to change that behaviour of my(). Anyone else care to
> elaborate on this?

Umm...  The keyword 'my' was introduced at the same time as lexical
variables.  They're basically two sides of the same coin.
In perl4, 'my $_;' is a syntax error.

The original poster was correct; "currently" means that in some later
version of Perl this could change.  But right now, all special variables
are stored in the symbol table.  And because they're special, they can't
just be yanked out of the symbol table to allow for lexical special
variables.

I think "currently" is sort of the opposite of "deprecated"; this
feature will be added in some future, unspecified version of Perl.  :-0

-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Mon, 1 Feb 1999 23:37:14 -0500
From: "John Counts" <jcounts@voicenet.com>
Subject: Re: Newbie question
Message-Id: <795vro$mdk$1@news1.fast.net>


Gary Smiley wrote in message <36B65899.1CCDC95B@nospam.mediaone.net>...
>Here's the latest: My syntax is OK. If I run the pgm via a DOS prompt, it
>"sees" the shared drive and writes to it. Over the Web via an HTML form, it
>dies trying to open the file for appending.


Your problem seems to be the file permissions of the user accessing the HTTP
server.  If you are running Apache this is usually 'nobody'  if you're
running IIS it's something like IUSER_[MACHINENAME].  You need to give this
user write permission on the file in question.  If you're running Apache you
can also change the username that it runs as.  I don't thnk this is possible
with IIS.  It works in DOS because the script is being executed as your
login username, which obviously has the correct permisions on the file.






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

Date: Mon, 1 Feb 1999 23:51:37 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Newbie question
Message-Id: <1dmkmpl.1gw591jppdxhrN@bay2-328.quincy.ziplink.net>

Gary Smiley <gasmiley@nospam.mediaone.net> wrote:

> Here's the latest: My syntax is OK. If I run the pgm via a DOS prompt, it
> "sees" the shared drive and writes to it. Over the Web via an HTML form, it
> dies trying to open the file for appending.

Can your web server see the shared drive?  Have you verified that the
permissions have been set correctly?

-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Mon, 1 Feb 1999 23:51:38 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Perl 5.001 File Locking?
Message-Id: <1dmkmuo.ti86wz4kg9j9N@bay2-328.quincy.ziplink.net>

Shanx <mkshanx@ust.hk> wrote:

> $EXCLUSIVE = 2;
> $UNLOCK    = 8;

use Fcntl;

Don't try to define the constants yourself.  It's not portable.

> open(MYFILE, ">>data.txt");

What if the open fails??


> print "Content-type:text/html\n\n";
                     ^^

You need a space after the colon.


> As some of you might recognize, I got this from the webreview column.

What webreview column?  Is this really the code from the column?  If so,
the publishers might want to find a better author for this column.

-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Tue, 02 Feb 1999 04:58:16 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl syntax ( URGENT )
Message-Id: <IBvt2.120$wk3.8102@nsw.nnrp.telstra.net>

[What's urgent to you may not be urgent to us.
Please read the following information on how to choose a good subject
line: http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post]


In article <7955r3$if9$1@nnrp1.dejanews.com>,
	kamez@my-dejanews.com writes:

Have you read any documentation? Have you considered buying a good
book on perl? There are some good pointers to both available from
www.perl.com. The perldoc command is also a good help here.

> chop                 ------------> what's the meaning of "chop" ?

# perldoc -f chop
# perldoc -f chomp

> $line=$_;

I suspect very much that the code you are using is being a bit silly.
Without seeing all of it, I can hardly tell.

> $line =~ s/\s+/ /g;            ------------------->?

substitution with regular expressions. 

# perldoc perlop
# perldoc perlre

>    @arr= split;                ------------------->?
>    @val=split(/:/,arr[2]);   $tt=val[0];  -------->?

# perldoc -f split

>    if ( ( index(line,"http-gw") !=-1)
>       && ( index(line,"out=") !=-1) ) {
>       @array=grep(/^in=/,@arr);
>       @val=split(/=/,array[0]);   in=val[1];
>       @array=grep(/^out=/,@arr);
>       @val=split(/=/,array[0]);  out=val[1];
>       if (index(line,pcnserver) >= 0 ) {
>          t_pcn+=in+out;

# perldoc -f index
# perldoc -f grep

And to understand the rest:

# perldoc perl
# perldoc perldata
# perldoc perlsyn

Please, do yourself a favour and buy 'Learning Perl' by Randal
Schwartz and Tom Christiansen, available from O'Reilly
(www.oreilly.com).

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: Mon, 1 Feb 1999 23:43:13 -0500
From: Wayne Cuddy <wayne@crb-web.com>
Subject: perl/tk slow dialog mapping?? (fwd)
Message-Id: <Pine.LNX.3.95.990201234241.18000A-100000@crb.crb-web.com>

I have tested the perl/tk samples on three different linux machines and one
HP.  It seems that some windows popup and are filled with content instantly,
but others (mainly dialogs) appear but I have to wait a few seconds for the
text to appear in the dialog.  

Does anyone know how to remedy this situation?

Thanks,
Wayne






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

Date: Tue, 02 Feb 1999 03:18:14 GMT
From: pigs_can_fly@mindless.com (Jason Q.)
Subject: substituting keywords in a string
Message-Id: <36b96aab.13678106@news.cyberway.com.sg>

A couple of weeks back I posted this problem and got it solved. However, I realised there was
something I overlooked.

This is the code I'm currently using.

------------------------------------------------------------
@keyword = ("einstein", "newton", "curie");

$string = "Albert Einstein, Isaac Newton, Marie Curie";

foreach (@keyword)
	{
	$string =~ s/($_)/<FONT COLOR=DARKRED>$1<\/FONT>/gi;
	}

print $string;
----------------------------------------------------------------

The problem arises in this scenario:

---------------------------------------------------------------
@keyword = ("to", "be", "or");

$string = "To be or not to be, that is the question";

foreach (@keyword)
	{
	$string =~ s/($_)/<font color=darkred>$1<\/font>/gi;
	}

print $string;
----------------------------------------------------------------

The code substitutes "to" and "be" fine, but when it comes to substituting "or", it will also
substitute the "or" in "<font colOR=darkred>", resulting in this:

<font col<font color=darkred>=darkred>

thus messing up my html. The same goes for "font", "color", "dark", "red"

Is there a better way to handle the substituting?

Any help would be appreciated. Thanks.


Jason Q.


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

Date: Mon, 1 Feb 1999 22:25:18 -0500
From: "John Counts" <jcounts@voicenet.com>
Subject: Re: substituting keywords in a string
Message-Id: <795rl2$it5$1@news1.fast.net>


Jason Q. wrote in message <36b96aab.13678106@news.cyberway.com.sg>...
>A couple of weeks back I posted this problem and got it solved. However, I
realised there was
>something I overlooked.
>
>This is the code I'm currently using.
>
>------------------------------------------------------------
>@keyword = ("einstein", "newton", "curie");
>
>$string = "Albert Einstein, Isaac Newton, Marie Curie";
>
>foreach (@keyword)
> {
> $string =~ s/($_)/<FONT COLOR=DARKRED>$1<\/FONT>/gi;
> }
>
>print $string;
----------------------------------------------------------------

Try this instead

---------------------------------------------------------------
@keyword = ("to", "be", "or");

$string = "To be or not to be, that is the question";

foreach (@keyword)
 {
 $string =~ s/\s($_)\s/ <font color=darkred>$1<\/font> /gi;
 }

print $string;
----------------------------------------------------------------

First put a space before and after your <>s so the words don't run together
and then put a \s (space) before and after your search pattern so that it
only finds whole words.





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

Date: Tue, 02 Feb 1999 05:14:39 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: substituting keywords in a string
Message-Id: <3Rvt2.131$wk3.8102@nsw.nnrp.telstra.net>

In article <36b96aab.13678106@news.cyberway.com.sg>,
	pigs_can_fly@mindless.com (Jason Q.) writes:

> The code substitutes "to" and "be" fine, but when it comes to substituting "or", it will also
> substitute the "or" in "<font colOR=darkred>", resulting in this:

> Is there a better way to handle the substituting?

Use \b in your regexp

# perldoc perlre

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | 
Commercial Dynamics Pty. Ltd.       | Curiouser and curiouser, said Alice.
NSW, Australia                      | 


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

Date: Tue, 02 Feb 1999 05:28:08 GMT
From: pigs_can_fly@mindless.com (Jason Q.)
Subject: Re: substituting keywords in a string
Message-Id: <36be8c27.22252060@news.cyberway.com.sg>

mgjv@comdyn.com.au (Martien Verbruggen) wrote:

>In article <36b96aab.13678106@news.cyberway.com.sg>,
>	pigs_can_fly@mindless.com (Jason Q.) writes:
>
>> The code substitutes "to" and "be" fine, but when it comes to substituting "or", it will also
>> substitute the "or" in "<font colOR=darkred>", resulting in this:
>
>> Is there a better way to handle the substituting?
>
>Use \b in your regexp

Like that?

$string =~ s/\b($_)\b/<font color=darkred>$1<\/font>/gi;

if keywords included "font", "color" or "darkred", my problem would still be there, wouldn't it?

Jason Q.


># perldoc perlre
>
>Martien
>-- 
>Martien Verbruggen                  | 
>Interactive Media Division          | 
>Commercial Dynamics Pty. Ltd.       | Curiouser and curiouser, said Alice.
>NSW, Australia                      | 



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

Date: Tue, 2 Feb 1999 05:54:02 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: substituting keywords in a string
Message-Id: <ebohlmanF6IJ22.3y9@netcom.com>

Jason Q. <pigs_can_fly@mindless.com> wrote:

: The problem arises in this scenario:

: ---------------------------------------------------------------
: @keyword = ("to", "be", "or");

: $string = "To be or not to be, that is the question";

: foreach (@keyword)
: 	{
: 	$string =~ s/($_)/<font color=darkred>$1<\/font>/gi;
: 	}

: print $string;
: ----------------------------------------------------------------

: The code substitutes "to" and "be" fine, but when it comes to substituting "or", it will also
: substitute the "or" in "<font colOR=darkred>", resulting in this:

: <font col<font color=darkred>=darkred>

: thus messing up my html. The same goes for "font", "color", "dark", "red"

: Is there a better way to handle the substituting?

Your problem is that after you do a substitution, you rescan the 
(now-transformed) string from the beginning, thus matching text that was 
already substituted.

What you need to do is harness the power of regexps to do your 
substitutions in parallel rather than in series:

@keyword = ("to", "be","or");
$kwstring = join('|',@keyword);

$string = "To be or not to be, that is the question";
$string =~ s/($kwstring)/<font color=darkred>$1<\/font>/gi;
print $string;



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

Date: Mon, 1 Feb 1999 23:51:40 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: The behaviour of split() - followup
Message-Id: <1dmkn76.1gp5b8hvafcd7N@bay2-328.quincy.ziplink.net>

Michael <michael.preminger@jbi.hioslo.no> wrote:

> Can this be a perl bug?

Can what be a perl bug??  I'm still waiting for a clear explanation of
the behavior you are seeing.  Some example code would be very helpful.

-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Tue, 02 Feb 1999 02:34:25 GMT
From: nick@valueclick.com (Nick Tonkin)
Subject: Trouble compiling Perl 5.005_2 with Apache on FreeBSD 3.0 dual Pentium IIs
Message-Id: <36b66259.277587930@news.sysci.org>

Hey

Has anybody had success compiling the new Perl 5.005 (whatever rev) on
FreeBSD 3.0 on a dual processor Pentium machine? This has failed on
all machines tested for us.

On the last tests we made, we just installed FreeBSD 3.0 on a new
system, with a Perl 5.005_2 binary already installed -- the Perl works
great but recompiling the source always ends in fatal error.

Many modules, including the Apache modules, also fail to compile with
tons of fatal library errors.

Any suggestions?

Thanks,

Nick


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

Date: Tue, 2 Feb 1999 05:11:02 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Using Net
Message-Id: <ebohlmanF6IH2E.Jx3@netcom.com>

John Corbin <jcorbin@apci.net> wrote:
: I have run across a line in a source file that reads;

: use Net::Telnet;

: When I try to use this source it says;

: Can't locate Net/Telnet.pm in @INC (@INC contains: C:\PERL\lib\site
: C:\PERL\lib
: c:\perl\lib c:\perl\lib\site c:\perl\lib\site .) at finger.pl line 1.
: BEGIN failed--compilation aborted at finger.pl line 1.

: I looked thru the FAQ but cant seem to find anything that pertains to
: this....whats the problem. I am using Win32, Perl 5.004_04. What's the
: problem?? Any help is much appreciated....

The problem is that you haven't installed the Net::Telnet module on your 
system.  Go over to CPAN, pick up the libnet bundle, and install it.  
That will give you Net::Telnet, Net::FTP, Net::SMTP, and much more.



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

Date: Tue, 02 Feb 1999 04:38:50 GMT
From: marc1859@my-dejanews.com
Subject: Using Perl to parse input from a url
Message-Id: <795vgp$6mo$1@nnrp1.dejanews.com>

I would like to write a small PERL routine that downloads a url and scans it
for a specific string.	For example, I might want to download a weather
webpage and extract the temperature to place in a separate variable. How do I
read a url and down load it into variables to parse?

Thanks.

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


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

Date: Tue, 02 Feb 1999 00:31:04 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Using Perl to parse input from a url
Message-Id: <comdog-ya02408000R0202990031040001@news.panix.com>

In article <795vgp$6mo$1@nnrp1.dejanews.com>, marc1859@my-dejanews.com posted:

> I would like to write a small PERL routine that downloads a url and scans it
> for a specific string.  For example, I might want to download a weather
> webpage and extract the temperature to place in a separate variable. How do I
> read a url and down load it into variables to parse?

use LWP::Simple qw(get);

my $url = ....;

my $data = get($url);

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>


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

Date: Tue, 2 Feb 1999 05:27:20 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Using Perl to parse input from a url
Message-Id: <ebohlmanF6IHtL.Kp3@netcom.com>

marc1859@my-dejanews.com wrote:
: I would like to write a small PERL routine that downloads a url and scans it
: for a specific string.	For example, I might want to download a weather
: webpage and extract the temperature to place in a separate variable. How do I
: read a url and down load it into variables to parse?

Use LWP to download the page, HTML::Parser to separate the markup from 
the text, and regexps to match portions of the text.



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

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


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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