[12425] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6025 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 16 21:07:22 1999

Date: Wed, 16 Jun 99 18:00:19 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 16 Jun 1999     Volume: 8 Number: 6025

Today's topics:
    Re: $_ and $@ - What are they? <crt@highvision.com>
        [Fwd: c::scan and c modules] <jonlee@sls.lcs.mit.edu>
    Re: Afraid to ask about Y2K! (Greg Andrews)
    Re: Bit Twiddling Troubles <rootbeer@redcat.com>
    Re: Cant make PPM work. <pjdurai@my-deja.com>
    Re: Cant make PPM work. <cassell@mail.cor.epa.gov>
        CGI:pm error message <reich@pants.internetcds.com>
    Re: including another variable into an array (Lee)
    Re: Load another html page ? <crt@highvision.com>
    Re: Load another html page ? <rick.delaney@home.com>
    Re: MacPerl newbie: installing module problem (Paul J. Schinder)
        Module installation question <chrisc@publishingonline.com>
    Re: newbie learning "my" declarations (Lee)
        perl on-line <leonid76@erols.com>
    Re: perl on-line dalehend@flash.net
    Re: print command (<<) in perl CGI <amasri@netscape.com>
    Re: Probably simple, but pulling hair out (Andrew Johnson)
    Re: Probably simple, but pulling hair out <rootbeer@redcat.com>
    Re: Probably simple, but pulling hair out <splinter@monmouth.com>
        problems receiving datastream via a socket <trader@underwear.heuristics.com>
        Real perl Y2K bug! (Bill)
    Re: Regex Help Needed <myparu@usa.net>
        s and tr <splinter@monmouth.com>
    Re: saving uploaded file <uucon@my-deja.com>
    Re: sending to html page... (Lee)
    Re: this  charecter @ ruined my day!! <wyzelli@yahoo.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Wed, 16 Jun 1999 19:36:11 -0400
From: "Casey Tweten" <crt@highvision.com>
Subject: Re: $_ and $@ - What are they?
Message-Id: <7k9cuq$5n156@news.icubed.com>

$_      The default input and pattern-searching space.
$@    The Perl error message from the last eval or do EXPR command.

It seems to be the entire groups attitude that completely (this is nice)
easy-to-find-answers-to-questions, are not tolerable.  I happen to agree,
however, I feel nice, or wierd, so I answered.

I found this in my Pocket Reference book that I see in just about every book
store for about $7.00.
However, because of laziness, I decided to cut and paste from the free
version online.

I have read every line of it, perhaps you should too.  This does not mean I
know every line of it, but I will. :o)~

Online Reference
http://reference.perl.com/guides/perl5.html
more directly.....
http://reference.perl.com/guides/perl5.html#specialvariables
--
               +-----------------+
               | Casey R. Tweten |
+--------------+--------+--------+--------------+
| * KiskiNet ISP        | HighVision Associates |
| * HighVision Studio   | Web Developer         |
| * ISP-ProServices     | www.highvision.com    |
| * CityBuilder.com     | crt@highvision.com    |
+-----------------------+-----------------------+
|   <joke>This is 100% virus free code</joke>   |
+-----------------------------------------------+

R.Joseph <streaking_pyro@my-deja.com> wrote in message
news:7k6do0$17b$1@nnrp1.deja.com...
: I have been seeing the two varibles $_ and $@ in alot of scripts that I
: have been reading lately, and I was wondering what they are and what
: they do?  Are they related?  Thanks for any help!
:
: --
: R.Joseph
: http://www.24-7design.com
: http://bowdown.to
:
:
: Sent via Deja.com http://www.deja.com/
: Share what you know. Learn what you don't.




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

Date: Wed, 16 Jun 1999 21:51:47 +0100
From: Jonathan Lee <jonlee@sls.lcs.mit.edu>
Subject: [Fwd: c::scan and c modules]
Message-Id: <780A83616B05D311968000204840250054E0A5@SEUBPEBAS54>

This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_000_01BEB84C.07010E0C
Content-Type: text/plain;
	charset="iso-8859-1"

perhaps someone in this ng could help me as well (originally sent this
to comp.lang.perl.modules)


------_=_NextPart_000_01BEB84C.07010E0C
Content-Type: message/rfc822

Newsgroups: comp.lang.perl.modules
From: Jonathan Lee <jonlee@sls.lcs.mit.edu>
Subject: c::scan and c modules
Message-ID: <3767FE7D.BE416141@sls.lcs.mit.edu>
Sender: Jonathan Lee <jonlee@sls.lcs.mit.edu>
Date: Wed, 16 Jun 1999 20:43:57 +0100
MIME-Version: 1.0
Lines: 25
X-Newsreader: Microsoft (R) Exchange Internet News Service Version 5.5.2448.0
Content-Type: text/plain

hello,

i'm a young, naive perl programmer who needs to do some interfacing
between c and unix.  but i've come across problems.

so i got c::scan and data::flow and i've been trying to use h2xs.  i had
purchased and read through oreilly's advanced perl programming book and
had gone through some of the examples.

but for some reason when i try to do everything on my own, i get errors
(of either type 1 or 2) when i try to execute "make".  perl Makefile.PL
works, but then "make" and "make test" don't.

here's a couple other things:
i'm a mere undergrad research assistant, of sorts.  so on the network i
can't be "superuser" and thus have no writing access to the
/usr/local/lib/perl5 directories to install.  so i tried to have all the
 .pm and .xs files install on my own dir. (for example, i modify the
Makefile.PL file by adding the line 'PREFIX'=> '/usr/users/jonlee',)

******i would like someone to simply explain what files i need to have
created first (and what actions i need to carry out) so that i can use
Makefile, and my glue code to make my perl program able to call these C
functions.

i have a .c file that has a whole bunch of subroutines.  do i need to
have a .h file as well?  does my .h file only have the basic prototype
structures, or can they have the whole subroutine included also?  do i
need to use #include?  any special lines like you need to use in perl
(#!/usr/local/bin/perl5).  can you have .pm modules installed elsewhere
instead of the main perl5 directory?

i've been frustratingly reading and rereading these books (i've got 4 of
them on my desks) to no avail for the past week now.

jon


------_=_NextPart_000_01BEB84C.07010E0C--



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

Date: 16 Jun 1999 17:09:49 -0700
From: gerg@shell.ncal.verio.com (Greg Andrews)
Subject: Re: Afraid to ask about Y2K!
Message-Id: <7k9ecd$sg7$1@shell1.ncal.verio.com>

tchrist@mox.perl.com (Tom Christiansen) writes:
>     [courtesy cc of this posting mailed to cited author]
>
>In comp.lang.perl.misc, 
>    "J|rgen Exner" <juex@my-dejanews.com> writes:
>:Is there anything wrong with 31.Dez, 24:00 being the same as 01.Jan, 00:00 ?
>
>You can't have 24:00 -- that's out of the valid range.  Hours are
>guaranteed less than 24.  After 11:59:59pm comes 12:00:00midnight.
>

Except when a leap second creates 23:59:59, followed
by 23:59:60 and then 00:00:00.

  -Greg


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

Date: Wed, 16 Jun 1999 16:45:50 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Bit Twiddling Troubles
Message-Id: <Pine.GSO.4.02A.9906161634500.26850-100000@user1.teleport.com>

On Wed, 16 Jun 1999, Hal Mounce wrote:

>         # cram our index into a 4 byte word
>         $bin = pack L, $i;

You should probably 'use strict' and put quotes around that L. But you
should even more probably use N instead of L (or see the perlfunc manpage
to learn why I say that, at least).

>         # turn on <0:1> 
> #       $bin = $bin | 0xC0000000;

Whoops! $bin comes from pack, so it's a string. But 0xC0000000 is a
number. If either operand of a bitwise operator is a number, you get a
numeric bitwise operation. You seem to want a string, so maybe that number
should be replaced with "\xC0\0\0\0".

Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 16 Jun 1999 21:52:31 GMT
From: pj durai <pjdurai@my-deja.com>
Subject: Re: Cant make PPM work.
Message-Id: <7k96aq$149$1@nnrp1.deja.com>


> I'm not surprised that you get an error when you try to install
> XML::Parser because it is actually used by PPM itself (although I
> get a different error when I try ).  It is installed already
> anyhow - does this happen with other modules ?
>

No luck there either.
my PPM seems to be broken permanently.

:-(


bash$ /perl/bin/ppm.bat install URI.ppd
Element 'OPTIONS' must have a 'TRACE' attribute. at C:\PERL\lib/PPM.pm
line 1711
 .
Element 'OPTIONS' must have a 'TRACEFILE' attribute. at C:
\PERL\lib/PPM.pm line
1711.
Error installing package 'URI.ppd': Read of ./ failed


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Wed, 16 Jun 1999 17:02:47 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Cant make PPM work.
Message-Id: <37683B27.2EB86D13@mail.cor.epa.gov>

pj durai wrote:
> 
> > I'm not surprised that you get an error when you try to install
> > XML::Parser because it is actually used by PPM itself (although I
> > get a different error when I try ).  It is installed already
> > anyhow - does this happen with other modules ?
> 
> No luck there either.
> my PPM seems to be broken permanently.

Looks like you hosed it trying to install XML::Parser.  Oops.
Until ActiveState re-writes ppm to check before trying to install
XML:Parser, you'll need to avoid doing this again.

Go to the ActiveState website.  I think that they have had 
this happen enough that someone has put up a zip file with
instructions for fixing this.  If not, Matt Sergeant will
correct me.. again.  :-)

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Wed, 16 Jun 1999 15:51:57 -0700
From: "Mahlon Smith" <reich@pants.internetcds.com>
Subject: CGI:pm error message
Message-Id: <7k99qe$r4b$1@news-02.meganews.com>

At least, I think it's CGI:pm that is giving me this.

A script I've been screwing with has suddenly died, but only when accessed
via the web.
No 500 error, just an internal error.

Running it from the command line works perfectly, no errors, even with
the -w switch.

Running perl -cw [scriptname] gives an error, however.
( I have had yet to see a script execute, but not verify via -c.)

The error is
Args must match #! line at [scriptname] line 1.

I of course know what the #! line is....
However the rest of the error message is not ringing a bell for me.

Can anyone shed some light?
Redirection to a man page is fine, I may have missed something.

please remove the 'pants' from my address to reply.


Mahlon




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

Date: Wed, 16 Jun 1999 20:01:01 -0500
From: rlb@intrinsix.ca (Lee)
Subject: Re: including another variable into an array
Message-Id: <B38DB2FD96683ADF3@204.112.166.88>

In article <slrn7mfd6i.do2.abigail@alexandra.delanet.com>,
abigail@delanet.com (Abigail) wrote:

>Matt (splinter@monmouth.com) wrote on MMCXV September MCMXCIII in
><URL:news:7k6skk$q34$1@news.monmouth.com>:
>{} Hey,
>{} 
>{} Very simple question.
>{} 
>{} I have an array.  I have a variable.  I want the variable appended onto that
>{} array.
>{} 
>{} Obviously I can't just do
>{} 
>{} 
>{} @array .= $variable
>{} 
>{} So what should I do?
>
>
>push

breathe!

Don't you remember anything from the Lamaze classes?

Lee




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

Date: Wed, 16 Jun 1999 19:15:23 -0400
From: "Casey Tweten" <crt@highvision.com>
Subject: Re: Load another html page ?
Message-Id: <7k9bnp$33185@news.icubed.com>

I am pretty sure that this is off topic, only becuase that seems to be the
concensus in the group, however, I like to help when I can.

#!/usr/local/bin/perl -w
use strict;
$|++;

use CGI qw(:standard);

my $page = param('page');

print header;

sub die_gracefully {
    print start_html,
            "Could not display page: $!\n",
    end_html;
}

if ( $page eq "gun_toting_perl_programmers" ) {
  open ( PAGE, $page ) || die_gracefully;
  print "$_" while (<PAGE>);
  close (FILE);
} else {
  open ( PAGE, $page ) || die_gracefully;
  print "$_" while (<PAGE>);
  close (FILE);
}

## End File

Of course, why not pass the name of the file and shorten your code?  We will
pass the entire name for this little ditty.

#!/usr/local/bin/perl -w
use strict;
$|++;

use CGI qw(:standard);

my $page = param('page');

print header;

sub die_gracefully {
    print start_html,
            "Could not display page: $!\n",
    end_html;
}

open ( PAGE, $page ) || die_gracefully;
print "$_" while (<PAGE>);
close (FILE);

## End File

have fun!

--
               +-----------------+
               | Casey R. Tweten |
+--------------+--------+--------+--------------+
| * KiskiNet ISP        | HighVision Associates |
| * HighVision Studio   | Web Developer         |
| * ISP-ProServices     | www.highvision.com    |
| * CityBuilder.com     | crt@highvision.com    |
+-----------------------+-----------------------+
|   <joke>This is 100% virus free code</joke>   |
+-----------------------------------------------+

Ken Patrick <ken.patrick@msl.redstone.army.mil> wrote in message
news:929452998.24162@www.remarq.com...
: In a Perl script how do you reference an html page.
:
: i.e.
:
: if <cond>
:   load html page
:
: Please email me.
:
: Thanks.
:
:
:
:
: **** Posted from RemarQ - http://www.remarq.com - Discussions Start Here
(tm) ****




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

Date: Thu, 17 Jun 1999 00:58:06 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Load another html page ?
Message-Id: <376847DA.BEB8FAFF@home.com>

[posted & mailed]

Casey Tweten wrote:
> 
> sub die_gracefully {
>     print start_html,
>             "Could not display page: $!\n",
>     end_html;
> }
> 
> if ( $page eq "gun_toting_perl_programmers" ) {
>   open ( PAGE, $page ) || die_gracefully;

You might want to terminate the program when die_gracefully is called. 
Printing a bunch of stuff after your </html> tag isn't very graceful.

>   print "$_" while (<PAGE>);
          ^^^^

There is no need for quotes around $_ here.  In fact, there is no need
for $_ here.  You might want to check out perlfaq4:

    What's wrong with always quoting "$vars"?

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Wed, 16 Jun 1999 22:59:42 GMT
From: schinder@leprss.gsfc.nasa.gov (Paul J. Schinder)
Subject: Re: MacPerl newbie: installing module problem
Message-Id: <y%V93.1191$S2.70298@iad-read.news.verio.net>

In <'x'campbell-lange-1606990902110001@campbell-lange.easynet.co.uk> 'x'campbell-lange@easynet.co.uk (Rory C-L) writes:

>I am having problems understanding the installation requirements of Chris'
>Mac-OSA-Simple-0.51 module.

>Basically, I don't understand the requirements for installing Simple.pm.

>I have placed Simple.pm in a folder called "site_perl" in the same
>directory as MacPerl itself, and directed MacPerl to see the directory in
>the library search path. I have run the tests below (needless to say, I
>don't understand what makefile.pl is for - I don't have SDK installed).
>Test.pl says that it can't find Simple.pm in @INC, and I have confirmed
>this by printing out @INC.

Sure it can't, because you've put it in the wrong place.  You should
think of

use Mac::OSA::Simple;

as indicating a platform portable path in one of the folders MacPerl
searches by default.  Simple.pm should be in a folder named "OSA" in a
folder named "Mac" in, say, the site_perl folder.  In MacSpeak, you
should put Simple.pm in "...:MacPerl f:site_perl:Mac:OSA:Simple.pm".

>In desperation, I also copied Simple.pm to ...:MacPerl f:ext:Mac:OSA:
>(which seems to be the required location from the error message), without
>any luck.

Not quite right.  ext is not searched by default.

>From Makefile.pl
>   " # On MacOS, we need to build under the Perl source directory or have the
>      MacPerl SDK installed in the MacPerl folder."

>Second line from test.pl
>   "# Can't locate Mac/OSA/Simple.pm in @INC." 

>I'd be grateful for anyone who could help me with this beginner's question.

You'll be *much* happier if you download and install Chris Nandor's
cpan-mac collection of tools (either from http://pudge.net/macperl/ or
from any CPAN site in his directory, CPAN/authors/id/CNANDOR.)  They
make installing modules about as painless as it's going to get under
MacOS.  They come with an installer which will install them in the
right place.

>Best wishes
>Rory


>p.s.
>Chris' whichMacPerl.pl gives me the following printout. Any ideas?

>   You're running on a PowerPC-based Mac OS system.
>   
>   Checking the versions of some system files:
>     File                         Version Needed  Version Present
>     ---------------------------  --------------  ---------------
>     AppleScriptLib                        1.2.2            1.2.2
>   I recommend installing the regular MacPerl distribution.

>-- 
>please remove the 'x' to reply

--
Paul J. Schinder 
NASA Goddard Space Flight Center 
schinder@leprss.gsfc.nasa.gov 


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

Date: Wed, 16 Jun 1999 16:04:37 -0500
From: Christopher Cavnor <chrisc@publishingonline.com>
Subject: Module installation question
Message-Id: <37681165.686AF5E0@publishingonline.com>

I am very new to perl module installation:

I am attempting to get  LWP::UserAgent  up and running, which means that

I needed to install the following first:

 URI
   MIME-Base64
   HTML-Parser
   libnet
   Digest::MD5

My question is more about module installation. When I unpack, it creates

a directory for the files. This puts the *.pm file in a subdirectory of
the rest of the *.pm files.  If I call a particular module through a
perl app (use *.pm), how is it going to find these? Should I move just
the *.pm file to the same level as all of the other Perl mods? Can I
trash everything else (the makefiles, c source files, etc)?



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

Date: Wed, 16 Jun 1999 18:21:27 -0500
From: rlb@intrinsix.ca (Lee)
Subject: Re: newbie learning "my" declarations
Message-Id: <B38D9BA796688F759@204.112.166.88>

In article <Pine.GSO.4.02A.9906161459500.26850-100000@user1.teleport.com>,
Tom Phoenix <rootbeer@redcat.com> wrote:

>> my $total; $total = $total + 1;
>> 
>> and
>> 
>> my $total; $total++;
>
>> I don't understand why the latter is not a warnable offence.
>
>I'm not sure why you think it should be. Incrementing from undef to one is
>a legitimate operation in the world of Perl.

Incrementing undef is conceptually different from adding one to it?

I've seen (and used) 

$me = $me +1;
$me += 1;
# and
$me++;

on undeffed $me for years, and never thought of them as significantly
different statements. Until I started reading here regularly and picked up
some good habits, and learned that -w and use strict draw a distinction. 

But I still don't understand the distinction, I just learned to initialize
variables that I intend to use as numbers to zero when I declare them. It's
nasty when your script breaks because you change $me++ to $me += 2.

Lee




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

Date: Wed, 16 Jun 1999 19:22:06 -0400
From: "Leonid Goltser" <leonid76@erols.com>
Subject: perl on-line
Message-Id: <7k9bgs$oi8$1@autumn.news.rcn.net>

I want to try to run perl scripts (with cgi) on-line but I can't find a
server that supports perl.
Where can I upload my scripts? (Preferably free).

Thank you




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

Date: Wed, 16 Jun 1999 23:58:52 GMT
From: dalehend@flash.net
Subject: Re: perl on-line
Message-Id: <37683a44.3241390@news.flash.net>



www.virtualave.net

On Wed, 16 Jun 1999 19:22:06 -0400, "Leonid Goltser"
<leonid76@erols.com> wrote:

>I want to try to run perl scripts (with cgi) on-line but I can't find a
>server that supports perl.
>Where can I upload my scripts? (Preferably free).
>
>Thank you
>
>



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

Date: Wed, 16 Jun 1999 17:41:03 -0700
From: Allan Masri <amasri@netscape.com>
Subject: Re: print command (<<) in perl CGI
Message-Id: <3768441F.6818AD99@netscape.com>

Well, that may be, but on page 43 of the camel book, it says:
"There must be no space between the << and the identifier...The terminating
string must appear by itself (unquoted and with no surrounding whitespace) on
the terminating line"

But even with all that, I can't get the same perl script that runs fine on
unix to run on NT with ActivePerl. Sheesh!

Larry Rosler wrote:

> In article <375FCC05.A28D919D@bigfoot.com> on Thu, 10 Jun 1999 16:30:29
> +0200, Andrzej Filip <anfi@bigfoot.com> says...
> > sunil@india-times.com wrote:
> > > I am writting a script in perl for one of my web application. when i
> > > execute the script instead of showing the ouput on the screen
> > > it generate/create a file and put the output in that file and offer it
> > > as if unknown/new file type to save.
>
> To sunil:
>
> Then that is a server or browser problem, not a Perl problem.  There are
> better newsgroups to ask in than this one.
>
> > <      Here is the piece of code Pls. expedite the things.
> > >
> > > $nn=<<"EOT"
> > >  <HTML>
> > >  <BODY>
> > >  <P>hello $$</P>
> > >  </P>
> > >  </BODY>
> > >  </HTML>
> > > EOT
> > > ;
> ...
> > Put semicolon after "EOT"
> > ---------------------------->
> > $nn=<<"EOT";
> >  <HTML> <BODY>
> >  <P>hello $$</P>
> >  </BODY> </HTML>
> > EOT
> > <----------------------------
>
> To Andrjez:
>
> That is totally irrelevant.  White-space in expressions is ignored in
> Perl.
>
> You should try such a thing both the original way and your suggested
> way, before wasting people's time with such a post.
>
> --
> (Just Another Larry) Rosler
> Hewlett-Packard Company
> http://www.hpl.hp.com/personal/Larry_Rosler/
> lr@hpl.hp.com



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

Date: Wed, 16 Jun 1999 23:07:58 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: Probably simple, but pulling hair out
Message-Id: <i7W93.5294$9P4.97825@news2.rdc1.on.home.com>

In article <37682736.285DFBC2@lmtas.lmco.com>,
 Michael Hill <l463520@lmtas.lmco.com> wrote:
! In my perl script I am trying to pass the value that is being stored to
! my variable.
! 
! $myvalue="fresh";
! print '<input type=hidden name="myfield" value=$myvalue>';
! 
! Of course what I get is $myvalue and not fresh.

of course you do --- variables do not get interpolated
in single quoted strings.

and before you wrap the whole thing in double quotes and
then ask how to include double quotes in a double quoted
string, please see the perlop manpage using either:

man perlop
or,      
perldoc perlop

and search for the heading: Quote and Quote-like Operators

regards
andrew


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

Date: Wed, 16 Jun 1999 16:29:57 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Probably simple, but pulling hair out
Message-Id: <Pine.GSO.4.02A.9906161626260.26850-100000@user1.teleport.com>

On Wed, 16 Jun 1999, Michael Hill wrote:

> In my perl script I am trying to pass the value that is being stored
> to my variable.
> 
> $myvalue="fresh";

The value being stored into your variable is 'fresh'. Is that what you're
trying to pass (to what?)?

> print '<input type=hidden name="myfield" value=$myvalue>';

Since this is a single-quoted string, it doesn't interpolate $myvalue. Is
that the problem you're having? You'll probably want to use qq{} from the
perlop manpage. Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 16 Jun 1999 19:39:55 -0400
From: "Matt" <splinter@monmouth.com>
Subject: Re: Probably simple, but pulling hair out
Message-Id: <7k9ck2$r9p$1@news.monmouth.com>

You want to do this:


print "<input type=hidden name=\"myfield\" value=\"$myvalue\">";


Printing it in ' ' says PRINT THIS EXACTLY
Printing it in " " says PRINT this but INTERPRET my variables please.


-Matt





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

Date: Wed, 16 Jun 1999 19:34:21 -0400
From: trader <trader@underwear.heuristics.com>
Subject: problems receiving datastream via a socket
Message-Id: <3768347D.2A22E063@underwear.heuristics.com>

first, a little background on my problem.

united parcel service has an on-line shipping calculator where you can
post some variables about a shipment and it will return the shipping
cost.  in the instructions ups provides, there's a perl script that
supposedly can be implemented so you don't have to access their cgi
through a web browser.  here's a snippet of the code they've supplied:

$AF_INET = 2;
$SOCK_STREAM = 2;
$sockaddr = "S n a4 x8";
$port = 80;
$them = "www.ups.com";
$function = "GET"; #Type of HTTP
$workFile = "/using/services/rave/qcostcgi.cgi";
$versionInfo = "HTTP/1.0\n\n";
$workString = "?";
$workString .= "accept_UPS_license_agreement=yes";
$workString .= (more variables like weight, destination zip code, etc.
removed for brevity)

$request = "$function $workFile$workString $versionInfo";
if (!&InitCommunications()) # This is a function to establish a socket
connection
{
  print S "$request\n";
  $resultlist = '';
  while (<S>)
   {
    $resultlist .=$_;
   }
  close(S);
 }
 sub InitCommunications
 {
     $errmsg = "";
     ($name, $aliases,$proto) = getprotobyname('tcp');
     ($name, $aliases,$port) = getservbyport($port,'tcp') unless $port
=~/^\d+$/;

     ($tname, $aliases,$type, $len, $thisaddr) =
gethostbyname($hostname);
     ($name, $aliases,$type, $len,$thataddr) = gethostbyname($them);

     $this = pack($sockaddr, $AF_INET, 0, $thisaddr);
     $that = pack($sockaddr, $AF_INET, $port, $thataddr);
     eval
     {
         alarm($connect_timeout);
         if (socket(S, $AF_INET, $SOCK_STREAM, $proto) < 0)
         {
           $raveServer = 0;
            return 0;
         }
         select(S);
         $| = 1;
         select(STDOUT);
         if (bind(S, $this) < 0)
         {
            $raveServer = 0;
         return 0;
         }
         if (!connect(S, $that))
         {
            $raveServer = 0;
         return 0;
         }
         alarm(0);
     };
 return $raveServer;
 }

after adding the shebang line and code to print the $resultlist (plus
the required variables), here is the output when run at the command
line:

[trader@micky test]$ ups.cgi
Name "main::tname" used only once: possible typo at ./ups.cgi line 75.
Use of uninitialized value at ./ups.cgi line 89.
bind() on closed fd at ./ups.cgi line 102.
print on closed filehandle main::S at ./ups.cgi line 40.
Read on closed filehandle <S> at ./ups.cgi line 45.
[trader@micky test]$


after looking on page 348 in "programming perl, 2nd edition" i saw the
following sentence:
"If you ever see code that does anything like explicitly setting
$AF_INET = 2, you know you're in for big trouble.  An immeasurably
superior approach is to use the Socket module....."

so, following the example on page 349 of the same text, i composed the
following:

#!/usr/bin/perl -w
use Socket;
use strict;
# initialize test variables
my $upsAction = 3;
my $upsProduct = "GND";
my $OriginPostalCode = 26059;
my $DestZipCode = 21082;
my $PackageWeight = 45;
my $hostname = $ENV{"HOSTNAME"};
my $remote = "www.ups.com";
my $function = "GET";   #Type of HTTP
my $workFile = "/using/services/rave/qcostcgi.cgi";
my $versionInfo = "HTTP/1.0\n\n";
my $workString = "?";
$workString .= "accept_UPS_license_agreement=yes";
$workString .= (more variables like weight, destination zip code, etc.
removed for brevity)

my $request = "$function $workFile$workString $versionInfo";
my ($port, $iaddr, $paddr, $proto, $results);
$port = shift || 80;
if ($port =~ /\D/) { $port = getservbyport($port, 'tcp') }
die "No port" unless $port;
$iaddr = inet_aton($remote) or die "no host: $remote";
$paddr = sockaddr_in($port, $iaddr);
$proto = getprotobyname('tcp');
socket(SOCK, PF_INET, SOCK_STREAM, $proto) or die "socket: $!";
connect(SOCK, $paddr) or die "connect: $!";
print SOCK "$request\n";
while (<SOCK>) {  $results .= $_; }
close (SOCK) or die "close: $!";
print "$results\n";
print "done.\n";
exit;

executing this at the command line produces the following output:

[trader@micky test]$ ups1.cgi
Use of uninitialized value at ./ups1.cgi line 53.

done.


the output is not immediate, there's about a 15 second pause before the
"Use of uninitialized...." line appears.  it seems to be trying to do
something, but there's nothing in the return datastream.  of course, no
one at ups tech support has a clue to what a telnet window is let alone
what i'm trying to do.

i've been programming perl for quite some time now, but this is my first
forray into sockets.  any suggestions?  i'm wondering if maybe it's not
working correctly on ups' end.

thanks, paul

--
The views expressed above are not necessarily those of anyone else on
the planet.
Email address spam protected; remove underwear to reply.




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

Date: Wed, 16 Jun 1999 16:54:34 -0700
From: moseley@best.com (Bill)
Subject: Real perl Y2K bug!
Message-Id: <MPG.11d1d9144861ba5b989749@206.184.139.132>

Ok, that subject is a dirty trick.  But the real Perl Y2K bug seems to be 
how many posts end up talking about Y2K.

My original & non-sexy post had a subject of:
[understanding 'You need to quote "sub" at..']

CGI.pm (at least my versions) defines a method 'sub', which is an 
unfortunate choice of names.

My Perl version is 5.005.

I'm trying to understand some Perl behavior, though.  Here's some test 
code.

#!perl -w

   use CGI qw/:standard -no_debug/; 
   my %SIGx;

   print hidden('name','value'),
         "\n",
         CGI::sub('hello'),
         "\n";

   local $SIG{ALRM} = sub { die "timed out" };

Now, this generates the 'You need to quote "sub" at...' warning since sub 
is declared in CGI.pm.  What's the best way to prevent this error?

Also, why does changing the last line to 

   local $SIGx{ALRM} = sub { die "timed out" };

make the warning go away?

Perhaps I'm confused about signals.



Now, my real code is part of my file locking routine.  It looks more like 
this:

eval {
  local $SIG{ALRM} = MAIN::sub { die 'timed out waiting for flock' };
  alarm 10;
  flock(FH, $lock_type);   # either blocking write, or share
  alarm 0;
};

if ($@) {
    print "<p>Eval Error: \$@ = $@<br>\$! = $!<P>\n";
    return undef;
}

 
I thought MAIN::sub? might be the solution.  But that seems to make it 
not wait for the the lock.  It doesn't wait and displays:
Eval Error: $@ = [Wed Jun 16 16:37:56 1999] index.html: timed out waiting 
for flock at test.cgi line 968. 
$! = 

(It does work fine other than the the warning, that is wait for the lock, 
without specifying the MAIN:: package.  I have a test program that locks 
the file.)

Thanks,

-- 
Bill Moseley mailto:moseley@best.com


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

Date: Wed, 16 Jun 1999 19:05:10 -0400
From: murali <myparu@usa.net>
Subject: Re: Regex Help Needed
Message-Id: <37682DA6.B0AD76AF@usa.net>

Greg Bacon wrote:

> In article <GfV93.321$Ty4.912@newsfeed.slurp.net>,
>         jwfrank@toad.net (John Frank) writes:
> :       I have 2 types of files in a long html page. They are
> : quite similar. One is s_a***.html and the other is a***.html.
> : I want to change the names of the a***.html files but not the
> : s_a*** files.
>
>     my @files_to_change = grep { ! /s_a...\.html$/ } <*a???.html>;

  Or s/^a*\.html/a*\.xyz/g;

murali



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

Date: Wed, 16 Jun 1999 19:37:06 -0400
From: "Matt" <splinter@monmouth.com>
Subject: s and tr
Message-Id: <7k9cep$r8d$1@news.monmouth.com>

Hi,

I have this database...records look like this:

0001:something:something:something:something\n
0002:something:something:something:something\n
0003:something:something:something:something\n
0004:something:something:something:something\n
0005:something:something:something:something\n

Now, when a user submits a form saying he wants to delete the record with
and id of 0003 I want to open up the database, and use something to delete
it.

I was thinking of doing something like

s/// or tr/// but they can't have variables in them like  s/$id//;  so what
would someone
suggest I use to remove a record like this in a text file?

-Matt




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

Date: Wed, 16 Jun 1999 22:21:26 GMT
From: Ryan Corder <uucon@my-deja.com>
Subject: Re: saving uploaded file
Message-Id: <7k980s$1pn$1@nnrp1.deja.com>

I'm new to perl, how do i use this?

ryan

In article <Pine.GSO.4.02A.9906161340230.26850-100000@user1.teleport.com>,
  Tom Phoenix <rootbeer@redcat.com> wrote:
> On Wed, 16 Jun 1999, Ryan Corder wrote:
>
> > Now, how do i strip the path from $filename so i can specify the file
> > to be saved in a specific directory?
>
> Use File::Basename. Cheers!
>
> --
> Tom Phoenix       Perl Training and Hacking       Esperanto
> Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/
>
>


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Wed, 16 Jun 1999 18:21:26 -0500
From: rlb@intrinsix.ca (Lee)
Subject: Re: sending to html page...
Message-Id: <B38D9BA696688F72A@204.112.166.88>

In article <3768018C.D1C3E582@bsat.com>,
Jeff Bowers <jbowers@bsat.com> wrote:

>  I have written the script that requests an ID and a password (simple,
>not very secure, but just to keep the peasants away).  

Apache has very good user authentication built-in. 

http://www.apache.org/docs/

>The problem is the syntax to say "Yes your Password is
>correct, here is your page".

print "Location: http://www.apache.org\n\n";

I think that's what you're asking for.

Lee




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

Date: Thu, 17 Jun 1999 10:15:12 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: this  charecter @ ruined my day!!
Message-Id: <GyX93.15$E4.25820@vic.nntp.telstra.net>

Craig Ciquera <craig@mathworks.com> wrote in message
news:3767E0E3.F894A2D7@mathworks.com...
> Toronto Augustan wrote:
>
> > Gabriel Russell explains it all:
> >
> > :ALWAYS ALWAYS ALWAYS debug your cgi scripts on the command line.
> > :If they wont work there then they wont work under a webserver.
> >
> > PLEASE PLEASE PLEASE snip unnecessary followup lines, and reply
> > below the quoted material you're replying to. Thanks.
> >
> > If those quickie web hosting companies won't provide logs, they
> > certainly won't provide command line access.
> >
>
> Don't know where this thread started, but I would certainly recommend
> running a web server configuration ON YOUR MACHINE, that mirrors the web
> server configuration of your ISP.  Then you can debug from the command
> line and rest at night knowing your scripts will work.
>
> Craig
>
Just to follow this thread..

PerlBuilder also provides a development environment which enables quick CGI
testing on the desktop without having to install a Web server.

Trial download from www.solutionsoft.com

(Speaking as a happy user, not a sales person)

Wyzelli




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

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

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