[18044] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 204 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 2 21:05:59 2001

Date: Fri, 2 Feb 2001 18:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <981165910-v10-i204@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 2 Feb 2001     Volume: 10 Number: 204

Today's topics:
    Re: 'print' problem-again! (David Efflandt)
    Re: Creating a file (David Efflandt)
    Re: Cron task [more] (David Efflandt)
    Re: File time difference <ashley@pcraft.com>
    Re: File time difference <juex@deja.com>
    Re: Help about    perl -e '`ping server`' (David Efflandt)
    Re: HELP firewall changed (David Efflandt)
    Re: Help: Script only runs if ' -w' is on line 1 <ron@savage.net.au>
    Re: Help: Script only runs if ' -w' is on line 1 <joe+usenet@sunstarsys.com>
        How To Reverse 8 bit arithmetic value gipperca@my-deja.com
    Re: How To Reverse 8 bit arithmetic value <elijah@workspot.net>
    Re: How To Reverse 8 bit arithmetic value <shino_korah@yahoo.com>
    Re: How To Reverse 8 bit arithmetic value <rick.delaney@home.com>
    Re: Initial Caps (Eric Bohlman)
        input parameters <derek@dpat.fsnet.co.uk>
    Re: Integrating Perl into Javascript <ron@savage.net.au>
        Modules/Constants. delanthear@my-deja.com
        pathnames with spaces on NT server <paulgoris_removethispart_@skynet.be>
    Re: pathnames with spaces on NT server <DNess@Home.Com>
    Re: pathnames with spaces on NT server (Clinton A. Pierce)
        Problems with installing SybPerl oso@freemail.hu
    Re: redirection problem (David Efflandt)
        REUSE CODE (BEGINNER LEVEL) <shino_korah@yahoo.com>
    Re: REUSE CODE (BEGINNER LEVEL) (Tony L. Svanstrom)
    Re: select and perlvar <uri@sysarch.com>
    Re: Sting validation question...? (Martien Verbruggen)
    Re: Trouble with split (Eric Bohlman)
    Re: Uploading files (David Efflandt)
    Re: Viewing the html code (David Efflandt)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 2 Feb 2001 23:58:31 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: 'print' problem-again!
Message-Id: <slrn97mibo.u7c.efflandt@efflandt.xnet.com>

On Fri, 2 Feb 2001 14:27:26 -0600, Bin - Lu <b0l4549@cs.tamu.edu> wrote:
>
>But I can't use if-else since I need to run them both. Any clue again???

But you do not need them both.  You need one or the other.  You cannot
print anything else if you are going to redirect.  Once you decide whether
you are going to redirect you will know whether to print the content-type
or not.  One thing you can do to trap many errors or see the output of or
die statements is to add near the beginning of your script:

use CGI::Carp qw(fatalsToBrowser);

And the CGI module function method can make it easy to add headers if you
are going to print something other than the redirect by simply:

print header,start_html('Error'),h1('Error'),hr,
"You forgot to do something";

>On Thu, 1 Feb 2001, it was written:
>
>> if() {
>>     # redirect
>> } else {
>>     # don't redirect
>> }
>> 
>> j.
>> 
>> "Bin - Lu" <b0l4549@cs.tamu.edu> wrote in message
>> news:Pine.SOL.4.10.10102010006070.3492-100000@robert...
>> >
>> > I have such a problem:
>> >
>> > At the beginning of my code I have to use
>> > print "content-type: text/html\n\n";
>> >
>> > But then I want to use:
>> > print "Location: $link\n\n";
>> > exit;
>> >
>> > which achieves redirection and requires not to use the first 'print' line.
>> > How can I 'deactivate' the first 'print' line or change the print content
>> > type?
>> >
>> 
>> 
>> 
>> 
>


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


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

Date: Sat, 3 Feb 2001 00:08:35 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Creating a file
Message-Id: <slrn97miug.u7c.efflandt@efflandt.xnet.com>

On Fri, 02 Feb 2001 15:42:17 +0000, Dave Clews <Dave@inner-realm.co.uk> wrote:
>Hello
>
>I am trying to create a file after the user has uploaded a document I am
>using the following code to achieve this.
>
>open(DOCUMENT, "> $doc_dir") ||  die "Couldn't open $doc_dir \n";
>print(DOCUMENT "$FORM{'doc'} \n");
>close(DOCUMENT);
>
>The aim is to open the file and store the contents of the uploaded file
>into the new file.  However the problem I get is that the file cannot be
>opened as it has not been created, how do I get around this.

The webserver likely runs CGI as someone other than you, so you need to
either create the file ahead of time and give the file 666 permission (or
possibly 646 or 606), or to creat a file the dir might need 777 permission
(or possibly 757).  That is rather insecure, since anybody else might be
able to modify your files from possibly either the shell or their own
CGI.  But their is little you can do about that unless you can convince
your host to run cgiwrap or the suexec option of apache, or find a host
who does.

>What has just occurred to me is using the uploaded document as the file,
>would this be set as:
>
>print $doc_dir/$FORM('doc');

It is usually best to supply a full system path if possible.  Just be
aware that the full system path might be different on the webserver than
it is from a login shell or ftp.  So you should run a test script that
outputs the current working dir (or a quick way to do it on a unix system
is:  print "Current dir is ",`pwd`,"\n";

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


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

Date: Sat, 3 Feb 2001 00:13:23 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Cron task [more]
Message-Id: <slrn97mj7l.u7c.efflandt@efflandt.xnet.com>

On 1 Feb 2001 14:03:03 -0000, jean@ematic.com <jean@ematic.com> wrote:
>On Thu, 01 Feb 2001, "TAPmaster" <thetap@home.com> wrote:
>>You could call the 2nd from your first when it was done running.
>
>
>heu... yes, but how to do ? Sorry, perl is a new language for me, and I am
>lost in the manual :-(

perldoc -f exec

If you exec anything from a perl script, the first script terminates and
the second script runs from there (except within an eval).  You could do
that at the end of the first script, and could even pass parameters to the
second script if needed.

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


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

Date: Fri, 02 Feb 2001 16:04:47 -0700
From: "Ashley M. Kirchner" <ashley@pcraft.com>
Subject: Re: File time difference
Message-Id: <3A7B3D0E.A3DF58B8@pcraft.com>

John Joseph Trammell wrote:

> man find

    Yeah, I'd like for you to explain for me exactly how 'man find' is going
to help me write a perl script.  If you can't come up with a better answer,
why bother answering at all.

    AMK4

--
W |
  |  I haven't lost my mind; it's backed up on tape somewhere.
  |____________________________________________________________________
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Ashley M. Kirchner <mailto:ashley@pcraft.com>   .   303.442.6410 x130
  SysAdmin / Websmith                           .     800.441.3873 x130
  Photo Craft Laboratories, Inc.             .        eFax 248.671.0909
  http://www.pcraft.com                  .         3550 Arapahoe Ave #6
  .................. .  .  .     .               Boulder, CO 80303, USA




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

Date: Fri, 2 Feb 2001 15:34:14 -0800
From: "Jürgen Exner" <juex@deja.com>
Subject: Re: File time difference
Message-Id: <3a7b43f6$1@news.microsoft.com>

"Ashley M. Kirchner" <ashley@pcraft.com> wrote in message
news:3A7B3D0E.A3DF58B8@pcraft.com...
> John Joseph Trammell wrote:
>
> > man find
>
>     Yeah, I'd like for you to explain for me exactly how 'man find' is
going
> to help me write a perl script.  If you can't come up with a better
answer,
> why bother answering at all.

You are absolutely right. John should have said

    perldoc File::find

jue




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

Date: Sat, 3 Feb 2001 00:29:11 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Help about    perl -e '`ping server`'
Message-Id: <slrn97mk58.u7c.efflandt@efflandt.xnet.com>

On Fri, 02 Feb 2001 21:16:59 GMT, Ken Laird <kenlaird@yahoo.com> wrote:
>I'd like to see the result of this command :
>
>perl -e '`ping server`'
>
>it works , but is it possible to see the output on the screen ?
>
>Moreover , why 

Because you are not printing anything out.  Try:

perl -e 'print `ping server`'

But why do you want to wrap it with Perl one liner when it would run from
the commandline?

>perl -e 'system ping server' 
>is not working at all?

system() only returns the return code (or error code if any) from running
the command and you are not printing that either.  If you don't print any
output, you get no output, duh!

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


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

Date: Sat, 3 Feb 2001 00:36:50 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: HELP firewall changed
Message-Id: <slrn97mkjj.u7c.efflandt@efflandt.xnet.com>

On 01 Feb 2001, lopez@abqato.abq.sc.philips.com
<lopez@abqato.abq.sc.philips.com> wrote:
>How to I tell perl the firewall has changed?  I have made changes to
>Net/libnet.cfg for the http prosy information but that does not have
>any ftp firewall information. Where is the ftp firewall information
>stored.

perldoc Net::FTP

Likely in a file called 'FTP.pm' in a dir called 'Net' somewhere in your
@INC searchlist:

#!/usr/bin/perl -w
foreach (@INC) { print "$_/Net/FTP.pm\n" if -e "$_/Net/FTP.pm"; }

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


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

Date: Sat, 3 Feb 2001 11:54:18 +1100
From: "Ron Savage" <ron@savage.net.au>
Subject: Re: Help: Script only runs if ' -w' is on line 1
Message-Id: <INHe6.80$sS4.3689@ozemail.com.au>

Thanx for your responses, but I did specifically state what vim tells me,
and yes, I do know what ^M is.

There _must_ be an explanation, since I (once) saw this problem years ago,
but have forgotten the fix.

Please keep cogitating...

--
Cheers
Ron  Savage
ron@savage.net.au
http://savage.net.au/index.html





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

Date: 02 Feb 2001 20:24:03 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Help: Script only runs if ' -w' is on line 1
Message-Id: <m3u26c4kzw.fsf@mumonkan.sunstarsys.com>

"Ron Savage" <ron@savage.net.au> writes:

> Thanx for your responses, but I did specifically state what vim tells me,
> and yes, I do know what ^M is.
> 
> There _must_ be an explanation, since I (once) saw this problem years ago,
> but have forgotten the fix.
> 
> Please keep cogitating...

With all due respect, I simply don't believe you.  Please post
the output of

% perl -le '$_=<>;map{print "$_:". ord $_}/./sg;' x.pl

Where x.pl is the name of your script.  Here's what a DOS'd 
shebang line on unix prints:

#:35
!:33
/:47
u:117
s:115
r:114
/:47
b:98
i:105
n:110
/:47
p:112
e:101
r:114
l:108
:13

:10


A Mac'd shebang line is different, of course, 
but just as corrupt on a unix box.

-- 
Joe Schaefer


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

Date: Fri, 02 Feb 2001 23:25:01 GMT
From: gipperca@my-deja.com
Subject: How To Reverse 8 bit arithmetic value
Message-Id: <95ffk3$t8v$1@nnrp1.deja.com>

How would I reverse an 8 bit value???

If the binary value were 01110001, or 0x71, I want the reversed
value, 10001110, or 0x8e.

Thanks for your time,
CG


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


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

Date: 2 Feb 2001 23:47:58 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: How To Reverse 8 bit arithmetic value
Message-Id: <eli$0102021840@qz.little-neck.ny.us>

In comp.lang.perl.misc,  <gipperca@my-deja.com> wrote:
> How would I reverse an 8 bit value???
> If the binary value were 01110001, or 0x71, I want the reversed
> value, 10001110, or 0x8e.

Perhaps it can be done in less code, but this works for perl 5.6.

$reversed = reverse sprintf("%v08b",chr(0x71));

Elijah
------
leaving out the chr() gives non-intuitive results


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

Date: Fri, 2 Feb 2001 16:30:23 -0800
From: "terminalsplash" <shino_korah@yahoo.com>
Subject: Re: How To Reverse 8 bit arithmetic value
Message-Id: <95fjf0$ah1@news.or.intel.com>

Hi
try to use the C header file in Perl.
the link is
http://www.perl.com/CPAN-local/modules/by-module/Bit/Bit-Vector-6.0.readme.
TS
<gipperca@my-deja.com> wrote in message news:95ffk3$t8v$1@nnrp1.deja.com...
> How would I reverse an 8 bit value???
>
> If the binary value were 01110001, or 0x71, I want the reversed
> value, 10001110, or 0x8e.
>
> Thanks for your time,
> CG
>
>
> Sent via Deja.com
> http://www.deja.com/




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

Date: Sat, 03 Feb 2001 01:02:29 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: How To Reverse 8 bit arithmetic value
Message-Id: <3A7B5BEC.854BF584@home.com>

[posted & mailed]

gipperca@my-deja.com wrote:
> 
> How would I reverse an 8 bit value???
> 
> If the binary value were 01110001, or 0x71, I want the reversed
> value, 10001110, or 0x8e.

    $reverse = pack b8 => unpack B8 => "\x71";

perldoc -f pack

-- 
Rick Delaney
rick.delaney@home.com


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

Date: 2 Feb 2001 23:15:38 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Initial Caps
Message-Id: <95ff2q$3g1$3@bob.news.rcn.net>

Barry Glick <barryg@kingcon.com> wrote:
> I'm in a on-line web master class, now learning to do CGI/PERL scripts.  The
> class has very little in the way of help, so I help some one in this
> newsgroup can help me.

> My assignment was to create a simple CGI script that will take input from
> the user in a form, strip out the extraneous characters (+,=,&), then print
> it with the first letter of each word capitalized.  I can almost do it with
> this:

> $value =~ s/\s(\w)/ \u$1/g;

> But that only capitalizes the first letter of every word AFTER the first
> one, since the first word has no space.  Can anyone tell me how to
> capitalize the first letter of ALL words entered into, say, a text box of an
> HTML form?

If your instructor hasn't taught you about Perl's on-line documentation 
and how to use it, you should really complain to him or her.  In this 
case, "perldoc -q capitalize" will give you the answer.






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

Date: Sat, 3 Feb 2001 00:59:57 -0000
From: "Derek Paterson" <derek@dpat.fsnet.co.uk>
Subject: input parameters
Message-Id: <95fl4l$3fu$1@newsg2.svr.pol.co.uk>

How do you read input paramters in perl?

eg:

perl locate target

----------

$target = <STDIN>  #I know this causes locate to wait for input...

$target=<ARGV> #although this looked right, it seems to want to open a file
called target

I' a turorial and some help files but no-where does it mention parameter
passing...

Any helpers...?

Thanks

Derek




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

Date: Sat, 3 Feb 2001 12:07:08 +1100
From: "Ron Savage" <ron@savage.net.au>
Subject: Re: Integrating Perl into Javascript
Message-Id: <KZHe6.88$sS4.2078@ozemail.com.au>

Here's a tut which I hope helps:
http://savage.net.au/Perl-tutorials.html#tut-28

--
Cheers
Ron  Savage
ron@savage.net.au
http://savage.net.au/index.html





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

Date: Sat, 03 Feb 2001 01:08:07 GMT
From: delanthear@my-deja.com
Subject: Modules/Constants.
Message-Id: <95fllj$2da$1@nnrp1.deja.com>

I'm playing with a script which uses quite a lot of constants.
(declared with "use constant CONSTANT_NAME => VALUE;")  I'd prefer to
keep them in a separate file than the main scripts.   What's the
easiest way of doing this?  I've played with creating a module, but I'm
unsure how to use the exporter to export constants and how to make them
visible to the other modules I'm using.

Anyone got any clues?  Or am I going about this the wrong way?

thanks
k


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


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

Date: Sat, 03 Feb 2001 01:35:34 +0100
From: Paul Goris <paulgoris_removethispart_@skynet.be>
Subject: pathnames with spaces on NT server
Message-Id: <B6A110E6.22D3%paulgoris_removethispart_@skynet.be>

Hi all,

On a Win NT web server, I have to refer to a document with a pathname that
contains spaces in one of the Perl cgi scripts.
Of course, Perl will cut off the pathname when it encounters the first space
and the script produces an error (file not found).
How do I work around this? There is no way I can change name of the
directory by removing the spaces from it... I also can't call the document
by referring to a virtual directory.

Any help greatly appreciated!


-- 
Paul Goris




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

Date: Sat, 03 Feb 2001 01:06:24 GMT
From: David Ness <DNess@Home.Com>
Subject: Re: pathnames with spaces on NT server
Message-Id: <3A7B59C7.9B6C5BA6@Home.Com>

Paul Goris wrote:
> 
> Hi all,
> 
> On a Win NT web server, I have to refer to a document with a pathname that
> contains spaces in one of the Perl cgi scripts.
> Of course, Perl will cut off the pathname when it encounters the first space
> and the script produces an error (file not found).
> How do I work around this? There is no way I can change name of the
> directory by removing the spaces from it... I also can't call the document
> by referring to a virtual directory.
> 
> Any help greatly appreciated!
> 
> --
> Paul Goris

This looks to me like an `NT question' not a `perl question'. I don't think
`...perl will cut off ...' makes any sense, to me at least, while it does makes
sense to say that `NT will cut off...' or some such.

In any case, the general NT treatment of filenames and file paths that contain blanks
is to surround the name with quotes. For example the command
  ren "This is a long goofy filename" a.b
works just fine to rename a file named "This is a long goofy filename" into one
named "a.b" (note that file names can contain blanks just as well as pathsname).


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

Date: Sat, 03 Feb 2001 01:12:22 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: pathnames with spaces on NT server
Message-Id: <WVIe6.273770$hD4.66386021@news1.rdc1.mi.home.com>

[Posted and mailed]

In article <B6A110E6.22D3%paulgoris_removethispart_@skynet.be>,
	Paul Goris <paulgoris_removethispart_@skynet.be> writes:
> On a Win NT web server, I have to refer to a document with a pathname that
> contains spaces in one of the Perl cgi scripts.

Yay.

> Of course, Perl will cut off the pathname when it encounters the first space

Untrue!  Lies!

> and the script produces an error (file not found).

Well, yeah.  But that's not Perl's issue.

	open(F, "c:/program files/desktop.ini") || die;
	@FOO=<F>;
	close(F);

Worked just fine.  You have other problems.  Calling system()?  
Backticks?  Well then you have to deal with one of the lame Windows 
"shells".  (CMD.EXE or COMMAND.COM).  Good luck, but that's not Perl's 
issue.  Opening files/pathnames with spaces works just fine.


-- 
    Clinton A. Pierce              Teach Yourself Perl in 24 Hours! 
  clintp@geeksalad.org         for details see http://www.geeksalad.org
"If you rush a Miracle Man, 
	you get rotten Miracles." --Miracle Max, The Princess Bride


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

Date: Sat, 03 Feb 2001 00:29:27 +0100
From: oso@freemail.hu
Subject: Problems with installing SybPerl
Message-Id: <3A7B42D7.A6DCB99B@freemail.hu>

I want to use Sybase databases and Apache + Perl (the IndigoPerl
package) on Win32 (on the same computer), so I tried to install the
SybPerl 2.x module.  I recieved numerous error messages when running
"perl makefile.pl", and though 'makefile' was created, i couldn't
install this SybPerl module.   What should i do to succeed?  Are there
any other options instead of SybPerl,  for using Sybase and Perl under a
Win32 op.system?
Thanx , in advance!



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

Date: Sat, 3 Feb 2001 00:53:15 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: redirection problem
Message-Id: <slrn97mlib.u7c.efflandt@efflandt.xnet.com>

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

You forgot to put any newline at all on the end of the cookie header, so
the redirect is included in the Cookie header, and therefore ignored as a
redirect.  Actually it should probably technically be a carriage return
and linefeed, but just the newline works with apache.  This is not a Perl
question, but another reply gave a CGI.pm example that should do the right
thing.

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


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

Date: Fri, 2 Feb 2001 16:14:37 -0800
From: "terminalsplash" <shino_korah@yahoo.com>
Subject: REUSE CODE (BEGINNER LEVEL)
Message-Id: <95fihe$a0a@news.or.intel.com>

Hi,

       I have a perl code which i want to use in other perl programs. How
can i do it? how does the library concept in perl i mean can i make a user
defned linrary?

Thanks in advance




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

Date: Sat, 03 Feb 2001 01:32:30 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: REUSE CODE (BEGINNER LEVEL)
Message-Id: <1eo8f09.1ayfc9r14fagouN%tony@svanstrom.com>

terminalsplash <shino_korah@yahoo.com> wrote:

>        I have a perl code which i want to use in other perl programs. How
> can i do it? how does the library concept in perl i mean can i make a user
> defned linrary?

There are too many unknown things here, best would be if you just RTFM.

For most people at beginner level copy & paste is the simplest solution.

     /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: Sat, 03 Feb 2001 00:23:51 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: select and perlvar
Message-Id: <x73ddwsjfs.fsf@home.sysarch.com>

>>>>> "TJ" == Thoren Johne <thoren@southern-division.com> writes:

  TJ> is there a place in perldoc, where i can see if a special variable is on 
  TJ> a 'per filehandle basis', like the example in 'perldoc -f select' says:

  TJ> $oldfh = select(STDERR); $| = 1; select($oldfh);

  TJ> problem is: i thought that analogous to the above example

  TJ> $oldfh = select(STDERR); $\ = ' err '; select($oldfh);
  TJ> $oldfh = select(STDOUT); $\ = ' out '; select($oldfh);


  TJ> does 'select' actual work as expected with '$|' but not with '$\'?

this is a well known issue (or bug as some might say). $/ and $\ are
globals and not file handle specific so select doesn't do anything with
them.

one basic solution is to localize $\ before you do any printing so you
can set it on demand:

	sub print_stderr {

		local( $/ ) = ' err ' ;
		print STDERR @_ ;
	}

then you don't have to deal with resetting $/ afterwards. the same idea
can be done with OO, and even closures:

	sub make_print_sub {

		my( $handle, $ors ) = @_ ;

		sub { local( $/ ) = $ors ; print $handle @_ }
	}

	$print_stderr = make_print_sub( \*STDERR, ' err ' ) ;

	$print_stderr->( "foo\n" ) ;

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Sat, 3 Feb 2001 10:18:23 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Sting validation question...?
Message-Id: <slrn97mg1v.vht.mgjv@martien.heliotrope.home>

On Fri, 02 Feb 2001 10:09:56 +0000,
	pkey@sghms.ac.uk <pkey@sghms.ac.uk> wrote:
> What regular expression do I need to use to validate that a string
> contains at least one integer

$string =~ /\d/;

>                               i.e. it is not made up just of the 26
> letters of the alphabet and that it is not just made up of numbers
> alone?

That is a different problem.

$string !~ /^[a-z]+$/i && $string !~ /^\d+$/;

The above allows the empty string, and string with garbage, and any
string with a combination of garbage and digits and/or alphas.


I suspect what you really want is a string that is made up of alphas and
digits, and contains at leat one digit, right?

$string =~ /\d/ && $string =~ /[a-z]/ && $string =~ /^[a-z\d]+$/;

You can combine stuff into a single regex, but it quickly can become
unreadable. I prefer to keep them separate.

Next time, please don't specify a problem in two contradictory ways, ok?

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


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

Date: 2 Feb 2001 23:08:22 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Trouble with split
Message-Id: <95fel6$3g1$2@bob.news.rcn.net>

LK <lkenny@fisheries.org> wrote:
> I have written a piece of code that is supposed to split a string on a
> box.  the code is as follows:

> 	open(FILE,"$file") || die("Cannot open file $file: $!"); 
> 	$data = do { local $/; <FILE>; };
> 	close (FILE);
>  	$data =~ s/\n/"|"/eg;
>   	@data = split(//, $data);                     

Are you trying to split on form-feeds?  If so, the correct representation 
of a form-feed in a regex is \cL, not ^L (which means "uppercase L at the 
beginning of the string).


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

Date: Sat, 3 Feb 2001 01:00:03 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Uploading files
Message-Id: <slrn97mlv4.u7c.efflandt@efflandt.xnet.com>

On Thu, 01 Feb 2001 19:17:49 GMT, Ian Dash <I.J.Dash@cs.cf.ac.uk> wrote:
>
>Im trying to upload files onto my unix space via the use of Perl. I my
>HTML sorted out with the <input type=file> tags etc. But its the Perl
>side of things I cant do. I have looked at some of the scripts around
>on the net, some of them throw up errors in the console and others just
>do nothing at all when run in a web browser. Anyone who can help me?
>Please!!!

There is another newsgroup for 'cgi' questions.

Type:  perldoc CGI

It has everything you need to create and process forms, including uploads.
Make sure that you return a useful error message to your browser from any
failed open() including $! that tells you why it failed.  Make sure your
CGI has permission to write to an existing file or write and execute
permission for a dir to create files.

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


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

Date: Sat, 3 Feb 2001 01:04:37 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Viewing the html code
Message-Id: <slrn97mm7n.u7c.efflandt@efflandt.xnet.com>

On Thu, 1 Feb 2001, Vishwanath Mantha <vm1@ece.msstate.edu> wrote:
>
>How do I view the html code for a URL in perl.

If you have the LWP module available use that.

Otherwise type:  perldoc perlipc
and see the webget example using IO::Socket.  But you may need to add a
Host: header to the GET request if it is a virtual host.

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


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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

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


------------------------------
End of Perl-Users Digest V10 Issue 204
**************************************


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