[11134] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4734 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jan 24 00:07:21 1999

Date: Sat, 23 Jan 99 21:00:19 -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           Sat, 23 Jan 1999     Volume: 8 Number: 4734

Today's topics:
    Re: as400 net.data <amra@us.ibm.com>
    Re: Can I process ONLY $ARGV as a string INSTEAD of it' (rogerDH)
        CGI.pm and Redirection question <nsurfer@bellsouth.net>
    Re: Easy way to grep all combinations of array subscrip <thelma@alpha2.csd.uwm.edu>
    Re: Getting the last number in an IP addr with a regex. (Mike Bristow)
        Having trouble building Perl 5.005.02 HELP (KJPhilbr13)
        help!?: how to a convert a sting ( "10" ) into a value  (nospam)
    Re: help!?: how to a convert a sting ( "10" ) into a va <abey@hill.ucr.edu>
    Re: help!?: how to a convert a sting ( "10" ) into a va (Steve Leibel)
        How do I Send a form to a printer ? <kf4dmb@camcomp.com>
        How do I split this string? (Ken Williams)
    Re: How long would the Unixes last without Perl? <kperrier@blkbox.com>
        How to insert newline break into a long string (Sun Qinghe)
    Re: Newbie - Whats wrong with this script? (M.J.T. Guy)
    Re: Newbie question: writing file <eugene@snailgem.org>
    Re: package context in evals/subrefs <bradfitz@bradfitz.com>
        Perl script as CGI client <Sven.Kirmess@gmx.net>
    Re: Perl script as CGI client <ebohlman@netcom.com>
    Re: PROOF: Jesus is NOT LORD of the Sabbath!    (erikc)
        Running CGI Progs. <Gavin@csluk.force9.co.uk>
    Re: Running CGI Progs. <STEVENHENDERSON@prodigy.net>
        system() broken on NT? <bingalls@panix.kom>
    Re: system() broken on NT? <abey@hill.ucr.edu>
    Re: system() broken on NT? <allan@due.net>
        Trying to change a line in a file (THE Groovy)
        uncuddled elses <abey@hill.ucr.edu>
    Re: uncuddled elses <allan@due.net>
    Re: Where can I find text parsing samples (Alastair)
        Win32 globbing always checks floppy (Martin Packer)
    Re: Writing files <eugene@snailgem.org>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Sat, 23 Jan 1999 19:24:22 -0600
From: Nadir Amra <amra@us.ibm.com>
Subject: Re: as400 net.data
Message-Id: <36AA7646.49BFBEEB@us.ibm.com>


There is no PERL language environment for AS/400 Net.Data.

Use the DTW_SYSTEM language environment to kick off the perl script via the
CL program.



Richard Robinson wrote:

> I've installed PERL 5.003 port for as400 on as400 box. The program is in
> /QSYS.LIB/PERL5.LIB/PERL.PGM
>
> All I need to do is get it activated for use via Net.data. I created a
> stub HTML block in a macro that has a call to a stub DTW_PERL function
> that merely prints "hello world".
>
> Then I  edited my DB2WWW.INI file with the following command:
>
> ENVIRONMENT (DTW_PERL) /QSYS.LIB/PERL5.LIB/PERL.PGM (OUT RETURN_CODE)
>
> but this doesn't work. Net.data gives me following error message:
>
> Net.data error: The activation of the language environment service
> program /QSYS.LIB/PERL5.LIB/PERL.PGM failed.
>
> Does anyone have any suggestions? The ENVIRONMENT line is obviously (?)
> wrong, but what should it be?
>
> Perl libraries are in /QopenSys/usr/local/lib
>
> --
> Richard Robinson
> Web Administrator
> Litho Development & Research
> richardr@ldr.com
> 503-255-5800 x172



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

Date: Sun, 24 Jan 1999 01:13:04 GMT
From: rogdh@iname.com (rogerDH)
Subject: Re: Can I process ONLY $ARGV as a string INSTEAD of it's contents?
Message-Id: <36ab72c5.12123773@news.earthlink.net>

On Sun, 24 Jan 1999 00:30:37 GMT, dragons@scescape.net (Matthew
Bafford) wrote:

>% perl -e 'for(@ARGV){print "$_ doesn't exist!\n" unless -e $_}' \


I'm new, I don't know what I'm doing, I'm lost... but I got my script
working with the use of your script.

Thanks VERY much for the response.

roger



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

Date: Sun, 24 Jan 1999 03:45:13 GMT
From: Steve Miles <nsurfer@bellsouth.net>
Subject: CGI.pm and Redirection question
Message-Id: <36AA9756.882949F1@bellsouth.net>

Hi,

In my script, I've used the CGI.pm module and have this at the beginning
of my script:
use CGI qw (:standard);
$query = new CGI;
print header;

Then, in one of the subroutines I'm using later on I want to redirect
the user so I put this:
print $query->redirect(-location=>'http://www.yahoo.com');
exit;

The problem is that the browser just "prints" the redirection and
doesn't send the user on to the site. It prints:
HTTP/1.0 "http://www.yahoo.com" Status: "http://www.yahoo.com"
Window-target: 302 Found Set-cookie: -Status Expires:
-Location Date: Sun, 24 Jan 1999 03:37:40 GMT -URI
http://www.groundbreak.com/cgi-bin/mycgi/replicator/replicator.cgi?action:
-nph 0 Content-type: LOCATION

Sorry for all the mess, but does anyone have a solution to the problem?
I think I have to change the header from text/html somehow, but I'm not
sure how.

Thanks in Advance,
Steve Miles
www.groundbreak.com



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

Date: 24 Jan 1999 00:31:07 GMT
From: Thelma Lubkin <thelma@alpha2.csd.uwm.edu>
Subject: Re: Easy way to grep all combinations of array subscripts?
Message-Id: <78dpkb$r8d$1@uwm.edu>

Clay Shirky <clays@panix.com> wrote:
: I am trying to figure out what percentage of 4 letter english words
: potential mispellings are _also_ valid words. I have a dictionary list
: of these words, and I

: foreach $word (@four) {

:     @word = split (//, $word);
: ...
: }

: what I would like to do where those 3 little dots are is like 

:     if (grep /$word[0]$word[2]$word[3]$word[1]/, @four) {

:         print "Type 1  $word - $word[0]$word[2]$word[3]$word[1]";
:     }
                  ...etc
: for all combinations of letters (there are 4 factorial -1 possible
: misspellings, i.e. 23 possible mispellings.)

: Is there an easier way to do this than 23 'if' tests?

#!/usr/bin/perl5 -w

my ($alfa,@letters,%matches,$matches,@thewords,$word);
my @words = ( "bore", "robe","bare","bear");

foreach $word (@words)
{ @letters = split //,$word;
  $alfa = join "",(@letters = sort @letters);   ###Sort letters of word
  push @{$matches{$alfa}},$word;                ###Add it to list of words
}                                               ###comprising those 4 letters

           ####You'll of course want to design a more meaningful print.
foreach $alfa (sort keys %matches)
{ print "Letters: $alfa\n";
  @thewords = @{$matches{$alfa}};
  foreach $word (@thewords) { print "$word\n"; }
}

Letters: aber
bare
bear
Letters: beor
bore
robe

          ####I'm sure that the join could be replaced with
          ####something better...                

                             --thelma
: -clay


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

Date: Sun, 24 Jan 1999 00:45:17 GMT
From: mike@fat.dotat.at (Mike Bristow)
Subject: Re: Getting the last number in an IP addr with a regex.
Message-Id: <slrn7akr8s.2m0.mike@lindt.fat.dotat.at>

On 23 Jan 1999 20:35:08 +0100, Jonathan Feinberg <jdf@pobox.com> wrote:
>mike@fat.dotat.at (Mike Bristow) writes:
>
>> my $octet = '0*(?:1?\d\d?|2[01234]\d|25[012345])';
>
>So 0000000000253 is a legal octet?

Do you want it to be?  It could be, if we assume that all the octets
are decimals.

As ever, with everything regexey, the hardest thing is deciding what
it is you want to match, not how you match it. 

Having said all that I can't remember why on earth I put the 0* at
the front.  Stupidity, I guess :-)

-- 
Unix IS user friendly. It's just selective about who its friends are
	-- Tom Diehl


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

Date: 24 Jan 1999 03:29:36 GMT
From: kjphilbr13@aol.com (KJPhilbr13)
Subject: Having trouble building Perl 5.005.02 HELP
Message-Id: <19990123222936.02106.00002077@ng05.aol.com>

I need to use DBI to interface with an Oracle database but it requires at least
5.003 or better.  I am currently using Perl 5.001 that came with the NT
Resource Kit.  I am trying to install it on Windows NT currently (Unix later if
I get this to work).  I am trying to follow all the install instructions. When
I run "nmake makefile"  I get an" syntax error : expecting ":" or "="...What is
happening?  I am a newbie to Perl...The nmake executable is from Visual C 98
(Visual Studio 98 - Enterprise Edition).  Any help would be most appreciated.

Thanks in advance!
Kevin Philbrick


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

Date: 24 Jan 1999 10:37:33 +1000
From: "Julian Kuiters" <j.kuiters@bigpond.com(nospam)>
Subject: help!?: how to a convert a sting ( "10" ) into a value ( 10 )
Message-Id: <01be4731$b746e980$4b4bd683@tbp.11519.Teletechintl.com>

Can some one tell me how the hell you convert a string to a value?

eg: 
the string: $age = "10" 
and string: $since = "2"
then if you do: $now = $age + $since
$now = "102"

what I want it to do is to make $now = 12 (as a number, not a string)

Thanx!
Julian Kuiters


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

Date: Sat, 23 Jan 1999 19:22:26 -0800
From: Abraham Grief <abey@hill.ucr.edu>
To: Julian Kuiters <j.kuiters@bigpond.com>
Subject: Re: help!?: how to a convert a sting ( "10" ) into a value ( 10 )
Message-Id: <Pine.LNX.4.05.9901231920170.24096-100000@hill.ucr.edu>


You could just initialize with integers, like $age = 10, but if it's
already a string, just use int($age) to turn it into an integer value.

On 24 Jan 1999, Julian Kuiters wrote:

> Can some one tell me how the hell you convert a string to a value?
> 
> eg: 
> the string: $age = "10" 
> and string: $since = "2"
> then if you do: $now = $age + $since
> $now = "102"
> 
> what I want it to do is to make $now = 12 (as a number, not a string)
> 
> Thanx!
> Julian Kuiters
> 
> 



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

Date: Sat, 23 Jan 1999 20:28:31 -0800
From: stevel@coastside.net (Steve Leibel)
Subject: Re: help!?: how to a convert a sting ( "10" ) into a value ( 10 )
Message-Id: <stevel-2301992028310001@192.168.100.2>

In article <01be4731$b746e980$4b4bd683@tbp.11519.Teletechintl.com>,
"Julian Kuiters" <j.kuiters@bigpond.com(nospam)> wrote:

> Can some one tell me how the hell you convert a string to a value?
> 
> eg: 
> the string: $age = "10" 
> and string: $since = "2"
> then if you do: $now = $age + $since
> $now = "102"
> 


Have you tried running the above code to see what actually happens?

Steve L
stevel@coastside.net


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

Date: Sun, 24 Jan 1999 21:39:38 -0500
From: "Jim and Lois" <kf4dmb@camcomp.com>
Subject: How do I Send a form to a printer ?
Message-Id: <36aa9e81@camcomp2.camcomp.com>

I am building a Help desk app . I would like users when the fill the form
out and press
a button they send it to the help desk printer.




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

Date: Sun, 24 Jan 1999 04:32:54 GMT
From: tekkin@hotmail.com (Ken Williams)
Subject: How do I split this string?
Message-Id: <36aaa246.0@news.cgocable.net>

inet addr:192.168.0.1  Bcast:192.168.0.255  Mask:255.255.255.0

The above is from ifconfig.  I need to pull the IP's out.  Specifically the 
first.  How do I split with a starting character of : and an ending character 
of space?

For example:

($IP, $BC, $MASK) = split (/: ??? /);

Anyone?

Thanks.



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

Date: 23 Jan 1999 22:44:55 -0600
From: Kent Perrier <kperrier@blkbox.com>
Subject: Re: How long would the Unixes last without Perl?
Message-Id: <ysiaez9l1o8.fsf@blkbox.com>

abigail@fnx.com (Abigail) writes:

> Doesn't HP ship perl4 by default? And doesn't RedHat come with some
> form of Perl?
> 

I don't have any experience with HP-UX and I don't consider RedHat a 
commercial unix.

Kent 


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

Date: Sun, 24 Jan 1999 04:13:38 GMT
From: sunq@ERE.UMontreal.CA (Sun Qinghe)
Subject: How to insert newline break into a long string
Message-Id: <S5xq2.13419$dB4.430977@carnaval.risq.qc.ca>

Hi everyone,

I have a very long string say 1000 characters called $content. If I
want send it to a friend like:

print <<Mail;

$content

Mail

It will be a very long line in the message. I want to insert newline
break into this long string at certain interval. Could you give me
a hint ?

Thanks,

Sun


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

Date: 24 Jan 1999 00:14:03 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Newbie - Whats wrong with this script?
Message-Id: <78dokb$7bd$1@pegasus.csx.cam.ac.uk>

Ronald J Kimball <rjk@linguist.dartmouth.edu> wrote:
>Michael J. Bahr <targa@cornhusker.net> wrote:
>> while() {            # While any failing nodes
>>    chop;                         take off extraneous
>>    $xy = $hosts{$_};          # Lookup x,y coordinate
>
>You forgot the comment character '#' before the comment on line 20.  
>
>take off extraneous $xy = $hosts{$_};
>
>looks to Perl like an assignment to a subroutine call.

Though that's mostly an illustration that Perl isn't really very
bright.    I can see that that would be an assignment to a subroutine
call if "take", "off" and "extraneous" had been predefined as subroutines
(with appropriate prototypes).  Or if the given expression was bracketed.

But as it is, I suspect indirect object confusion.


Mike Guy


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

Date: Sat, 23 Jan 1999 20:20:16 -0500
From: Eugene Sotirescu <eugene@snailgem.org>
To: chester@ultranet.com
Subject: Re: Newbie question: writing file
Message-Id: <36AA7550.995EC320@snailgem.org>

Kevin Chester wrote:
> 
> Thanks for your quick reply! I made the change and received this error msg.
> 
> Cannot open tokens/285789068 for writing: Permission denied
> 
> Before I started the script I telnet'd from the cgibin "chmod 755
> cart.cgi". I thought this was the correct setting.
> 

Aha, things are clearer now: is this a CGI script trying to write to a
file? What matters is not the permissions of the script (which were
correct to start with, otherwise you wouldn't have gotten as far as that
error message), but those of the file you're trying to modify. 
You can fix this by making  tokens/262805729 (I gather this is the file
you're trying to modify) world writable, but this of course opens
another can of worms: anybody with shell access to your server can then
change this file.


> 
> Rick Delaney wrote:
> 
> > [posted & mailed]
> >
> > Kevin D. Chester wrote:
> > >
> > > Hello Perl Group,
> > >
> > > What am I doing wrong here?
> > >
> > > #! /usr/local/bin/perl5.003
> >                         ^^^^^
> > You should consider an upgrade, but that's not your problem.
> >
> > > ...
> > > open(token_file, ">$token_file_name") || &err_trap("Cannot open
> > > $token_file_name for writing\n");
> > > print(token_file "$token\n");
> > > close token_file;
> > > ...
> > >
> > > All I get is "Cannot open tokens/262805729 for writing ".
> >
> > If you want to know the reason the file couldn't be opened for writing,
> > you will have to modify &err_trap to tell you.
> >
> > Something like:
> >
> >     open(TOKEN_FILE, ">$token_file_name")
> >         || die "Can't open $token_file_name for writing: $!\n";
> >
> > It is customary to use all uppercase for filehandles so that they stand
> > out.  The key thing here is $! which gives the system error string.
> >
> > perldoc perlvar
> >
> > --
> > Rick Delaney
> > rick.delaney@shaw.wave.ca
> 
> --
> ==========================================
> Kevin D. Chester  chester@ma.ultranet.com
> ==========================================

-- 

Eugene

 "I have an Apache Web Server that uses CGI forms written in COBOL."
 							Post in clpm


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

Date: Sat, 23 Jan 1999 16:27:08 -0800
From: "Brad Fitzpatrick" <bradfitz@bradfitz.com>
Subject: Re: package context in evals/subrefs
Message-Id: <78dpcb$ng6$1@nntp6.u.washington.edu>

I'm doing exactly that, as I was before, but the $sucked_in_code doesn't
seem to be running in the foreign package.  It can see a bunch of variables
that are declared in the package that I run the eval from.  This seems to be
closure-like behavior.

How can I *disable* closures?  I want evals and anonymous subs to run from
the context at which I call them.

Thanks in advance,
Brad


M.J.T. Guy <mjtg@cus.cam.ac.uk> wrote in message
news:782j6v$i5s$1@pegasus.csx.cam.ac.uk...
>Brad Fitzpatrick <bradfitz@bradfitz.com> wrote:
>>How can I control what package context evals and anonymous sub references
>>run in when executed from somewhere else?  I'm sucking in foreign code to
be
>>executed within the current program but I want to have it run in its own
>>namespace, instead of walking all over my existing program.
>
>For eval(), the package currently in scope defines the namespace used.
>So since package directives are lexically scoped, you can write
>
>     { package ForeignCode; eval $sucked_in_code };
>or
>     eval "package ForeignCode; $sucked_in_code";
>
>
>Mike Guy




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

Date: Sun, 24 Jan 1999 02:09:48 +0100
From: Sven Kirmess <Sven.Kirmess@gmx.net>
Subject: Perl script as CGI client
Message-Id: <36AA72DC.90CF5C68@gmx.net>

I try to create a Perl script which works as a client for a CGI-script.
The CGI-script uses the post methode. How can I send the response to
this script with a Perl-Client (without using a browser)?

Sven





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

Date: Sun, 24 Jan 1999 01:49:20 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Perl script as CGI client
Message-Id: <ebohlmanF61Jq8.82D@netcom.com>

Sven Kirmess <Sven.Kirmess@gmx.net> wrote:
: I try to create a Perl script which works as a client for a CGI-script.
: The CGI-script uses the post methode. How can I send the response to
: this script with a Perl-Client (without using a browser)?

perldoc LWP
perldoc lwpcook



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

Date: Sun, 24 Jan 1999 00:00:17 GMT
From: firewevrMAPSITNA@insync.net (erikc)
Subject: Re: PROOF: Jesus is NOT LORD of the Sabbath!   
Message-Id: <36aa6270.4946965@news.insync.net>

On Sat, 23 Jan 1999 04:59:56 -0500
"MindSpring User" <kdp10@mindspring.com> wrote:
-- origin: alt.atheism:

>|How about a little compassion the my friend ... hate is what is tearing this
>|world apart ... only unconditional love, compassion, and acceptance are
>|gonna make a difference ... granted most Bible thumpers have to learn this
>|much more than the rest of us ... but it has to start someplace ....

The christers could start by refraining from trying to convert people
who do not believe in thier nonsense, of which there are many.  They
have several newsgroups of thier own; they can keep thier conversation
there.  This would go a long way towards alleviating the hard feelings
between we in alt.atheism and the christers.   We atheists do not go
barging into other groups telling people to give up thier religions,
what fucking right do they have to barge into our group and tell us
that we have to accept thiers?

At the very least, this is rude and inconsiderate, and is the root
cause of most of the animosity that exists between atheists and xians.



Erikc (alt.atheist #002) | "An Fhirinne in aghaidh an tSaoil." 
                         |      "The Truth against the World."
ICQ 26776011             |                           -- Bardic Motto
If we don't believe in freedom of expression for
people we despise, we don't believe in it at all.
   ---- Noam Chomsky


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

Date: Sun, 24 Jan 1999 00:32:20 +0000
From: Gavin <Gavin@csluk.force9.co.uk>
Subject: Running CGI Progs.
Message-Id: <36AA6A13.B2D5B040@csluk.force9.co.uk>

How can I (or is it possible) to run a cgi prog on my win95 machine.
I`ve tried everything. All I keep getting is the browser trying to
download the file.

Please Help!

Gavin.



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

Date: Sat, 23 Jan 1999 18:05:37 -0800
From: "steven t henderson" <STEVENHENDERSON@prodigy.net>
Subject: Re: Running CGI Progs.
Message-Id: <78dvn7$71s4$1@newssvr03-int.news.prodigy.com>

this one drove me nuts for hours!!! make sure the following is the FIRST
thing printed from your program:

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

 ... and the two newlines are critical.


additionally, for some reason when i am running my IE4 locally (ie. not
across the net) it prints out the header information so you have this line
accross the top of your page wich can be anoying so i added the following
condition:

if(! ("localhost" =~ /$ENV{'SERVER_NAME'}/))
{
    print "Content-type: text/html\n\n";
}

which will only print the line when running the program over the net. enjoy
and hope it works for you.




Gavin wrote in message <36AA6A13.B2D5B040@csluk.force9.co.uk>...
>How can I (or is it possible) to run a cgi prog on my win95 machine.
>I`ve tried everything. All I keep getting is the browser trying to
>download the file.
>
>Please Help!
>
>Gavin.
>




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

Date: Sat, 23 Jan 1999 21:15:48 -0500
From: Bruce Ingalls <bingalls@panix.kom>
Subject: system() broken on NT?
Message-Id: <36AA8254.C205B49C@panix.kom>

This command works on Solaris, but not on NT:
perl -e '$ls=dir; system "$ls"'

NT responds:
Can't find string terminator "'" anywhere before EOF at -e line 1.

Note that backticks won't work on either system:
perl -e '$ls=dir; `$ls`'

FWIW, use diagnostics; $^W=1;  doesn't help.
I am using Perls 5.003 - 5.005. Thanks!




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

Date: Sat, 23 Jan 1999 19:29:19 -0800
From: Abraham Grief <abey@hill.ucr.edu>
To: Bruce Ingalls <bingalls@panix.kom>
Subject: Re: system() broken on NT?
Message-Id: <Pine.LNX.4.05.9901231928220.24096-100000@hill.ucr.edu>


There are some helpful hints in section 3 of the perl faq, at
http://language.perl.com/faq/



On Sat, 23 Jan 1999, Bruce Ingalls wrote:

> This command works on Solaris, but not on NT:
> perl -e '$ls=dir; system "$ls"'
> 
> NT responds:
> Can't find string terminator "'" anywhere before EOF at -e line 1.
> 
> Note that backticks won't work on either system:
> perl -e '$ls=dir; `$ls`'
> 
> FWIW, use diagnostics; $^W=1;  doesn't help.
> I am using Perls 5.003 - 5.005. Thanks!
> 
> 
> 
> 



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

Date: Sat, 23 Jan 1999 22:38:21 -0500
From: "Allan M. Due" <allan@due.net>
Subject: Re: system() broken on NT?
Message-Id: <vBwq2.206$WR1.3194@nntp1.nac.net>

Bruce Ingalls wrote in message <36AA8254.C205B49C@panix.kom>...
:This command works on Solaris, but not on NT:
:perl -e '$ls=dir; system "$ls"'
:NT responds:
:Can't find string terminator "'" anywhere before EOF at -e line 1.
:Note that backticks won't work on either system:
:perl -e '$ls=dir; `$ls`'
:FWIW, use diagnostics; $^W=1;  doesn't help.
:I am using Perls 5.003 - 5.005. Thanks!


See perlfaq3
Why don't perl one-liners work on my DOS/Mac/VMS system?

It states:
# DOS, etc.    perl -e "print \"Hello world\n\""

DOS always starts with a quote.  I find it easier to use q and qq when running
at the prompt.  So I would write your code

perl -e "$ls=q(dir); system qq($ls)"

(q(dir) cause we don't want any bare words now do we <g>)

and for your backtick version, we need something to capture the output of the
backticks as well as converting it to run under Winhoze.

perl -e "$ls=q(dir); $out = qx($ls); print qq($out)";

HTH

AmD





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

Date: 24 Jan 1999 03:31:34 GMT
From: thegroovy@aol.comNOSPAM (THE Groovy)
Subject: Trying to change a line in a file
Message-Id: <19990123223134.09864.00001849@ng-cd1.aol.com>

I am making a script that has several users, all with ID's (starting with 1 and
going up) and each ID has a line in a file that logs hits to an area with their
ID. The hit file is in the format ID|TotalHits\n. When there is another hit for
someone with an ID, I want it to add 1 to the Total Hits for that user. I was
trying to do it with the splice function, but couldn't find enought information
on it. Here is the code I have, which doesn't work :-).

open (HITS,"hits.log");
@hits=<HITS>;
close(HITS);

foreach $reseller (@hits) {
	$reseller =~ s/\n//g;
	@reseller_info = split(/\|/, $reseller);

	if ($reseller_info[0] == "$idnumber") {
		$hits = $reseller_info[1];
		$new_hits = $hits++;
		$new_info =~ s/$idnumber|$hits/$idnumber|$new_hits\n/;
		open (HITS,"hits.log");
		s/$reseller/$new_info/g;
		close(HITS);
	}
}


Any ideas on why it won't add 1 to the total hit count?






Regards,
Gil Hildebrand, Jr.
UIN: 28517138
THEGroovy\@aol.com
remove the \ to email me (I hate spam!)


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

Date: Sat, 23 Jan 1999 18:01:43 -0800
From: Abraham Grief <abey@hill.ucr.edu>
Subject: uncuddled elses
Message-Id: <Pine.LNX.4.05.9901231759130.22167-100000@hill.ucr.edu>


In the perlstyle man page, one of the tips is to use uncuddled elses.
Can someone please show me what an uncuddled else is as opposed to a
cuddled one?  Thanks in advance.



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

Date: Sat, 23 Jan 1999 22:14:19 -0500
From: "Allan M. Due" <allan@due.net>
Subject: Re: uncuddled elses
Message-Id: <Yewq2.205$WR1.2411@nntp1.nac.net>

Abraham Grief wrote in message ...
:
:In the perlstyle man page, one of the tips is to use uncuddled elses.
:Can someone please show me what an uncuddled else is as opposed to a
:cuddled one?  Thanks in advance.


Funny how things come in waves.  We just talked about this a week or so ago.
Many seemed to favor cuddled, but I am an uncuddly guy myself.  YMMV.

cuddled:

if (condition) {
    do stuff;
}else{ 
    do other stuff;
}

uncuddled:

if (condition) {
    do stuff;
}
else {
    do stuff;
}

HTH

AmD






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

Date: Sun, 24 Jan 1999 00:28:22 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Where can I find text parsing samples
Message-Id: <slrn7akqai.4i4.alastair@calliope.demon.co.uk>

Ron <e_ron.no.spam@netvision.net.il> wrote:
>
>I will have to avoid thorough learning as I am under pressure to
>finish a project so I just started playing.

Well, I haven't learned anything 'thoroughly'!

>Any other built in function which can help in parsing text? And can I
>detect special characters while splitting such as \t tab?

Regular expressions. See the 'perlre' pages e.g.

#!/usr/bin/perl -w

my $string = "hello there       "; # 2 tabs in there!

if ($string =~ /\t/) {
        print "Got a tab!\n";
}

HTH.

-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: Fri, 22 Jan 1999 22:26:32 -0500
From: mpacker@concentric.net (Martin Packer)
Subject: Win32 globbing always checks floppy
Message-Id: <36a93f46.38148561@news.mindspring.com>

I am running perl, version 5.004_02 on a Window 95 machine.  I am running
the following script to calculate the bytes used in each directory (on the
c: drive for now):

sizedir("c:/*");

sub sizedir {
   my($startdir) = @_;
   my($dirsize) = 0;

#             ****** glob is here

   foreach $file (glob($startdir)) { # floppy accessed here

#             ****** glob is here

   if (-f $file) {
      $dirsize += -s $file;
      }
   else {
      sizedir($file."/*");
      }
   }  # end of loop through this directory!
   # we would actually look at $dirsize's size here and act on it
   print "directory $startdir: $dirsize bytes\n";
}

=========== end of script

Each time the glob is called, the floppy drive is accessed for a second or
two, even though the a: drive isn't the one being looked at by the glob.
Is there a way to suppress this behavior?  Am I going at it all wrong?  If
I need to wait out a floppy check on each glob, this won't fly!

TIA,


Marty Packer
Elbow Technologies
"Reason with them, it drives them crazy"


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

Date: Sat, 23 Jan 1999 20:31:51 -0500
From: Eugene Sotirescu <eugene@snailgem.org>
To: alcazar@netcomp.net
Subject: Re: Writing files
Message-Id: <36AA7807.D79A0418@snailgem.org>

R. Alcazar wrote:
> 
>     Hello all,
> 
>     I'm trying to do something quite simple...  however, its got me stumped.
> All I wanna do is open a file (thus, creating a new file) inside of a
> directory store in my webserver.  However, it fails and returns an error:
> permission denied.  Such that:
> 
>     open(SOMEFILE, "/somedirectory/somefile.txt") || die "$!\n";

Your line probably is:

open(SOMEFILE, ">/somedirectory/somefile.txt") || die "$!\n";

i.e. you're creating a file by opening it for writing.

But WHO's actually trying to do the writing? Well, it's your script. And
who is the user of that script? If you're running it as a CGI script,
the user is your server, usually designated as user 'nobody', a user
with low privilges. Of course it can't write to a file unless that file
is owned by 'nobody' or has world write permissions . . .



> 
>     I've checked the file permissions, and the only way I can get it to
> write to that directory is if I specify 777 on that directory.  (Which is
> obviously what I DON'T want to do).  It seems that (at the very least) in
> order for me to open/create a file inside that directory I need permissions
> of 007.  I wrote another script outside of my prog which does the same thing
> and that seems to be working fine.
> 
>     The prog with this problem is quite lengthly and I don't feel the need
> to recode it.  I haven't had any chmod functions or file operators anywhere
> in the script and I don't know why it is returning "permission denied"
> unless I specify 007.  Any ideas why this is happening... any suggestions
> are appreciated...
> 
> illfigah

-- 

Eugene

 "I have an Apache Web Server that uses CGI forms written in COBOL."
 							Post in clpm


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

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

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