[17181] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4593 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 12 09:05:28 2000

Date: Thu, 12 Oct 2000 06:05:10 -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: <971355910-v9-i4593@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 12 Oct 2000     Volume: 9 Number: 4593

Today's topics:
    Re: $ARGV[0] in one-liner in Unix csh alias? <kistler@gmx.net>
    Re: $ARGV[0] in one-liner in Unix csh alias? <lincmad001@telecom-digest.zzn.com>
    Re: A lot of s///g; feels like a slow idea. mexicanmeatballs@my-deja.com
        can javascript be used to execute a perl script and hav <wedeking@msa.attmil.ne.jp>
    Re: challenging problem <tony_curtis32@yahoo.com>
        Collecting Information gvtt@my-deja.com
    Re: Collecting Information <anders@wall.alweb.dk>
    Re: Cutesy Arrows - Just say nope! <uri@sysarch.com>
    Re: files changes when uploading. <johan.ditmar@era.ericsson.se>
        h2ph dosn't work well <john@imining.com.tw>
    Re: Help with CGI <dunfeeje@pilot.msu.edu>
    Re: How to remove all white spaces alichambers@madasafish.com
        interpreting hidden backslash constructs <risto.vaarandi@eyp.ee>
    Re: interpreting hidden backslash constructs (Logan Shaw)
    Re: ip under win9x/2k from the commandline? <zakazan@gmx.de>
    Re: is there a better way to do this? (Martien Verbruggen)
    Re: is there a better way to do this? mexicanmeatballs@my-deja.com
        Maintaining State on a TCP socket <bmaynard@voodoox.net>
    Re: Making this match better (que. about regexp and arr jimmylantz@my-deja.com
    Re: Newbie Pattern Match Question <andreas_berg_genient@my-deja.com>
    Re: Newbie Pattern Match Question (Logan Shaw)
    Re: newbie: pws and active perl (Pieter Overbeeke)
    Re: newbie: pws and active perl (Pieter Overbeeke)
    Re: Problems with script to download a file <michael@GeekTimes.com>
    Re: Problems with script to download a file <michael@GeekTimes.com>
        regular expression <jylog@netcourrier.com>
    Re: regular expression (Logan Shaw)
    Re: regular expression <cec2000@mail.ru>
    Re: regular expression <jylog@netcourrier.com>
        Script syntax help slickric01@my-deja.com
    Re: Script syntax help <uri@sysarch.com>
        Very Newbie Question - Form output to file vs mail <bfulb@bellsouth.net>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 12 Oct 2000 11:59:15 +0200
From: Per Kistler <kistler@gmx.net>
To: Linc Madison <lincmad001@telecom-digest.zzn.com>
Subject: Re: $ARGV[0] in one-liner in Unix csh alias?
Message-Id: <39E58B73.74DE1E2B@gmx.net>

With csh on linux the following works:

alias foo 'perl -e "print eval(qq(\044ARGV[0].qq(\n)));"'

Per.


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

Date: Thu, 12 Oct 2000 05:25:00 -0700
From: Linc Madison <lincmad001@telecom-digest.zzn.com>
Subject: Re: $ARGV[0] in one-liner in Unix csh alias?
Message-Id: <121020000525005066%lincmad001@telecom-digest.zzn.com>

In article <39E58B73.74DE1E2B@gmx.net>, Per Kistler <kistler@gmx.net>
wrote:

> With csh on linux the following works:
> 
> alias foo 'perl -e "print eval(qq(\044ARGV[0].qq(\n)));"'

I *never* would have thought to escape $ARGV[0] in quite *that* way.

My final one-liner comes out thusly:

alias dotquad 'perl -e "print((eval qq(\044ARGV[0])>0x00ffffff and eval
qq(\044ARGV[0])<0xffffffff)?(join qq(.),unpack qq(C*),pack qq(N),eval
qq(\044ARGV[0])):qq(Invalid value: enter decimal IP to convert to
dotted quad),qq(\n));"'

I tested it on SunOS 4.1.4.

Usage:

% dotquad 1234567890
73.150.2.210

so that when you get one of those nasty spams with something like
http://1234567890 you can convert the IP address to standard format.

Of course, it's easy enough to set it up as an executable file:

#! /usr/local/bin/perl -w

my $d = $ARGV[0];
$d = <STDIN>
   if !$d && print "Enter decimal IP to convert to dotted quad: ";
die "Invalid input value\n" if $d < 0x010000 or $d >= 0xffffffff;
print( (join ".", unpack "C*", pack "N", $d), "\n");


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

Date: Thu, 12 Oct 2000 10:46:26 GMT
From: mexicanmeatballs@my-deja.com
Subject: Re: A lot of s///g; feels like a slow idea.
Message-Id: <8s44q1$4lc$1@nnrp1.deja.com>

In article <MPG.144e7c638cacdcec98ae29@nntp.hpl.hp.com>,
  Larry Rosler <lr@hpl.hp.com> wrote:
> In article <8s278o$ill$1@nnrp1.deja.com> on Wed, 11 Oct 2000 17:16:16
> GMT, mexicanmeatballs@my-deja.com <mexicanmeatballs@my-deja.com>
says...
> > my $char_list= '(['.join("", keys(%translations)).'])';
> > $line=~s/$char_list/$translations{$1}/gsoe;
> No need for the 's' or 'e' modifiers.

Yep, I was having a modifier frenzy.

> And you can eliminate the 'o' modifier by quoting $char_list with qr()
> instead of just q().
But the qr would have to be on the value returned by the join, which
would result in a somewhat convoluted looking qr or an intermediate
step.

    my $char_list= qr(([${\join("", keys(%translations))}]));
    $line=~s/$char_list/$translations{$1}/g;

> I don't know if any of that would make it faster, though, and I'm too
> lazy to benchmark it.
Well, since I have the code in front of me...
Trying a few variations on the qr theme and your modifier corrections
yields about 0.5 of a second per 1000 lines gain for your suggestions.

 I don't see why qr gains over an o though, surely the compiler
optimizes these in pretty much the same way.

--
Jon
perl -e 'print map {chr(ord($_)-3)} split //, "MrqEdunhuClqdph1frp";'


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 12 Oct 2000 17:58:28 +0900
From: "Dan and Shelly" <wedeking@msa.attmil.ne.jp>
Subject: can javascript be used to execute a perl script and have results displayed in browser?
Message-Id: <8s3u40$5d2$1@newsflood.tokyo.att.ne.jp>

I was wanting to make a form in a web page that allows people to post
information that is then checked with a perl script.  Then I want to have
the results of the perl checking script displayed in the netscape browser.
Does anyone know how to do this?

I was going to use cgi but my web page is on a unix directory that is not a
web server.  Other people in the office have access to the directory so they
can access the html page with the input form.

I also saw a miniserver.pm module that is supposed to simulate a web server.
Does anyone know if miniserver.pm can be used if the javascript idea won't
work?

Dan




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

Date: 12 Oct 2000 05:12:17 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: challenging problem
Message-Id: <8766mys70e.fsf@limey.hpcc.uh.edu>

>> On Thu, 12 Oct 2000 01:55:29 -0400,
>> paceman97@aol.com said:

> There is a script that takes simple numbers (1-8000) as
> input and based on that sends you to some URL.  Is there
> a way for me to get a list of those URL's ?  Perhaps
> connect to each one of those url's and find out where
> its leading?  (i tried that and it didnt work for me)

Look at the source code.

> Maybe there is some way to do it through Unix ?  or
> another scripting language.

UNIX is a scripting language?

What does this have to do with perl anyway?

hth
t
-- 
Eih bennek, eih blavek.


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

Date: Thu, 12 Oct 2000 07:28:06 GMT
From: gvtt@my-deja.com
Subject: Collecting Information
Message-Id: <8s3p63$sl7$1@nnrp1.deja.com>

Hi,

Could anyone tell me if there is CGI code for free or to buy which,
when someone visits my web site, the code will collect information
about which sites that person has been on before?

Could you point me in the right direction? Is CGI best for this sort of
things or do I have to look for something else?

     Thanks


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 12 Oct 2000 11:30:57 +0200
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: Collecting Information
Message-Id: <byfF5.10461$u23.297151@news000.worldonline.dk>

gvtt@my-deja.com wrote:

> Hi,
> 
> Could anyone tell me if there is CGI code for free or to buy which,
> when someone visits my web site, the code will collect information
> about which sites that person has been on before?
> 

So, you don't give a damn about privacy? Are you a spammer too?

> Could you point me in the right direction? Is CGI best for this sort of
> things or do I have to look for something else?

Luckily, you need to cooperate with morally criminal organisations like eg 
doubleclick.net who abuses the naivity of the averidge web user.

One thing that may be availible is the referrer, but this is not a perl 
issue, more likely a HTTP or <your web server> one

-anders

-- 
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]


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

Date: Thu, 12 Oct 2000 10:34:02 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Cutesy Arrows - Just say nope!
Message-Id: <x7r95mxs9x.fsf@home.sysarch.com>

>>>>> "G" == Godzilla!  <godzilla@stomp.stomp.tokyo> writes:

  G> With hopes of not reading disrespectful, your description
  G> perfectly and precisely defines use of modules, which are
  G> clearly, modern day Perl cargo cult.

so don't you ever use them again. but i have seen you use LWP and a few
others so you are a hypocrit as well as a moron. oh, well, such a
shining example or perl purity just got shot down. now you can leave in
shame with you tail between your legs. now go away!

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Thu, 12 Oct 2000 10:20:24 +0200
From: "Johan Ditmar" <johan.ditmar@era.ericsson.se>
Subject: Re: files changes when uploading.
Message-Id: <8s3rp9$87t$1@newstoo.ericsson.se>

$bitfile is a file handle, recieved from a form. I solved the problem by
using Jon's solution (binmode) and now everything works. It was probably the
line-terminator as Tim mentioned that was the problem.

Thanks a lot,

Johan

Johan Ditmar wrote in message <8s25kd$l29$1@newstoo.ericsson.se>...
>Hi,
>
>I am trying to upload a file and I am using the code below to do that:
>
>----
>open (SAVE,">./bitfile.bit") || die $!;
>
>   while (read($bitfile,$data,1024)) {
>     print SAVE $data;
>
>   }
>   close SAVE;
>----
>For my application, it's very important that the uploaded file is not
>changed in any way. It seems though that it is changed when using my code.
>It becomes a little larger also. Is there some way to upload files without
>changing them?
>
>Thanks,
>
>Johan
>
>




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

Date: Thu, 12 Oct 2000 17:21:50 +0800
From: "John" <john@imining.com.tw>
Subject: h2ph dosn't work well
Message-Id: <8s4037$ht6@netnews.hinet.net>

I used h2ph to generate .ph files from <net/if.h> in Linux.
The command is
   h2ph -d /home/john/perl_ph -a -l /usr/include/net/if.h
I found that limits.ph contains a line
   require 'syslimits.ph';
while h2ph did not generate syslimits.ph for me.
More strange, limits.h does not include syslimits.h and
there is no syslimits.h in /usr/include and it's subdirectories.
Why?




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

Date: Thu, 12 Oct 2000 08:50:23 -0400
From: Jeff Dunfee <dunfeeje@pilot.msu.edu>
Subject: Re: Help with CGI
Message-Id: <39E5B38F.25D99492@pilot.msu.edu>

Seeming from the input and from reading alittle I have completely dumped
this old script and gone with the CGI.pm module in a new script.  Thanks
for the input.

-jeff

Jeffrey Scott Dunfee II wrote:

> I have a cgi script written in perl used for a feedback form on a web
> page.  When you click on the submit button it sends an e-mail and then
> tries to print html back to the browser to display a "temporary" web
> page thanking the user, and then eventually I am going to add some html
> to re-direct the web page back to the original. Anyways, the problem is
> encountered when it tries to print the html back to the web browser, it
> gets through the e-mail section, sends the e-mail but when it hits the
> first print statement for the html it asks to open the file or save it
> to disk (I'm using netscape on this one, it works in I.E, but the users
> don't want to switch so I'm stuck making it work for netscape).  And
> when you choose Open it, it displays the html printed into my default
> text editor.  And only the html.  if you could take a look and see if I
> am doing something wrong that would be much appreciated.  Oh, we are
> running perl 5.0 on an NT system.  Thanks
>
> do "cgi-lib.pl" || die "Fatal Error: Can't load cgi library";
> &ReadParse;
> open(FEEDBACK,'>>C:\InetPub\mailroot\compose\feedback.txt');
> print FEEDBACK "IP Address:   $ENV{'REMOTE_ADDR'}\n";
> print FEEDBACK "Host Name:   $ENV{'REMOTE_HOST'}\n";
> print FEEDBACK "Name:   $in{'FULLNAME'}\n";
> print FEEDBACK "Phone:  $in{'PHONE'}\n";
> print FEEDBACK "E-Mail: $in{'EMAIL'}\n||\n";
> print FEEDBACK "Comments:\n$in{'COMMENTS'}\n\n";
> close FEEDBACK;
> open(SEND,'>C:\InetPub\mailroot\compose\send.txt');
> print SEND "x-sender: web\@pp.msu.edu\n";
> #print SEND "x-receiver: amcarey\@pplant.msu.edu\n";
> print SEND "x-receiver: cmantes\@pplant.msu.edu\n";
> print SEND "Subject: Physical Plant Home Page comment.\n";
> print SEND "IP Address:   $ENV{'REMOTE_ADDR'}\n";
> print SEND "Host Name:   $ENV{'REMOTE_HOST'}\n";
> print SEND "Name:   $in{'FULLNAME'}\n";
> print SEND "Phone:  $in{'PHONE'}\n";
> print SEND "E-Mail: $in{'EMAIL'}\n";
> print SEND "Comments:\n$in{'COMMENTS'}\n";
> close SEND;
> $command='copy C:\Inetpub\mailroot\compose\send.txt
> c:\inetpub\mailroot\pickup\send.txt';
> system($command);
> unlink('C:\Inetpub\mailroot\compose\send.txt');
> print "Content-type: text/html\n\n";
> print "<HTML>\n";
> print "<HEAD>\n";
> print "<TITLE> Your Feedback has been successfully sent</TITLE>\n";
> print "</HEAD>\n";
> print "<BODY>\n";
> print "<H1>Thank You</H1>\n";
> print "</BODY>\n";
> print "</HTML>\n";

--
*********************************************************************************

                        "To laugh often and much,
                 to win the respect of intelligent people
                      and the affection of children,
                 to earn the appreciation of honest critics
                  and endure the betrayal of false friends,
                 to appreciate beauty, to find the best in others,
                      to leave the world a bit better,
                          whether by a healthy child,
                a garden patch, or a redeemed social condition;
          to know even one life has breathed easier because you have lived.

                            This is to have succeeded!"
                             ... Ralph Waldo Emerson
*********************************************************************************

@@@@@@@@@@@@@@@@@@@@@
    Jeff Dunfee
College of Engineering

  dunfeeje@egr.msu.edu
 -
  dunfeeje@msu.edu
@@@@@@@@@@@@@@@@@@@@@




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

Date: Thu, 12 Oct 2000 08:31:20 GMT
From: alichambers@madasafish.com
Subject: Re: How to remove all white spaces
Message-Id: <8s3ssp$v59$1@nnrp1.deja.com>

Thanks for all your replies. The problem is solved.

Regards

Alex Chambers


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 12 Oct 2000 13:02:54 +0200
From: Risto Vaarandi <risto.vaarandi@eyp.ee>
Subject: interpreting hidden backslash constructs
Message-Id: <39E59A5E.85C44A16@eyp.ee>

hello,

in perl many special characters can be expressed
with backslash construct (\n means newline, \t is
tabulation etc.).
How can i force perl to interpret these backslash
constructs if they are hidden inside a variable:

$line = <STDIN>;   # user types a, \, n, b

I could use

$line =~ s/\\n/\n/g;
$line =~ s/\\t/\t/g;
 ...

but can the same effect be achieved with one
sentence?

I also tried  $line = eval { $line } , but it did
not give desired result - print $line gives a\nb
instead of
a
b

Any suggestions?

best regards,
risto


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

Date: 12 Oct 2000 06:19:30 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: interpreting hidden backslash constructs
Message-Id: <8s46o2$1f6$1@provolone.cs.utexas.edu>

In article <39E59A5E.85C44A16@eyp.ee>,
Risto Vaarandi  <risto.vaarandi@eyp.ee> wrote:
>in perl many special characters can be expressed
>with backslash construct (\n means newline, \t is
>tabulation etc.).
>How can i force perl to interpret these backslash
>constructs if they are hidden inside a variable:
>
>$line = <STDIN>;   # user types a, \, n, b
>
>I could use
>
>$line =~ s/\\n/\n/g;
>$line =~ s/\\t/\t/g;
>...
>
>but can the same effect be achieved with one
>sentence?
>
>I also tried  $line = eval { $line } , but it did
>not give desired result - print $line gives a\nb

You can use

	$line = eval "\"$line\"";

But it's not very secure -- particularly if the user types

	\" . system ('rm -rf /') . \"

as their input string.

  - Logan


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

Date: Thu, 12 Oct 2000 11:44:30 +0200
From: "Werner, Wolfgang" <zakazan@gmx.de>
Subject: Re: ip under win9x/2k from the commandline?
Message-Id: <39E587FE.A4682572@gmx.de>

hi jason,
nope, seems not to work on my machine.
any idea?
thakns for your time anyway :)

jason wrote:

> Werner, Wolfgang wrote ..
> >how can i find ount my ip using the windows commandline and perl?
>
>   perl -MSocket -e"print inet_ntoa inet_aton $ENV{COMPUTERNAME}"
>
> --
>   jason -- elephant@squirrelgroup.com --



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

Date: Thu, 12 Oct 2000 21:15:29 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: is there a better way to do this?
Message-Id: <slrn8ub3q1.2tj.mgjv@martien.heliotrope.home>

On Thu, 12 Oct 2000 06:08:49 GMT,
	David <no@spam.org> wrote:

> My apologies if my original post confused anyone.  The question was,
> er, is there a better way to do this?

I didn't mean that you were deliberately confusing me, just that the use
of the hash in your code was a bit confusing, as in not very clear. :)
It just looked much more complicatedto me than was necessary.

> 
> Thanks for the reply Martien. As some of the functions you've used are
> beyond me at the moment (just finished chapt 5 - Learning Perl), I
> will hang on to your example for future reference.  There are several
> features I'll implement to this and other simple scripts I've written
> (such as checking for, or creating a directory as you pointed out) as
> I gain a better understanding of Perl.  Meantime, I'll continue to
> follow this ng and this thread to see how others approached this
> problem.

That's ok, other may come up with alternative, and even better ways, of
doing this. Although, I do believe that most people prefer the use of
opendir/readdir above glob, probably for the same reason as I did.

The only new thing I introduced beside those is the -f operator. They're
really powerful. You can read more about them in the perlfunc
documentation:

# perldoc perlfunc

And I am sure that /Learning Perl/ has some examples that use it (I
don't own a copy, unfortunately).

If there is anything that you don't understand about the code, feel free
to ask. 

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | That's funny, that plane's dustin'
Commercial Dynamics Pty. Ltd.   | crops where there ain't no crops.
NSW, Australia                  | 


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

Date: Thu, 12 Oct 2000 11:17:51 GMT
From: mexicanmeatballs@my-deja.com
Subject: Re: is there a better way to do this?
Message-Id: <8s46kr$65n$1@nnrp1.deja.com>

In article <39E52EF6.8592495F@stomp.stomp.tokyo>,
  "Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:
> A suggestion. If you are looking for help of a sort,
> you need to ask a question. You have asked no question
> nor have you described anything with which you need help.
> Do you have a question? Do you need help?

SUBJECT: is there a better way to do this?

Duh?

--
Jon
perl -e 'print map {chr(ord($_)-3)} split //, "MrqEdunhuClqdph1frp";'


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 12 Oct 2000 10:17:41 +0100
From: "liliafan" <bmaynard@voodoox.net>
Subject: Maintaining State on a TCP socket
Message-Id: <39e580d4@news.jakinternet.co.uk>

Hi I posted to perl.modules a little while ago,  with a similar
problem, however, I am still looking for advice.

I have a socket being opened for a continuous stream from a
single connection, however, for some reason after I have
recieved just 2 bits of data, the socket stops recieving, and
closes, can anyone offer advice, I have added forking hoping
this would fix the problem, and it did make a slight improvement
as before it was only taking one piece of data.

This is the code:

sub connect_port {
$local = IO::Socket::INET->new(Type=> SOCK_STREAM,
                                                        Proto=>"tcp",
                                                        LocalPort=>$sck,
                                                        Listen=>1,
                                                        Reuse=>1)
                || die dienice();

open(PRO, "> pid.dat") || die print "Cannot print process: $!";
        print PRO getppid();
close(PRO);

while ($remote = $local->accept()) {

        $remote->autoflush(1);

        FORK: {

            my $kid = fork;
            if (defined($kid)) {
                my $nread = sysread($remote, $inp, 100000024);
                chomp($inp); # Remove trailing \n from $inp
                if ($inp=~ /901/) { # If $inp is "901" terminate program
                    close($local);
                    print "*** Terminate Signal Recieved
exiting....(exit(1))";
                    unlink <pid.dat>;
                    $dbh->disconnect();
                    exit();
                } else {
                     print "*** $inp\n"; # Else print to screen and
datasource
                    database_connect();
                }
        }
        elsif ($! =~ /No more process/) {
            sleep 5;
            redo FORK;
        } else {
            print "Failed!"
        }
    }
}
connect_port($sck, $datasource, $datasource2);
}

Looking at this can anyone hazard a guess as to why it closes and stops
recieving.

TIA

Ben







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

Date: Thu, 12 Oct 2000 07:37:22 GMT
From: jimmylantz@my-deja.com
Subject: Re: Making this match better (que. about regexp and arrayhandling).
Message-Id: <8s3pnh$t2p$1@nnrp1.deja.com>

In article <MPG.144e79d699c00e4498ae28@nntp.hpl.hp.com>,
  Larry Rosler <lr@hpl.hp.com> wrote:
<Snip>

> > Below theres an foreach statement within an foreach statement, there
> > must be a way to make this better ?
>
Yes, as is often the case.  Replace one of the loops by a hash lookup.
>
<snip>
> Reproduced below.
>
> #!/usr/bin/perl -w
> use strict;
>
> my $hex = 'C2A5B8DF';
> my %hex;
> @hex{$hex =~ /..../g} = ();
> my @hits;
>
> while (my $line = <DATA>) {
>
> # This pushes lines with multiple matches multiple times,
> #   as in the posted code.
>
>     push @hits, ($line) x grep exists $hex{$_} =>
>         substr($line, 0, index $line, ':') =~ /..../g;
>
> # This pushes lines with multiple matches once only,
> #   which is more efficient.
>
> #   for (substr($line, 0, index $line, ':') =~ /..../g) {
> #       next unless exists $hex{$_};
> #       push @hits, $line;
> #       last;
> #   }
>
> }
>
> print @hits;
<snip>

Thank you very much Larry.
Kind regards
Jimmy Lantz


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 12 Oct 2000 10:43:54 GMT
From: Andreas Berg <andreas_berg_genient@my-deja.com>
Subject: Re: Newbie Pattern Match Question
Message-Id: <8s44l9$4je$1@nnrp1.deja.com>

Mark, thanks very much for your response. This indeed helped me a lot.
I just haven't had the idea to match as much text as possible before
the "<table", I was just looking at ways to match the specific pattern.
So finally I just modified my original pattern

<table(?:[\d\D]*?)Some specific text(?:[\d\D]*?)</table>

to

([\d\D]*)<table(?:[\d\D]*?)Some specific text(?:[\d\D]*?)</table>

and instead of deleting the match replaced it with the first
backreference. So basically exactly what you did but just in another
syntax.

I think [\d\D] and . are not exactly the same since [\d\D] also matches
newlines and . does not.

Andreas.


In article <nD9F5.29231$3_4.347700@news1.rdc1.sdca.home.com>,
  "Mark McCarthy" <markmccarthy1@home.com> wrote:
>
> <andreas_berg_genient@my-deja.com> wrote in message
> news:8s2cgo$nht$1@nnrp1.deja.com...
> >
> >
> > Hi,
> >
> > I somehow cannot get the right pattern to match
> > the following text. Suppose I have an HTML file:
> >
> > <table width="100">
> >
> > <table width="50">
> > <tr><td>Some unknown text</td></tr>
> > <tr><td>Some unknown text</td></tr>
> > </table>
> >
> > <table width="50">
> > <tr><td>Some unknown text</td></tr>
> > <tr><td>Some specific text</td></tr>
> > <tr><td>Some unknown text</td></tr>
> > </table>
> >
> > <table width="50">
> > <tr><td>Some unknown text</td></tr>
> > <tr><td>Some unknown text</td></tr>
> > <tr><td>Some unknown text</td></tr>
> > </table>
> >
> > </table>
> >
> > Now I want to match the part:
> >
> > <table width="50">
> > <tr><td>Some unknown text</td></tr>
> > <tr><td>Some specific text</td></tr>
> > <tr><td>Some unknown text</td></tr>
> > </table>
> >
> > I tried the pattern
> >
> > <table(?:[\d\D]*?)Some specific text(?:[\d\D]*?)
> > </table>
>
> Here is some insight. Im not much more than a newbie myself but
> noone has taken this on, so here goes.
>
> The heavyweights can correct my misconceptions if they care to help
out ...
>
> [\d\D] is the same as . so use that instead
> You need the s modifier ie m//s because youre traversing many lines.
> What youre needing is:
>
> As much text as possible
> followed minimally by text which has been preceeded by < table
> followed by "Some specific text"
> followed minimally by text which has </table after it
> followed greedily by all else that is left.
>
> if (m#(.*)((?<=<table)(.*?)Some specific text(.*?)(?=</table>))(.*)#s)
> {print $2};
>
> Look up zero-width assertions in perlre. Notice I used a lookbehind
and a
> lookahead here.
>
> Took me a long session to discover all this so hope it helps.
>
> Mark McCarthy
>
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 12 Oct 2000 05:54:09 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Newbie Pattern Match Question
Message-Id: <8s458h$1ba$1@provolone.cs.utexas.edu>

In article <8s44l9$4je$1@nnrp1.deja.com>,
Andreas Berg  <andreas_berg_genient@my-deja.com> wrote:
>I think [\d\D] and . are not exactly the same since [\d\D] also matches
>newlines and . does not.

Except when the "s" modifier is in effect for your regular expression,
in which case they should be exactly the same.  "perldoc perlre" for
more information on that (and other) modifiers.

  - Logan


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

Date: Thu, 12 Oct 2000 08:37:02 GMT
From: overbeek@chello.nl (Pieter Overbeeke)
Subject: Re: newbie: pws and active perl
Message-Id: <39e578ab.89803226@news.arnhem.chello.nl>

On Wed, 11 Oct 2000 15:09:57 +1000, jason <elephant@squirrelgroup.com>
wrote:

>Pieter Overbeeke wrote ..
>>Hi all, 
>>
>>I'm trying to get cgi (perl) scripts working on pws but i'm bot being
>>very succesfull yet. So i hope someone can help me.
>>
>>I am running pws on win98. I have installed activeperl, set the
>>mimetypes right, in the registry, in
>>HKEY_LOCAL_MACHINE/System/CurrentControlSet/Services/w3svc/parameters/Script
>>Map i have added .pl .cgi and .plx which refer to c:/perl/bin/perl.exe
>>%s %s (also tried c:/perl/bin/perl5.6.0.exe %s %s).
>
>c:/perl/bin/perl.exe is not a valid Windows path .. while you can use 
>forward slashes in native Perl functions - you cannot use them in 
>everything related to Perl
>
>c:\perl\bin\perl.exe is a valid Windows path .. if it's also the path to 
>your perl.exe then that might solve your problem
>
>btw .. if you install ActivePerl *after* installing PWS then it should 
>add the appropriate script mappings for you
>
>-- 
>  jason -- elephant@squirrelgroup.com --

I just mistyped myself there in the message. So thats not whats
causing the problem. I did install active perl after installing psw
but found no script mappings... i think i'm going to try installing
active perl again. Thanks anyway!

Pieter Overbeeke


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

Date: Thu, 12 Oct 2000 09:33:27 GMT
From: overbeek@chello.nl (Pieter Overbeeke)
Subject: Re: newbie: pws and active perl
Message-Id: <39e5855e.393109@news.arnhem.chello.nl>

On Wed, 11 Oct 2000 15:09:57 +1000, jason <elephant@squirrelgroup.com>
wrote:

>Pieter Overbeeke wrote ..
>>Hi all, 
>>
>>I'm trying to get cgi (perl) scripts working on pws but i'm bot being
>>very succesfull yet. So i hope someone can help me.
>>
>>I am running pws on win98. I have installed activeperl, set the
>>mimetypes right, in the registry, in
>>HKEY_LOCAL_MACHINE/System/CurrentControlSet/Services/w3svc/parameters/Script
>>Map i have added .pl .cgi and .plx which refer to c:/perl/bin/perl.exe
>>%s %s (also tried c:/perl/bin/perl5.6.0.exe %s %s).
>
>c:/perl/bin/perl.exe is not a valid Windows path .. while you can use 
>forward slashes in native Perl functions - you cannot use them in 
>everything related to Perl
>
>c:\perl\bin\perl.exe is a valid Windows path .. if it's also the path to 
>your perl.exe then that might solve your problem
>
>btw .. if you install ActivePerl *after* installing PWS then it should 
>add the appropriate script mappings for you
>
>-- 
>  jason -- elephant@squirrelgroup.com --


I have improved but it is still not working. What happens now is when
i try to activate a perlscript in my browser like:
http://ns/cgi-bin/xxx.pl  is that my browser asks me if i would like
to open the file or if i would like to download it! When i choose
open, a dosbox appears and it seems that the script is executed in
that box, but no html appears in my browser like it is supposed to do.
(I've tested the script on the server of my host-provider and it
works...)
So maybe this gives you a better idea of what i am doing wrong.
Thankx.

Pieter


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

Date: Thu, 12 Oct 2000 01:19:39 -0700
From: Michael Sattler <michael@GeekTimes.com>
Subject: Re: Problems with script to download a file
Message-Id: <michael-018AB0.01193912102000@nntp3.tsoft.net>

In article <A6vq5.4712$EB2.103470@news2-win.server.ntlworld.com>, 
"grocock" <grocock@ntlworld.com> wrote:

>why don't you just add a link to the pdf file? the only reason I can think
>of for using a cgi-script is to track the number of downloads, which your
>program doesn't do...

It seems that the poster wants - as do I - to obscure the path to the 
file.

Michael

--
Michael "Mickey" Sattler, Geek Times   <mailto:michael@GeekTimes-NOSPAM.com>
San Francisco, California, USA    <http://www.GeekTimes.com/michael/>


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

Date: Thu, 12 Oct 2000 01:23:06 -0700
From: Michael Sattler <michael@GeekTimes.com>
Subject: Re: Problems with script to download a file
Message-Id: <michael-59EF75.01230612102000@nntp3.tsoft.net>

In article <MPG.1415aaf2496b2e0898971c@localhost>, jason 
<elephant@squirrelgroup.com> wrote:

>I'm not sure of whether there is a solution to this .. perhaps there's 
>an HTTP header that allows you to override the name of the file

I was pointed to the following code. Sadly the FiLeNaMe.pdf never seems 
to be picked up, the dialog box shows foo.cgi instead. Help would be 
appreciated. Direct email even more :-)

#!/usr/bin/perl

$binary = "/full/path/to/ht-docs/filename.pdf" ; 
$size = -s "$binary";

open(DOWNLOAD,"<$binary") or die $!;

#print "Content-Type:application/octet-stream\n";
print "Content-Type:application/pdf\n";
print "Content-Disposition:attachment; filename=FiLeNaMe.pdf\n";
print "Content-Length:$size\n\n";binmode(DOWNLOAD);binmode(STDOUT);

while(read DOWNLOAD, $buffer, 256){ print $buffer; }

close(DOWNLOAD);

Michael

--
Michael "Mickey" Sattler, Geek Times   <mailto:michael@GeekTimes-NOSPAM.com>
San Francisco, California, USA    <http://www.GeekTimes.com/michael/>


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

Date: Thu, 12 Oct 2000 14:15:02 +0200
From: "Laurent" <jylog@netcourrier.com>
Subject: regular expression
Message-Id: <8s49d1$oi4$1@reader1.imaginet.fr>

Hello

i would like to do a regular expression to replace something which is
between two known words, with a string.

for example, i have: " word1 bla bla bla bla  word2 bla bla bla bla"
then i want : " world1 my_replacement_string word2 bla bla bla bla"

and only for the first occurs
for example, i have: " word1 bla bla bla bla  word2 bla bla bla bla word1
bla bla bla word2"
then i want to have:" word1 my_replacement_string  word2 bla bla bla bla
word1 bla bla bla word2"

thanks for your help
--

Laurent




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

Date: 12 Oct 2000 07:17:16 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: regular expression
Message-Id: <8s4a4c$1kr$1@provolone.cs.utexas.edu>

In article <8s49d1$oi4$1@reader1.imaginet.fr>,
Laurent <jylog@netcourrier.com> wrote:
>Hello
>
>i would like to do a regular expression to replace something which is
>between two known words, with a string.
>
>for example, i have: " word1 bla bla bla bla  word2 bla bla bla bla"
>then i want : " world1 my_replacement_string word2 bla bla bla bla"
>
>and only for the first occurs

What you want is:

	s/(word1).*?(word2)/\1my_replacement_string\2/;

The parenthesis match "word1" and "word2" so you can put them back into
the replacement string.  The ".*?" matches everything inbetween and
non-greedily, which means it will match the shortest possible string
rather than the longest possible one.

If you want to be sneaky, I believe you can also use this:

	s/(?<=word1).*?(?=word2)/my_replacement_string/;

This will cause the matches of "word1" and "word2" to match but to be
left alone (i.e. not replaced).

"perldoc perlre" for more infomation.

  - Logan


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

Date: Thu, 12 Oct 2000 16:18:57 +0400
From: "Sergey" <cec2000@mail.ru>
Subject: Re: regular expression
Message-Id: <8s4a7c$4db$1@pumba.cell.ru>

So what's the problem?

s/word1.+?word2/word1 my_replacement_string  word2/;

? sing makes the re expression non-greedy.

Hope this helps.

Sergey.

Laurent <jylog@netcourrier.com> сообщил в новостях
следующее:8s49d1$oi4$1@reader1.imaginet.fr...
> Hello
>
> i would like to do a regular expression to replace something which is
> between two known words, with a string.
>
> for example, i have: " word1 bla bla bla bla  word2 bla bla bla bla"
> then i want : " world1 my_replacement_string word2 bla bla bla bla"
>
> and only for the first occurs
> for example, i have: " word1 bla bla bla bla  word2 bla bla bla bla word1
> bla bla bla word2"
> then i want to have:" word1 my_replacement_string  word2 bla bla bla bla
> word1 bla bla bla word2"
>
> thanks for your help
> --
>
> Laurent
>
>




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

Date: Thu, 12 Oct 2000 15:07:07 +0200
From: "Laurent" <jylog@netcourrier.com>
Subject: Re: regular expression
Message-Id: <8s4cen$p9d$1@reader1.imaginet.fr>

In fact, i want to use the expression in PHP language and i translate the
expression to work under PHP with the ereg_replace function but it seems
that the expression doesn't work fine
(i translate the expression in PHP as  "WORD1(.+)?WORD2" . do you know if
it's correct?)

for example i have " WORD1 words3 WORD2 words4 WORD1 words5 WORD2 words6"
it gives me: "WORD1 my_replacement_string WORD2 words6"
it replaces all the caractere between the first occurs of WORD1 and the LAST
occurs of WORD2 !!

arg i don't want that...
i would like :" WORD1 my_replacement_string WORD2 words4 WORD1 words5 WORD2
words6"


thanks for your help

Laurent


"Logan Shaw" <logan@cs.utexas.edu> a Иcrit dans le message news:
8s4a4c$1kr$1@provolone.cs.utexas.edu...
> In article <8s49d1$oi4$1@reader1.imaginet.fr>,
> Laurent <jylog@netcourrier.com> wrote:
> >Hello
> >
> >i would like to do a regular expression to replace something which is
> >between two known words, with a string.
> >
> >for example, i have: " word1 bla bla bla bla  word2 bla bla bla bla"
> >then i want : " world1 my_replacement_string word2 bla bla bla bla"
> >
> >and only for the first occurs
>
> What you want is:
>
> s/(word1).*?(word2)/\1my_replacement_string\2/;
>
> The parenthesis match "word1" and "word2" so you can put them back into
> the replacement string.  The ".*?" matches everything inbetween and
> non-greedily, which means it will match the shortest possible string
> rather than the longest possible one.
>
> If you want to be sneaky, I believe you can also use this:
>
> s/(?<=word1).*?(?=word2)/my_replacement_string/;
>
> This will cause the matches of "word1" and "word2" to match but to be
> left alone (i.e. not replaced).
>
> "perldoc perlre" for more infomation.
>
>   - Logan




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

Date: Thu, 12 Oct 2000 10:30:43 GMT
From: slickric01@my-deja.com
Subject: Script syntax help
Message-Id: <8s43sm$448$1@nnrp1.deja.com>

I am trying to write a small script that executes a few commands with
some variables but I am having problems with the syntax. I know what I
want to logically happen. For every domain listed in the script, i want
to execute an nslookup command and save the results to a file. Then
using grep, I parse what I need and save it to a variable. Finally I
run a dig command using the variable.


//Here are the domains
$1=kcal.com
$2=kcal9online.com
$3=...
//for every domain execute the following code
For $i = $1 to $2 do
// This executes an nslookup to query for the authoritative nameserver
and saves the results to a file
nslookup type=NS $i > /var/tmp/tmplookup
// This line sets the variable $ns to the nameserver for the nslookup
using grep
$ns = '< grep *** tmplookup | head -1'
// this executes a dig query using the $ns variable previously set
dig @$ns $i > $i'.com'

Any help and guidance is much appreciated.

Thanks,
Eric


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 12 Oct 2000 10:53:19 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Script syntax help
Message-Id: <x7lmvuxrdr.fsf@home.sysarch.com>

>>>>> "s" == slickric01  <slickric01@my-deja.com> writes:

  s> $1=kcal.com
  s> $2=kcal9online.com
  s> $3=...
  s> //for every domain execute the following code
  s> For $i = $1 to $2 do
  s> // This executes an nslookup to query for the authoritative nameserver
  s> and saves the results to a file
  s> nslookup type=NS $i > /var/tmp/tmplookup
  s> // This line sets the variable $ns to the nameserver for the nslookup
  s> using grep
  s> $ns = '< grep *** tmplookup | head -1'
  s> // this executes a dig query using the $ns variable previously set
  s> dig @$ns $i > $i'.com'

what language do you think you are programming in? that is such a mess
of stuff. if you want to write perl, get a good beginning book like
learning perl or elements of programming in perl.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Thu, 12 Oct 2000 08:23:24 -0000
From: "Bill Fulbright" <bfulb@bellsouth.net>
Subject: Very Newbie Question - Form output to file vs mail
Message-Id: <h%hF5.4994$6E.60393@news4.mia>

Hi all,

I am very new to Perl and CGI, altho I have used modules on various free
wesite hosts.  I am familiar with using:

<FORM ACTION="/bin/script_library/form_handler_file" METHOD=POST>

and

<FORM ACTION="/bin/script_library/form_handler_mail" METHOD=POST>

These are statements I got from Tripod's "Form Handler" script.

1.  Are these standard and compatible with Perl 5?

2.  what do I need to do to use this in my own server?

I have been asked by my company to build a simple form with output to a
file, which we will import to Access, etc.

I am using Perl Builder Software with the CGI Wizard, and have looked
through the help for how to output to file, and have not been able to find
anything.

Any help understanding this will be very much appreciated.

thanks,

Bill Fulbright




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

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

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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


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