[24447] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6630 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 31 09:05:49 2004

Date: Mon, 31 May 2004 06:05:12 -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, 31 May 2004     Volume: 10 Number: 6630

Today's topics:
        (?{ ... }) puzzlement <jkrugman345@yahbitoo.com>
    Re: (?{ ... }) puzzlement <usenet@morrow.me.uk>
        Beginner needs help with script :) <notachance@inhell.com>
    Re: Beginner needs help with script :) <noreply@gunnar.cc>
    Re: Beginner needs help with script :) <ittyspam@yahoo.com>
    Re: Beginner needs help with script :) <notachance@inhell.com>
    Re: Beginner needs help with script :) <notachance@inhell.com>
    Re: Beginner needs help with script :) <notachance@inhell.com>
    Re: Beginner needs help with script :) <ittyspam@yahoo.com>
    Re: Beginner needs help with script :) <noreply@gunnar.cc>
    Re: Beginner needs help with script :) <flavell@ph.gla.ac.uk>
    Re: Beginner needs help with script :) <gnari@simnet.is>
    Re: Beginner needs help with script :) <notachance@inhell.com>
    Re: Beginner needs help with script :) <gnari@simnet.is>
    Re: Beginner needs help with script :) <notachance@inhell.com>
    Re: Beginner needs help with script :) <usenet@morrow.me.uk>
    Re: Beginner needs help with script :) <notachance@inhell.com>
        Cookies <daveharney@wi.rr.com>
    Re: Cookies <noreply@gunnar.cc>
    Re: Cookies <daveharney@wi.rr.com>
    Re: Cookies <noreply@gunnar.cc>
    Re: How to Extract a Single Quote from a file Using GRE (Anno Siegel)
    Re: How to Extract a Single Quote from a file Using GRE <uri@stemsystems.com>
    Re: How to Extract a Single Quote from a file Using GRE (Anno Siegel)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 31 May 2004 12:34:32 +0000 (UTC)
From: J Krugman <jkrugman345@yahbitoo.com>
Subject: (?{ ... }) puzzlement
Message-Id: <c9f8on$no6$1@reader2.panix.com>




In an attempt to find a single regexp that would succeed if three
different sub-regexps matched in any order (see why in the thread
called '"Commutative" regexps'), I started playing with (?{...})-type
regexps.  As warm-up, I tried this:

     1  use strict;
     2  use re 'eval';
     3  
     4  my @re0  = qw(abc pqr xyz);
     5  my @seen = (undef) x @re0;
     6  my @re   = map sprintf('%s(?{ $seen[%d] ||= "@-" })',
     7                         $re0[$_], $_),
     8                 0..$#re0;
     9  my $re   = eval "qr/@{[join('|', @re)]}/";
    10  
    11  #0         1         2
    12  #01234567890123456789012345
    13  '__pqr____xyz__pqr___abc___' =~ /(($re).*?)*/;
    14  
    15  print "\$seen[$_] = $seen[$_]\n" for (0..$#seen);
    16  
    17  __END__

    $seen[0] = 
    $seen[1] = 
    $seen[2] = 

If I change line 13 to

    13  '__pqr____xyz__pqr___abc___' =~ /(($re).*?)*(?!)/;

The output I get changes to

    $seen[0] = 2 14 14
    $seen[1] = 2
    $seen[2] = 2 2 2


I find both results completely puzzling.  I realize that ?{ ... }
is a highly experimental feature, but if anyone can explain to me
what's going on I'd very much appreciate it.

TIA,

jill

P.S.  Unrelated regexp question:  if I have a string or regexp in
a variable $x, and I want to use this variable to write a regexp
corresponding to 5 repeats of the contents of $x, how do I write
it? If I wrote /$x{5}/, it would be interpreted by perl as attempting
to access the value corresponding to key '5' in the hash %x.

-- 
To  s&e^n]d  me  m~a}i]l  r%e*m?o\v[e  bit from my a|d)d:r{e:s]s.



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

Date: Mon, 31 May 2004 13:01:39 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: (?{ ... }) puzzlement
Message-Id: <c9fabj$8bg$1@wisteria.csv.warwick.ac.uk>


Quoth J Krugman <jkrugman345@yahbitoo.com>:
>
> In an attempt to find a single regexp that would succeed if three
> different sub-regexps matched in any order (see why in the thread
> called '"Commutative" regexps'), I started playing with (?{...})-type
> regexps.  As warm-up, I tried this:
> 
>      1  use strict;
>      2  use re 'eval';
>      3  
>      4  my @re0  = qw(abc pqr xyz);
>      5  my @seen = (undef) x @re0;
>      6  my @re   = map sprintf('%s(?{ $seen[%d] ||= "@-" })',
>      7                         $re0[$_], $_),
>      8                 0..$#re0;

@- only contains entries for () sub-expressions. You have none here
(that have matched yet), so it won't work. (My guess is that the first
entry isn't filled in until after the match has finished, but I don't
rightly know...)

>      9  my $re   = eval "qr/@{[join('|', @re)]}/";
>     10  
>     11  #0         1         2
>     12  #01234567890123456789012345
>     13  '__pqr____xyz__pqr___abc___' =~ /(($re).*?)*/;
>     14  
>     15  print "\$seen[$_] = $seen[$_]\n" for (0..$#seen);
>     16  
>     17  __END__
> 
>     $seen[0] = 
>     $seen[1] = 
>     $seen[2] = 
> 
> If I change line 13 to
> 
>     13  '__pqr____xyz__pqr___abc___' =~ /(($re).*?)*(?!)/;
> 
> The output I get changes to
> 
>     $seen[0] = 2 14 14
>     $seen[1] = 2
>     $seen[2] = 2 2 2

Presumably the (?!) is causing it to carry on trying, so it re-runs
those bits of code after @- has some entries.

Try something more like (completely untested):

my @pats = qw/abc pqr xyx/;
my %seen;
my $re = join '|', map { 
    qr/(\Q$_\E) (?{ $seen{$_} = 1 }) (?!)/x
} @pats;

'__pqr__xyz__pqr__abc__' =~ /$re/;

$, = $\ = "\n"
print keys %seen;

> P.S.  Unrelated regexp question:  if I have a string or regexp in
> a variable $x, and I want to use this variable to write a regexp
> corresponding to 5 repeats of the contents of $x, how do I write
> it? If I wrote /$x{5}/, it would be interpreted by perl as attempting
> to access the value corresponding to key '5' in the hash %x.

Try /(?:$x){5}/.

Ben

-- 
For the last month, a large number of PSNs in the Arpa[Inter-]net have been
reporting symptoms of congestion ... These reports have been accompanied by an
increasing number of user complaints ... As of June,... the Arpanet contained
47 nodes and 63 links. [ftp://rtfm.mit.edu/pub/arpaprob.txt] * ben@morrow.me.uk


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

Date: Mon, 31 May 2004 11:33:43 +0100
From: "Player" <notachance@inhell.com>
Subject: Beginner needs help with script :)
Message-Id: <c9f1m7$meh$1@news6.svr.pol.co.uk>

Hello all

 I am teaching myself perl, with the help of a few texts/tutorials and a
book.
I have installed the latest Activestate perl build ActivePerl 5.8 on my
WindowsXP Pro machine.
Everything seemed to be going alright with the first few scripts, up untill
I did this one.

%grades=();

print "Enter students names (press <CTRL>+D when done): ";
@names = <STDIN>;
chomp @names;
print "\n\n";
print "Enter associated grades (press <CTRL>+D when done): ";
@scores = <STDIN>;

@grades{@names} = @scores

The problem is when I am inside the command prompt window and run the
script, i called it gradehash.pl, it runs fine to the first stdin line were
after I have finished entering the names to go into the @names list, I have
to press <CTRL>+D in order to stop that stdin and the script to go onto the
next line.
By pressing <CTRL>+D alls I get is this  ^D    coming up insteadof it
stopping the stdin and going to run the next line of the script.

Can anyone help me?
Can I only use <CTRL>+D on a linux setup? and if so what is the windows
alternative for what I am trying to do in those lines?

Thanks in advance :)
Player






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

Date: Mon, 31 May 2004 12:53:52 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Beginner needs help with script :)
Message-Id: <2i0hglFhh1agU1@uni-berlin.de>

Player wrote:
> Hello all

Don't post the same question in different messages to multiple newsgroups!

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Mon, 31 May 2004 07:11:45 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Beginner needs help with script :)
Message-Id: <20040531071110.W18263@dishwasher.cs.rpi.edu>

On Mon, 31 May 2004, Player wrote:

> Can anyone help me?
> Can I only use <CTRL>+D on a linux setup? and if so what is the windows
> alternative for what I am trying to do in those lines?

The windows equivalent of CTRL-D is CTRL-Z <enter>

Paul Lalli


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

Date: Mon, 31 May 2004 12:12:53 +0100
From: "Player" <notachance@inhell.com>
Subject: Re: Beginner needs help with script :)
Message-Id: <c9f3vl$dk6$1@newsg2.svr.pol.co.uk>


"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:2i0hglFhh1agU1@uni-berlin.de...
> Player wrote:
> > Hello all
>
> Don't post the same question in different messages to multiple newsgroups!
>
> -- 
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl
>

Its a legitimate question posted in two appropriate news groups.
There is nothing wrong with that what-so-ever, as I am subscribed to both
news groups and the news groups in questions are both there to offer help
and advice on perl.
So what-ever- got up your nose, isn't worth the effort of those few lines
you wrote, because it's only two news groups and both are there to help
people with perl.
So take your bullying tactics else were they are not appreciated here, thank
you very much.
Player




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

Date: Mon, 31 May 2004 12:14:22 +0100
From: "Player" <notachance@inhell.com>
Subject: Re: Beginner needs help with script :)
Message-Id: <c9f42e$oc3$1@news6.svr.pol.co.uk>


"Paul Lalli" <ittyspam@yahoo.com> wrote in message
news:20040531071110.W18263@dishwasher.cs.rpi.edu...
> On Mon, 31 May 2004, Player wrote:
>
> > Can anyone help me?
> > Can I only use <CTRL>+D on a linux setup? and if so what is the windows
> > alternative for what I am trying to do in those lines?
>
> The windows equivalent of CTRL-D is CTRL-Z <enter>
>
> Paul Lalli

Thank Paul I will try that out :)
Regards Player




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

Date: Mon, 31 May 2004 12:21:38 +0100
From: "Player" <notachance@inhell.com>
Subject: Re: Beginner needs help with script :)
Message-Id: <c9f4g2$e34$1@newsg2.svr.pol.co.uk>


"Paul Lalli" <ittyspam@yahoo.com> wrote in message
news:20040531071110.W18263@dishwasher.cs.rpi.edu...
> On Mon, 31 May 2004, Player wrote:
>
> > Can anyone help me?
> > Can I only use <CTRL>+D on a linux setup? and if so what is the windows
> > alternative for what I am trying to do in those lines?
>
> The windows equivalent of CTRL-D is CTRL-Z <enter>
>
> Paul Lalli

No Paul  <CTRL>+Z simply did the same as <CTRL>+D did, only it displayed  ^Z
instead of  ^D
I don't understand this at all lol, as <CTRL>+C sends the sig term to quit
the script ok, but the ctrl+d or ctrl+x simply print ^d and  ^x respectively
on the command console.

Anyone no what I am doing wrong here?
Regards Player




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

Date: Mon, 31 May 2004 07:22:23 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Beginner needs help with script :)
Message-Id: <20040531071959.G18263@dishwasher.cs.rpi.edu>

On Mon, 31 May 2004, Player wrote:

> "Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
> news:2i0hglFhh1agU1@uni-berlin.de...
> > Player wrote:
> > > Hello all
> >
> > Don't post the same question in different messages to multiple newsgroups!
>
> Its a legitimate question posted in two appropriate news groups.

No one's claiming it's not.

> There is nothing wrong with that what-so-ever, as I am subscribed to both
> news groups and the news groups in questions are both there to offer help
> and advice on perl.

No one's opposing that position either.

What Gunnar is telling you is that posting the same question IN TWO
DIFFERENT MESSAGES is rude.  The correct etiquete is to type ONE message,
listing both groups in the Newsgrps: or To: header.  That way, people who
subscribe to both groups don't have to see the same post twice.  Please
learn to follow established Usenet proticol.


> So what-ever- got up your nose, isn't worth the effort of those few lines
> you wrote, because it's only two news groups and both are there to help
> people with perl.
> So take your bullying tactics else were they are not appreciated here, thank
> you very much.


Now *that* was extraordinarily rude, uncalled for, and will likely prevent
many more people from trying to help you in this group.

Good day.


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

Date: Mon, 31 May 2004 13:35:29 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Beginner needs help with script :)
Message-Id: <2i0jupFh6oiiU1@uni-berlin.de>

Player wrote:
> Gunnar Hjalmarsson wrote:
>> Don't post the same question in different messages to multiple
>> newsgroups!
> 
> Its a legitimate question posted in two appropriate news groups.

I did not claim otherwise.

> There is nothing wrong with that what-so-ever, as I am subscribed
> to both news groups and the news groups in questions are both there
> to offer help and advice on perl.

You obviously haven't learned to distinguish between cross-posting and
multi-posting. For good reasons, multi-posting is considered wrong by
the netiquette guidelines.

     http://asg.web.cmu.edu/rfc/rfc1855.html

<rambling snipped>

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Mon, 31 May 2004 12:54:09 +0100
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: Beginner needs help with script :)
Message-Id: <Pine.LNX.4.53.0405311251320.30551@ppepc56.ph.gla.ac.uk>

On Mon, 31 May 2004, Gunnar Hjalmarsson reveals to discerning readers
that:

> Player wrote:
> >
> > Its a legitimate question posted in two appropriate news groups.
>
> I did not claim otherwise.

Seems to me that the subject line already told us as much as we needed
to know about the questioner and its attitude to posting guidelines.

> <rambling snipped>

Indeed!


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

Date: Mon, 31 May 2004 11:06:14 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: Beginner needs help with script :)
Message-Id: <c9f3fv$mme$1@news.simnet.is>

"Player" <notachance@inhell.com> wrote in message
news:c9f1m7$meh$1@news6.svr.pol.co.uk...
> Hello all
>
>  I am teaching myself perl, with the help of a few texts/tutorials and a
> book.
> I have installed the latest Activestate perl build ActivePerl 5.8 on my
> WindowsXP Pro machine.
> Everything seemed to be going alright with the first few scripts, up
untill
> I did this one.
>
> %grades=();
>
> print "Enter students names (press <CTRL>+D when done): ";
> @names = <STDIN>;
> chomp @names;
> print "\n\n";
> print "Enter associated grades (press <CTRL>+D when done): ";
> @scores = <STDIN>;
>
> @grades{@names} = @scores

this tutorial seems to be written for unix-like operating
systems.

on unix CTRL-D is an end of file character. a similar character
on windows is CTRL-Z

this tutorial is just to demonstrate how <> work in a
list context (read whole file). it is dubious technique to use
this for interactive user input.

gnari





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

Date: Mon, 31 May 2004 13:02:39 +0100
From: "Player" <notachance@inhell.com>
Subject: Re: Beginner needs help with script :)
Message-Id: <c9f6sv$v9g$1@newsg4.svr.pol.co.uk>


"Paul Lalli" <ittyspam@yahoo.com> wrote in message
news:20040531071959.G18263@dishwasher.cs.rpi.edu...
> On Mon, 31 May 2004, Player wrote:
>
> > "Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
> > news:2i0hglFhh1agU1@uni-berlin.de...
> > > Player wrote:
> > > > Hello all
> > >
> > > Don't post the same question in different messages to multiple
newsgroups!
> >
> > Its a legitimate question posted in two appropriate news groups.
>
> No one's claiming it's not.
>
> > There is nothing wrong with that what-so-ever, as I am subscribed to
both
> > news groups and the news groups in questions are both there to offer
help
> > and advice on perl.
>
> No one's opposing that position either.
>
> What Gunnar is telling you is that posting the same question IN TWO
> DIFFERENT MESSAGES is rude.  The correct etiquete is to type ONE message,
> listing both groups in the Newsgrps: or To: header.  That way, people who
> subscribe to both groups don't have to see the same post twice.  Please
> learn to follow established Usenet proticol.
>
>
> > So what-ever- got up your nose, isn't worth the effort of those few
lines
> > you wrote, because it's only two news groups and both are there to help
> > people with perl.
> > So take your bullying tactics else were they are not appreciated here,
thank
> > you very much.
>
>
> Now *that* was extraordinarily rude, uncalled for, and will likely prevent
> many more people from trying to help you in this group.
>
> Good day.

No its quit obviously not rude at all.
I don't like being bullied, its as simple that, and as I am new to news
groups in general, I am hardly going to no every single detail of what-ever
bunch of in-house-secret-guidelines people have made up over the years.
A simple, please, "check this url" followed by the url were the rules sit,
would of been enough.
I don't take kindly to people telling me, "DON'T" one something I pay money
to gain access to, especially when those people are not in any position of
authority were my money heads to.

However I can see this from both sides, so as it is my experience that
people communicating online can often misunderstand and not 'GET' peoples
senses of humour or manner via simple text, that is what I going to put this
down to.
As I obviously thought he was being crude and rather bullyish, when it
appears he wasn't.

But in the end I would still say that telling someone 'DON'T in these
circumstances, is asking form trouble.
The appropriate response in most cases to such a statement, would be, "I Beg
your pardon? are some sort of authority figure here?"

Anyways My Regards to you all




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

Date: Mon, 31 May 2004 11:31:28 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: Beginner needs help with script :)
Message-Id: <c9f4v9$mqf$1@news.simnet.is>

"Player" <notachance@inhell.com> wrote in message
news:c9f4g2$e34$1@newsg2.svr.pol.co.uk...
>
> "Paul Lalli" <ittyspam@yahoo.com> wrote in message
> news:20040531071110.W18263@dishwasher.cs.rpi.edu...
> > On Mon, 31 May 2004, Player wrote:
> >
> > > Can anyone help me?
> > > Can I only use <CTRL>+D on a linux setup? and if so what is the
windows
> > > alternative for what I am trying to do in those lines?
> >
> > The windows equivalent of CTRL-D is CTRL-Z <enter>
> >
> > Paul Lalli
>
> No Paul  <CTRL>+Z simply did the same as <CTRL>+D did, only it displayed
^Z
> instead of  ^D
> I don't understand this at all lol, as <CTRL>+C sends the sig term to quit
> the script ok, but the ctrl+d or ctrl+x simply print ^d and  ^x
respectively
> on the command console.
>
> Anyone no what I am doing wrong here?

are you sure the CTRL-Z is the only character in the line?

gnari






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

Date: Mon, 31 May 2004 13:12:00 +0100
From: "Player" <notachance@inhell.com>
Subject: Re: Beginner needs help with script :)
Message-Id: <c9f7eg$s2j$1@news7.svr.pol.co.uk>


"gnari" <gnari@simnet.is> wrote in message
news:c9f4v9$mqf$1@news.simnet.is...
> "Player" <notachance@inhell.com> wrote in message
> news:c9f4g2$e34$1@newsg2.svr.pol.co.uk...
> >
> > "Paul Lalli" <ittyspam@yahoo.com> wrote in message
> > news:20040531071110.W18263@dishwasher.cs.rpi.edu...
> > > On Mon, 31 May 2004, Player wrote:
> > >
> > > > Can anyone help me?
> > > > Can I only use <CTRL>+D on a linux setup? and if so what is the
> windows
> > > > alternative for what I am trying to do in those lines?
> > >
> > > The windows equivalent of CTRL-D is CTRL-Z <enter>
> > >
> > > Paul Lalli
> >
> > No Paul  <CTRL>+Z simply did the same as <CTRL>+D did, only it displayed
> ^Z
> > instead of  ^D
> > I don't understand this at all lol, as <CTRL>+C sends the sig term to
quit
> > the script ok, but the ctrl+d or ctrl+x simply print ^d and  ^x
> respectively
> > on the command console.
> >
> > Anyone no what I am doing wrong here?
>
> are you sure the CTRL-Z is the only character in the line?
>
> gnari
>
>
>
>

Yeah what it is asking is for the reader to to the ctrl+d or ctrl+z to stop
the stdin and go onto the next line.
But when pressing ctrl+d or ctrl+z in the windows xp command console black
window, it simply prints either of these two characters on the command
console window, ^z  ^d

So as yet I haven't a clue as to what I can do to make the script work.
Regards Player




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

Date: Mon, 31 May 2004 12:14:46 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Beginner needs help with script :)
Message-Id: <c9f7jm$63g$1@wisteria.csv.warwick.ac.uk>


Quoth "Player" <notachance@inhell.com>:
> 
> > > "Paul Lalli" <ittyspam@yahoo.com> wrote in message
> > > news:20040531071110.W18263@dishwasher.cs.rpi.edu...
> > > > On Mon, 31 May 2004, Player wrote:
> > > >
> > > > > Can anyone help me?
> > > > > Can I only use <CTRL>+D on a linux setup? and if so what is the
> > windows
> > > > > alternative for what I am trying to do in those lines?
> > > >
> > > > The windows equivalent of CTRL-D is CTRL-Z <enter>
>
> Yeah what it is asking is for the reader to to the ctrl+d or ctrl+z to stop
> the stdin and go onto the next line.
> But when pressing ctrl+d or ctrl+z in the windows xp command console black
> window, it simply prints either of these two characters on the command
> console window, ^z  ^d
> 
> So as yet I haven't a clue as to what I can do to make the script work.

Have you tried pressing <Return> after the ^Z? It is necessary under windows.

Ben

-- 
If I were a butterfly I'd live for a day, / I would be free, just blowing away.
This cruel country has driven me down / Teased me and lied, teased me and lied.
I've only sad stories to tell to this town: / My dreams have withered and died.
  ben@morrow.me.uk                                                 (Kate Rusby)


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

Date: Mon, 31 May 2004 13:43:42 +0100
From: "Player" <notachance@inhell.com>
Subject: Re: Beginner needs help with script :)
Message-Id: <c9f99u$lpv$1@newsg1.svr.pol.co.uk>


"Ben Morrow" <usenet@morrow.me.uk> wrote in message
news:c9f7jm$63g$1@wisteria.csv.warwick.ac.uk...
>
> Quoth "Player" <notachance@inhell.com>:
> >
> > > > "Paul Lalli" <ittyspam@yahoo.com> wrote in message
> > > > news:20040531071110.W18263@dishwasher.cs.rpi.edu...
> > > > > On Mon, 31 May 2004, Player wrote:
> > > > >
> > > > > > Can anyone help me?
> > > > > > Can I only use <CTRL>+D on a linux setup? and if so what is the
> > > windows
> > > > > > alternative for what I am trying to do in those lines?
> > > > >
> > > > > The windows equivalent of CTRL-D is CTRL-Z <enter>
> >
> > Yeah what it is asking is for the reader to to the ctrl+d or ctrl+z to
stop
> > the stdin and go onto the next line.
> > But when pressing ctrl+d or ctrl+z in the windows xp command console
black
> > window, it simply prints either of these two characters on the command
> > console window, ^z  ^d
> >
> > So as yet I haven't a clue as to what I can do to make the script work.
>
> Have you tried pressing <Return> after the ^Z? It is necessary under
windows.
>
> Ben


Yeah still no joy, it just moves onto the next line down, and stays there
waiting for me to type something.
What it doesnt do is what it's supposed to do, which is to print two blank
lines via executing the

print /n/n

line and then print

 "Enter associated grades (press <CTRL>+Z when done"

which is were the user of the script is suppposed to type in the numbers to
go into the list @scores.
It has me vexed :(
Regards Player


> -- 
> If I were a butterfly I'd live for a day, / I would be free, just blowing
away.
> This cruel country has driven me down / Teased me and lied, teased me and
lied.
> I've only sad stories to tell to this town: / My dreams have withered and
died.
>   ben@morrow.me.uk                                                 (Kate
Rusby)




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

Date: Sun, 30 May 2004 22:28:57 -0500
From: "dave h" <daveharney@wi.rr.com>
Subject: Cookies
Message-Id: <7Dxuc.16401$to.3143@twister.rdc-kc.rr.com>

Hi, I'm unable to get cookies working on my IIS 6 Server and IE6 browser.
I'm using the latest version of Active Perl.  I have a "home" page that runs
a perl cgi script that creates a cookie and also tries to read it when the
page is called again.  I have a second page that calls the home page to
simulate a second request for the home page.  I assume that the second time
the page is called the cookie should be present.  The problem is that the
cookie never seems to get created.  Any ideas on what is wrong with either
my approach or the syntax for creating the cookie?

Here is the "Home" page:

<html> <head>
  <meta http-equiv="Content-Type" content="text/html">
         <meta name="hideHeader" content="">
  <title>index</title>
 </head> <body>
  this is a cookie test
  <hr><!--#exec cgi="/perl1/CookieScript.pl" --> <hr>
  <a href="http://localhost/perl1/perlHelper.htm">Another Page</a>
  </body></html>

Here is the "Other" page - it just calls the home page - I assume the second
request for the home page should present the cookie back to the server
script:

<HTML> <HEAD>
  <title>perlHelper</title>
 </HEAD> <body>
  some text<br>
  <a href="http://localhost/perl1/index.shtml">Home Page</a>
 </body></HTML>

And this is the perl script:

#! c:\perl\bin
use CGI qw/:standard/;
use CGI::Cookie;
my $q = new CGI;
my $c = $q->cookie( -name => "foo", -value => "bar", -expires => "+3M");
# create cookie
print $q->header(-type => "text/html", -cookie => $c);           # put
cookie into the header to give to the browser
 %cookies = raw_fetch CGI::Cookie;                           # get cookie
back from browser on subsequent request
  foreach (keys %cookies)
  {     print "$cookies{$_} <br>\n";  }                           # look at
all the cookies - I just get a default cookie
$fooValue = $q->cookie("foo");                                   # another
way to get at foo - never returns the "bar" value
print "fooValue: $fooValue \n";                                      # no
value printed





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

Date: Mon, 31 May 2004 12:40:45 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Cookies
Message-Id: <2i0go2FhhdnrU1@uni-berlin.de>

dave h wrote:
> Any ideas on what is wrong with either my approach or the syntax
> for creating the cookie?

You are trying to set it via SSI. See:

http://groups.google.com/groups?selm=67550059482efeed121446f370a19ac1%40news.teranews.com

The cookie will probably be set if you call the CGI script once
directly from the browser.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Mon, 31 May 2004 07:40:04 -0500
From: "dave h" <daveharney@wi.rr.com>
Subject: Re: Cookies
Message-Id: <THFuc.16423$to.6564@twister.rdc-kc.rr.com>

Hi Gunnar,

Thanks for the insight.  However, the only perl cgi programming I've ever
done is via SSI.  Can you give me a small example of how to call the CGI
script directly from the browser?  Thanks - much appreciated.

Dave H.

"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:2i0go2FhhdnrU1@uni-berlin.de...
> dave h wrote:
> > Any ideas on what is wrong with either my approach or the syntax
> > for creating the cookie?
>
> You are trying to set it via SSI. See:
>
>
http://groups.google.com/groups?selm=67550059482efeed121446f370a19ac1%40news.teranews.com
>
> The cookie will probably be set if you call the CGI script once
> directly from the browser.
>
> -- 
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl
>




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

Date: Mon, 31 May 2004 14:52:19 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Cookies
Message-Id: <2i0oesFg3a8lU1@uni-berlin.de>

[ Please type your reply below the quoted part of the message you are
replying to. ]

dave h wrote:
> Gunnar Hjalmarsson wrote:
>> dave h wrote:
>>> Any ideas on what is wrong with either my approach or the
>>> syntax for creating the cookie?
>> 
>> You are trying to set it via SSI. See:
>> 
>> http://groups.google.com/groups?selm=67550059482efeed121446f370a19ac1%40news.teranews.com
>> 
>> The cookie will probably be set if you call the CGI script once 
>> directly from the browser.
> 
> Thanks for the insight.  However, the only perl cgi programming
> I've ever done is via SSI.  Can you give me a small example of how
> to call the CGI script directly from the browser?

Just type the URL to the CGI script in your browser's address bar. Or
click this link:

     http://localhost/perl1/CookieScript.pl

:)

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: 31 May 2004 01:29:03 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to Extract a Single Quote from a file Using GREP
Message-Id: <c9e1ov$k6l$1@mamenchi.zrz.TU-Berlin.DE>

Walter Roberson <roberson@ibd.nrc-cnrc.gc.ca> wrote in comp.lang.perl.misc:
> In article <e604be8.0405301558.35215bae@posting.google.com>,
> Ben Nguyen <benn686@hotmail.com> wrote:
> :I have some text files that on the 12th line of each file has a sentence 
> :in quotes.
> 
> :Id like to extract the sentence (without the quotes) from all
> :the files and put them into a single new file.
> 
> :Seems like grep is designed for this type of thing, but not exactly sure
> :how to enter it :(
> 
> # untried
> print NEWFILE grep { close ARGV if eof; $. == 12 ? s/^.*"(.*)".*/$1\n/ :
> 0 } (<>)

That won't work for at least two reasons.  One is that s/// changes
$_, but returns a boolean, not the changed value of $_.

> The close of ARGV is needed to reset the $. counter upon EOF of
> each of the individual ARGV files. The $. == 12 tests for line 12.
> The substitute changes the implicit $_ string in place.

$. and the related actions are useless in this kind of loop.  <> in
list context reads all of STDIN in one go, and $. goes to its final
value.  The operations you are trying work in a while-loop:

    while ( <> ) {
        close ARGV if eof;
        next unless $. == 12;
        s/.*"(.*)".*/$1/;
        print;
    }

The substitution lets the linefeed intact (why?).  Your code would have
introduced an extra one.  But it is better to extract the text without
an un-necessary change to $_: 'print "$1\n" if /"(.*)"/' does it in
one step and with less technology.

Anno


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

Date: Mon, 31 May 2004 01:55:14 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: How to Extract a Single Quote from a file Using GREP
Message-Id: <x7n03p8inx.fsf@mail.sysarch.com>

>>>>> "AS" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:

  AS>     while ( <> ) {
  AS>         close ARGV if eof;
  AS>         next unless $. == 12;
  AS>         s/.*"(.*)".*/$1/;
  AS>         print;
  AS>     }

  AS> The substitution lets the linefeed intact (why?).  Your code would have
  AS> introduced an extra one.  But it is better to extract the text without
  AS> an un-necessary change to $_: 'print "$1\n" if /"(.*)"/' does it in
  AS> one step and with less technology.

why do a s/// instead of //? and why loop to eof? if you have read the
12th line close the file

	while ( <> ) {
		next unless $. == 12;
		print /.*"(.*)".*/, "\n" ;
		close ARGV ;
	}

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: 31 May 2004 10:14:04 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to Extract a Single Quote from a file Using GREP
Message-Id: <c9f0hc$7hr$1@mamenchi.zrz.TU-Berlin.DE>

Uri Guttman  <uri@stemsystems.com> wrote in comp.lang.perl.misc:
> >>>>> "AS" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:
> 
>   AS>     while ( <> ) {
>   AS>         close ARGV if eof;
>   AS>         next unless $. == 12;
>   AS>         s/.*"(.*)".*/$1/;
>   AS>         print;
>   AS>     }
> 
>   AS> The substitution lets the linefeed intact (why?).  Your code would have
>   AS> introduced an extra one.  But it is better to extract the text without
>   AS> an un-necessary change to $_: 'print "$1\n" if /"(.*)"/' does it in
>   AS> one step and with less technology.
> 
> why do a s/// instead of //?

I suggested print "$1\n" if /"(.*)"/

>                               and why loop to eof? if you have read the
> 12th line close the file

Yes, nice improvement.

> 	while ( <> ) {
> 		next unless $. == 12;
> 		print /.*"(.*)".*/, "\n" ;

                print /"(.*)"/, "\n" ;

> 		close ARGV ;
> 	}

Anno


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

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


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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

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

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


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


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