[24075] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6270 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 17 18:05:43 2004

Date: Wed, 17 Mar 2004 15:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 17 Mar 2004     Volume: 10 Number: 6270

Today's topics:
        Any Help would be great (Matt Carlson)
    Re: Any Help would be great <noreply@gunnar.cc>
    Re: Any Help would be great <remorse@partners.org>
        array of array <andrea@spitaleri.fsnet.co.uk>
    Re: array of array <trammell+usenet@hypersloth.invalid>
        capitalizing each word in an array (D. Alvarado)
    Re: capitalizing each word in an array <vetro@online.no>
        CPAN module install error (Page)
        How do you reference web form elements? <baisley@hotmail.com.REMOVETHIS>
    Re: How do you reference web form elements? <remorse@partners.org>
    Re: How do you reference web form elements? <baisley@hotmail.com.REMOVETHIS>
    Re: How to fill a hash from the products of a split moller@notvalid.se
        List Scalar Hash question moller@notvalid.se
    Re: List Scalar Hash question <tassilo.parseval@rwth-aachen.de>
    Re: List Scalar Hash question moller@notvalid.se
    Re: LWP - build a cookie by hand? <nobull@mail.com>
    Re: LWP - build a cookie by hand? <gnari@simnet.is>
        Monitoring files in real time (IO::poll question?) <ben@easynews.com>
    Re: Monitoring files in real time (IO::poll question?) <someone@somewhere.nl>
    Re: Monitoring files in real time (IO::poll question?) <ben@easynews.com>
        NT task <andy.cook@pacbell.net>
    Re: problem passing args with system function <nobull@mail.com>
    Re: Retrieving text between 2 tags. <ittyspam@yahoo.com>
    Re: Retrieving text between 2 tags. <spam-block-@-SEE-MY-SIG.com>
    Re: Simple Sort Keys Question from a Simpleton <ittyspam@yahoo.com>
    Re: Transparently Intercepting Mail <someone@somewhere.nl>
    Re: truncated data after INSERT with undef in DBI - bug <nobull@mail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 17 Mar 2004 13:45:52 -0800
From: saryon@swbell.net (Matt Carlson)
Subject: Any Help would be great
Message-Id: <7698d2a2.0403171345.4ec6f6ef@posting.google.com>

Hello all, I have been asked to write a quick and dirty perl script. 
I unfortunatly dont know the first thing about perl, and neither do
the people who asked me.  It is kind of time critical, and the only
thing I could think of is to come here.

I think this script should be easy.(At least in my head).  

What it needs to do is this.  Open a file, and read its contents.

EX. 

Wed Mar 17 14:00:00 CST 2004
ent0: Bytes: 106779649 Bytes: 3539900048
ent2: Bytes: 16579540 Bytes: 2862382308
Wed Mar 17 15:00:00 CST 2004
ent0: Bytes: 156590900 Bytes: 7441862213
ent2: Bytes: 14765674 Bytes: 752784621

A little bit of playing with numbers is needed as well.  
The output needs to print the date line, and then the numbers after
manipulation.  This output is the transmit and recieve of two ethernet
cards.

They want the numbers to be divided by 3600(to make per second), by
1024(for KB/s), and then again by 1024 to have the result shown as
MB/s.

This file is going to be appended to, and would be just as easy if it
were printed in one long list.

I would appreciate any help anyone would have, and if anyone wants to
make it, hey, I have no problems with that at all.

Thanks in advance.

Matt

saryon at swbell dot net


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

Date: Wed, 17 Mar 2004 22:45:04 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Any Help would be great
Message-Id: <c3ahf4$25qob1$1@ID-184292.news.uni-berlin.de>

Matt Carlson wrote:
> Hello all, I have been asked to write a quick and dirty perl
> script. I unfortunatly dont know the first thing about perl, and
> neither do the people who asked me.

     http://learn.perl.org/

> It is kind of time critical, and the only thing I could think of is
> to come here.

Wrong thought. This newsgroup is not the place to go if you want to
hire somebody to write some code for you. This would be a better shot:

     http://jobs.perl.org/

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



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

Date: Wed, 17 Mar 2004 17:15:10 -0500
From: Richard Morse <remorse@partners.org>
Subject: Re: Any Help would be great
Message-Id: <remorse-CE0F1F.17151017032004@plato.harvard.edu>

In article <7698d2a2.0403171345.4ec6f6ef@posting.google.com>,
 saryon@swbell.net (Matt Carlson) wrote:

> Hello all, I have been asked to write a quick and dirty perl script. 
> I unfortunatly dont know the first thing about perl, and neither do
> the people who asked me.  It is kind of time critical, and the only
> thing I could think of is to come here.
> 
> I think this script should be easy.(At least in my head).  
> 
> What it needs to do is this.  Open a file, and read its contents.

perldoc perlopentut


> A little bit of playing with numbers is needed as well.  
> The output needs to print the date line, and then the numbers after
> manipulation.  This output is the transmit and recieve of two ethernet
> cards.
> 
> They want the numbers to be divided by 3600(to make per second), by
> 1024(for KB/s), and then again by 1024 to have the result shown as
> MB/s.

look at regular expressions (perldoc perlretut) to get the numbers out 
of the lines, and then look at print (perldoc -f print) to display.

HTH,
Ricky


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

Date: Wed, 17 Mar 2004 22:00:44 +0000
From: xspirix <andrea@spitaleri.fsnet.co.uk>
Subject: array of array
Message-Id: <c3ai17$l54$1@newsg3.svr.pol.co.uk>

Hy boys,
I am having some fun with perl. I cannot sort out this dilemma:
file test within:
1 a
2 b
1 c
2 d
1 e
2 f
and I would like to get as output this:
1 a c e
2 b d f
I thought something like that:
open(FILE,"test") || die "cannot open test";
while($line=<FILE>){
chomp $line;
@A=split(/ /,$line);
print "@AoA[0][0]\n@AoA[1][0]\n";
print "@AoA[0][1]\n@AoA[1][1]\n";
 ..........
but it doesn't work!
any idea?
thanks

and


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

Date: Wed, 17 Mar 2004 22:19:24 +0000 (UTC)
From: "John J. Trammell" <trammell+usenet@hypersloth.invalid>
Subject: Re: array of array
Message-Id: <slrnc5hjnc.1dk.trammell+usenet@hypersloth.el-swifto.com.invalid>

On Wed, 17 Mar 2004 22:00:44 +0000, xspirix
<andrea@spitaleri.fsnet.co.uk> wrote:
> Hy boys,
> I am having some fun with perl. I cannot sort out this dilemma:
> file test within:
> 1 a
> 2 b
> 1 c
> 2 d
> 1 e
> 2 f
> and I would like to get as output this:
> 1 a c e
> 2 b d f

How about (untested):

  use strict;
  open(FILE,"test") || die "cannot open test: $!";
  my %foo;
  while (<FILE>) {
    chomp;
    my ($key, $value) = split(' ', $_, 2);
	push @{$foo{$key}}, $value;
  }
  print "$_ @{$foo{$_}}\n" for sort keys %foo;



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

Date: 17 Mar 2004 14:15:32 -0800
From: laredotornado@zipmail.com (D. Alvarado)
Subject: capitalizing each word in an array
Message-Id: <9fe1f2ad.0403171415.58da667f@posting.google.com>

Hi, I have an array of strings and it would be cool if, in one line, I
could  capitalize all characters in each word of the array.

@upper_case_arr = func( @lower_case_arr );

except that I can place my function inline because it is only a single
line anyway.  Thanks for any advice - Dave


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

Date: Wed, 17 Mar 2004 23:31:21 +0100
From: Vetle Roeim <vetro@online.no>
Subject: Re: capitalizing each word in an array
Message-Id: <m3r7vrjebq.fsf@quimby.dirtyhack.org>

* D. Alvarado
> Hi, I have an array of strings and it would be cool if, in one line, I
> could  capitalize all characters in each word of the array.
>
> @upper_case_arr = func( @lower_case_arr );

  Try this:
 
    @upper_case_arr = map { func($_ ) } @lower_case_arr;


[...]
-- 
#!/usr/bin/vr


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

Date: 17 Mar 2004 13:26:11 -0800
From: dummymb@hotmail.com (Page)
Subject: CPAN module install error
Message-Id: <6742094.0403171326.2dfb7b9e@posting.google.com>

I tried to install a module on my WinXP machine using the CPAN
installer.  Everything seemed to go well, but the modules aren't being
installed.  Can someone tell me what I need to do to remedy the
following error?

cpan> install XML::NamespaceSupport
Running install for module XML::NamespaceSupport
Running make for R/RB/RBERJON/XML-NamespaceSupport-1.08.tar.gz
  Is already unwrapped into directory
\.cpan\build\XML-NamespaceSupport-1.08
  Has already been processed within this session
Running make test
'test' is not recognized as an internal or external command,
operable program or batch file.
   test -- NOT OK
Running make install
  make test had returned bad status, won't install without force
 
cpan>


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

Date: Wed, 17 Mar 2004 21:41:43 GMT
From: "Brett Baisley" <baisley@hotmail.com.REMOVETHIS>
Subject: How do you reference web form elements?
Message-Id: <rC36c.118919$IF6.3972241@ursa-nb00s0.nbnet.nb.ca>

Hello

I am trying to use Perl/CGI to make a web page with a form. I have the page
working now using Javascript, but I have to port it to Perl.

I have 2 questions:

1. What is the perl for of this javascript code:
document.getElementById("courses").focus();
2. How do you write this to run a perl app? <input type="text"
onClick="perl.pl">

Thanks




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

Date: Wed, 17 Mar 2004 17:11:41 -0500
From: Richard Morse <remorse@partners.org>
Subject: Re: How do you reference web form elements?
Message-Id: <remorse-55EE04.17114117032004@plato.harvard.edu>

In article <rC36c.118919$IF6.3972241@ursa-nb00s0.nbnet.nb.ca>,
 "Brett Baisley" <baisley@hotmail.com.REMOVETHIS> wrote:

> Hello
> 
> I am trying to use Perl/CGI to make a web page with a form. I have the page
> working now using Javascript, but I have to port it to Perl.
> 
> I have 2 questions:
> 
> 1. What is the perl for of this javascript code:
> document.getElementById("courses").focus();
> 2. How do you write this to run a perl app? <input type="text"
> onClick="perl.pl">

Unless you intend to have PerlScript installed on all of your client 
machines, this isn't possible.

It's the difference between client-side and server-side.  The web page 
is viewed in a web browser on the client's computer.  Javascript in the 
web page executes on the client's computer.

However, CGIs execute on the _server_ -- any thing that you wish to do 
with the CGI requires submitting a form to the server and waiting to 
return information to the client.

Thus, a CGI (on the server) can't call the "focus()" method on the 
client.

HTH,
Ricky


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

Date: Wed, 17 Mar 2004 22:52:01 GMT
From: "Brett Baisley" <baisley@hotmail.com.REMOVETHIS>
Subject: Re: How do you reference web form elements?
Message-Id: <lE46c.118972$IF6.3973962@ursa-nb00s0.nbnet.nb.ca>

Ok then, can I call a Perl function from within a javascript one?


"Richard Morse" <remorse@partners.org> wrote in message
news:remorse-55EE04.17114117032004@plato.harvard.edu...
> In article <rC36c.118919$IF6.3972241@ursa-nb00s0.nbnet.nb.ca>,
>  "Brett Baisley" <baisley@hotmail.com.REMOVETHIS> wrote:
>
> > Hello
> >
> > I am trying to use Perl/CGI to make a web page with a form. I have the
page
> > working now using Javascript, but I have to port it to Perl.
> >
> > I have 2 questions:
> >
> > 1. What is the perl for of this javascript code:
> > document.getElementById("courses").focus();
> > 2. How do you write this to run a perl app? <input type="text"
> > onClick="perl.pl">
>
> Unless you intend to have PerlScript installed on all of your client
> machines, this isn't possible.
>
> It's the difference between client-side and server-side.  The web page
> is viewed in a web browser on the client's computer.  Javascript in the
> web page executes on the client's computer.
>
> However, CGIs execute on the _server_ -- any thing that you wish to do
> with the CGI requires submitting a form to the server and waiting to
> return information to the client.
>
> Thus, a CGI (on the server) can't call the "focus()" method on the
> client.
>
> HTH,
> Ricky




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

Date: Wed, 17 Mar 2004 22:22:40 GMT
From: moller@notvalid.se
Subject: Re: How to fill a hash from the products of a split
Message-Id: <uznafjepf.fsf@notvalid.se>

Uri Guttman <uri@stemsystems.com> writes:

> >>>>> "ga" == gabe anzelini <usenet@c0s.org> writes:
> 
>   ga> what I would do:
>   ga> map{
>   ga> 	$img_titles{$1}=$2 if /(.*?)\t(.*)/;
>   ga> }<TITLEFILE>;
> 
> another map in void context!!! 
> 
> and in this case not needed so no fighting.
> 
> use File::Slurp ;
> 
> my $text = read_file( 'whatever' ) ;
> 
> my %img_titles = $text =~ /^(.*?)\t(.*)/gm ;

Please someone!! Explain this line to a noob..... 


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

Date: Wed, 17 Mar 2004 22:00:15 GMT
From: moller@notvalid.se
Subject: List Scalar Hash question
Message-Id: <u65d3kube.fsf@notvalid.se>


Please look at my small example below. 

Why does @cdir get an extra undefined element in
the first assignment? 

ActiveState perl v5.6.1

#### Prog start
use strict;
use warnings;

my %UserID;

$UserID{ '(000883)' }{ dir } = ();

my @cdir = $UserID{ '(000883)' }{ dir };  # First assignment

warn scalar @cdir;   # Prints 1
push @cdir, 'usr';

warn join "/",@cdir; # This gives the following error:
                     # "Use of uninitialized value in join
                     # or string at news.pl line 14."
                     # And it prints /usr

warn scalar @cdir;   # Prints 2
pop @cdir;
warn scalar @cdir;   # Prints 1


@cdir = ();  # Second assignment


warn scalar @cdir;    # Prints 0
push @cdir, 'usr';
warn join "/",@cdir;  # Works as I expect prints  usr
warn scalar @cdir;    # Prints 1
pop @cdir;
warn scalar @cdir;    # Prints 0

#### Prog end


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

Date: 17 Mar 2004 22:17:05 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: List Scalar Hash question
Message-Id: <c3aip1$n05$1@nets3.rz.RWTH-Aachen.DE>

Also sprach moller@notvalid.se:

> Please look at my small example below. 
> 
> Why does @cdir get an extra undefined element in
> the first assignment? 
> 
> ActiveState perl v5.6.1
> 
> #### Prog start
> use strict;
> use warnings;
> 
> my %UserID;
> 
> $UserID{ '(000883)' }{ dir } = ();

This is the same as

    $UserID{ '(000883)' }{ dir } = undef;

> my @cdir = $UserID{ '(000883)' }{ dir };  # First assignment

And here you copy the previous undef into @cdir. It will now be the
first element.

> warn scalar @cdir;   # Prints 1

That's because @cdir contains one element which is undef.

> push @cdir, 'usr';
> 
> warn join "/",@cdir; # This gives the following error:
>                      # "Use of uninitialized value in join
>                      # or string at news.pl line 14."
>                      # And it prints /usr

As a matter of fact, it's only a warning. It happens because one of the
two elements that you want to join together is undef.

> warn scalar @cdir;   # Prints 2
> pop @cdir;
> warn scalar @cdir;   # Prints 1
> 
> 
> @cdir = ();  # Second assignment

This assigns the empty list. After that @cdir will be empty. Note the
difference between an empty array and an array that contains one
undefined value.

> warn scalar @cdir;    # Prints 0
> push @cdir, 'usr';
> warn join "/",@cdir;  # Works as I expect prints  usr

You don't get a warning here because all elements in @cdir (there is
only one) are defined.

> warn scalar @cdir;    # Prints 1
> pop @cdir;
> warn scalar @cdir;    # Prints 0

Maybe this post is a good example why sometimes spurious initialization
(when done improperly) can harm. We had this discussion recently.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Wed, 17 Mar 2004 22:58:19 GMT
From: moller@notvalid.se
Subject: Re: List Scalar Hash question
Message-Id: <uu10njd1q.fsf@notvalid.se>

"Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de> writes:

> Also sprach moller@notvalid.se:
> 
> > Please look at my small example below. 
> > 
> > Why does @cdir get an extra undefined element in
> > the first assignment? 
> > 
> > ActiveState perl v5.6.1
> > 
> > #### Prog start
> > use strict;
> > use warnings;
> > 
> > my %UserID;
> > 
> > $UserID{ '(000883)' }{ dir } = ();
> 
> This is the same as
> 
>     $UserID{ '(000883)' }{ dir } = undef;
> 
> > my @cdir = $UserID{ '(000883)' }{ dir };  # First assignment
> 
> And here you copy the previous undef into @cdir. It will now be the
> first element.
> 
> > warn scalar @cdir;   # Prints 1
> 
> That's because @cdir contains one element which is undef.
> 
> > push @cdir, 'usr';
> > 
> > warn join "/",@cdir; # This gives the following error:
> >                      # "Use of uninitialized value in join
> >                      # or string at news.pl line 14."
> >                      # And it prints /usr
> 
> As a matter of fact, it's only a warning. It happens because one of the
> two elements that you want to join together is undef.
> 
> > warn scalar @cdir;   # Prints 2
> > pop @cdir;
> > warn scalar @cdir;   # Prints 1
> > 
> > 
> > @cdir = ();  # Second assignment
> 
> This assigns the empty list. After that @cdir will be empty. Note the
> difference between an empty array and an array that contains one
> undefined value.
> 
> > warn scalar @cdir;    # Prints 0
> > push @cdir, 'usr';
> > warn join "/",@cdir;  # Works as I expect prints  usr
> 
> You don't get a warning here because all elements in @cdir (there is
> only one) are defined.
> 
> > warn scalar @cdir;    # Prints 1
> > pop @cdir;
> > warn scalar @cdir;    # Prints 0
> 
> Maybe this post is a good example why sometimes spurious initialization
> (when done improperly) can harm. We had this discussion recently.

Do you remember the subject so that I can google for it?


What should I do instead? Should I test to see if the hash is undefined
and then use an empty list instead?

> 
> Tassilo
> -- 
> $_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
> pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
> $_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: 17 Mar 2004 19:30:49 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: LWP - build a cookie by hand?
Message-Id: <u9fzc7i846.fsf@wcl-l.bham.ac.uk>

"187" <bigal187.invalid@adexec.com> writes:

> Is it possible to build your own cookies by hand, to send with a GET or
> POST ?

Yes, of course, just do it (using header()), but why not use
HTTP::Cookies?

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Wed, 17 Mar 2004 18:53:36 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: LWP - build a cookie by hand?
Message-Id: <c3a6p8$url$1@news.simnet.is>

"187" <bigal187.invalid@adexec.com> wrote in message
news:c39ml1$263gq1$1@ID-196529.news.uni-berlin.de...
> Is it possible to build your own cookies by hand, to send with a GET or
> POST ?

create a HTTP::Request object with Cookie: header
and pass that to UserAgent

gnari





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

Date: Wed, 17 Mar 2004 21:53:09 GMT
From: Ben <ben@easynews.com>
Subject: Monitoring files in real time (IO::poll question?)
Message-Id: <8N36c.10961229$Of.1836543@news.easynews.com>

Hello,

I need a method to monitor syslog files in real time.

I'm attempting to use IO::poll on a file descriptor but obviously doing 
something incorrect.  Could someone give a working example of monitoring 
a file for new data?  Specifically my goal is to monitor a syslog file 
for new lines.  Once I have the data I got the rest covered, just having 
issues with actually obtaining it.

Thanks,
Ben Lull

---
Systems Administrator
Easynews, Inc.


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

Date: Wed, 17 Mar 2004 23:00:34 +0100
From: "Stefan" <someone@somewhere.nl>
Subject: Re: Monitoring files in real time (IO::poll question?)
Message-Id: <4058ca83$0$572$e4fe514c@news.xs4all.nl>

"Ben" <ben@easynews.com> schreef in bericht
news:8N36c.10961229$Of.1836543@news.easynews.com...
> Hello,
>
> I need a method to monitor syslog files in real time.
>
> I'm attempting to use IO::poll on a file descriptor but obviously doing
> something incorrect.  Could someone give a working example of monitoring
> a file for new data?  Specifically my goal is to monitor a syslog file
> for new lines.  Once I have the data I got the rest covered, just having
> issues with actually obtaining it.
>
> Thanks,
> Ben Lull
>

Without IO::poll but probably what you're looking for: perldoc -q tail

Stefan




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

Date: Wed, 17 Mar 2004 22:19:49 GMT
From: Ben <ben@easynews.com>
Subject: Re: Monitoring files in real time (IO::poll question?)
Message-Id: <9a46c.10871559$Id.1823941@news.easynews.com>

Ben wrote:
> Hello,
> 
> I need a method to monitor syslog files in real time.
> 
> I'm attempting to use IO::poll on a file descriptor but obviously doing 
> something incorrect.  Could someone give a working example of monitoring 
> a file for new data?  Specifically my goal is to monitor a syslog file 
> for new lines.  Once I have the data I got the rest covered, just having 
> issues with actually obtaining it.
> 
> Thanks,
> Ben Lull
> 
> ---
> Systems Administrator
> Easynews, Inc.

Here is what I came up with, works nicely, any comments welcome :)

use strict;
use IO::Poll 0.04 qw(POLLIN POLLERR POLLHUP);

my $poll = IO::Poll->new();
my $line;

open FD, "</var/log/dump";
my @foo = <FD>;

$poll->mask(\*FD => POLLIN);
while($poll->handles) {
     $poll->poll();
     for my $handle($poll->handles(POLLIN)) {
         if($handle eq \*FD) {
             $line = <FD>;
             chomp($line);
             if($line) {

             }
         }
     }
     sleep 1;
}

close(FD);


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

Date: Wed, 17 Mar 2004 20:18:43 GMT
From: "Andy Cook" <andy.cook@pacbell.net>
Subject: NT task
Message-Id: <Do26c.39746$Ao2.22326@newssvr25.news.prodigy.com>

I have a scheduled job that runs daily, via the NT task scheduler.  It does
various functions and has to run with admin permission.  This is NT 4.0 SP
6.

Now what I want is way of firing this off via the WEB site residing on that
sever, (so I can run it on demand) but when I have my perl script fire the
task off, it fails.  I've already changed the permissions, but it's still
failing.

Everthing is written in perl, of course.  I know I could stash a bit of data
somewhere and have a task run every five miuntes to pick it up, and use that
as the trrigger.  But if could actually run the script via the web page, I
could pick up the output and script through the process using LWP.

And ideas why my website can't run my Script?  Any ideas how to debug it?

Thanks.




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

Date: 17 Mar 2004 19:27:08 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: problem passing args with system function
Message-Id: <u9k71ji8ab.fsf@wcl-l.bham.ac.uk>

Tim Heaney <theaney@cablespeed.com> writes:

> Woody <sugargenius@houston.rr.com> writes:
> >
> > Why is wget not getting the url?
> 
> You need to use double quotes to interpolate the variable
> 
>   system "wget -bc $url";

Don't do that.  $url could contain shell meta-characters. Use Use the
LIST form of system().

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Wed, 17 Mar 2004 12:12:34 -0500
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Retrieving text between 2 tags.
Message-Id: <20040317120448.A21521@dishwasher.cs.rpi.edu>

On Wed, 17 Mar 2004, v796 wrote:

> Date: 17 Mar 2004 08:56:17 -0800
> From: v796 <vicky7909@rediffmail.com>
> Newsgroups: comp.lang.perl.misc
> Subject: Retrieving text between 2 tags.
>
> Hi,
>
> This is beyond me. Maybe you can help.
>
> I am parsing a text file in PERL. Contents are
>
> ...
> :70E::ADTX//ABCS
> text
> text
> XYZ
> :16S:stuff OR :95Qstuff
> ...
> ...
>
>
> Now I have found the tag ':70E::ADTX//'
> This tag is followed by text and other tags on one or more lines.
> Eventually we will reach ':16S' or ':95Q'
> I want all the text between the // and the tag ':16S' or ':95Q',
> whichever is *earlier*
> The text may span multiple lines and the closing tags may not be at
> the start of a newline.
>
> So I need ABCS to XYZ stored in 1 scalar variable $myText.
>
>
> Also I read the file like this:
>
> # which file
> my $data_file="a.txt";
> # open it
> open(DAT, $data_file) || die("Could not open file!");
> # Put file contents into the raw_data array
> @raw_data = <DAT>;
> # Close the file handler
> close(DAT);
>
> # Process the contents.
> foreach $line(@raw_data) {
> ...
> }

You don't want that.  Since your pattern spans multiple lines, you need to
read the file as one big scalar.  Note that if this is a LARGE file, it's
going to cause you problems:

my $data_file = "a.txt";
open DAT, $data_file or die "Could not open file: $!";
my $contents;
{
	local $/ = undef;
	$contents = <DAT>;
}
close DAT;

my $match;
if ($contents =~ !:70E::ADTX//(.*?)(:16S|:95Q)!s){
	$match = $1;
}


>
> How do I get the text? If you use regex. pleae explain cause I am not
> good at them.

The regexp searches the entire string contained in $contents (which is the
whole file).  It looks for your starting tag, and then literally anything,
and then either of the two end tags.  The 'anything' in between is saved
(because of the parentheses).  The s modifier at the end allows the .
wildcard to match newlines.


> Am new to PERL.

Then as a helpful clue, don't call it PERL.  The language is Perl.  The
program that executes your code is perl.  Never all caps.

>
> Is this really a hard task in PERL? On a scale of 1-10(hardest) what
> do you give it?

2.

>
> Also, does anyone know any good PERL forums (besides USENET of
> course), which are FREE.

Perl Mongers - http://www.pm.org


Paul Lalli


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

Date: Wed, 17 Mar 2004 19:10:12 +0000
From: James Taylor <spam-block-@-SEE-MY-SIG.com>
Subject: Re: Retrieving text between 2 tags.
Message-Id: <ant1719129eefNdQ@nospam.demon.co.uk>

In article <c3a5e6$s6j$1@mamenchi.zrz.TU-Berlin.DE>,
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> 
> The brute-force approach is simple:  Slurp the file and do a capturing
> match.
> 
>     my $begin = qr!:70E::ADTX//!;
>     my $end = qr/:16S|:95Q/; # two alternatives
> 
>     # /m not needed for these patterns, but perhaps for others
>     my ( $content) = do { local $/; <DATA> } =~ ^/$begin(.*?)$end/sm;

Shouldn't the $end pattern be in grouping brackets like this?:

    my $end = qr/(?::16S|:95Q)/; # two alternatives

> A line-wise approach takes a more code, but it's more elegant.  Like the
> regex, it picks up the first occurrence of a tag pair.
> 
> 
>     my $content;
>     while ( <DATA> ) {
>         $content .= $_ if s/.*$begin// .. s/($end).*//s;
>         last if $1; # end matched
>     }

Now that's really cute!

-- 
James Taylor, Cheltenham, Gloucestershire, UK.       PGP key: 3FBE1BF9
To protect against spam, the address in the "From:" header is not valid.
In any case, you should reply to the group so that everyone can benefit.
If you must send me a private email, use james at oakseed demon co uk.



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

Date: Wed, 17 Mar 2004 12:46:10 -0500
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Simple Sort Keys Question from a Simpleton
Message-Id: <20040317124415.E21521@dishwasher.cs.rpi.edu>

On Wed, 17 Mar 2004, Bumble wrote:

> Hey, been stuck on this for a good couple of hours now (LOL!), I've had it
> working before in a different program of mine, but now I just can't get it
> working in a simpler form! Can anyone see what stupid thing I've done or
> missed from the following, I have been looking online but how mine is
> different to those? (many thanks in advance!)
>
> #!/usr/bin/perl -w
> use CGI ':standard';
> open (FP1, "<people.txt") or die "Unable to open sales file!\n";
> open (FP2, ">results.txt") or die "Unable to create output file!\n";
>
> while ($line = <FP1>)
> {
>  @fields = split (/\s+/, $line);
>  $surname=$fields[0];
>  $firstname=$fields[1];
>  $totsales=$fields[2];
> }
>
> foreach $key (sort(keys %totsales))
> {
>     print FP2 $key;
> }
> close FP1;
> close FP2;

What exactly are you *thinking* this is going to do?  %totsales doesn't
exist.  It's therefore defaulting to an empty hash, so there are clearly
no keys in it.  Earlier in the script, you repeatedly assign values to
three different scalar variables (one of which is named $totsales - but
this is still unrelated to %totsales), and then do absolutely nothing with
those values.

So again, what are you *trying* to do?

Paul Lalli



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

Date: Wed, 17 Mar 2004 23:13:58 +0100
From: "Stefan" <someone@somewhere.nl>
Subject: Re: Transparently Intercepting Mail
Message-Id: <4058cda4$0$566$e4fe514c@news.xs4all.nl>

"Kees" <witsuk@btopenworld.com> schreef in bericht
news:c373mf$bo6$1@hercules.btinternet.com...
> I am trying to write a little POP3 / SMTP proxy that will encrypt all
> email for the users (on a windows platform). This in itself is not very
> difficult. However it would be great if I could install this without
> having to change to settings on the users' email clients.
>
> I know this should be possible (firewalls intercept all in and outgoing
> connections, I just want the pop and smtp ones), but I have no idea
> where to start. I think this is not really perl related, but I can't
> find any information on this and I don't know where else to start.
>
> Any help, comments, pointers, links, etc are very welcome,
>
> Thank you very much,
>
> Kees


You want to redirect traffic to, lets say  pop3.isp.com,  to your proxy,
which is not on  pop3.isp.com  If you don't want to change the client
settings, you'll definitely have to "redefine" pop3.isp.com using another
method. I think it's only possible by changing the hosts file on the Windows
PC. Changing the DSN entry is also an option but I don't think you want to
do that.

Just a thought, hope it helps,
Stefan




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

Date: 17 Mar 2004 19:08:35 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: truncated data after INSERT with undef in DBI - bug?
Message-Id: <u9smg7i958.fsf@wcl-l.bham.ac.uk>

"iain" <irhm@clara.net> writes:

> With DBI and SQL Server ODBC driver I have prepared an INSERT statement with
> placeholders.  But if the first execute has a undef (aka NULL), the execute
> for the following row is truncated to just the first character for the same
> field.
> 
> Has anyone else found this, or got a workaround?  Is it a problem with DBI,
> the DBD::ODBC driver or the SQL Server ODBC driver or SQL Server itself?

I've run your test script here and not reproduced the problem with:
  perl5.8.0 (ActiveState 806).
  DBI 1.37
  DBD::ODBC 1.05
  SQL server ODBC driver 2000.81.9042.00
  odbc32.dll,odbccp32.dll 3.520.9042.0
  odbccr32.dll,odbccu32.dll 3.520.9030.0
  SQL server 8.00.534 (SP2)

In addition to DBI tracing options mentioned by someone else you may
also want to trace the SQL server using the SQL Profiler tool.

I've experienced equally strnage problems on SQL servers lacking SP2.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

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


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