[16745] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4157 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 28 21:05:36 2000

Date: Mon, 28 Aug 2000 18:05:21 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <967511120-v9-i4157@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 28 Aug 2000     Volume: 9 Number: 4157

Today's topics:
    Re: AIX and IBM cc and gnu make to compile perl 5-6.0 (Steven Rosenthal)
        braincramp question on parameters being entered into a  <carrotshoes@mail.rit.edu>
        Compiled Perl code related question medi@cybershell.com
        DBI - DBI::ORACLE HELP umesh.patel@usa.net
    Re: Executable file creating executable file -- doesn't <elephant@squirrelgroup.com>
    Re: File access over a network (David Efflandt)
    Re: Get ip-adress of webserver <elephant@squirrelgroup.com>
    Re: Get ip-adress of webserver (David Efflandt)
    Re: Get own machine's dial-up IP address? <jraff@home.com>
    Re: Global symbol "$dbh" requires explicit package name <elephant@squirrelgroup.com>
    Re: How do I manipulate each element of an array? (Craig Berry)
    Re: How do I manipulate each element of an array? <zli@umr.edu>
    Re: How to encode for the web? <mahnke@uni-freiburg.de>
        Indexing a String for a RegEx help? ptomsic@my-deja.com
    Re: Indexing a String for a RegEx help? (Eric Bohlman)
    Re: Kill Me! (Tim)
        Loading a array from a file. r_conner@my-deja.com
    Re: Loading a array from a file. (Mike Stok)
    Re: making sure input is a certain way i.e. starting an <elephant@squirrelgroup.com>
    Re: my($a)=shift or warn; (Abigail)
    Re: Please help: How to check for $var is null or not? <elephant@squirrelgroup.com>
    Re: Problems with script to download a file <elephant@squirrelgroup.com>
    Re: Problems with script to download a file (Tony L. Svanstrom)
    Re: processing files in a directory and stuff (Eric Bohlman)
    Re: processing files in a directory and stuff <anmcguire@ce.mediaone.net>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 29 Aug 2000 00:48:42 GMT
From: sbr@columbia.edu (Steven Rosenthal)
Subject: Re: AIX and IBM cc and gnu make to compile perl 5-6.0
Message-Id: <39ab0422.88293960@news.columbia.edu>

Hi,
 I've had exactly the same problems as were described below.  Were
these problems ever resolved?  Has anyone successfully built Perl 5.6
on AIX 4.3.2 using "IBM C for AIX"?  My IBM C compiler is vac.C
4.4.0.3.

Thanks,

Steven Rosenthal
  
On Thu, 06 Jul 2000 17:10:46 GMT, shapirod112@my-deja.com wrote:

>Hello,
>
>I am having a difficult time compiling perl on my AIX 4.3.2.0 box
>(workgroup server F40).  It stops on pp_sys.c and complains about two
>different things from lines 4306-4648.  Here are examples of the two
>messages:
>
>line 4306.14: 1506-068 (w) Operation between types "struct hostent*"
>and "int" is not allowed.
>
>line 4338.21: 1506-285 (S) The indirection operator cannot be applied
>to a pointer to an incomplete struct or union.
>
>It ends with an Error 1.  Has anybody seen this and overcome it?
>
>I tried this with gcc 2.95.2 and it stops on pp_sys.c too.
>
>Please help.
>
>David
>
>
>Sent via Deja.com http://www.deja.com/
>Before you buy.



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

Date: Tue, 29 Aug 2000 00:26:01 GMT
From: "Carrotshoes" <carrotshoes@mail.rit.edu>
Subject: braincramp question on parameters being entered into a perl scrip
Message-Id: <tqDq5.1609$%f1.40959@news1.news.adelphia.net>

Hey all, I have a perl script that I want to take in some parameters at
start up, I know that to get to the variables within the script its

$foo = $_[x] etc .  I just can seem to get the script to see the variables
from command line. Do I separate with commas, put it all in parenthesis or
what.
I'm running ActivePerl on a win98 box. Some sample code is below to clarify
me.  Thanks for your help


#!/usr/bin/perl
#get the parameters here
$theDate  = $_[0];
$header  = $_[1];
$opening = $_[2];
$entry  = $_[3];
$closing = $_[4];
#create the html file

open (OUT, ">$theDate.html")
 || warn "Couldn't open file";

all my variables have no value when printed out later. thanks again

Don
carrotshoes@mail.rit.edu




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

Date: Mon, 28 Aug 2000 22:50:48 GMT
From: medi@cybershell.com
Subject: Compiled Perl code related question
Message-Id: <8oeqc1$cbg$1@nnrp1.deja.com>

I have written a CGI and compiled it into a binary executable
via B::C.pm

The idea was to set setuid on the executable as my HP-UX current
kernel does not setuid on scripts.

I get the following error message

No -e allowed in setuid scripts.

Here is some status on this file

ls -l ChgPasswd_exe.cgi
-rwsr-xr-x   1 root  bin   1347246 Aug 28 13:18 ./ChgPasswd_exe.cgi

file ChgPasswd_exe.cgi
ChgPasswd_exe.cgi:    PA-RISC2.0 shared executable dynamically linked
-not stripped

Anyone has any ideas? You'd need to know HP-UX, Setuid stuff and
Perl for this.

Thanks


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 28 Aug 2000 23:13:48 GMT
From: umesh.patel@usa.net
Subject: DBI - DBI::ORACLE HELP
Message-Id: <8oermt$do5$1@nnrp1.deja.com>

How can you  run
set transaction use rollback segment R_BIG
delete xyz table where stauts = 'open'

When I run only delete statement mostly it works but sometimes it fails
due to rollback segment got fill. So I added set transaction.. statement
I prepared and excute it then I prepare delete statement,execute ,finish
and disconnect it. When I do that I found out that Oracle is not using
R_BIG rollback segment it is using default rollback segment which is I
do not want to use.
(I can use set trans... and delete statement.... together from SQLPLUS
without any problem)
Any idea how to do it in perl?

Thanks,


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 28 Aug 2000 23:47:33 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Executable file creating executable file -- doesn't work
Message-Id: <MPG.1415978e52f98fd9989715@localhost>

joshfeingold@my-deja.com <joshfeingold@my-deja.com> wrote ..
>I have a file "parent.pl" which creates a file "child.pl". The problem
>is that when parent.pl is run and creats child.pl via the Internet the
>file is put in the Unix group "staff" which is not executable by me.
>How can I make a file which can be executed and have permissions
>changed by me?

Perl will create a file with whatever permissions the program was run 
with .. so if the web server is configured to run scripts as 'staff' (a 
non-ideal situation btw) then the files that the scripts create will 
have that permission as well

depending on how your system is set up the script might be able to 
change the ownership of the created file (this depends on the authority 
that the 'staff' group has on your system) so that you can access it .. 
try the Perl function chown

  perldoc -f chown

if that doesn't work as expected (and as documented) then the 'staff' 
group probably doesn't have the appropriate permissions .. talk to your 
system administrator about what to do (to be honest - the system is in 
all likelihood misconfigured if CGI programs are run as 'staff')

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Tue, 29 Aug 2000 00:15:08 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: File access over a network
Message-Id: <slrn8qm03q.t67.efflandt@efflandt.xnet.com>

On Mon, 28 Aug 2000 19:21:38 GMT, kliquori <kliquori@my-deja.com> wrote:
>I'm trying to write a Perl script to access files on different UNIX
>boxes. I want to be able to search through /etc/passwd on three
>different boxes. I would like, however, to avoid using shell commands
>if possible. I see one of two ways:
>1) Use NFS and access the file as if it's local.
>2) Use rcp with the system command to copy the files locally.
>
>Are there any other ways to do this?

Net::FTP in the libnet module package.  Or Net::Telnet to the other side
and rcp them back to you if you don't have enough permission from where
you are at.  I hope the systems are secure enough that /etc/passwd does
not contain the actual passwords.

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/  http://cgi-help.virtualave.net/



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

Date: Tue, 29 Aug 2000 00:25:06 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Get ip-adress of webserver
Message-Id: <MPG.1415a053b50305e4989719@localhost>

Irmo <irmo@mailroom.com> wrote ..
>Is there any way to get the ip adress of the server, a (perl) script is
>running on ?

this is a FAQ

"How do I find out my hostname/domainname/IP address?" in perlfaq9

you can find this and many more answers using the perldoc utility on any 
Perl platform with a command line

I used the following to find your answer

  perldoc -q "IP address"

for more information about perldoc type

  perldoc perldoc

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Tue, 29 Aug 2000 00:54:31 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Get ip-adress of webserver
Message-Id: <slrn8qm2dm.t67.efflandt@efflandt.xnet.com>

On Mon, 28 Aug 2000 20:04:02 GMT, Irmo <irmo@mailroom.com> wrote:
>
>Is there any way to get the ip adress of the server, a (perl) script is
>running on ?

perldoc perlfaq9
How do I find out my hostname/domainname/IP address?

Or if you are asking about on a webserver:

#!/usr/bin/perl -w
use Socket;
use CGI qw/:standard/;
$peer_addr = inet_ntoa(scalar(gethostbyname($ENV{HTTP_HOST})));
print header,start_html('Host to IP'),
"The IP of webserver $ENV{HTTP_HOST} is $peer_addr",end_html;


-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/  http://cgi-help.virtualave.net/



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

Date: Mon, 28 Aug 2000 22:36:33 GMT
From: "john" <jraff@home.com>
Subject: Re: Get own machine's dial-up IP address?
Message-Id: <RPBq5.30270$e11.209966@news1.rdc1.nj.home.com>

I wrote a small perl script that sits on a server somewhere.
All it does is echo the REMOTE_ADDR & REMOTE_HOST environment variables.
On UNIX like systems they are different.
I call it 'remote address echo' for want of a better name.
http://www.acgnj.org/cgi-bin/rae.pl

Then I run a perl script on the dial-up machine to fetch this response (LWP
works fine for me), parse it, get the IP and URL, build a HTML page with the
new data, date and time, and FTP it to some personal private place on the
web. I figure about every 15min. is often enough.

BTW: go direct not through a proxy, otherwise you get the address of the
proxy not your box.
----------------------------------------------------------------
"Randall Parker" <rgparker@west.net> wrote in message
news:MPG.14147162c4575c0c9898f1@news.onlynews.com...
> Suppose a machine has a permanent (or even dynamic) IP address it uses on
> a local network. But suppose in addition it gets a dynamic IP address
> handed to it every time it does dial-up to an ISP using a phone modem or
> cable modem or DSL modem.
>
> Okay, the question is, how to find out what that second IP address is?
>
> My goal is to have some machine sitting at home that is connected via
> auto-dial phone modem or cable modem at a certain time of the day
> (using a Perl script of course) to  connect to the internet, find out its
> dynamic IP address, and then connect to a machine I have at work (that
> has a static IP address) and tell it what the dynamic IP address is.
>
> If possible I'd like to do this in a portable way that will work across
> Linux, OS/2, and NT. A friend has an OS/2 box and he and I both want to
> do this.
>
> Alternatively: Suppose the home machine just went and made the socket
> connection to the work machine. Then could the work machine see from the
> socket connection object what IP address it is coming from?
>
> Even if the latter would work I'd still like a better way to find out a
> machine's own IP address(es).
>




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

Date: Mon, 28 Aug 2000 22:36:13 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Global symbol "$dbh" requires explicit package name at   d:\...\Behzad.pl line 17.
Message-Id: <MPG.141586d6e0250703989710@localhost>

  [ posted to comp.lang.perl.misc and CCed to ren.maddox@tivoli.com ]

Ren Maddox <ren.maddox@tivoli.com> wrote ..
>jason <elephant@squirrelgroup.com> writes:
>
>> the other point I was making was that if you're going to use a variable 
>> in an 'or die' construct then you must have already declared it (and 
>> ideally initialised it as well) because if the thing that you're testing 
>> fails then the word will not be declared and you will get errors from 
>> strict
>
>My perl agrees with you, though I find it odd... Base on the
>precedence table, "=" binds more tightly than "or", so one (me) would
>think that the variable would be declared before the "die".
>
>However, I quick Deparse gave what I considered to be surprising
>results:
>
>% perl -MO=Deparse -e 'use strict; my $x = 0 or die "blah $x\n";'
>Global symbol "$x" requires explicit package name at -e line 1.
>-e had compilation errors.
>die "blah ${'x'}\n" unless my $x = 0;
>
>
>Now, I was aware that this construct (or, more particularly, the
>reversed construct "my $x = 0 unless undef;") resulted in the variable
>not being declared, but I had no idea that the use of "or" in a
>declaration would get so turned around.
>
>It seems to get even stranger... if you force the "or" to be in a
>context were it cannot simply be reworked into a conditional, then you
>get something that Deparses into "||", as I would expect.  However,
>this does not get read of the problem.  For example:
>
>use strict;
>my $y = (my $x = 0 or die "blah $x\n");
>
>Deparses into:
>my $y = (my $x = 0) || die("blah ${'x'}\n");
>
>
>which, as the "${'x'}" syntax would indicate, still gets an error
>under "strict".
>
>This all just seems wrong....

obviously the former is not confusing or wrong - other than perhaps 
perl's parsing choices

the latter (where or is forced to be ||) .. I think there's a basic rule 
of thumb which is that a variable is not declared (completely if you 
will) until the next line .. same happens with the following under 
strict

  my @x = ( my $y, $y );

you can't use $y until after that line of code

I'm not sure if this is documented anywhere .. I thought it was common 
knowledge .. 'though I've never looked for any counter examples - so 
there might be some which negate my rule of thumb

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Mon, 28 Aug 2000 22:40:36 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: How do I manipulate each element of an array?
Message-Id: <sqlqj4c7t9194@corp.supernews.com>

Bart Lateur (bart.lateur@skynet.be) wrote:
: Craig Berry wrote:
: 
: >Or, rearranging and going for max compression,
: >
: >  $_ ||= '&nbsp' for @array;
: 
: Any reason for replacing every zero with a non-breaking space?

I pointed out this limitation immediately following the text you quoted.
Sometimes all the potential false values should be replaced by a default,
which is when this wonderfully concise variant is welcome.  Other times,
this is not the case, and one must be somewhat wordier.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Every force evolves a form."
   |              - Shriekback


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

Date: Mon, 28 Aug 2000 18:11:48 -0500
From: "ZLI" <zli@umr.edu>
Subject: Re: How do I manipulate each element of an array?
Message-Id: <39aaf2a6@news.cc.umr.edu>


> map { s/^$/&nbsp;/ } @array;
>

Or:

map { s/^\s*$/&nbsp;/ } @array;





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

Date: Tue, 29 Aug 2000 01:11:14 +0100
From: "Christian Mahnke" <mahnke@uni-freiburg.de>
Subject: Re: How to encode for the web?
Message-Id: <8oer8k$dmd$1@n.ruf.uni-freiburg.de>

Is there a manual way to encode non-alphanumeric characters, described in 2?
So far I came up with
$number = "+";
unpack ("C", $number);
$number = sprintf "%lx", $number;

But this works only for one digit. What to do with a string like that:
$string = qq {
<form method=get action="http://www.skyways.de/cgi/favail"
target="_blank"><input type="image" name=submit
src="/Grafiken/pruef-buttton.gif" Border=0><input type=hidden name=args
value="0~~1~Frankfurt~New+York~2451808~2451822"><input type=hidden name=adt
value="1"><input type=hidden name=chd value="0"><input type=hidden name=inf
value="0"><input type=hidden name=flight value="FRA|NYC|670|131.90"><input
type=hidden value="Verfügbarkeit" name="FRA|NYC|670|131.90"></form>
};


Eric Bohlman <ebohlman@netcom.com> schrieb in im Newsbeitrag:
8oen9e$isd$5@nntp9.atl.mindspring.net...
> arjenwiersma@my-deja.com wrote:
> : And btw,
> :
> : This you can just put into a HTML file and feed it to the browser,
> : there is no encoding needed...
> :
> : Arjen
> :
> : In article <8oeksm$5so$1@nnrp1.deja.com>,
> :   arjenwiersma@my-deja.com wrote:
> : > You probably want to do something like this:
> : >
> : > $infos=qq{<form action="/cgi-bin/pascale"><input type hidden
> : > name=sessionid value="1234234"</form>}
> : >
> : > this way you wont need to escape the "'s.
>
> In this specific case, there's no encoding required, but in the general
> case, there are two forms of encoding that may be needed:
>
> 1) In HTML, literal ampersands need to be replaced with &amp; regardless
> of where they occur, and literal less-than signs need to be replaced with
> &lt; if they occur in the content of elements (in XHTML, they need to be
> replaced everywhere they occur, even in attribute values).
>
> 2) In attribute values that are supposed to hold URLs (e.g. href values),
> many non-alphanumeric characters need to be encoded as a '%' followed by
> a 2-digit hex value.  This includes spaces.
>
> CGI.pm has functions to do both kinds of encoding.
>




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

Date: Mon, 28 Aug 2000 22:06:54 GMT
From: ptomsic@my-deja.com
Subject: Indexing a String for a RegEx help?
Message-Id: <8oenpe$9gg$1@nnrp1.deja.com>

How do I search a string for a specific string to be contained within?

More specifically, I'm traversing a directory of files, and if the
extension is of "html" or "htm" then I want to extract the TITLE of the
file, from a function, and return the html TITLE to the caller.

the problem is when there is no TITLE tag contained within the document.
Is there a way for me to traverse thru the document, and see if there's
a TITLE tag, then grab it and return it?

I've got the following:

sub getTitle {
   my($filename) = @_;
   open(FILE, $filename) || return "";
   my $filestring = join("", <FILE>);
   my $pos = -1;
   close(FILE) || return "";
   if(!length $filestring) {
      return "";
   } else {
      while(($pos = index($filestring,"<TITLE>", $pos)) > -1 {
          $filestring =~s/^.*<TITLE>(.*)<\/TITLE>.*/$1/i;
          $pos++;
       }
   }
   if($pos > -1) {
      return $filestring;
   } else {
      return "";
   }
}

but every file that I try to send in, leaves $pos as -1.

1. Would it be possible for the third param of the index() function to
be a RegEx (possibly the one that I use above to extract the title, and
if so, how do you do pass a regex to the index() function?

2. what am I doing wrong?   The above code works for all files when I
take out the WHILE loop, except those that don't contain a TITLE
string, in which case, they return the WHOLE file.

Any help greatly appreciated.

Thanks


PJT



Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 28 Aug 2000 22:32:26 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Indexing a String for a RegEx help?
Message-Id: <8oep9q$isd$8@nntp9.atl.mindspring.net>

ptomsic@my-deja.com wrote:
: How do I search a string for a specific string to be contained within?
: 
: More specifically, I'm traversing a directory of files, and if the
: extension is of "html" or "htm" then I want to extract the TITLE of the
: file, from a function, and return the html TITLE to the caller.
: 
: the problem is when there is no TITLE tag contained within the document.
: Is there a way for me to traverse thru the document, and see if there's
: a TITLE tag, then grab it and return it?
: 
: I've got the following:

You'd be much better off using HTML::HeadParser.  It's extremely easy 
to use (*much* easier than using the raw HTML::Parser interface).  
Install it if you don't already have it and read the documentation; one 
of the first things you'll see is some sample code that, among other 
things, extracts the title from a document.



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

Date: Tue, 29 Aug 2000 00:16:32 GMT
From: SPAM+indigo@dimensional.com (Tim)
Subject: Re: Kill Me!
Message-Id: <8F9EBE068indigodimcom@166.93.207.145>

timewarp@shentel.net (Albert Dewey) wrote:

>Keep
>in mind that the 'natural flow of time' also dictates that lemmings will
>run off of cliffs on a regular basis.

Lemmings only "run" off of cliffs when thrown by Disney producers.

If you must use worn out cliches, try using one that is marginally
true.

-T


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

Date: Mon, 28 Aug 2000 23:42:56 GMT
From: r_conner@my-deja.com
Subject: Loading a array from a file.
Message-Id: <8oetds$fnv$1@nnrp1.deja.com>

I have been trying to load an array from a text file, but with only
kludge results.

the file is a simple tab delimited file, and I want to load it in way
that rows become columns.
so that
1,2,3,3
4,5,6,1

becomes
1,4
2,5
3,6
3,1


The perllol page suggested this:



    # add new columns to an existing row
    push @{ $LoL[0] }, "wilma", "betty";

does'nt look right, does'nt work.

Any ideas?






Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 29 Aug 2000 00:44:15 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Loading a array from a file.
Message-Id: <zHDq5.21184$C5.356406@typhoon.austin.rr.com>

In article <8oetds$fnv$1@nnrp1.deja.com>,  <r_conner@my-deja.com> wrote:
>I have been trying to load an array from a text file, but with only
>kludge results.
>
>the file is a simple tab delimited file, and I want to load it in way
>that rows become columns.
>so that
>1,2,3,3
>4,5,6,1
>
>becomes
>1,4
>2,5
>3,6
>3,1
>
>
>The perllol page suggested this:
>
>
>
>    # add new columns to an existing row
>    push @{ $LoL[0] }, "wilma", "betty";
>
>does'nt look right, does'nt work.

How have you tried?  Maybe this will help a little:

#!/usr/local/bin/perl

use Data::Dumper;

my @result;

while (<DATA>) {
    chomp;

    my $row = 0;

    foreach my $datum (split( /,/ )) {
        push @{$result[$row++]}, $datum;
    }
}

print Dumper( \@result );

__END__
1,2,3,3
4,5,6,1

-----Cut here----

There may be things in there which you don't understand, but saving it in
a file and using the debugger to examine @array as it's built in the line
which looks suspiciously like the one from perllol might be instructive.

The use of Data::Dumper isn't really necessary, but if you have it
installed then you can get a good picture of the contents of
@result.  What happens to the value of $row?  Can you picture what's going
on?

Try messing with the code, if odd things happen then maybe the -w (see
perlrun) flag would help you figure out what's going on.

Hope this helps,

Mike
-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |
GPG PGP Key 1024D/059913DA         | Fingerprint      0570 71CD 6790 7C28 3D60
stok@colltech.com (CT - work)      |                  75D2 9EC4 C1C0 0599 13DA


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

Date: Mon, 28 Aug 2000 23:36:02 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: making sure input is a certain way i.e. starting and ending with double quotes
Message-Id: <MPG.141594dc1b29f694989713@localhost>

arthur <star@sonic.net> wrote ..
>#!/usr/bin/perl -w
>
>use CGI qw(:standard);
>use CGI::Carp qw(fatalsToBrowser);
>use IO File;
>use strict;
>use File::Copy;
>
>Good Morning,
>
>regarding the script below:
>
>I need what the user (I love that name) inputs into 'question' to start and
>end with double quotes. How can I check that and put up a warning message if
>they have not started and ended in double quotes.

  perldoc -f substr

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: 29 Aug 2000 00:00:07 GMT
From: abigail@foad.org (Abigail)
Subject: Re: my($a)=shift or warn;
Message-Id: <slrn8qlv6n.bbg.abigail@alexandra.foad.org>

Bart Lateur (bart.lateur@skynet.be) wrote on MMDLIV September MCMXCIII in
<URL:news:9gllqs8hagds7sprjgrgg2s6hh8nhic1ov@4ax.com>:
== Abigail wrote:
== 
== >:: >   What does the assignmen my($a)=shift return?
== >:: 
== >:: Whatever the shift returns.
== >
== >Really? Did you _try_? I guess not.
== 
== I cancelled that message minutes after I posted it. If all went well,
== you shouldn't even have seen it. The parens in the declaration make
== things different.


You're a few years late if you still want to cancel your own articles.
H*pcr*m* has ruined it.



Abigail
-- 
$_ = "\x3C\x3C\x45\x4F\x54";
print if s/<<EOT/<<EOT/e;
Just another Perl Hacker
EOT


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

Date: Tue, 29 Aug 2000 00:02:34 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Please help: How to check for $var is null or not?
Message-Id: <MPG.14159b109fc0d14c989716@localhost>

houseofpain@my-deja.com <houseofpain@my-deja.com> wrote ..
>In article <8oedrf$t48$1@nnrp1.deja.com>,
>  kiran_mamidi@my-deja.com wrote:
-
>> How do I check if a variable is null.
>>
>> For example if I want to check $rec_date is null or not. How do I do
>> that,
-
>Try using if (defined $foo){}

taking your definition of 'null' that will test if variable $foo is NOT 
null .. the originator wanted to know if it was NULL

see other posts in this thread for better answers

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Mon, 28 Aug 2000 22:49:19 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Problems with script to download a file
Message-Id: <MPG.141589e943a6572a989711@localhost>

J. Cooper <jcoop@interlog.com> wrote ..
>I'm trying to get a script working which will download an 
>Acrobat file from our Website.  Both the perl script and the file are
>in cgi-bin.  The calling html page is a subdirectory off the main site
>".../tlc3/
>
>The script is called by the following line:
>
><a href="../cgi-bin/dl_file.pl">Download Proceedings</a>
>
>The actual script is:
>
>#!/usr/bin/perl
># dl_file.pl : simple cgi file download
>use CGI;
>print "content-type: application/*\n\n";
>$DLFILE="../cgi-bin/Symposium2000Proceedings.pdf";
>open(DLFILE, $DLFILE) || die "Can not open $DLFILE: $!\n";
>while(read DLFILE, $buffer, 256)
>{
>   print $buffer;
>}
>close (DLFILE);
>exit; 
>
>What happens is that the dialog box appears, asking if user wants to
>save file to disk, or run from current location.  This is what I want
>to happen.  Unfortunately, the wrong file is downloaded.  The
>dl_file.pl is downloaded instead of the symposium2000proceedings.pdf.
>Anyone have any ideas as to what is going wrong?

yes .. your web server is misconfigured .. contact your server 
administrator - or ask in a forum that relates to your web server

also .. you should have a look at your HTTP header .. case of headers 
can make a difference

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Tue, 29 Aug 2000 02:56:08 +0200
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: Problems with script to download a file
Message-Id: <1eg3ur9.jq9qj35dlpdsN%tony@svanstrom.com>

jason <elephant@squirrelgroup.com> wrote:

> J. Cooper <jcoop@interlog.com> wrote ..

> ><a href="../cgi-bin/dl_file.pl">Download Proceedings</a>
> >
> >The actual script is:
> >
> >#!/usr/bin/perl
> ># dl_file.pl : simple cgi file download
> >use CGI;
> >print "content-type: application/*\n\n";
> >$DLFILE="../cgi-bin/Symposium2000Proceedings.pdf";
> >open(DLFILE, $DLFILE) || die "Can not open $DLFILE: $!\n";
> >while(read DLFILE, $buffer, 256)
> >{
> >   print $buffer;
> >}
> >close (DLFILE);
> >exit; 
> >
> >What happens is that the dialog box appears, asking if user wants to
> >save file to disk, or run from current location.  This is what I want
> >to happen.  Unfortunately, the wrong file is downloaded.  The
> >dl_file.pl is downloaded instead of the symposium2000proceedings.pdf.
> >Anyone have any ideas as to what is going wrong?
> 
> yes .. your web server is misconfigured .. contact your server 
> administrator - or ask in a forum that relates to your web server

That's just BS, the one downloading sends a request for dl_file.pl and
therefore it's that name that shows.


     /Tony
-- 
     /\___/\ Who would you like to read your messages today? /\___/\
     \_@ @_/  Protect your privacy:  <http://www.pgpi.com/>  \_@ @_/
 --oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
   on the verge of frenzy - i think my mask of sanity is about to slip
 ---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
    \O/   \O/  ©99-00 <http://www.svanstrom.com/?ref=news>  \O/   \O/


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

Date: 28 Aug 2000 22:05:26 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: processing files in a directory and stuff
Message-Id: <8oenn6$isd$6@nntp9.atl.mindspring.net>

Gorbeast (gorbeast@SPAMSUCKS.subduction.org) wrote:
: I have a directory on a Win32 computer that has a large number of text
: files, all of which have content similar to this :
: 
: 	489384    44  34   foo  bar  9458  5i4i 345485
: 	483455    12  49   foo  bar  9589  7t9k 458945
: 	548899    87  09   foo  bar  5988  9489 650966
: 
: ... and so on.  In other words, each line of each text file has the
: format of: zero or more whitespaces, a string of numbers, more
: whitespace, another string of numbers, yet more whitespace, another
: number, whitespace, etc.
: 
: I am trying to figure out how the program can read each file of this
: directory and keep a tally of how many times a number of the _first_
: column occurs.  It will only occur once each file, but it could be
: multiple files of this directory.

1) Use opendir(), readdir(), etc. to find the filenames.

2) Use open() to open the files.

3) Use the "while (<FILE>)" syntax to read each line of each file.

4) Use a regex, the three-argument form of split(), or a combination of 
index() and substr() to extract the first number from each line.

5) Use a hash to keep count of how many times each number occurs.

Everything I've referred to is covered in the excellent documentation 
that comes with every Perl installation.

If you need to extend this to searching files that aren't all in the same 
directory, look into File::Find.




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

Date: Mon, 28 Aug 2000 19:19:07 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: Re: processing files in a directory and stuff
Message-Id: <Pine.LNX.4.21.0008281915130.1724-100000@hawk.ce.mediaone.net>

On Mon, 28 Aug 2000, Gorbeast quoth:

~~ Date: Mon, 28 Aug 2000 14:55:55 -0700
~~ From: Gorbeast <gorbeast@SPAMSUCKS.subduction.org>
~~ Newsgroups: comp.lang.perl.misc
~~ Subject: processing files in a directory and stuff
~~ 
~~ Hello,
~~ 
~~ I have a directory on a Win32 computer that has a large number of text
~~ files, all of which have content similar to this :
~~ 
~~ 	489384    44  34   foo  bar  9458  5i4i 345485
~~ 	483455    12  49   foo  bar  9589  7t9k 458945
~~ 	548899    87  09   foo  bar  5988  9489 650966
~~ 
~~ ... and so on.  In other words, each line of each text file has the
~~ format of: zero or more whitespaces, a string of numbers, more
~~ whitespace, another string of numbers, yet more whitespace, another
~~ number, whitespace, etc.
~~ 
~~ I am trying to figure out how the program can read each file of this
~~ directory and keep a tally of how many times a number of the _first_
~~ column occurs.  It will only occur once each file, but it could be
~~ multiple files of this directory.
~~ 
~~ If any one can help me out that would be very kind and I thank you.

Here is one way:

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

my %numap = ();

while (<>) {
    next unless m~^\s*(\d+)\s+~;
    $numap{$1}++;
}

print "$_ => $numap{$_}\n" for keys %numap;

__END__


There is probably better, though!

anm
-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Andrew N. McGuire                                                      ~
~ anmcguire@ce.mediaone.net                                              ~
~ "Plan to throw one away; you will, anyhow." - Frederick P. Brooks, Jr. ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



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

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


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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

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


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


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