[19269] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1464 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 8 11:05:38 2001

Date: Wed, 8 Aug 2001 08:05:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <997283111-v10-i1464@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 8 Aug 2001     Volume: 10 Number: 1464

Today's topics:
    Re: Another string manipulation question <john.imrie@pa.press.net>
        cgi->upload <richard@sunsetandlabrea.com>
    Re: cgi->upload <cpryce@pryce.net>
        Command line parameters under mod_perl <stefan.tillich@siemens.at>
    Re: Command line parameters under mod_perl <tom.melly@ccl.com>
    Re: For loop aliasing?? (Martien Verbruggen)
    Re: getting the name of a sub from a sub ref (Anno Siegel)
    Re: Hash, List, Ref Problem <jasper@guideguide.com>
    Re: Hash, List, Ref Problem <peb@bms.umist.ac.uk>
    Re: Hash, List, Ref Problem <philippe.perrin@sxb.bsf.alcatel.fr>
        How to get Mac and IP address of computers over a netwo (Fred)
    Re: How to get Mac and IP address of computers over a n <paul.johnston@dsvr.co.uk>
    Re: IF $FileArray[$index] CONTAINS..... (Anno Siegel)
        Intermittent problems printing from perl (Zenon Bachir)
    Re: Line counting in a file (Yves Orton)
    Re: Line counting in a file (Anno Siegel)
        manipulating webpages? <nathan.randle@ntlworld.com>
        Not matching strings (Grunge Man)
    Re: Not matching strings <jasper@guideguide.com>
    Re: Not matching strings <jasper@guideguide.com>
    Re: Pattern Matching: Which subpattern (rather than sub <jasper@guideguide.com>
    Re: Pattern Matching: Which subpattern (rather than sub (Martien Verbruggen)
    Re: Perl & Cookies <Thomas@Baetzler.de>
    Re: Perl & Cookies <tom.melly@ccl.com>
    Re: Perl editor for win32 needed (Yves Orton)
    Re: Perl Logical Knot Problem (And web pages that dont  (Yves Orton)
    Re: Print outputs despite no value to print out?? <mjcarman@home.com>
    Re: Q:  csh together with perl (Martien Verbruggen)
        RegEXP's <newsgroup@12mm.de>
    Re: SOAP::Transport and forking servers... how to do it <rich@i-dont-like-spam-annexia.org>
    Re: String manipulation <bart.lateur@skynet.be>
    Re: String version of += assignment operator?? <me@my_no_spam.org>
    Re: System Call Question <bowman@montana.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 8 Aug 2001 15:14:29 +0100
From: John Imrie <john.imrie@pa.press.net>
Subject: Re: Another string manipulation question
Message-Id: <UPbc7.248$t97.2559@news.uk.colt.net>

Paul Fortescue wrote:

> This is without a doubt the longets answer you will get. I await with
> interest the 'right' way to do this, from the experts.
> But this is how C programmers (old ones at that) would do something like
> this ...
> $t="11:00 PM EST";
> $ampm=substr($t, 6, 2);
> $newt=substr($t, 0, 2)+1 ;
> if ($newt==13) {
> $newt=1;
> $ampm="PM";
> }
> if ($newt==12&&($ampm eq "PM")) {
> $newt=0;
> $ampm="AM";
> }
> $u=sprintf ("%02d%03s%s%s\r\n",$newt,substr($t,2,4),$ampm,substr($t,8));
> print "$u\r\n";
> 
> 

A shorter way to do this
$t='11:00 PM EST';
substr($t,0,2)++;
substr($t,6,1) = substr($t,6,1) eq 'A' ? 'P' : 'A'  if substr($t,0,2) >=12;
substr($t,0,2) = '01' if substr($t,0,2) eq '13';

 print "$t\n";


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

Date: Wed, 8 Aug 2001 15:26:41 +0000
From: Richard Chamberlain <richard@sunsetandlabrea.com>
Subject: cgi->upload
Message-Id: <bRbc7.1135$tq.177308@news6-win.server.ntlworld.com>

Hi,

I'm a perl newbie and I'm having tremendous difficulties getting ->upload 
to work using CGI.pm.

from what I can tell i just need to do:

$file=q->param('file');
$fh=q->upload($file);

the last statement returns false, i.e. if I do:

if ($fh=q->upload($file)) {
        # do something or other
}

the do something or other never occurs

Also what I'm uploading is a simple text file, whats the easiest way to get 
the contents into another variable.

Any hints would be great,

Thanks,

Richard


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

Date: Wed, 8 Aug 2001 09:54:52 -0500
From: "cp" <cpryce@pryce.net>
Subject: Re: cgi->upload
Message-Id: <Smcc7.3818$x84.979407@ruti.visi.com>


"Richard Chamberlain" <richard@sunsetandlabrea.com> wrote in message
news:bRbc7.1135$tq.177308@news6-win.server.ntlworld.com...
> Hi,
>
> I'm a perl newbie and I'm having tremendous difficulties getting ->upload
> to work using CGI.pm.
>
> from what I can tell i just need to do:
>
> $file=q->param('file');
> $fh=q->upload($file);
>
> the last statement returns false, i.e. if I do:
>
> if ($fh=q->upload($file)) {
>         # do something or other
> }

1) remember to use start_multipart_form instead of start_form.

2) the $q->upload function is new as of CGI.pm 2.47. If you have an older
version of the module, that function is not available. Using warnings will
alert you to that.

3) the correct syntax, if 'file' is the name of your file upload field,
according to the Docs is:

$fh = $q->upload('file')
while (<$fh>) {
    # do something or other
}

http://stein.cshl.org/WWW/software/CGI/cgi_docs.html#forms
for more info

cp




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

Date: Wed, 08 Aug 2001 15:09:47 +0200
From: Stefan Tillich <stefan.tillich@siemens.at>
Subject: Command line parameters under mod_perl
Message-Id: <3B713A1B.4F2AE221@siemens.at>

I'm trying to read in the parameters passes to a perl-script using
@ARVG. The parameters are passes in the URL: e.g.
http://www.someplace.com/cgi-bin/script.perl-cgi?param1+param2+param3

The script is run under mod_perl on the apache webserver and the
parameters are not passes to @ARGV.

Is there some other way to access them?

Steve



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

Date: Wed, 8 Aug 2001 14:36:50 +0100
From: "Tom Melly" <tom.melly@ccl.com>
Subject: Re: Command line parameters under mod_perl
Message-Id: <3b714072$0$3761$ed9e5944@reading.news.pipex.net>


"Stefan Tillich" <stefan.tillich@siemens.at> wrote in message
news:3B713A1B.4F2AE221@siemens.at...
> I'm trying to read in the parameters passes to a perl-script using
> @ARVG. The parameters are passes in the URL: e.g.
> http://www.someplace.com/cgi-bin/script.perl-cgi?param1+param2+param3
>
> The script is run under mod_perl on the apache webserver and the
> parameters are not passes to @ARGV.
>
> Is there some other way to access them?
>

Well, assuming your problem isn't that you're REALLY trying to read from
@ARVG...

It looks as though you are trying to read params as you would running the perl
script from the command line.

For cgi, the format is:
http://cgi.barfoo.co.uk/cgi-bin/demo.cgi?foo=bar

i.e. the cgi param foo has a value bar.

You then need to read these values into conventional perl vars - e.g.

use CGI qw(:standard);
$foo = param("foo"); # $foo now equals "bar"




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

Date: Wed, 8 Aug 2001 23:19:02 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: For loop aliasing??
Message-Id: <slrn9n2f25.cq.mgjv@martien.heliotrope.home>

[Please, in the future, put your reply _after_ the suitably trimmed text
you reply to. It's the generally accepted convention on this newsgroup,
and Usenet in general]

On Wed, 8 Aug 2001 00:44:17 -0500,
	Aether <aether@centurytel.net> wrote:

[reorganised and trimmed post]

> Carlos C. Gonzalez <miscellaneousemail@yahoo.com> wrote in message
> news:MPG.15da70323bf95606989717@news.edmonton.telusplanet.net...
>>
>> Given the code snippet below...
>>
>> for ($string) {
>>   s/^\s+//; # ^ anchor to beginning, \s space, + multiple spaces, replace
>> with nothing.
>>   s/\s+$//; # $ anchor to end, replace with nothing.
>> }

>> What I don't understand is the aliasing that is occuring inside the for
>> loop.  Does the scalar $string get assigned to the $_ implied variable
>> and then does this $_ variable become the target of each regular
>> expression?
>>
> Yes $string gets assigned to $_.

Not true. $_ becomes an _alias_ for $string. Different thing, especially
when you modify $_.

>                                  If there were multiple iterations of the
> loop (like a for each) the same would happen for each value.

In Perl, for and foreach are the same thing.

> One difference between this version and yours is that the "loop" does not
> alter the value of $string. It assigns it to $_ and modifies that. Of
> course, this code does nothing with $_ so the loop does nothing.

Huh?

Did you try it?

$ perl -wl
$string = "   fooo    ";
for ($string) { s/^\s+//; s/\s+$//; }
print "'$string'"
__END__
'fooo'

$  perl -wl
$string = "   fooo    ";
$string =~ s/^\s+//;
$string =~ s/\s+$//;
print "'$string'"
__END__
'fooo'

Identical result.

>> Can someone recommend a good link somewhere on aliasing and what happens
>> and when underneath code like above.  I have been looking and reading and
>> searching and searching but it's like looking for a needle in a haystack.
>>
> I don't have a link for you but a suggestion. Sams Teach Yourself Perl. It's
> a little basic and doesn't spend much time on modules, but it covers the
> fundamentals nicely. Worth a read.

I have a link for the OP, and for you:

The perlsyn documentation talks explicitly about the aliasing behaviour
of for (and foreach, and that they're the same). 

The Perl FAQ, section 4 contains a question about how to strip blank
space from the start and end of a string, which contains the exact code
the OP was presenting, and it probably came from there.

Both pieces of documentation should be installed wherever Perl is
installed.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Never hire a poor lawyer. Never buy
Commercial Dynamics Pty. Ltd.   | from a rich salesperson.
NSW, Australia                  | 


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

Date: 8 Aug 2001 13:31:53 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: getting the name of a sub from a sub ref
Message-Id: <9krf09$b6j$1@mamenchi.zrz.TU-Berlin.DE>

According to John Imrie  <john.imrie@pa.press.net>:
> is it possible to extract the name of the subrouteen pointed to by a sub ref

In general, no.  It may not have one (an anonymous sub) or it may have
more than one (exported subroutines frequently do).  You could probably
do an exhaustive search of all symbol tables and see what you come up
with, but that's hardly worth the effort.

If the subroutine is currently running, caller(0) gives you the name it
was called as, if there is one.

Anno


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

Date: Wed, 08 Aug 2001 14:30:16 +0100
From: Jasper McCrea <jasper@guideguide.com>
Subject: Re: Hash, List, Ref Problem
Message-Id: <3B713EE8.1DB975D1@guideguide.com>

Philippe PERRIN wrote:
> 
> So why does the following NOT work ?
> 
> @list = (1, 2);
> %h = (10 => \@list);
> ($a, $b) = @$h{10};
> print "[$a] [$b]\n"; # I get [] [] ==> :-(
> 

use strict;

and all will be revealed. (as usual).

Jasper
-- 
      split//,'019617511192'.
      '17011111610114101114'.
      '21011141011840799901'.
            '17101174';
            foreach(0..
            $#_){$_[$_
            ++]^=$_[$_
            --]^=$_[$_
]^=$_[++    $_]if!($_%
2)}$g.=$_  ,chr($g)=~
 /(\w)/&&($o.=$1and
   $g='')foreach@_;
      print"$o\n"


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

Date: Wed, 08 Aug 2001 14:43:01 +0100
From: Paul Boardman <peb@bms.umist.ac.uk>
Subject: Re: Hash, List, Ref Problem
Message-Id: <3B7141E5.FDC1371D@bms.umist.ac.uk>

Philippe PERRIN wrote:
> 
> Hi
> 
> Here's a summary of my problem...
> 
> @list = (1, 2);
> %h = (10 => \@list);
> $refList = $h{10};
> ($a, $b) = @$refList;
> print "[$a] [$b]\n"; # I get [1] [2] ==> OK
> 
> So why does the following NOT work ?
> 
> @list = (1, 2);
> %h = (10 => \@list);
> ($a, $b) = @$h{10};
> print "[$a] [$b]\n"; # I get [] [] ==> :-(

try putting 'curlies' around the array ref to let Perl know precisely what you're up to.

i.e. ($a, $b) = @{ $h{10} };

This should correct the problem.

HTH

Paul


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

Date: Wed, 08 Aug 2001 16:43:49 +0200
From: Philippe PERRIN <philippe.perrin@sxb.bsf.alcatel.fr>
Subject: Re: Hash, List, Ref Problem
Message-Id: <3B715025.6A062C6@sxb.bsf.alcatel.fr>

Paul Boardman wrote:
> try putting 'curlies' around the array ref to let Perl know precisely what you're up to.
> 
> i.e. ($a, $b) = @{ $h{10} };

Works fine, thnx. I tried with @(), but didn't think of @{}.

-- 
PhP


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

Date: 8 Aug 2001 07:02:27 -0700
From: flichtenfels@hotmail.com (Fred)
Subject: How to get Mac and IP address of computers over a network?
Message-Id: <88a56672.0108080602.7bc2e273@posting.google.com>

Hello all,

I am trying to get Mac and IP addresses of every computer on a
network.  Does anyone have any ideas on how to do this?

Thanks,
Fred


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

Date: Wed, 08 Aug 2001 15:27:41 +0100
From: Paul Johnston <paul.johnston@dsvr.co.uk>
Subject: Re: How to get Mac and IP address of computers over a network?
Message-Id: <3B714C5D.92BA476C@dsvr.co.uk>

Hi,

> I am trying to get Mac and IP addresses of every computer on a
> network.  Does anyone have any ideas on how to do this?

Use nmap in sweep ping mode to ping everything, e.g. nmap -sP
212.1.128.0/24
Then dump the ARP table, on most Unices just type arp
Then (bringing this back on-topic) use perl to parse the results :-)

Paul


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

Date: 8 Aug 2001 14:22:31 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: IF $FileArray[$index] CONTAINS.....
Message-Id: <9krhv7$fv3$1@mamenchi.zrz.TU-Berlin.DE>

According to Paul Fortescue <paul@net366.com>:
> Nice one Mike.
> 
> I am VERY new to Perl, I only learnt it last weekend :) with a LOT of help
> from Ilya Martynov who is great.
> 
> I hope my answers, naive as they are, will help other newbies because that
> is where I'm coming from. I am trying to put something back into the
> newsgroup which helped me.
> 
> Let me know if I should hide until I am much better!

Nah, that's fine.  As long as you don't post misleading code, or
baseless conjecture, you're welcome.  Test your code, or say so
if you don't for some reason.

But if you want to play, please trim the quoted material and place
your replies after the text you are referring to.  The top-posting
style you have practiced is frowned upon in large parts of Usenet.

The grep-solution you posted to the OPs request isn't at all bad.

You wrote:

> $x[0]="fred";
> $x[1]="bert";
> $x[2]="freddie";

In Perl you rarely need to refer to array elements through their
indexes.  Just

  @x = qw( fred bert freddie);

would have done.
 
> @y=grep(m/fred/, @x);

That's the spirit.  Deal with an array as one unit wherever possible.

> print "@y\r\n";

Why do you explicitly print the "\r\n" combo?  "\n" usually prints
the kind of linefeed your system requires.

Anno


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

Date: 8 Aug 2001 07:38:01 -0700
From: bachirz@war.wyeth.com (Zenon Bachir)
Subject: Intermittent problems printing from perl
Message-Id: <79c2b111.0108080638.5c2c44cb@posting.google.com>

Hello,
 
I am getting an intermittent problem trying to print a postscript
file. I have a perl batch program which runs automatically from a
scheduler. It logs onto our Oracle database and checks a queue for
pending jobs. It then calls our report generator (SQR) which creates a
postscript file. It tries to print the file using the &#8216;lp&#8217;
command. If all goes well it removes the job from the queue.

It seems that sometimes (30% of the time) the file does not print!
There is no error. It just quietly goes on its way. The postscript
file looks OK. I can view/print it with no problems.

Is it possible that the postscript file does not yet exist when we try
to print? Is checking for the return from &#8216;system&#8217; enough
to detect any problems that occurred?

Any help would be appreciated.

Zenon Bachir


Here is the snippet that prints:

   # use the sqr report tool to print a postscript report with
barcodes
   # $outFile contains the name of the postscript file
   $sqrString = 'sqr ' . $SQR_REPORT_DIRECTORY . 'request.sqr ' .
$ORACLE_SQR_USER . '@' .
                $DB_MACHINE . ' ' . $requestId . ' ' . $cpdRoomId . '
-e -PRINTER:PS -F' . $outFile . ' -E' . $errFile;
   $sysRet = system($sqrString);

   # if the report has completed correctly then print it
   if ($sysRet == 0) {
      $printerQueue = get_printer ($cpdRoomId); # this is a local
function
      if ($printerQueue eq "") {
         # process_error is my routine that sends out e-mail if an
error occured
         process_error "Invalid printer: $printerQueue for Compound
Room $cpdRoomId \n";
         die;
      }

      $sqrString = 'lp -d ' . $printerQueue . ' '. $outFile;
      print "PRINTING... ". $printerCommand . "\n";
      
	sleep 2; # desperation
	$sysRet = system($printerCommand);
  }
 
   if ($sysRet == 0) {
      ##################################################################
      # remove the report from the job queue
      ##################################################################
      $csr = $dbh->prepare(q{
         BEGIN
            GCIS.JOBS_API.REMOVE(:job_id);
         END;
      });
      $csr->bind_param(":job_id", $jobId);

      $csr->execute;
      if ($DBI::err){
         print "Could not remove job: $DBI::err --- $DBI::errstr \n";
      }
      else {
         print "REMOVED FROM QUEUE... job_id = $jobId \n";
      }
   }
   else {
         process_error "ERROR could not print report $sysRet: $! \n";
   }


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

Date: 8 Aug 2001 06:30:17 -0700
From: demerphq@hotmail.com (Yves Orton)
Subject: Re: Line counting in a file
Message-Id: <74f348f7.0108080530.5175022c@posting.google.com>

anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message news:<9kqrk4$pth$1@mamenchi.zrz.TU-Berlin.DE>...
> According to Yves Orton <demerphq@hotmail.com>:
> > anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message
> > news:<9kos74$fjn$2@mamenchi.zrz.TU-Berlin.DE>...
> > > According to John Imrie  <john.imrie@pa.press.net>:

SNIP

> > Just curious as to why even bother with lines.
> > 
> > select FILE;
> 
> Select doesn't do what you think it does.  It only influences output.
> 
> > while (<>) {}
> > print $.;
> > 
> > Doesnt that work as well?
> 
> What happened when you tried it?
> 
> Anno

It printed out the correct number of lines.  Is there a point there
anno? :-)

As for the select, I somehow thought that to get $. to refer to
correct filehandle you had to select().  Upon RTM I realize I was
wrong, all you have to do is read() or equiv. Sorry.

Anyway try this

my $lines=0;
open (IN,$0) || die $!;
while (<IN>) {$lines++};
print "$.\t$lines\n";

When I run it it prints out the same number twice, so why other with
$lines?

Yves


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

Date: 8 Aug 2001 14:42:23 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Line counting in a file
Message-Id: <9krj4f$gq6$1@mamenchi.zrz.TU-Berlin.DE>

According to Yves Orton <demerphq@hotmail.com>:
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message
> news:<9kqrk4$pth$1@mamenchi.zrz.TU-Berlin.DE>...
> > According to Yves Orton <demerphq@hotmail.com>:
> > > anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message
> > > news:<9kos74$fjn$2@mamenchi.zrz.TU-Berlin.DE>...
> > > > According to John Imrie  <john.imrie@pa.press.net>:
> 
> SNIP
> 
> > > Just curious as to why even bother with lines.
> > > 
> > > select FILE;
> > 
> > Select doesn't do what you think it does.  It only influences output.
> > 
> > > while (<>) {}
> > > print $.;
> > > 
> > > Doesnt that work as well?
> > 
> > What happened when you tried it?
> > 
> > Anno
> 
> It printed out the correct number of lines.  Is there a point there
> anno? :-)

Yes.  It didn't print anything, most likely print failed.  If it could,
it would print the total of lines in the files mentioned on the command
line, or count lines from STDIN.  Unless FILE happens to be opened to
one of these, the count printed has nothing to do with the number of
lines in FILE.

Apparently you didn't try the code you posted.

Anno


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

Date: Wed, 8 Aug 2001 15:52:04 +0100
From: "Nathan Randle" <nathan.randle@ntlworld.com>
Subject: manipulating webpages?
Message-Id: <Nncc7.3586$e%3.324969@news2-win.server.ntlworld.com>

How do you get a script to perform diffferent actions depending on the links
found on a webpage then follow certain links?




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

Date: 8 Aug 2001 07:05:49 -0700
From: grunge12345@hotmail.com (Grunge Man)
Subject: Not matching strings
Message-Id: <8371f728.0108080605.d70a951@posting.google.com>

Is there are method of not matching a pattern in an entire
line without using !~

if ($string =~ /^(?:(?!PAT)|.)*$/) {
   print "hi\n";
}

will print hi whenever PAT doesn't occur anywhere in the string,
but it also fails for lines like "asdfPATzxcv".

i.e. Is there a way of doing:

if ($string !~ /^PAT$/) {
   print "hi\n";
}

but using =~ instead of !~

Regards
G


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

Date: Wed, 08 Aug 2001 15:15:58 +0100
From: Jasper McCrea <jasper@guideguide.com>
Subject: Re: Not matching strings
Message-Id: <3B71499E.EB421ECD@guideguide.com>

Grunge Man wrote:
> 
> Is there are method of not matching a pattern in an entire
> line without using !~
> 
> if ($string =~ /^(?:(?!PAT)|.)*$/) {
>    print "hi\n";
> }
> 
> will print hi whenever PAT doesn't occur anywhere in the string,
> but it also fails for lines like "asdfPATzxcv".
> 
> i.e. Is there a way of doing:
> 
> if ($string !~ /^PAT$/) {
>    print "hi\n";
> }
> 
> but using =~ instead of !~
> 
> Regards
> G

it would seem you want the ne (not equal, but for strings) operator.

i.e

print "hi\n" if $string ne 'PAT';

Jasper
-- 
      split//,'019617511192'.
      '17011111610114101114'.
      '21011141011840799901'.
            '17101174';
            foreach(0..
            $#_){$_[$_
            ++]^=$_[$_
            --]^=$_[$_
]^=$_[++    $_]if!($_%
2)}$g.=$_  ,chr($g)=~
 /(\w)/&&($o.=$1and
   $g='')foreach@_;
      print"$o\n"


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

Date: Wed, 08 Aug 2001 15:17:44 +0100
From: Jasper McCrea <jasper@guideguide.com>
Subject: Re: Not matching strings
Message-Id: <3B714A08.BC2C7D5E@guideguide.com>

Jasper McCrea wrote:
> 
> Grunge Man wrote:
> >
> > Is there are method of not matching a pattern in an entire
> > line without using !~
> >
> > if ($string =~ /^(?:(?!PAT)|.)*$/) {
> >    print "hi\n";
> > }
> >
> > will print hi whenever PAT doesn't occur anywhere in the string,
> > but it also fails for lines like "asdfPATzxcv".
> >
> > i.e. Is there a way of doing:
> >
> > if ($string !~ /^PAT$/) {
> >    print "hi\n";
> > }
> >
> > but using =~ instead of !~
> >
> > Regards
> > G

sorry, didn't really read that. If you're determinded to use =~, use
unless

print "hi\n" unless $string =~ /^PAT$/;

Jasper
-- 
      split//,'019617511192'.
      '17011111610114101114'.
      '21011141011840799901'.
            '17101174';
            foreach(0..
            $#_){$_[$_
            ++]^=$_[$_
            --]^=$_[$_
]^=$_[++    $_]if!($_%
2)}$g.=$_  ,chr($g)=~
 /(\w)/&&($o.=$1and
   $g='')foreach@_;
      print"$o\n"


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

Date: Wed, 08 Aug 2001 14:32:03 +0100
From: Jasper McCrea <jasper@guideguide.com>
Subject: Re: Pattern Matching: Which subpattern (rather than substring) was   matched?
Message-Id: <3B713F53.51F4BF53@guideguide.com>

Martien Verbruggen wrote:
> 
> On Wed, 08 Aug 2001 03:01:18 +0100,
>         Simon Best <barsticus@earthling.net> wrote:
> > "John W. Krahn" wrote:
> >>
> >> print "Matched pattern number $#-\n"
> >> # OR
> >> print "Matched pattern number $#+\n"
> >
> > Thanks, but @- and @+ don't seem to exist!  Perhaps it's 'cause I'm
> > using Perl 5.005_03?
> 
> Indeed.
> 
> Martien

Is this also the reason I can't find an 'any' key?

Jasper
-- 
      split//,'019617511192'.
      '17011111610114101114'.
      '21011141011840799901'.
            '17101174';
            foreach(0..
            $#_){$_[$_
            ++]^=$_[$_
            --]^=$_[$_
]^=$_[++    $_]if!($_%
2)}$g.=$_  ,chr($g)=~
 /(\w)/&&($o.=$1and
   $g='')foreach@_;
      print"$o\n"


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

Date: Wed, 8 Aug 2001 23:23:08 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Pattern Matching: Which subpattern (rather than substring) was  matched?
Message-Id: <slrn9n2f9s.cq.mgjv@martien.heliotrope.home>

On Wed, 08 Aug 2001 03:01:18 +0100,
	Simon Best <barsticus@earthling.net> wrote:
> "John W. Krahn" wrote:
>> 
>> print "Matched pattern number $#-\n"
>> # OR
>> print "Matched pattern number $#+\n"
> 
> Thanks, but @- and @+ don't seem to exist!  Perhaps it's 'cause I'm
> using Perl 5.005_03?

Indeed.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Failure is not an option. It comes
Commercial Dynamics Pty. Ltd.   | bundled with your Microsoft product.
NSW, Australia                  | 


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

Date: Wed, 08 Aug 2001 15:10:58 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: Perl & Cookies
Message-Id: <5ie2nto5btvbp7uc1ouqqpv2ke3rujfd7o@4ax.com>

On Wed, 8 Aug 2001, "Jeff Snoxell" <Jeff@aetherweb.co.uk> wrote:
>How can I use perl/cgi to get and set cookies (all from one domain name)
[...]

perldoc CGI
perldoc CGI::Cookie

HTH,
-- 
Thomas Baetzler - http://baetzler.de/ - Clan LoL - http://lavabackflips.de/
I am the "ILOVEGNU" signature virus. Just copy me to your signature.
This post was infected under the terms of the GNU General Public License.


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

Date: Wed, 8 Aug 2001 14:44:54 +0100
From: "Tom Melly" <tom.melly@ccl.com>
Subject: Re: Perl & Cookies
Message-Id: <3b714256$0$3761$ed9e5944@reading.news.pipex.net>

"Jeff Snoxell" <Jeff@aetherweb.co.uk> wrote in message
news:9krbfb$sol$1@neptunium.btinternet.com...
> Hi,
>
> How can I use perl/cgi to get and set cookies (all from one domain name)
> which can be read from various pages within my domain. I've read, in the
> unofficial cookie FAQ here...http://www.cookiecentral.com/faq/#3.2, that
> cookies are stored on a per document basis, and only that document can
> access the cookie again....

Hmm, it would seem to say rather the opposite:

"This header entry would result in a cookie named foo. The value of foo is bar.
In addition, this cookie has a path of /, meaning that it is valid for the
entire site, and it has an expiration date of Dec 9, 2002 at 1:46pm Greenwich
Mean Time (or Universal Time). Provided the browser can understand this header,
the cookie will be set. "

In other words, set path to / and the cookie should be valid for the entire
site.

If you don't specify path, then the cookie path is set to the document url.





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

Date: 8 Aug 2001 06:15:17 -0700
From: demerphq@hotmail.com (Yves Orton)
Subject: Re: Perl editor for win32 needed
Message-Id: <74f348f7.0108080515.ec95136@posting.google.com>

Michael Carman <mjcarman@home.com> wrote in message news:<3B702868.71D199B0@home.com>...
> Trevor Ward wrote:
> > 
> > "Yves Orton" <demerphq@hotmail.com> wrote in message
> > news:74f348f7.0108070654.39665b57@posting.google.com...
> > >
> > > "Trevor Ward" <tward10@jaguar.com> wrote in message
>  news:<9kof9q$3ff13@eccws12.dearborn.ford.com>...

SNIP

> > Are but I bet we would like your new perl editor file
> > (PLEASEEEEEEEEEEEE).
> 
> This whole thread is horribly off-topic, but here's the Perl entry from
> my UE wordfile. Hopefully the line wrapping doesn't screw it up too
> badly.

Likewise: (And if someone has a place I can upload it then gladly:)

/L1"Perl" Line Comment = # Escape Char = \ String Chars = "' File
Extensions = CGI PL PM PMS PLF PMF PLS PMBAK PLBAK
/Delimiters = ~!^&*()+-=|\/{}[];"'<> 	,.?/
/Indent Strings = "{"
/Unindent Strings = "}"
/Function String = "%[ ^t]++sub[ ^t]+^([a-z_]+[a-z_0-9]++^)[ {^p(^t]"
/C1"Keywords"
-A -B -C -M -O -R -S -T -W -X -b -c -d -e -f -g -k -l -o -p -r -s -t
-u -w -x -z
continue
do
else elsif exit
for foreach
goto
if
last local
my
next no
our
redo return
sub
until unless
wantarray while
/C2"Functions"
accept alarm atan2
bind binmode bless
caller chdir chmod chomp chop chown chr chroot close closedir connect
cos crypt
dbmclose dbmopen defined delete dump
each endgrent endhostent endnetent endprotoent endpwent endservent eof
eval exec exp exists
fcntl fileno flock fork formline format
getc getgrent getgrgid getgrname gethostbyaddr gethostbyname
gethostent getlogin getnetbyaddr getnetbyname getnetent getpeername
getpgrp getppid getpriority getprotobyname getprotobynumber
getprotoent getpwent getpwnam getpwuid getservbyname getservbyport
getservent getsockname getsockopt glob gmtime grep
hex
index int ioctl
join
keys kill
lc lcfirst length link listen localtime log lstat
map mkdir msgctl msgget msgrcv msgsnd
oct open opendir ord
pack pipe pop pos print printf push
rand read readdir readline readlink recv ref rename reset reverse
rewinddir rindex rmdir
scalar seek seekdir select semctl semgett semop send setgrent
sethostent setnetent setpgrp setpriority setprotoent setpwent
setservent setsockopt shift shmctl shmget shmread shmwrite shutdown
sin sleep socket socketpair sort splice split sprintf sqrt srand stat
study substr symlink syscall sysopen sysread system syswrite
tell telldir tie tied time times truncate
uc ucfirst umask undef unlink unpack unshift utime
values vec
wait waitpid write
/C3"Magic Tied Pragma Package"
AUTOLOAD
BEGIN
CLEAR CORE
DELETE DESTROY
END EXISTS
FETCH FETCHSIZE FIRSTKEY
NEXTKEY
POP PUSH
SHIFT SPLICE STORE STORESIZE SUPER
TIEARRAY TIEHASH TIESCALAR
UNIVERSAL UNSHIFT
__DATA__ __END__ __FILE__ __LINE__ __PACKAGE__
attributes attrs autouse
base blib bytes
charnames constant 
diagnostics
fields filetest
integer
less lib locale
open ops overload
package perllocal 
re require
sigtrap strict subs
utf8 use
vars
warnings
/C4"Operators"
and
eq
ge gt
le lt
ne not
or
x xor
+ ++
- ->
*
/
!
< <= <=> 
> >= 
= => =~
| ||
& &&
^
~
m
q qq qw qx quotemeta
s
tr
y
/C5"Debugging Words"
warn
die
carp croak cluck confess
/C6"Scalars"
** $
/C7"Arrays"
** @
/C8"Hashes"
** %


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

Date: 8 Aug 2001 06:08:31 -0700
From: demerphq@hotmail.com (Yves Orton)
Subject: Re: Perl Logical Knot Problem (And web pages that dont work outside of NA)
Message-Id: <74f348f7.0108080508.74744316@posting.google.com>

"Stephen Harris" <stephen.p.harris@worldnet.att.net> wrote in message news:<br0c7.7069$1p1.568874@bgtnsc04-news.ops.worldnet.att.net>...
> "Yves Orton" <demerphq@hotmail.com> wrote in message
> news:74f348f7.0108070205.25f906d9@posting.google.com...
> > Andras Malatinszky <andras@mortgagestats.com> wrote in message
>  news:<3B6F70C3.46EA410C@mortgagestats.com>...
> >
> > Exactly.  If I try to buy a product or use a site that has this type
> > of N.A.  arrogance then they dont get my business.
> >
> > Its amazing the number of sites that dont understand
> > internationalization issues.
> >
> > Yves
> 
> This is not a commercial site but a piddly guestbook. Those fields
> are optional for everyone. I have an indirect reason for those
> fields which has to do with a US encrytpion software policy. I'm
> sorry, I could tell you what that policy is, but then I would have
> to kill you(which is inefficient)! People in the US have started
> poking fun at this line which has become a spy movie cliche.
> I thought I would explain that line just in case it hasn't become
> popular in Europe, though that tends to spoil the humor.

Originally I am from Toronto so I know the line line :-)

On the other hand, might not be safe making judgements about
encryption policies between the EU and the US.  Basically the US has
laws that say you cant use encryption that the US cant crack, the EU
on the other hand has a recommendation that states that European
Corporations SHOULD use encryption the US cant crack.  They got a bit
pissed off about Echelon being used to spy on European Corporate
information and then passed on to US companies. Not to mention the
fact that no one in the US intelligence community would talk to them
about it.

So basically Europe allows and encourages the use of much more
sophisticated stuff than the US legally permits.

Oh well, just another reson not to join the empire.

:-)

Yves
ps Sometimes the best way to disarm sarcasm is to take it seriously.
:-)


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

Date: Wed, 08 Aug 2001 08:50:39 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Print outputs despite no value to print out??
Message-Id: <3B7143AF.BBB4722B@home.com>

Craig Berry wrote:
> 
> Michael Carman <mjcarman@home.com> wrote in
> news:3B70447B.5E6D6BBC@home.com:
> 
> > With nothing else in the sub, the return value becomes @_. That
> > is, it returns whatever you passed in.
> 
> Is this behavior documented anywhere?  I can't seem to find it.
> Certainly makes sense as a default, just curious if it's documented.

Not that I can find. Admittedly, it was really more of an educated guess
backed by a little experimentation than anything else.

The only thing running with -MO=Deparse revealed is that this:

sub test {}

gets turned into this:

sub test { () }

which is just for context.

Upon further experimentation, I'm less certain about my statement:

#!/usr/local/bin/perl

@x = test(1, 2, 3);
$x = test(1, 2, 3);

print "\@: [@x]\n";
print "\$: [$x]\n";

sub test {}
__END__
@: [1 2 3]
$: []

If there really is an implicit return value of @_ for an empty sub, I
would have expected to get "$: [3]" above.

The only hint I've been able to find is in the prototype section of
perlsub [the try/catch example] where an aside says 'Yes, there are
still unresolved issues having to do with the visibility of "@_".' Not
particularly enlightening. It looks like this behavior is more
side-effect than design, though I still wouldn't call it a bug.

Anyone with knowledge of the internals care to comment?

-mjc


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

Date: Wed, 8 Aug 2001 23:54:35 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Q:  csh together with perl
Message-Id: <slrn9n2h4r.cq.mgjv@martien.heliotrope.home>

[Superseded because of dumb typo error]

On 8 Aug 2001 03:01:39 -0700,
	wade <jjchen@alumni.ice.ntnu.edu.tw> wrote:
> Rainer Theuer <Rainer.Theuer@sci-worx.com> wrote in message news:<3B67E68F.33004255@sci-worx.com>...
>> #!/bin/csh -f
>> 
>>  setenv new $2
>>  setenv old $1
>>  setenv  files $3
> 
> I tried, it run well..
> or you can try this:
> #!/bin/sh
> export new $2
> export old $1
> export files $3
> .....

\begin{offtopic}

If you really mean /bin/sh, then you better make this portable to
systems where that isn't really bash or somthing like that:

new=$2; export new

etc.

\end{offtopic}

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Little girls, like butterflies, need
Commercial Dynamics Pty. Ltd.   | no excuse - Lazarus Long
NSW, Australia                  | 


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

Date: Wed, 8 Aug 2001 16:50:30 -0800
From: "Adrian Immler" <newsgroup@12mm.de>
Subject: RegEXP's
Message-Id: <9krjeu$64vma$1@ID-17302.news.dfncis.de>

let's say i've got a string like this:

$string = 'this is my great <b>string</b> with lots of <a
href="http://www.foo-bar.com/index.php?action=listall&user=foo">links</a> in
it to some place on the net.';

is it possible to create an array with RegEXP's that looks like this? :

$array[0] = 'this';
$array[1] = 'is';
$array[2] = 'my';
$array[3] = 'great';
$array[4] = '<b>';
$array[5] = 'string';
$array[6] = '</b>';
$array[7] = 'with';
 ...
$array[n] = '<a
href="http://www.foo-bar.com/index.php?action=listall&user=foo">';
$array[n] = 'links';
 ....


i've got the problems with that it should not break it up at spaces within
<>.

question1: how is the performance if the string got a lenngth of lets say
5000 signs !?

question2: can someone tell me that regexp?

note: i'm usually from php, but it is also possible to use RegEXP's in
there, if someone got an idea of doing this without regexps or some notes
for use with PHP please also let me know.

thanks






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

Date: Wed, 8 Aug 2001 13:44:45 +0100
From: "Richard Jones" <rich@i-dont-like-spam-annexia.org>
Subject: Re: SOAP::Transport and forking servers... how to do it?
Message-Id: <t7crk9.5j.ln@www.bibliotech.net>

landman@delete_this_part_of_the_address.mediaone.net wrote:
[...]

Have you looked at the Net::Server module on CPAN?

Rich.

-- 
Richard Jones <rich@annexia.org>         http://www.annexia.org/


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

Date: Wed, 08 Aug 2001 14:43:52 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: String manipulation
Message-Id: <ldj2nto6nnpfapn28as6fl5gb04ub5qe65@4ax.com>

Brent Dax wrote:

>    push @dstr, /(\d{4})/g;
>
>    push @dstr, $1 while(/(\d\d)/g);

I think the first statement will push the lot onto @dstr, because the
regex is matched in list context.

	$_ = '20010808091821';
	push @dstr, /(\d{4})/g;
	push @dstr, $1 while /(\d{2})/g;
	$" = ':';
	print "@dstr\n";
-->
	2001:0808:0918:20:01:08:08:09:18:21

Indeed. It even resets pos() at the end of the match, because of the
failure.

And there is no need for a loop in the second statement.

	/^(\d{4})/g and @dstr = $1;
	push @dstr, /\d\d/g;

(/\d\d/ is faster than /\d{2}/)

Also:

	@dstr = (scalar(/^(\d{4})/g, "$1"), /\d\d/g);

Note that I had to "stringify" $1 in order to prevent the first value
from being overwritten.

I would call none of these "better" than the original.

-- 
	Bart.


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

Date: Wed, 8 Aug 2001 07:41:38 -0500 
From: Dave VP <me@my_no_spam.org>
Subject: Re: String version of += assignment operator??
Message-Id: <3B713382.E56F29BD@my_no_spam.org>

"Carlos C. Gonzalez" wrote:
> 
<snip>

> I will have to read the perlop Tad.  It's a hassle to use perldoc on
> Windows.  It comes up in this archaic DOS window which scrolls off the
> screen with every page and that I cannot readily page up on.

You could try:
	perldoc perlop | more

You can't page up, but it'll fix the scrolling problem.  You could write
your own pager, or consider using 'less' rather than more.  One way to
get this is with Cygwin
(http://sources.redhat.com/cygwin/download.html).  You'll get a ton of
'NIX tools working on Win32.

HTH

--

Dave



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

Date: Tue, 7 Aug 2001 21:00:01 -0600
From: "bowman" <bowman@montana.com>
Subject: Re: System Call Question
Message-Id: <9Xac7.130$L63.103657@newsfeed.slurp.net>


"Mark Riehl" <mark.riehl@agilecommunications.com> wrote in message
news:vzZb7.503$Pz1.66571@typhoon1.gnilink.net...
> All - I've got a Win2k box and I'd like to make a system call (ipconfig)
and
> determine my own IP address (trying to debug an ISP issue with changing IP
> addresses).

I do a similar thing to find my ephemeral IP address on a dialup connection
with

my $netstat = `netstat -n`;
if ($netstat =~ /.+TCP\s+([0-9.]+):.*$/s) {
  $addr = $1;
}

simple minded, but it works. do the same with ipconfig to get the data, and
then parse it out as required.






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

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.  

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


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