[9222] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2817 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 8 20:07:21 1998

Date: Mon, 8 Jun 98 17:00:24 -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           Mon, 8 Jun 1998     Volume: 8 Number: 2817

Today's topics:
    Re: Capitalizing acronyms (Re: Is PERL case sensitive?) <ljz@asfast.com>
    Re: Day of Week Display for User-defined date (Jonathan Stowe)
    Re: Exercise in Llama Book <rootbeer@teleport.com>
    Re: Field order from a Web Server (Jonathan Stowe)
    Re: File Upload <rootbeer@teleport.com>
    Re: Idiom for updating file? <vallon@bear.com>
    Re: Is PERL case sensitive? (Martien Verbruggen)
    Re: Looking for examples of perl working with javascrip <ebohlman@netcom.com>
    Re: Newbie Question - Contest Script...? (Abigail)
    Re: Passing arguements to interactive shell commands <rootbeer@teleport.com>
    Re: Perl script for UPS listening <jarrod@visi.com>
    Re: Perl script for UPS listening <rootbeer@teleport.com>
    Re: Preventing file conflicts <kennerDELETE.ME@xnet.com>
    Re: print <<EOT; problems <mhickey@reed.edu>
        RADIUS Authentication w/ Perl (Eric Mason)
    Re: raliases???? <rootbeer@teleport.com>
    Re: Script Auto-restart - using -M file test - Cannonic (Jeremy Mathers)
    Re: Spider programms in PERL <metcher@spider.herston.uq.edu.au>
    Re: Substr <rootbeer@teleport.com>
    Re: Testing for valid URL before writing HTML code (cgi <ebohlman@netcom.com>
        The Perl Conference 2.0 <gnat@frii.com>
    Re: upload scripts and taint, and other upload problem <rootbeer@teleport.com>
    Re: use strict vs. iterative filehandles? (Thomas Wernitz)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 08 Jun 1998 19:38:07 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: Capitalizing acronyms (Re: Is PERL case sensitive?)
Message-Id: <lthg1vo468.fsf@asfast.com>

Tom Phoenix <rootbeer@teleport.com> writes:

> On Sat, 6 Jun 1998, REUBEN LOGSDON wrote:
> 
> > PERL is an acroynm for "Practical Extraction and Report Language".  It's
> > common practice to capitalize acronyms. 
> 
> You're right, but once the acronym becomes a word (such as laser, scuba,
> or zip code) the caps are dropped. Thus the FAQ turns out to be correct
> once again. :-)

At least he's right about how it's a common practice to capitalize
acronyms.  As for the part about Perl standing for "Practical
Extraction and Report Language", well, looking at some old (i.e., late
1980's) man pages for Perl gives a somewhat different viewpoint, the
specifics of which we were asked to not tell anyone about ... :)

-- 
 Lloyd Zusman   ljz@asfast.com
 perl -e '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
 $t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
 $x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x\n"'


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

Date: Mon, 08 Jun 1998 23:12:22 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Day of Week Display for User-defined date
Message-Id: <357c4b17.14373488@news.btinternet.com>

On Mon, 08 Jun 1998 14:41:20 -0400, KC Lucchese wrote :

>What a witch.  Your trailer park cancel bingo again, honey?
>

You'd better hope you're wrong buddy 'cause you're going look pretty
silly trying to read that FAQ with the webbed feet and bulgy eyes.

/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: Mon, 08 Jun 1998 23:11:19 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Exercise in Llama Book
Message-Id: <Pine.GSO.3.96.980608160747.29617M-100000@user2.teleport.com>

On Sun, 7 Jun 1998, Tim Benjamin wrote:

> which worked fine, (for the "extra challenge" bit), but if you take out
> the "sort" in line 10, the program ignores some words beginning with x
> and y when you type them in.

This doesn't happen on my machine, but I'm not running Windows (and you
are, right?). If you're running a recent version of Perl, see whether you
can make a small program which demonstrates this buggy behavior. It
shouldn't be any longer than half a dozen lines, and (ideally) shouldn't
need to get any input from the user. Then post it here, and I'm sure that
someone will take a look at it. Thanks!

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



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

Date: Mon, 08 Jun 1998 23:12:29 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Field order from a Web Server
Message-Id: <357c4c92.14751976@news.btinternet.com>

On Mon, 8 Jun 1998 17:09:33 +0100, Robin Smith wrote :

>Does anyone know if it is possible to control/re-arrange the order that
>fields are passed to a perl script.  I have a questionaire that has fields
>
<snip>
>
>I need them to be in the correct order that they appear in on the form.
>Why are they being changed??
>
Havent the faintest idea.  It depends on the behaviour of all the
various software involved long before your Perl program gets hold of
it.
>I am Running Windows NT4 SP3, IIS4, and Perl 5.001m Build 105.
>
I would seriously recommend upgrading that Perl - the latest
"standard" distribution is at 5.004.02. 

>I am somewhat new to perl, so apologies if this is simple.  Any help greatly
>appreciated.
>
>Some code snippets of what I am doing are as follows:
>
>#Get the data into variables
>$data = &getInput();
>$originaldata=$data;
>%data = &getData($data);
>
<snip curious code>

If you had a more recent distribution of Perl then you would have
CGI.pm a module that will simplify to a great degree your CGI
programming in Perl.  Of course there has been some discussion here
about its virtues and vices but you can see that on DejaNews.

Anyhow you will understand  once you have read the documentation for
this module that the parameter ordering is no longer relevant.

This is of course is not a complete example but it shows this point:

use CGI;

my $query = new CGI;

print $query->header;
print $query->start_html;

foreach ( sort $query->param() )
 {
    print $_, "= ", $query->param($_),"<BR>\n";
  }

print $query->end_html;

__END__

I have assumed here that the names of your parameters can be sorted
simply with the sort builtin.

   
/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: Mon, 08 Jun 1998 23:43:57 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: File Upload
Message-Id: <Pine.GSO.3.96.980608163057.29617S-100000@user2.teleport.com>

On 8 Jun 1998, B00rah wrote:

> I am looking for a simple script to Upload just one graphic at a time
> through a Web Browser without using modules.  Can anyone point me in the
> right direction? 

You're doing this in Perl, but without using modules? Okay - download a
module, extract its code, then incorporate that code into your program. If
there's no module which does what you want, write one first. :-)

But, really, why don't you want to use a module? If you're trying to do
this the hard way, perhaps because you want to learn, then why ask for
help? :-)

>  How do I parse out the contents of the file and the file name from the
> multipart/file encoding? 

Use a module. :-)

Of course, these pieces of information are passed to your program
according to various standards and specifications. If you read those
documents, you'll know what you need to do to decode and interpret them.
You should be able to find the standards documents with the help of Yahoo
or a similar search engine. Start with the HTTP spec. Good luck! 

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



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

Date: Mon, 08 Jun 1998 23:18:35 GMT
From: Justin Vallon <vallon@bear.com>
Subject: Re: Idiom for updating file?
Message-Id: <x6ek96ro52s.fsf@pearl.bear.com>

[repost since I forgot to CC the previous posting]

cberry@cinenet.net (Craig Berry) writes:

>   open DB, '+< dbfile' or die $!;
>   flock DB, LOCK_EX;
>   { local $/; $data = <DB>; }
>   # Process data here; external rep lands back in $data.
>   truncate DB, 0;

And what if Something Bad Happens here?  Bye bye data.

>   seek DB, 0, 0;
>   print DB, $data;
>   flock DB, LOCK_UN;
>   close DB;

Atomically updating a file is practially impossible if you write in 
place.  So, write to a temp file.

Then, "rename $RealFile, $OldFile; rename $NewFile, $RealFile;".

But, then between the renames, you've lost the lock.  So, lock a 
lock file:

  $RealFile = "database";
  my $LockFile = "$RealFile.lock";
  my $OldFile = "$RealFile.old";
  my $NewFile = "$RealFile.new";

  open LOCKFILE, "$LockFile";
  flock LOCKFILE, LOCK_EX;
  open REALFILE, "<$RealFile";
  # Build new file in $data
  close REALFILE;
  open NEWFILE, ">$NewFile";
  print NEWFILE $data;
  close NEWFILE;
  # Yea! The data has been committed.
  rename $RealFile, $OldFile;
  rename $OldFile, $NewFile;
  unlink $OldFile;
  flock LOCKFILE, LOCK_UN;

The renames are still not atomic.  If the first rename succeeds and 
the second fails, you've lost $RealFile.  You could try to recover 
in the die (rename $OldFile, $RealFile), but that might fail 
(disk down, process killed, etc).  You can make the initial open 
smarter:

  flock LOCKFILE, LOCK_EX;

  # Recover state
  if (! -f $RealFile) {
    # RealFile is missing, should be in $OldFile
    if (! -f $OldFile) {
      die "Database lost";
    }
    # RealFile was renamed to OldFile, recover it.
    rename($OldFile, $RealFile) || die "die";
  }
  # $RealFile recovered.  Clean up.
  if (-f $OldFile) {
    unlink($OldFile) || die "die";
  }
  if (-f $NewFile) {
    unlink($NewFile) || die "die";
  }
  # $RealFile exists, $OldFile not there, $NewFile not there.

  open REALFILE, "<$RealFile";

The rename/rename/unlink is not atomic.  However the update maintains
the following invariants:

   If $RealFile exists, it is good.
   If $RealFile does not exist, $OldFile exists and is good.

The recover section uses these two rules to recover $RealFile.

-- 
-Justin
vallon@bear.com


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

Date: 8 Jun 1998 23:34:29 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Is PERL case sensitive?
Message-Id: <6lhse5$grd$1@comdyn.comdyn.com.au>

In article <Pine.BSI.3.96.980606193640.639B-100000@pentagon.io.com>,
	REUBEN LOGSDON <rlogsdon@io.com> writes:
> On 5 Jun 1998, Martien Verbruggen wrote:
> 
>> That is case sensitive. The program perl, and the language Perl are
>> both case sensitive as well. I don't really know about PERL.
> 
> PERL is an acroynm for "Practical Extraction and Report Language".  It's
> common practice to capitalize acronyms.

Apart from the other responses you got to this: If you send a cc to
the poster of an article on Usenet, you should mention so in both your
post and the email. It makes it clear to the receiver that this was
not a provate email, but rather a copy of a posted article.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | I took an IQ test and the results were
Commercial Dynamics Pty. Ltd.       | negative.
NSW, Australia                      | 


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

Date: Mon, 8 Jun 1998 23:15:51 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Looking for examples of perl working with javascript
Message-Id: <ebohlmanEu99yF.43E@netcom.com>

Joseph Norris <sirron@mail.mcoe.k12.ca.us> wrote:
: Hello listeros,

: I am looking for examples of mix of perl and javascript with the
: following questions in
: mind.

: 1.    Can I use perl to create form with javascript embedded?

Yes, just as you could use any language that can output text to do it.

: 2.    Can I use the javascript to check errors on form before passing
: data to
:         perl program?

Yes and no.  You can do it, but you can't rely on it having been done.  
Not all browsers support JavaScript and all of them that do allow the 
user to turn that support off.  For various reasons, good and bad, many 
people *do* turn it off.  You can't control this.  Therefore, any 
program, in whatever language, whether run as a CGI program or not, that 
processes data from an HTML form *must* check that data for validity and 
deal with invalid data appropriately.

It's certainly convenient to the user to provide first-stage validation via 
client-side scripting; given the slow responses often encountered on the 
World Wide Wait, it can be annoying to fill in a form, submit it, wait 
for a response, and then discover an error.  As long as you don't do it 
in a way that makes it impossible for people without scripting to use 
your form, I'd say go ahead and do it *for convenience only*.  Do *not* 
rely on it to keep invalid data out of your databases.

ObPerl: Using a module like CGI.pm to do the grunt work of extracting 
data passed across the CGI interface frees up your time to do things like 
properly validating the data.



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

Date: 8 Jun 1998 23:22:30 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Newbie Question - Contest Script...?
Message-Id: <6lhrnm$f4o$1@client3.news.psi.net>

Ythan Burstein (ythan@hempseed.com) wrote on MDCCXLII September MCMXCIII
in <URL: news:357C681E.81F38A3A@hempseed.com>:
++ I'm trying to write a CGI script for my webpage which allows my visitors
++ to submit their address to be entered in a random drawing to win a
++ prize. I want them to be able to enter once every 24 hours with the same
++ IP address (so if they have a dynamic IP address they *can* enter more
++ than once a day, as long as their IP address is different every time). 

I guess the 7 million AOL customers who hide behind a handful of proxy
servers will be very pleased with that. And so will any other person
using a large provider and a proxy.

++ Once they enter their postal address and click "submit", the script will
++ check a file which contains the IP addresses of everyone who has entered
++ the contest in the last 24 hours. If their IP address is not in the
++ file, then their address is added to a different file and the IP list is
++ updated so they can't enter again for 24 hours.
++ 
++ I am totally lost as to how I would even begin going about writing this
++ script, but if someone could point me in the right direction or supply
++ me with some sample code, I'd be incredibly grateful.


Start with 'use CGI; use AnyDBM_File;' and take it from there.




Abigail
-- 
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET", "http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content)) =~ /(.*\))[-\s]+Addition/s) [0]'


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

Date: Mon, 08 Jun 1998 23:29:26 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Passing arguements to interactive shell commands
Message-Id: <Pine.GSO.3.96.980608162806.29617R-100000@user2.teleport.com>

On Mon, 8 Jun 1998, Joe Novielli wrote:

> Is there a way I can pass the answers to interactive shell commands from
> a PERL script?
> 
> e.g.: answering the command "rm -i filename" (interactive removal which
> prompts for a "yes" or "no" answer.)

Yes, you can pass "arguements" to that program from Perl. But why are you
running rm when you can just unlink from Perl directly?

> e.g.: submitting  new web users and their passwords by a PERL CGI script
> by executing  Apache's "htpasswd" utility.

Yes, you can do that, too. But why don't you use a module which lets you
do this directly from Perl?

Hope this helps!

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



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

Date: Mon, 08 Jun 1998 23:18:07 GMT
From: Jarrod Stenberg <jarrod@visi.com>
Subject: Re: Perl script for UPS listening
Message-Id: <357C7329.634555AB@visi.com>



I know this is likely to be very simple but how can I get a perl script
to listen to the port attached to a Deltec UPS?

Thanks,
-jarrod



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

Date: Mon, 08 Jun 1998 23:53:35 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Perl script for UPS listening
Message-Id: <Pine.GSO.3.96.980608165221.29617W-100000@user2.teleport.com>

On Mon, 8 Jun 1998, Jarrod Stenberg wrote:

> Subject: Re: Perl script for UPS listening

Why does your subject start with Re: when it's not a response to a
previous posting with that subject?

> I know this is likely to be very simple but how can I get a perl script
> to listen to the port attached to a Deltec UPS?

The same way you can get it to listen to a port that's not attached to a
Deltec UPS. :-)

But have you seen what the FAQ says about reading and writing to serial
ports? Hope this helps!

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



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

Date: Mon, 8 Jun 1998 18:04:17 -0500
From: "Kenner" <kennerDELETE.ME@xnet.com>
Subject: Re: Preventing file conflicts
Message-Id: <6lhsk5$eid$1@flood.xnet.com>

Oh my god, Jeremy - WHAT HAVE YOU DONE?  You dare, you DARE to question?
Lurk a while and you'll see that Mr. Christiansen's epithets and
name-calling are pretty much the bread-and-butter of c.l.p.m.  Your sin in
this regard may well be unforgivable - in fact, it would not surprise me in
the least to find that your insolence leads to an awe-inspiring
demonstration of unholy "killfile" might!
Stay tuned, however........ I am learning a lot every day just by reading
the posts - even those of the aforementioned Perl guru; usually, embedded
somewhere in his puling nonsense, you will find the answers you seek.
Not to mention Tom P., Larry, Greg, Mark-Jason, Abigail ( hi, Abby :-) ),
and several others who consistently offer good info and fingers (yes, on
occasion THAT finger, but help nonetheless) pointing people in the right
direction.  I know too little to be of much help, I just wanted to offer
that there is a lot of good info on the newsgroup, so don't let the above
snippy response put you off.

--
Kenner
# If you want to send me e-mail, please remove the "DELETE.ME" from my
address. #
# (or call me a nimrod, I guess) #
"I'm glad that I could help out my friend Stephen with his art."  - Stuart
Davis





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

Date: Mon, 8 Jun 1998 15:55:34 -0700
From: youth philharmonic <mhickey@reed.edu>
Subject: Re: print <<EOT; problems
Message-Id: <Pine.OSF.3.96.980608155059.23167C-100000@amon.reed.edu>

> >   print &PrintHeader;
> >   print &HtmlTop("testing");
> >   print <<EOT;
> >      testing
> >      EOT
> >   print &HtmlBot;
> >
> >My web browser gives me:
> >"Can't find string terminator "EOT" anywhere before EOF at <path>."
> >
> >What is going on???  I have been driving myself CRAZY all day trying
> >to figure this one out.  In all my books of code, they all use this
> >same format for print <<MARKER; text  MARKER.  What am I doing wrong??
> 
> Try moving the EOT against the left margin (column 0):
> 
> 	print <<EOT;
> 	testing
> EOT

Another way to do it, if you want to preserve the indentation is like
this:

for (@blah) {
	print <<"	EOT";
		Yadda yadda yadda
		Yadda.
	EOT
}

Noting that whatever is in quotes has to be what occurs later on to match,
in this case I have "<tab>EOT".  And, the outputted "Yadda Yadda" will be
tabbed over as well, which may be important or not, depending...



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

Date: 8 Jun 1998 23:49:23 GMT
From: emason@shell.flinet.com (Eric Mason)
Subject: RADIUS Authentication w/ Perl
Message-Id: <6lhta3$sti$1@news.flinet.com>

Does anyone have any subroutines for Perl to interact with RADIUS. 
Maybe a subroutine, or an idea of how to do it.  I suppose we could 
always get the RFCs for the protocol and write a routine for it, but
why reinvent the wheel?

Thanks in advance,

Dan

P.S.  If you could reply to dsc@technocraft.com, I would greatly 
      appreciate it for this is a friend's account.  


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

Date: Mon, 08 Jun 1998 23:50:57 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: raliases????
Message-Id: <Pine.GSO.3.96.980608164944.29617U-100000@user2.teleport.com>

On Mon, 8 Jun 1998, Chris Reynolds wrote:

> How and/or would the best way be to make a mail alias.  You know, like
> make a script that will extract the email address corresponding to an
> email alias in unix.

Perhaps you want to read the system mail aliases database? If that's not
what you want, maybe you should ask again. Hope this helps!

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



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

Date: Mon, 8 Jun 1998 23:16:48 GMT
From: pynq@midway.uchicago.edu (Jeremy Mathers)
Subject: Re: Script Auto-restart - using -M file test - Cannonical way?
Message-Id: <Eu9A00.1q0@midway.uchicago.edu>

In article <QKTe1.910$14.4921360@news2.voicenet.com>,
Matt Knecht <hex@voicenet.com> wrote:
>Jeremy Mathers <pynq@midway.uchicago.edu> wrote:
>>The -M file test operator will tell you if a given file has been changed
>>since the script has started running.  An obvious application of this is for
>>the script to periodically query its source file (the .pl file) and see if
>>it has been edited.  If so, the script ought to restart itself.
>
>I don't think that an obvious application of using -M.  I think it's a
>convoluted way of using -M. :)
>
>>Suppose you have a Perl script running as a daemon, possibly on a distant
>>machine.  You make changes to the script, then have to walk over to the
>>distant machine and restart the script.  It seems there ought to be a
>>standard way for this process to be automated.
>
>If you can get to the machine to edit the script, why can't you restart
>the script after you are done editing and testing it?

The script is on a network drive.  The machine is not, e.g.,
telnet-accessible.

The goal of the exercise is for the script to automatically restart itself,
without needing human intervention to make it happen.  All of your examples
involve some active event to cause it to restart.

************************************************************************
Evangelists do more than lay people.

	- pynq@quads.uchicago.edu, who is still costing the net
	  hundreds, if not thousands, of dollars, every time he posts -
************************************************************************
rwvpf wpnrrj ibf ijrfer


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

Date: Tue, 09 Jun 1998 09:24:50 +1000
From: Jaime Metcher <metcher@spider.herston.uq.edu.au>
Subject: Re: Spider programms in PERL
Message-Id: <357C72C2.375D60E0@spider.herston.uq.edu.au>

Tom Christiansen wrote:
> 
>  [courtesy cc of this posting sent to cited author via email]
> 
> In comp.lang.perl.misc, Ala Qumsieh <aqumsieh@matrox.com> writes:
> : Boy .. that is the longest sentence I've ever read!
> 
> Then you haven't read much of my writing. :-)  I have a simple rule:
> at the end of every paragraph, I place a period whether I'm ready for it
> or not.  It has been noted by others that my syntactic attention span is,
> um, well, rather above average. :-)
> 
> --tom
> 
<snip marvellous sentence>

There was a young man from Japan
Whose limericks ne'er quite seemed to scan.
When asked why 'twas so
He replied "I don't know,
"But I always try to fit as many words into the last line as I can."

I'd like to see Tom's version of that last line!

-- 
Jaime Metcher


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

Date: Mon, 08 Jun 1998 23:27:50 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Substr
Message-Id: <Pine.GSO.3.96.980608162428.29617Q-100000@user2.teleport.com>

On Mon, 8 Jun 1998, Richard Gunkel wrote:

> I'm trying to use substr to remove JUST the first 4 Characters from a
> String read form <STDIN>

You do it in the same way no matter what the source. :-)

> The String is a Fixed width Format:
> 
> "    San Diego        51      test"
> "       Portland      132     false"
> "            Troy   12235         te"

I don't know what you mean by that. Did you intend to line up those
columns?

> The problem is the output is:
> 
> San             Diego      51      test
> Portland          132  false
> Troy            12235      te
> 
> The code I'm working with is a follows:
> 
> $shortline = substr( $line, 4, 100);
> print "$shortline \n";

Well, that input and that code won't give that output. So you're making at
least one mistake, and that is that you're not telling us what you're
_really_ doing. 

But substr (possibly with the third parameter omitted) should be able to
do what you say you want. Good luck!

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



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

Date: Mon, 8 Jun 1998 23:18:02 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Testing for valid URL before writing HTML code (cgi)
Message-Id: <ebohlmanEu9A22.45K@netcom.com>

genglergarret@my-dejanews.com wrote:
: The images reside on a different web server than the cgi-script.

: What I'd like my cgi script to be able to do is to check that the file exists,
: somehow, and if it doesn't, try back another day, or two, until it finds a
: valid file.

: If my script was on the same server as the images, it would be much easier
: (just file open error code stuff).  But since the files are on another web
: server, I have no idea how to proceed.

: Can a perl script establish http connections and get back error codes?  How?

The answer is definitely yes.  There are many ways to do it, but in your
case it's almost certain that the best way will be to use the LWP::Simple
module, available at finer CPAN sites near you. 



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

Date: 08 Jun 1998 17:45:44 -0600
From: Nathan Torkington <gnat@frii.com>
Subject: The Perl Conference 2.0
Message-Id: <5qpvgjmp93.fsf@prometheus.frii.com>

Once again, it's time for the Perl Conference.  I went last year, and
loved it.  This year, I'm on the Program Committee and giving a talk.
I think this was a result of using strong words on my feedback form
:-). 

Why should you go to the Perl Conference?  You'll meet the movers and
shakers in the Perl community.  You can congratulate Malcolm Beattie
on the compiler.  You can ask Sarathy why there's no 5.004_04 build
for Win32.  You can ask Tom Christiansen about the GPL.  You can even
buy me a beer and ask what it's like writing a book with Tom :-)

But star factor isn't the real reason.  You should go because it's a
technical conference about Perl.  Last year's conference didn't have
enough hard-core technical material, so this year we've worked hard to
make it practical and detailed.  If you look at the program on the web
site, http://conference.perl.com/, there should be very few times
during the two days when you aren't being forced to choose between at
least two excellent presentations.  I know *I'm* going to be sprinting
between rooms a lot.

We have some excellent papers lined up.  We're making the final cut
right now, and it's *very* hard to do.  The User Applications track is
going to be packed full of cool uses of Perl, most of which we can all
learn something from and some of which are going to be simply "wow.
You did WHAT with Perl?".

If attendance this year is anything like last year's, you'll have
around a thousand of your fellow Perl users to dine and talk with.  I
have many fond memories of drinking with Greg Bacon and doing Beavis
and Butthead impersonations on the subject of Solaris.  I expect this
year will be just the same, except that we'll be doing South Park
impersonations.  "Cartman, your Solaris box is such a fat ass, when it
swaps because of Netscape, everyone in the room says GODDAMN!  There
swaps a BIG FAT ASS."  Hmm, maybe not.

In fact, the post-session drinking and dining was probably the best
part of last year's conference.  I can't overstate the thrill in
finding other people who think in Perl, have solved your problems, and
are more than willing to tell you how they did it for only the price
of a few small beers :-)

So start making plans and working on your boss for conference money.
This is going to be a blast.

Nat
ob.perl:   exec { "real name" } "fake name", @arguments


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

Date: Mon, 08 Jun 1998 23:12:48 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: upload scripts and taint, and other upload problem
Message-Id: <Pine.GSO.3.96.980608161212.29617N-100000@user2.teleport.com>

On Sun, 7 Jun 1998, Vic Parekh wrote:

> also, this script does not work with the taint flag turned on. Is it a
> script specific issue, or is there some problem with using taint flag on
> upload scripts as a whole? 

It's that script; you could make a file-uploading script which is
taint-clean. Hope this helps!

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



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

Date: Tue, 09 Jun 98 18:21:51 GMT
From: NOSPAM.thomas_wernitz@tait.co.nz (Thomas Wernitz)
Subject: Re: use strict vs. iterative filehandles?
Message-Id: <6lhrs4$d4b$1@wolfman.xtra.co.nz>

In article <p5solfa9mh.fsf@baynetworks.com>, psmith@baynetworks.com wrote:

>Without use strict this works great; with it I get:
>
>  $ perl -w ./strict-tst
>  Can't use string ("FH0001") as a symbol ref while "strict refs" in use at
> ./strict-tst line 11.
>
>I understand from the docs why this is (more or less), but I'm unsure
>what to do about it.

release strict refs around the relevant code:

no strict 'refs';
pipe(...);
use strict 'refs';

HTH,
Thomas

"most people would die sooner than think -- in fact, they do so."
                                                         -- Bertrand Russell


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.  

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

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