[12920] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 330 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 2 04:07:15 1999

Date: Mon, 2 Aug 1999 01:05:07 -0700 (PDT)
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, 2 Aug 1999     Volume: 9 Number: 330

Today's topics:
    Re: $/ for cross platform text files? (Bart Lateur)
    Re: $/ for cross platform text files? (Abigail)
    Re: binary data (Alan Curry)
    Re: binary data <uri@sysarch.com>
    Re: binary data <uri@sysarch.com>
    Re: binary data (Larry Rosler)
    Re: binary data (Abigail)
    Re: binary data <uri@sysarch.com>
    Re: binary data (Sam Holden)
        Creating new files and directories <v0xman@yahoo.com>
    Re: Creating new files and directories (Abigail)
    Re: Does anyone know how to create a CGI program for Mu <bie@connect.ab.ca>
    Re: How to access only last field of a split ? (elephant)
    Re: How to compare two files and get the differences ? <factory@factory.co.kr>
    Re: How to compare two files and get the differences ? (Abigail)
    Re: modem dialingL HOWTO. (Asher)
    Re: Newbie Q: How to check if invoked as CGI program (Bart Lateur)
    Re: Paasing Arguments to System Function (PaulK)
        Perl and pws <andy@webfx3.freeserve.co.uk>
    Re: print "Location: http://..." avec paramètres (Andreas Fehr)
    Re: print "Location: http://..." avec paramètres (Larry Rosler)
    Re: print "Location: http://..." avec paramètres (Andreas Fehr)
        Suggest a site script (A. Peters)
    Re: Why won't this little script work? <bie@connect.ab.ca>
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: Mon, 02 Aug 1999 07:36:52 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: $/ for cross platform text files?
Message-Id: <37a746e3.3433142@news.skynet.be>

Rolf Howarth wrote:

>What's the easiest way to process a text file a line at a time if you
>don't know in advance whether it's DOS (\r\n), Unix (\n) or Macintosh
>(\r) format?
>
>DOS and Unix is easy, set the input record separator $/ to \n and remove
>any trailing \r's, but if your script encounters a Mac file then it will
>read the entire file in one go.
>
>I keep thinking this ought to be trivially easy (even the default
>behaviour of $/ if you don't set it to anything else), but can't think
>of any way of doing it without reading the file twice (the first time to
>identify it's type), reading it a character at a time and splitting it
>into lines myself, or slurping it all into memory and then splitting it,
>none of which are ideal. The file might be huge, so efficiency is
>important. Am I missing something obvious?

No, you're not.

If $/ would have accepted regexes, you might have done it just like
that, but $/ is just a string.

I think that one reason for keeping it this way, is that performance for
reading lines would drop considerably, say to around 50% of what it is
now, even for the common case where $/ is just plain text. That would
put it in the same range as what you get now, but ALWAYS.

You could read() in just a chunk of the file, say, at most a few k, and
try to determine the line terminators from that chunk.

	/(\012\015?|\015)/ and $/ = $1
	
If it doesn't contain a line terminator, you may read in another chunk,
repeat until you get one. Then, finally, just do

	seek FILE, 0, 0;

and now you're ready for the real work.

	Bart.


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

Date: 2 Aug 1999 02:59:18 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: $/ for cross platform text files?
Message-Id: <slrn7qajtk.q17.abigail@alexandra.delanet.com>

Bart Lateur (bart.lateur@skynet.be) wrote on MMCLXII September MCMXCIII
in <URL:news:37a746e3.3433142@news.skynet.be>:
%% 
%% I think that one reason for keeping it this way, is that performance for
%% reading lines would drop considerably, say to around 50% of what it is
%% now, even for the common case where $/ is just plain text. That would
%% put it in the same range as what you get now, but ALWAYS.


What makes you think it will take such a huge performance hit? awk has
always done it, and it's very trivial to determine that a regex only
contains a fixed string. Not to mention the fact nothing different than
now needs to be done if $/ isn't set in the program.



Abigail
-- 
sub f{sprintf$_[0],$_[1],$_[2]}print f('%c%s',74,f('%c%s',117,f('%c%s',115,f(
'%c%s',116,f('%c%s',32,f('%c%s',97,f('%c%s',0x6e,f('%c%s',111,f('%c%s',116,f(
'%c%s',104,f('%c%s',0x65,f('%c%s',114,f('%c%s',32,f('%c%s',80,f('%c%s',101,f(
'%c%s',114,f('%c%s',0x6c,f('%c%s',32,f('%c%s',0x48,f('%c%s',97,f('%c%s',99,f(
'%c%s',107,f('%c%s',101,f('%c%s',114,f('%c%s',10,)))))))))))))))))))))))))


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Mon, 02 Aug 1999 05:24:17 GMT
From: pacman@defiant.cqc.com (Alan Curry)
Subject: Re: binary data
Message-Id: <5Y9p3.2026$c17.43036@news15.ispnews.com>

In article <x7zp0alw3t.fsf@home.sysarch.com>,
Uri Guttman  <uri@sysarch.com> wrote:
>
>i wouldn't call them "expert perl whatevers". here is some sample code
>from a free script they offer. it has no matt viruses and actually uses
>cgi.pm but it is pretty bad on its own:
>
> while (<FILE>) {
>      chomp;
>      $_ =~ s/(\#.*)//g;    #ingore comments
>
>why /g?

s///g is a very frequently useful thing. Worthy of being one of the first
things you should learn in perl. s/// without the g, on the other hand, is
weird and rarely useful. I don't blame anyone for reading over perlop(1) and
choosing to remember only the more useful constructs.

>note the lovely use of $_ =~ and the poor choice of delimiters.

Once again, $foo =~ ... is generally useful, and omitting the $foo to have it
default to $_ is only a useless special case.

>
>$buffer =~ s/[\n\s]+/ /gs;
>
>that one is fun. \s has \n in it. and /s is not needed as . is not in
>the regex. and tr/// would be faster.

Putting a /s on all your regexps basically eliminates one obscure matching
rule, making it that much easier to write correct regexps. If you want [^\n],
you can say so. If you can just remember to use s///gs all the time, that's
two obscure rules you don't have to worry about. Sounds like a good policy.

>  while (<FILE>) {
>    chomp;
>    push @stopwords, $_;
>  }
>}
>
>that could be done with
>	chomp( @stopwords = <FILE> ) ;

Whitespace doesn't win you perl golf. Or was there an actual point in this
rewrite?

>i won't show any more but it is all the same vintage. 

Code that works, and isn't dedicated to the "I know more obscure rules than
you do" dicksize war?
-- 
Alan Curry    |Declaration of   | _../\. ./\.._     ____.    ____.
pacman@cqc.com|bigotries (should| [    | |    ]    /    _>  /    _>
--------------+save some time): |  \__/   \__/     \___:    \___:
 Linux,vim,trn,GPL,zsh,qmail,^H | "Screw you guys, I'm going home" -- Cartman


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

Date: 02 Aug 1999 01:37:31 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: binary data
Message-Id: <x7wvvelp44.fsf@home.sysarch.com>

>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:

  LR> In article <x7zp0alw3t.fsf@home.sysarch.com> on 01 Aug 1999 23:06:30 -
  LR> 0400, Uri Guttman <uri@sysarch.com> says...
  LR> ...
  >> $_ =~ s/(\#.*)//g;    #ingore comments
  >> 
  >> why /g?
  >> 
  >> note the lovely use of $_ =~ and the poor choice of delimiters.

  LR> I don't see anything wrong with the choice of delimiters.  I don't
  LR> like the backslash before the '#', though.  Or the useless
  LR> parentheses.  And out of context, I wonder if it's Perl they're
  LR> parsing and don't know about all the other places '#' may be
  LR> found.

actually i editied out another line which had a backwhacked / in the
regex, hence my comment.

it was just a small sample of the poor code in this script. not what i
call experts.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.


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

Date: 02 Aug 1999 01:53:43 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: binary data
Message-Id: <x7so62lod4.fsf@home.sysarch.com>

>>>>> "AC" == Alan Curry <pacman@defiant.cqc.com> writes:

  AC> In article <x7zp0alw3t.fsf@home.sysarch.com>,
  AC> Uri Guttman  <uri@sysarch.com> wrote:
  >> 
  >> i wouldn't call them "expert perl whatevers". here is some sample code
  >> from a free script they offer. it has no matt viruses and actually uses
  >> cgi.pm but it is pretty bad on its own:
  >> 
  >> while (<FILE>) {
  >> chomp;
  >> $_ =~ s/(\#.*)//g;    #ingore comments
  >> 
  >> why /g?

  AC> s///g is a very frequently useful thing. Worthy of being one of
  AC> the first things you should learn in perl. s/// without the g, on
  AC> the other hand, is weird and rarely useful. I don't blame anyone
  AC> for reading over perlop(1) and choosing to remember only the more
  AC> useful constructs.

but if it is not needed why use /g? a comment usually extends to the end
of the line or string (assuming # style comments) and so /g makes no
sense as it #.* can match at most one time.

  >> note the lovely use of $_ =~ and the poor choice of delimiters.

  AC> Once again, $foo =~ ... is generally useful, and omitting the $foo
  AC> to have it default to $_ is only a useless special case.

but $_ =~ is redundant, redundant. either use a bound expression or
use the default $_. do you wear a belt and suspenders?

  >> $buffer =~ s/[\n\s]+/ /gs;
  >> 
  >> that one is fun. \s has \n in it. and /s is not needed as . is not in
  >> the regex. and tr/// would be faster.

  AC> Putting a /s on all your regexps basically eliminates one obscure
  AC> matching rule, making it that much easier to write correct
  AC> regexps. If you want [^\n], you can say so. If you can just
  AC> remember to use s///gs all the time, that's two obscure rules you
  AC> don't have to worry about. Sounds like a good policy.

sounds like a mistake. if you think /g is used all the time that is very
wrong. and /s is telling the reader that a . could match a \n but if
there is no . then you are basically lying. that is bad policy.

  >> while (<FILE>) {
  >> chomp;
  >> push @stopwords, $_;
  >> }
  >> }
  >> 
  >> that could be done with
  >> chomp( @stopwords = <FILE> ) ;

  AC> Whitespace doesn't win you perl golf. Or was there an actual point
  AC> in this rewrite?

it does win perl golf. and it is faster and better perl by any
standard. you could make the chomp a separate statement if you wish. and
it is faster by a fair amount i bet but i am not going to benchmark it
for you. we have an 2 internal loops vs. a longer perl loop. which do
you think wins? this happens to be in a search script so speed matters
a little.

  >> i won't show any more but it is all the same vintage. 

  AC> Code that works, and isn't dedicated to the "I know more obscure
  AC> rules than you do" dicksize war?

well you are the biggest dick in this thread, so you win!

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.


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

Date: Sun, 1 Aug 1999 23:15:29 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: binary data
Message-Id: <MPG.120ed75d47332f15989d93@nntp.hpl.hp.com>

In article <5Y9p3.2026$c17.43036@news15.ispnews.com> on Mon, 02 Aug 1999 
05:24:17 GMT, Alan Curry <pacman@defiant.cqc.com> says...
+ In article <x7zp0alw3t.fsf@home.sysarch.com>,
+ Uri Guttman  <uri@sysarch.com> wrote:
 ...
+ >      $_ =~ s/(\#.*)//g;    #ingore comments
+ >
+ >why /g?
+ 
+ s///g is a very frequently useful thing. Worthy of being one of the
+ first things you should learn in perl. s/// without the g, on the
+ other hand, is weird and rarely useful. I don't blame anyone for
+ reading over perlop(1) and choosing to remember only the more
+ useful constructs.

Extra syntax should imply extra semantics, not noise.

+ >note the lovely use of $_ =~ and the poor choice of delimiters.
+ 
+ Once again, $foo =~ ... is generally useful, and omitting the $foo to
+ have it default to $_ is only a useless special case.

Extra syntax should imply extra semantics, not noise.

+ >$buffer =~ s/[\n\s]+/ /gs;
+ >
+ >that one is fun. \s has \n in it. and /s is not needed as . is not in
+ >the regex. and tr/// would be faster.
+ 
+ Putting a /s on all your regexps basically eliminates one obscure
+ matching rule, making it that much easier to write correct regexps.
+ If you want [^\n], you can say so. If you can just remember to use
+ s///gs all the time, that's two obscure rules you don't have to
+ worry about. Sounds like a good policy.

Extra syntax should imply extra semantics, not noise.

+ >  while (<FILE>) {
+ >    chomp;
+ >    push @stopwords, $_;
+ >  }
+ >}
+ >
+ >that could be done with
+ >	chomp( @stopwords = <FILE> ) ;
+ 
+ Whitespace doesn't win you perl golf. Or was there an actual point in
+ this rewrite?
+ 
+ >i won't show any more but it is all the same vintage. 
+ 
+ Code that works, and isn't dedicated to the "I know more obscure rules
+ than you do" dicksize war?

Perl baby talk is encouraged.  (See the beginning of 'Programming 
Perl'.)  But baby talk amongst adults is a turn-off.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 2 Aug 1999 01:21:06 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: binary data
Message-Id: <slrn7qae5g.q17.abigail@alexandra.delanet.com>

Alan Curry (pacman@defiant.cqc.com) wrote on MMCLXII September MCMXCIII
in <URL:news:5Y9p3.2026$c17.43036@news15.ispnews.com>:
`` 
`` s///g is a very frequently useful thing. Worthy of being one of the first
`` things you should learn in perl. s/// without the g, on the other hand, is
`` weird and rarely useful. I don't blame anyone for reading over perlop(1) and
`` choosing to remember only the more useful constructs.
`` 
`` Once again, $foo =~ ... is generally useful, and omitting the $foo to have it
`` default to $_ is only a useless special case.
`` 
`` Putting a /s on all your regexps basically eliminates one obscure matching
`` rule, making it that much easier to write correct regexps. If you want [^\n],
`` you can say so. If you can just remember to use s///gs all the time, that's
`` two obscure rules you don't have to worry about. Sounds like a good policy.
`` 
`` Code that works, and isn't dedicated to the "I know more obscure rules than
`` you do" dicksize war?


Are you a troll, or just plain stupid?



Abigail
-- 
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 02 Aug 1999 02:39:59 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: binary data
Message-Id: <x7lnbulm80.fsf@home.sysarch.com>

>>>>> "A" == Abigail  <abigail@delanet.com> writes:

  A> Alan Curry (pacman@defiant.cqc.com) wrote on MMCLXII September
  A> MCMXCIII `` Code that works, and isn't dedicated to the "I know
  A> more obscure rules than `` you do" dicksize war?

  A> Are you a troll, or just plain stupid?

this twit emailed a reply to my followup (no stealth cc, he wanted speed
via email ;-).

his quote about always using /gs is priceless!

i sent an appropriate reply with a benchmark. the one line slurp and
chomp is over twice as fast as the loop. but the improvement is
dependent on the size of the file. 

uri

you should see the email he sent to me defending his sandcastle. here
are my favorite parts:

<edited below>

My news server is too slow, so I'll just use mail.

Let me ask again. Why should every perl programmer learn both s/// AND s///g
when s///g is probably the only one they'll ever need? Is it not allowed to
learn just the useful subset of perl?

<raise your hands if you ever have used s/// with out /g and especially
where /g would be a bug>

Why should every perl programmer learn both $foo =~ s//// and the implicit $_
version? It's easier to learn just one of them and one of them is completely
unnecessary.

<so are 3/4 of perl's operator and functions. you can fake them all with subs>

If you use /gs on every regexp you are telling the reader "I didn't feel like
memorizing two obscure rules, so I instead memorized the flags to disable
them". It's just picking a useful subset and restricting yourself to it.
Nothing wrong with that.

<that is the winning para!!>

I meant "chomp(@stopwords=<FILE>);", without the whitespace, would be
shorter. And shortness is the only advantage I could see with your rewrite.

<that is a winner too!>

OK, so your version is faster. But I can't see any really obvious reason
that it should be. You just know the compiler better. Lack of knowledge
about how perl optimizes specific loops is not something to be ashamed
of.

<this is plain dumb. he thinks perl optimizes external loops into
internal ones!>

so is he dumb or a troll? you decide!

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.


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

Date: 2 Aug 1999 07:01:29 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: binary data
Message-Id: <slrn7qagiq.rn4.sholden@pgrad.cs.usyd.edu.au>

On 02 Aug 1999 02:39:59 -0400, Uri Guttman <uri@sysarch.com> wrote:
>
>so is he dumb or a troll? you decide!

I tend to err on the side that gives the most credit to the person. So in this
case that would be dumb.


-- 
Sam

I explicitly give people the freedom not to use Perl, just as God gives
people the freedom to go to the devil if they so choose.
	--Larry Wall


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

Date: Mon, 2 Aug 1999 02:25:03 -0300
From: "Vox" <v0xman@yahoo.com>
Subject: Creating new files and directories
Message-Id: <W5ap3.45659$jl.31864525@newscontent-01.sprint.ca>

I know how to print output with: print "Content-type: text/html"
but I don't know how to dynamically make a new files or directories and name
them.  All i know how to do is open and modify files but not create files or
even new directories.

If anyone knows how to do this can they please help me.  Thanks.




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

Date: 2 Aug 1999 01:21:54 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Creating new files and directories
Message-Id: <slrn7qae70.q17.abigail@alexandra.delanet.com>

Vox (v0xman@yahoo.com) wrote on MMCLXII September MCMXCIII in
<URL:news:W5ap3.45659$jl.31864525@newscontent-01.sprint.ca>:
\\ I know how to print output with: print "Content-type: text/html"
\\ but I don't know how to dynamically make a new files or directories and name
\\ them.  All i know how to do is open and modify files but not create files or
\\ even new directories.
\\ 
\\ If anyone knows how to do this can they please help me.  Thanks.


The manual knows how to do this. Go bug the manual.



Abigail
-- 
perl -wlne '}for($.){print' file  # Count the number of lines.


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Sun, 01 Aug 1999 21:41:39 -0600
From: Tim <bie@connect.ab.ca>
Subject: Re: Does anyone know how to create a CGI program for Multiple Choice test using Perl on website?
Message-Id: <37A51373.47A5@connect.ab.ca>

Hey Patrick,

I could explain how to make a script just like the one you want. then
someone else could post another version & it could be done a whole
different way, but do the same end job. And another, and another. There
isn't one set way to do anything. So if you know cgi / are learning then
think about it, plan it from what you know and practise practise
practise till u don't know where to look next (read info before asking).
then ask. If you just want to set up a script, go to
www.cgi-resources.com , if you have trouble setting up the script, then
it sux to be you


Tim


Patrick wrote:
> 
> As title, pls. help me  by advising me the structure of the program, any
> database i need to create and other necessary things thanks.
> 
> Patrick
> pat4b@hongkong.com
> icq: 8882328

-- 

-------------------------------------------------------
| TBE: http://tbe.virtualave.net                      |
| * 3:2 Ratio + 100 Free credits! *                   |
| Tim's Chat Doors: http://www.connect.ab.ca/~mundy/  |
-------------------------------------------------------


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

Date: Mon, 2 Aug 1999 15:15:53 +1000
From: e-lephant@b-igpond.com (elephant)
Subject: Re: How to access only last field of a split ?
Message-Id: <MPG.120fd4953fc873cd989bad@news-server>

elephant writes ..
>  my $sep = '.';	# assuming you meant to split on the period
>  $_ = 'word.10.word.20.30.40.50';
>  my $last = /\Q$sep\E([^$sep]+)$/ ? $1 : '';

slight adjustment .. to more accurately mimic the split behaviour

  my $last = /\Q$sep\E([^$sep]+)$/ ? $1 : $_;

although .. someone's posted a solution using split .. which is quicker 
for short lists (like the sample data)

-- 
 jason - remove all hyphens for email reply -


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

Date: Mon, 2 Aug 1999 16:38:11 +0900
From: "Yeong Mo/Director Hana co." <factory@factory.co.kr>
Subject: Re: How to compare two files and get the differences ?
Message-Id: <7o3hav$162$1@news1.kornet.net>


Larry Rosler ÀÌ(°¡) ¸Þ½ÃÁö¿¡¼­ ÀÛ¼ºÇÏ¿´½À´Ï´Ù...
>In article <7o25oc$jfb$1@news.ml.com> on 1 Aug 1999 19:04:44 GMT,
>Michael Wang <mwang@tech.cicg.ml.com> says...
>> Yeong Mo/Director Hana co. <factory@factory.co.kr> wrote:
>> >aaa.txt has the following lines;
>> >f1, 123, .........
>> >f2, 222, .........
>> >f3, 5555, .......
>> >f4, xxx, ........
>> >....................
>> >
>> >and bbb.txt has the following lines;
>> >f2, 222, ...........
>> >f3, 5555, .........
>> >......................
>>
>> I would just go with
>> system("diff aaa.txt bbb.txt"); or
>> `diff "aaa.txt" "bbb.text"`
>>
>> It is diff's job.
>
>Only if the data must be in the specified sequence.  For arbitrarily
>ordered input that won't work at all.  And there is no indication of
>ordering in the original question.
>
>perlfaq4: "How do I compute the difference of two arrays? How do I
>compute the intersection of two arrays?"
>

About perlfaq4.
Then is this right to get the differences if there is following 2 arrays ?
@array1=(1,2,3,4,5);
@array2=(0,2,3,4);
    @union = @intersection = @difference = ();
    %count = ();
    foreach $element (@array1, @array2) { $count{$element}++ }
    foreach $element (keys %count) {
        push @union, $element;
        push @{ $count{$element} > 1 ? \@intersection : \@difference },
$element;
    }
print "$element\n";




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

Date: 2 Aug 1999 02:55:25 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: How to compare two files and get the differences ?
Message-Id: <slrn7qajm9.q17.abigail@alexandra.delanet.com>

Yeong Mo/Director Hana co. (factory@factory.co.kr) wrote on MMCLXII
September MCMXCIII in <URL:news:7o3hav$162$1@news1.kornet.net>:
## 
## >perlfaq4: "How do I compute the difference of two arrays? How do I
## >compute the intersection of two arrays?"
## >
## 
## About perlfaq4.
## Then is this right to get the differences if there is following 2 arrays ?
## @array1=(1,2,3,4,5);
## @array2=(0,2,3,4);
##     @union = @intersection = @difference = ();
##     %count = ();
##     foreach $element (@array1, @array2) { $count{$element}++ }
##     foreach $element (keys %count) {
##         push @union, $element;
##         push @{ $count{$element} > 1 ? \@intersection : \@difference },
## $element;
##     }

The above is right. It comes straight from the faq.

## print "$element\n";

Did you bother to try out the line above to see what it prints?


You're one of the biggest lusers found in this newsgroup. It's probably
beyond you to realize that '@union', '@intersection' and '@difference'
aren't just randomly choosen sequences of characters.



Abigail
-- 
perl -wle '$, = " "; print grep {(1 x $_) !~ /^(11+)\1+$/} 2 .. shift'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Mon, 02 Aug 1999 06:10:50 GMT
From: asher@localhost.localdomain (Asher)
Subject: Re: modem dialingL HOWTO.
Message-Id: <slrn7qacde.vd.asher@localhost.localdomain>

On Fri, 30 Jul 1999 23:46:35 -0700, Jason C. Leach <jcl@mail.ocis.net> wrote:
>hi,
>
>I am looking for a simple way to get my Perl app to pick up the phone,
>and dial.  That's it.
>
>Thanks,
>    Jason
>
[Apologies if this post appears twice.]

Assumption:  You want to run your Perl app on linux.

Simplest way:

open(MODEM,">/dev/modem") || die"Can't open modem: $!";
print MODEM "ATDT5551212\r";  # Hayes command language common to 
                              # most modems
close MODEM;

Hope this helps.


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

Date: Mon, 02 Aug 1999 07:36:55 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Newbie Q: How to check if invoked as CGI program
Message-Id: <37a8499e.4131952@news.skynet.be>

Andrew Fry wrote:

>>Check out the contents of %ENV in both cases.
>
>And what would I expect to find ?

I tend to check out $ENV{REQUEST_METHOD}. If it is set (usually to "GET"
or "POST", i.e. true), then you're in a CGI. It is *very* uncommon for
this environment variable to be set on other systems.

	Bart.


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

Date: Mon, 02 Aug 1999 05:49:35 GMT
From: paul@vdkamer.nl (PaulK)
Subject: Re: Paasing Arguments to System Function
Message-Id: <37a530ef.493587@news.wxs.nl>

The script query1.cgi uses param(FileNaam) to read the command-line
argument.
i do not know if this is cargo-cult ? whatever that means.
Please any working example can help.


On 1 Aug 1999 22:31:35 GMT, ebohlman@netcom.com (Eric Bohlman) wrote:

>paul (paul@balans.net) wrote:
>: I'm getting a bit angry avout this one because i do not see the
>: mistake i'm making.
>: 
>: $test = 'perl  \\query\\query1.cgi';
>: $uitkomst = `$test "FileNaam=test.txt"`;
>: 
>: I'm trying to run query1.cgi with the the variable FileNaam filled
>: with test.txt.
>
>CGI programs don't expect to get their input as command-line arguments. 
>Read up on the CGI spec until you're familiar with the two possible ways
>that CGI programs can get their input, examine query1.cgi to find out
>which way it's using (if it was written using CGI.pm, either way will
>work, but unfortunately many CGI programs use a cargo-cult parameter 
>decoder instead), and then pass the input the proper way. 
>



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

Date: Mon, 2 Aug 1999 07:29:21 -0000
From: "Andy" <andy@webfx3.freeserve.co.uk>
Subject: Perl and pws
Message-Id: <7o3dv9$p27$1@news8.svr.pol.co.uk>

Hi

I have a   simple question . I am using PWS and win98 + perl (for
windows)when
i try to   run a script from pws it tries to download it not run it???? What
is wrong.
I know this  is in an FAQ somewhere but  i cant find it

Any Ideas
Thanks Andy
Andy@webfx.uk.com




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

Date: Mon, 02 Aug 1999 06:19:05 GMT
From: backwards.saerdna@srm.hc (Andreas Fehr)
Subject: Re: print "Location: http://..." avec paramètres
Message-Id: <37a5375e.3268459@news.uniplus.ch>

On Thu, 29 Jul 1999 17:26:39 +0200, "Sébastien BEAUGRAND"
<beaugrand@activebaseconcept.com> wrote:

>Comment envoyer des paramètres dans une redirection perl :
>J'essaie :
>    print "Location: usr_copie.asp?Login=".$Login."\n\n";
>et ça ne marche pas. La redirection marche, mais je ne reçopis pas lme
>paramètre Login.
>

Est il possible de poser cette question on Anglais?
Je ne suis pas sure, si je le comprends.

Andreas


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

Date: Mon, 2 Aug 1999 00:14:14 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: print "Location: http://..." avec paramètres
Message-Id: <MPG.120ee51f7a49ece9989d94@nntp.hpl.hp.com>

In article <37a5375e.3268459@news.uniplus.ch> on Mon, 02 Aug 1999 
06:19:05 GMT, Andreas Fehr <backwards.saerdna@srm.hc> says...
> On Thu, 29 Jul 1999 17:26:39 +0200, "Sébastien BEAUGRAND"
> <beaugrand@activebaseconcept.com> wrote:
> 
> >Comment envoyer des paramètres dans une redirection perl :
> >J'essaie :
> >    print "Location: usr_copie.asp?Login=".$Login."\n\n";
> >et ça ne marche pas. La redirection marche, mais je ne reçopis pas lme
> >paramètre Login.
> >
> 
> Est il possible de poser cette question on Anglais?
> Je ne suis pas sure, si je le comprends.

Sind Sie nicht schweizer?  Sie solten viele Sprachen kennen, besonders 
Französisch, nicht wahr?

He wants to know how to send parameters in a redirection.  The 
redirection works, but he doesn't receive the parameter.

He thinks it is a Perl problem, but unfortunately it isn't, so this 
isn't the right newgroup to ask.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Mon, 02 Aug 1999 08:00:27 GMT
From: backwards.saerdna@srm.hc (Andreas Fehr)
Subject: Re: print "Location: http://..." avec paramètres
Message-Id: <37a54e5a.9152620@news.uniplus.ch>

On Mon, 2 Aug 1999 00:14:14 -0700, lr@hpl.hp.com (Larry Rosler) wrote:

>Sind Sie nicht schweizer?  Sie solten viele Sprachen kennen, besonders 
>Französisch, nicht wahr?

I'm Swiss, that's true. I know a lot of languages, but I don't speak
them...

But as you are American, why do you speak German? Are you allowd to
speak it? Isn't there any law about cryptography? Don't foreign
languages fall under these laws? :)

>He wants to know how to send parameters in a redirection.  The 
>redirection works, but he doesn't receive the parameter.

Thanks anyway

Andreas


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

Date: 2 Aug 1999 07:50:20 GMT
From: apeters@euronet.nl-nospam (A. Peters)
Subject: Suggest a site script
Message-Id: <7o3ijs$k7e@news3.euro.net>

Hi all!

I came across this nice script at www.suggestsite.com

Well, pretty nice, butt....I do not like it that my (future) visitors seeing a 
Thank You-page that is not mine.
They see the one the makers of this script have made.

Does anyone know of a free Perl-script that does the following, and is 
customisable *and* works uhh... bugfree (am i dreaming?):
- a visitor can send a friend (or multiple friends!) a message (which the 
site-owner makes) saying something like: Hey! Look at this great website! bla 
bla bla...
- the email-message and the thank you-page are fully customisable by the 
site-admin.

Anyone, please let me know if you know of a script that does this!

p.s. I am on a server with Apache(1.3.4), PHP (3.0.7), Perl 4, 5-5.004

thanks for reading...

Aaron Peters
aaronp@dds.nl









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

Date: Sun, 01 Aug 1999 21:43:05 -0600
From: Tim <bie@connect.ab.ca>
Subject: Re: Why won't this little script work?
Message-Id: <37A513C9.2D04@connect.ab.ca>

Sorry about the attachments, & I mean it doesn't work because I get a
Internal Server Error. I don't know why I get that though (or else I;'d
fix it)


Tim

Tim wrote:
> 
> Hello,
> 
> I have no idea why this won't work. everything looks right 2 me
> Please help me
> 
> here it is:
> 
> #!/usr/bin/perl5
> require "subparseform.lib";
> &Parse_Form;
> 
> print "Content-type:text/html\n\n";
> 
> ##################################################
> 
> $usera = $formdata{'usera'};
> $userb = $formdata{'userb'};
> $checka = "z" . "$usera" . ".txt";
> $checkb = "z" . "$userb" . ".txt";
> 
> ##################################################
> 
> if (-e $checka) {
> 
> open(DAONE, "$checka") || &Error;
>  @stuff = <DAONE>;
> close(DAONE);
> 
> $money1 = @stuff[3];
> }
> else {
> PRINT "THE FIRST USERNAME IS WRONG";
> exit;
> }
> 
> ##################################################
> 
> if (-e $checkb) {
> 
> open(SEB, "$checkb") || &Error;
>  @play = <SEB>;
> close(SEB);
> 
> $money2 = @play[3];
> &out;
> }
> else {
> PRINT "THE SECOND USERNAME IS WRONG";
> exit;
> }
> 
> ##################################################
> sub out {
> print <<"OUTPSDI";
> <title>The Results</title>
> <body bgcolor=000000 text=FFFFFF>
> <!-- VA Banner -->
> <BR>
> <center>
> <img src="http://tbe.virtualave.net/chatters/dealin/title.gif"
> alt=Dealin>
> <br><br>
> <a
> href="http://tracker.clicktrade.com/tracker/tracker.dll?to='http://www.cleartest.com/'&ad=166180.0&lp=43225"
> target="new"><img
> src="http://www.cleartest.com/links/banners/clearly2.gif" border=0>
> <br>[ Visit This Sponsor ]</a><br><br>
> 
> <h2>Here Is The Results</h2><br>
> <center>
> <TABLE border="3">
> <TR>
> <TD> $usera </TD>
> <TD bgcolor=green>$money1</TD>
> </TR>
> <TR>
> <TD> $userb </TD>
> <TD bgcolor=green> $money2 </TD>
> </TR>
> </TABLE>
> </center>
> <br>
> $checka
> $checkb
> </BODY>
> OUTPSDI
> }
> 
> ##################################################
> sub Error {
> print "There was an Error";
> exit;
> }
> 
>     ---------------------------------------------------------------
> 
>                         Name: challenge.pl
>          Part 1.2       Type: Perl Program (application/x-perl)
>                     Encoding: base64
> 
>                                [Dealin]
> 
> Check to see who has more money with a friend
> 
> Username:
> Username:

-- 

-------------------------------------------------------
| TBE: http://tbe.virtualave.net                      |
| * 3:2 Ratio + 100 Free credits! *                   |
| Tim's Chat Doors: http://www.connect.ab.ca/~mundy/  |
-------------------------------------------------------


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

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

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 V9 Issue 330
*************************************


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