[22361] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4582 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 18 21:05:47 2003

Date: Tue, 18 Feb 2003 18: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           Tue, 18 Feb 2003     Volume: 10 Number: 4582

Today's topics:
        calling mrtg from a perlscript  <cyberob@freemail.nl>
        Extracting patterns <remccart@uiuc.edu.spam>
    Re: Extracting patterns (Jay Tilton)
    Re: Extracting patterns <noreply@gunnar.cc>
    Re: How do I install a new module in an ActiveState ins <geoff.news6@alphaworks.co.uk>
    Re: Need Help with Pattern Matching <PleaseDontThrowSpam@Me.com>
        nested loop logic <junk@afcoms.com>
    Re: nested loop logic (Jay Tilton)
    Re: nested loop logic <junk@afcoms.com>
        Problem with buffering on non-blocking socket under win <dodgynewsgroups@ewildgoose.demon.co.uk>
    Re: Problem with buffering on non-blocking socket under <dodgynewsgroups@ewildgoose.demon.co.uk>
        Removing HTML tags. <acm2@ukc.ac.uk>
    Re: Removing HTML tags. (Walter Roberson)
    Re: Removing HTML tags. <acm2@ukc.ac.uk>
    Re: Removing HTML tags. <abigail@abigail.nl>
    Re: Removing HTML tags. <tore@aursand.no>
    Re: Removing HTML tags. <acm2@ukc.ac.uk>
    Re: Returning the field list from DBI <peakpeek@purethought.com>
    Re: Unsuccesful "Print" <tassilo.parseval@post.rwth-aachen.de>
    Re: Unsuccesful "Print" <PleaseDontThrowSpam@Me.com>
    Re: Unsuccesful "Print" <tony_curtis32@yahoo.com>
    Re: Unsuccesful "Print" <PleaseDontThrowSpam@Me.com>
    Re: Unsuccesful "Print" <PleaseDontThrowSpam@Me.com>
        Uploading a file (g)
    Re: Uploading a file <tore@aursand.no>
    Re: Uploading a file <noreply@gunnar.cc>
    Re: use DBI; <rereidy@indra.com>
        Using Perl For My Printer Status ??? (Adam Rumpke)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 19 Feb 2003 00:11:30 +0100
From: "Rob" <cyberob@freemail.nl>
Subject: calling mrtg from a perlscript 
Message-Id: <3e52bfa8$0$2235$e4fe514c@dreader6.news.xs4all.nl>

Hello group,

We use MRTG with RRD to monitor our servers.

We have a perl script called mrtgmon.pl which executes the mrtg script
with a "do" function from a subroutine, it works but the perl process
runs out of memory. It seems that it is the MRTG perl script because if
we use a standard system call from the mrtgmon.pl script, the memory
of the perl process keeps low, because the separate process for MRTG
is terminated. This way the memory allocated by MRTG is freed again.

Why change it? Because if we use the do function we gain about 200
percent speed in monitoring all the servers(about 150 hosts in 45 sec.
instead of 200 sec.), while there are no separate processes started
for mrtg. In this way both the mrtmon.pl and mrtg script run in the
same interpreter.

Our question? Is it possible with the do function to free the memory
that the MRTG script uses, like in the system call.

Thankz in advance

gr,





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

Date: Tue, 18 Feb 2003 18:00:49 -0600
From: Ryan McCarthy <remccart@uiuc.edu.spam>
Subject: Extracting patterns
Message-Id: <vKz4a.37$o7.1175@vixen.cso.uiuc.edu>

I am trying to extract to an array all the different permutations of a 
string formatted like this:

ABCD(E|F)GHI...

Where this would produce an array with two entries

1. ABCDEGHI
2. ABCDFGHI

The trick is that there can be 0 or more of these (X|Y) notations. 
Anybody have any suggestions?

Thanks!



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

Date: Wed, 19 Feb 2003 00:54:32 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Extracting patterns
Message-Id: <3e52d4fd.24820835@news.erols.com>

Ryan McCarthy <remccart@uiuc.edu.spam> wrote:

: I am trying to extract to an array all the different permutations of a 
: string formatted like this:
: 
: ABCD(E|F)GHI...

Is that format set in stone, or are you permitted to change it?

: Where this would produce an array with two entries
: 
: 1. ABCDEGHI
: 2. ABCDFGHI
: 
: The trick is that there can be 0 or more of these (X|Y) notations. 
: Anybody have any suggestions?

You can use an often overlooked ability of glob() to do that.

    #!perl -l
    print for glob( 'ABCD{E,F}GHI' );

The string argument to glob() is similar in format to yours, but not
quite the same.



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

Date: Wed, 19 Feb 2003 01:36:25 GMT
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Extracting patterns
Message-Id: <tcB4a.719$ID6.2139@newsc.telia.net>

Ryan McCarthy wrote:
> I am trying to extract to an array all the different permutations of a 
> string formatted like this:
> 
> ABCD(E|F)GHI...
> 
> Where this would produce an array with two entries
> 
> 1. ABCDEGHI
> 2. ABCDFGHI
> 
> The trick is that there can be 0 or more of these (X|Y) notations. 
> Anybody have any suggestions?

Do you mean that two (X|Y) notations would result in 2 x 2 = 4 entries 
in the array, and that three of them would result in 2 x 2 x 2 = 8 
entries, etc.?

/ Gunnar

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



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

Date: Tue, 18 Feb 2003 23:24:58 -0000
From: "Geoff Soper" <geoff.news6@alphaworks.co.uk>
Subject: Re: How do I install a new module in an ActiveState installation
Message-Id: <3e52c0cb$0$364$cc9e4d1f@news.dial.pipex.com>

"David K. Wall" <usenet@dwall.fastmail.fm> wrote in message
news:Xns9326B6242B49Bdkwwashere@216.168.3.30...
> Geoff Soper <geoff.news6@alphaworks.co.uk> wrote on 18 Feb 2003:
>
> > I'm using an ActiveState installation of Perl running on a Win XP
> > PC. How do I install and use a module that isn't currently
> > installed. In this case I want to use Crypt::BlowFish in a script.
> > I've tried simply creating a directory named Crypt in C:\Perl\lib\
> > and putting BlowFish.pm in it but this didn't work. I've put use
> > Crypt::Blowfish; in the file I'm trying to execute.
>
> Read the docs for PPM, the Perl Package Manager that Activestate uses.
>
> Activestate Docs -> Table of Contents -> ActivePerl Components -> PPM
>

Yup, that's just been suggested by someone else and did the trick. Thanks
very much!

Geoff




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

Date: Wed, 19 Feb 2003 01:50:07 -0000
From: "Mikey" <PleaseDontThrowSpam@Me.com>
Subject: Re: Need Help with Pattern Matching
Message-Id: <b2unps$mme$1@wisteria.csv.warwick.ac.uk>


"Benjamin Goldberg" <goldbb2@earthlink.net> wrote in message
news:3E52B77F.4086D47C@earthlink.net...
> Mikey wrote:
> [snip]
> > I'm trying to sort the following data by Height:
> > (this data resides in store.dat, each field separated by a space)
> >
> > DOB Cash Name Height
> >
> > 12.01.1963 100 John Smith 5.11
> > 27.02.1955 200 Jimmy Dolan Andrews 5.8
> > 16.03.1977 400 Johnny Barrosh 5.4
> > 09.01.1987 200 Steve McHooter 5.5
> > 01.02.1983 100 Blaro Van Daronimo 4.4
> >
> > I can't work out a correct pattern matching line which will
> > successfully separate these fields.
>
> The problem is that the fields are seperated by spaces, and the Name
> field has a variable number of embeded spaces.
>
> Thus, you can't just split on spaces and get the 4th element after
> splitting.
>
> However... the height field is always the *last* field when splitting on
> whitespace, even if the number of fields before it vary.

This is true but I also may want to access the oter fields later. Would this
type of pattern matching be possible despite the fact that the separotors
are spaces and a field can have random number of spaces in it?

 >So, you can do the following:
>
>    open( FH, "<", "store.dat" ) or die $!;
>    print sort {
>       (split(' ', $a))[-1] <=> (split(' ', $b))[-1]
>    } <FH>;
>    __END__
>

This compiles and runs but how do I print the newly sorted data?

> Note that for large files, this repeated splitting is innefficient...
> One may get faster results with:
>
>    open( FH, "<", "store.dat" ) or die $!;
>    print $_->[0] for
>       sort { $a->[1] <=> $b->[1] }
>       map [ $_, /(\S+)$/ ],
>       <FH>; # read the data in.
>    __END__
>
> This the 'Schwartzian-Transform', a commonly used optomization when
> sorting data with perl.
>




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

Date: Wed, 19 Feb 2003 00:03:17 GMT
From: "Chip" <junk@afcoms.com>
Subject: nested loop logic
Message-Id: <9Rz4a.10827$jR3.5645267@news1.news.adelphia.net>

I am trying to compare items in two different arrays.
I want to have the matches of the two arrays put into
one array and  non-matches either put into a new array
or left in the original array.

After days of searching I can't seem to find this on FAQ's or Google.
I have found tons of information on matching and putting the
matches into an array but can't seem to find any info on putting
the non-matches into a different array.

The following code was an attempt to pop the data from the
first array into a new array if the data matched but not pop
the data from the first array if it did not match. Thus putting
the matches into a new array and leaving the non-matches in
the first array.

<snip>
for ( $i = 0; $i <= $size_of_array; $i++ )
  {
    $data = $first_array[$i];
      for ( $j = 0; $j <= $size_of_array; $j++ )
        {
           push(@matches, pop(@first_array)) if $data eq $second_array[$j];
         }
   }
</snip>

I think that all of the logic must be done in the nested loop
but can't get it working.
Any and all help is greatly appreciated.
Chip








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

Date: Wed, 19 Feb 2003 01:03:17 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: nested loop logic
Message-Id: <3e52d635.25133155@news.erols.com>

"Chip" <junk@afcoms.com> wrote:

: I am trying to compare items in two different arrays.
: I want to have the matches of the two arrays put into
: one array 

The 'matches' form what is called the intersection of two arrays.

: and  non-matches either put into a new array
: or left in the original array.

The 'non-matches' form what is called the difference of two arrays.
 
: After days of searching I can't seem to find this on FAQ's or Google.

Was the information in subsection of perlfaq4 titled How do I compute
the difference of two arrays? How do I compute the intersection of two
arrays?" unhelpful?



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

Date: Wed, 19 Feb 2003 01:38:45 GMT
From: "Chip" <junk@afcoms.com>
Subject: Re: nested loop logic
Message-Id: <FeB4a.10879$jR3.5663872@news1.news.adelphia.net>

Thanks Jay,

I was not aware of intersection and difference.
It does exactly what I was looking for.

Chip

"Jay Tilton" <tiltonj@erols.com> wrote in message
news:3e52d635.25133155@news.erols.com...
> "Chip" <junk@afcoms.com> wrote:
>
> The 'matches' form what is called the intersection of two arrays.
> The 'non-matches' form what is called the difference of two arrays.
>
> Was the information in subsection of perlfaq4 titled How do I compute
> the difference of two arrays? How do I compute the intersection of two
> arrays?" unhelpful?
>




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

Date: Tue, 18 Feb 2003 23:38:52 GMT
From: "Ed W" <dodgynewsgroups@ewildgoose.demon.co.uk>
Subject: Problem with buffering on non-blocking socket under win32
Message-Id: <guz4a.672138$zx5.100444@news.easynews.com>

Many thanks to those who have answered my foolish questions about sockets in
the past....!

Today's little teaser is to do with non-blocking sockets, specifically under
win32 and activeperl 5.6.1 (on Win XP)

In a nutshell I try and write a huge amount of data to a standard IO:Socket
(say, 1-10MB), and I expect to see that (say) 32KB gets swallowed, the rest
is left.  However, in fact the whole lot gets written .... somewhere ....
and the syswrite function then returns immediately (where did it all go?)

I want to limit the amount of data that the OS/Perl is buffering because I
am writing an application proxy (for email) and I don't want to accept too
much data if it isn't getting written back out again swiftly enough (and it
needs to be non-blocking so that I can handle multiple connections).  Here
it seems that I am just stuffing the data into a blackhole and not getting
any feedback on whether it is getting written across the wire or not...

Any thoughts?

Thanks all

Ed



Demonstration code below:

#!/usr/bin/perl -w

use strict;
use warnings;
use IO::Socket;


    my $remote = IO::Socket::INET->new(
        Proto    => "tcp",
        Type     => SOCK_STREAM);

    $remote->blocking(0);

    my $iaddr   = inet_aton("192.168.105.1")               || die "no host";
    my $paddr   = sockaddr_in(80, $iaddr);
    $remote->connect($paddr) or die "error in connect";

    my $buf_temp = '';
    my $buf = '';

    # Nasty way to generate a 1MB string
    for my $x (1..1024) {
      $buf_temp .= 'X';
    }
    for my $y (1..1024) {
      $buf .= $buf_temp
    }

    print "String length: " . length($buf) . "\r\n";

    my $n = syswrite( $remote, $buf );

    # See it writes the whole lot to the socket
    print "Amount written: $n\r\n";




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

Date: Tue, 18 Feb 2003 23:45:55 GMT
From: "Ed W" <dodgynewsgroups@ewildgoose.demon.co.uk>
Subject: Re: Problem with buffering on non-blocking socket under win32
Message-Id: <TAz4a.362996$1y5.2627426@news.easynews.com>

In fact I have just noticed that if I comment out the $remote->blocking(0)
then syswrite still returns immediately and I can see from the performance
monitor that the OS/Perl carries on in the background actually writing the
stuff over the wire...

 ...is this normal?  I am writing over a very slow satellite modem and
reading from an email client on the local machine so I really need to be
able to see how much data is outstanding to be written to the modem (it
could take a very long time to clear down!)

Ed




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

Date: Tue, 18 Feb 2003 23:42:53 -0000
From: Tony McNulty <acm2@ukc.ac.uk>
Subject: Removing HTML tags.
Message-Id: <oprktdhrl52czp9w@news.ukc.ac.uk>

Hello there,

This is my first posting to the group, but I confess to having been a 
lurker for a little over a year.

Funnily enough, I'm having a little trouble writing a perl script. I am 
attempting to strip the html out of my string.

Essentially, I'm writing an add-on for an irc bot that I wrote a little 
while ago. I'm attempting to get a page from the web, and then stripping 
the html tags from it to make it easier to extract the text that I need 
from it.

I've just been browsing through the module lists on CPAN to see if there 
was any there to help with this, and only found one that applied to files 
only. Hopefully one of you lovely people might know aof a module around 
that might help... Oh, and I already checked the perlfaq -q's for all I 
could think of, with no luck :)

Regards,

Tony McNulty



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

Date: 18 Feb 2003 23:52:02 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: Removing HTML tags.
Message-Id: <b2ugv2$l2g$1@canopus.cc.umanitoba.ca>

In article <oprktdhrl52czp9w@news.ukc.ac.uk>,
Tony McNulty  <acm2@ukc.ac.uk> wrote:
:Funnily enough, I'm having a little trouble writing a perl script. I am 
:attempting to strip the html out of my string.

:Essentially, I'm writing an add-on for an irc bot that I wrote a little 
:while ago. I'm attempting to get a page from the web, and then stripping 
:the html tags from it to make it easier to extract the text that I need 
:from it.

HTML::Parse perhaps?
-- 
   I was very young in those days, but I was also rather dim.
   -- Christopher Priest


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

Date: Tue, 18 Feb 2003 23:54:54 -0000
From: Tony McNulty <acm2@ukc.ac.uk>
Subject: Re: Removing HTML tags.
Message-Id: <oprktd1sm62czp9w@news.ukc.ac.uk>

On 18 Feb 2003 23:52:02 GMT, Walter Roberson <roberson@ibd.nrc-cnrc.gc.ca> 
wrote:

> In article <oprktdhrl52czp9w@news.ukc.ac.uk>,
> :Essentially, I'm writing an add-on for an irc bot that I wrote a little 
> :while ago. I'm attempting to get a page from the web, and then stripping 
> :the html tags from it to make it easier to extract the text that I need 
> :from it.
>
> HTML::Parse perhaps?

Hasn't that been deprecated?

Cheers,

Tony


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

Date: 19 Feb 2003 00:09:29 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Removing HTML tags.
Message-Id: <slrnb55ipp.263.abigail@alexandra.abigail.nl>

Tony McNulty (acm2@ukc.ac.uk) wrote on MMMCDLVIII September MCMXCIII in
<URL:news:oprktdhrl52czp9w@news.ukc.ac.uk>:
:)  Hello there,
:)  
:)  This is my first posting to the group, but I confess to having been a 
:)  lurker for a little over a year.

Lurking for a while is good. But only if you pay attention.

:)  Funnily enough, I'm having a little trouble writing a perl script. I am 
:)  attempting to strip the html out of my string.

I'm flabbergasted. You've been lurking more than a year, and on your first
post you ask a FAQ? And one of the more frequently asked ones as well.


Do you have a reason I shouldn't ploink you and give myself a chance
to read a potential second posting by you?



Abigail
-- 
perl -wle'print"Κυστ αξοτθες Πεςμ Θαγλες"^"\x80"x24'


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

Date: Wed, 19 Feb 2003 02:17:38 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: Removing HTML tags.
Message-Id: <pan.2003.02.19.01.05.52.977631@aursand.no>

On Tue, 18 Feb 2003 23:54:54 +0000, Tony McNulty wrote:
>> HTML::Parse perhaps?

> Hasn't that been deprecated?

Whoa!  You know that the module is deprecated, but you don't know what
replacement modules to use?  You should really start _reading_ the module
documentation from now on!

Excerpt from 'perldoc HTML::Parse':

    "Disclaimer: This module is provided only for backwards
     compatibility with earlier versions of this library.  New
     code should not use this module, and should really use
     the HTML::Parser and HTML::TreeBuilder modules directly,
     instead."


-- 
Tore Aursand - tore@aursand.no - http://www.aursand.no/



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

Date: Wed, 19 Feb 2003 02:00:09 -0000
From: Tony McNulty <acm2@ukc.ac.uk>
Subject: Re: Removing HTML tags.
Message-Id: <oprktjujbf2czp9w@news.ukc.ac.uk>

On Wed, 19 Feb 2003 02:17:38 +0100, Tore Aursand <tore@aursand.no> wrote:

> On Tue, 18 Feb 2003 23:54:54 +0000, Tony McNulty wrote:
>>> HTML::Parse perhaps?
>
>> Hasn't that been deprecated?
>
> Whoa!  You know that the module is deprecated, but you don't know what
> replacement modules to use?  You should really start _reading_ the module
> documentation from now on!

Hmm, read through and played around with Parse, Parser and TreeBuilder. 
Decided none of them are what I want to use now. Figured it might just be 
simpler to design a regex, and turns out it is :) Hopefully the site aren't 
planning on changing their layout soon :)

Apologies for sparking the reactions I did... I've never held an interest 
in html parsing before (generally just JAPH's and perl golf), and often 
skip over the posts on the matter. A quick search through groups.google.com 
proved how much I had actually overlooked :)

Cheers,

Tony


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

Date: Wed, 19 Feb 2003 01:07:15 +0000
From: Sharon Grant <peakpeek@purethought.com>
Subject: Re: Returning the field list from DBI
Message-Id: <4hj55vc0q3nqqhvt2ounjltqj145li3vsk@4ax.com>

On Tue, 18 Feb 2003 15:43:23 -0500, in comp.lang.perl.misc, Benjamin Goldberg <goldbb2@earthlink.net> wrote:

>Jason Singleton wrote:
>> 
>> Also how do I change the read position in the returned data? I don't
>> want to return all records to the user at once I want it to display
>> the returned data in pages like a search engine.

SQL is a set-oriented data access language. The general advice
has always been that there should not be a need to return part
of a set. Instead the query should be refined to return a
smaller set


>There's two possible ways, both of which require support from the SQL
>driver.
>
>One is to use a LIMIT clause; this is the prefered way.
>
>The other is to use the ->func method on the statement handle, to tell
>the driver that you want to skip forward some number of records.  I'm
>not sure what databases, if any, have this kind of functionality.
>
>There's sortof a third way -- simply read and discard as many records as
>you want to skip.  This is innefficient, but portable

All the above suggestions assume that the DBMS is going to
return the data in the same order each time, which an SQL DBMS
may not do unless:
- the query has an ORDER BY clause, and
- the column names in the ORDER BY clause specify a unique key

This is explained more eloquently in the PostgreSQL
documentation of the LIMIT clause:
 http://tinyurl.com/61r3

Now, since a uniquely keyed ORDER BY clause is required in any
case, paging can be implemented (portably) by saving the key
of the last row of the current page, and including that key in
the search conditions of the WHERE clause of the query which
is to produce the next page

The syntax of the search conditions gets a bit verbose for a
multi-column key, but that's part of the cost of SQL

-- 
Sharon


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

Date: 18 Feb 2003 23:12:52 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Unsuccesful "Print"
Message-Id: <b2uelk$p6a$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Mikey:

> I am trying to run a Perl file on a Unix machine.
> 
> The following command successfully runs on a windows machine
> 
> print "Incorrect Usage\n";
> 
> But on the Unix machine nothing happens, the program doesn't error or
> anything, it just fails to print.
> 
> The weird thing is that when I give an invalid option to the Perl file the
> following is successfully output:
> 
> Unknown option: x

Probably because it's going to stderr which is typically unbuffered.

> So what is happening? Why are somethings being out put whilst others aren't?
> 
> How can I fix it so that all is desired output is successful?

By turning on autoflush on the selected filehandle (stdout usually). Add
this to the top of your script:

    $| = 1;
    
> PS. Sorry for the cross post, I think I got the wrong newsgroup

You did not cross-post. This remark gives me the uneasy impression that
you multi-posted (separate posts into several groups). A cross-post
would be preferable since it keeps the postings joined together.

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, 19 Feb 2003 01:34:39 -0000
From: "Mikey" <PleaseDontThrowSpam@Me.com>
Subject: Re: Unsuccesful "Print"
Message-Id: <b2umsr$mc8$1@wisteria.csv.warwick.ac.uk>


"Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de> wrote in
message news:b2uelk$p6a$1@nets3.rz.RWTH-Aachen.DE...
> Also sprach Mikey:
>
> > I am trying to run a Perl file on a Unix machine.
> >
> > The following command successfully runs on a windows machine
> >
> > print "Incorrect Usage\n";
> >
> > But on the Unix machine nothing happens, the program doesn't error or
> > anything, it just fails to print.
> >
> > The weird thing is that when I give an invalid option to the Perl file
the
> > following is successfully output:
> >
> > Unknown option: x
>
> Probably because it's going to stderr which is typically unbuffered.
>
> > So what is happening? Why are somethings being out put whilst others
aren't?
> >
> > How can I fix it so that all is desired output is successful?
>
> By turning on autoflush on the selected filehandle (stdout usually). Add
> this to the top of your script:
>
>     $| = 1;
>

I simply added this to the first line of my code and it didn't work.
Results were exactly as before.

What is going wrong?

Mikey




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

Date: Tue, 18 Feb 2003 19:36:46 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Unsuccesful "Print"
Message-Id: <87isvhuk41.fsf@limey.hpcc.uh.edu>

>> On Wed, 19 Feb 2003 01:34:39 -0000,
>> "Mikey" <PleaseDontThrowSpam@Me.com> said:

>> > I am trying to run a Perl file on a Unix machine.
>> > The following command successfully runs on a windows
>> machine
>> > print "Incorrect Usage\n";
>> > But on the Unix machine nothing happens, the program
>> doesn't error or > anything, it just fails to print.
>> > The weird thing is that when I give an invalid option
>> to the Perl file
> the
>> > following is successfully output:
>> >
>> > Unknown option: x
>> 
>> By turning on autoflush on the selected filehandle
>> (stdout usually). Add this to the top of your script:
>> 
>> $| = 1;
>> 

> I simply added this to the first line of my code and it
> didn't work.  Results were exactly as before.
> What is going wrong?

Show us the *real* code.  If the program was just

    print "Incorrect Usage\n";

then it wouldn't be parsing command-line options.

hth
t


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

Date: Wed, 19 Feb 2003 01:41:55 -0000
From: "Mikey" <PleaseDontThrowSpam@Me.com>
Subject: Re: Unsuccesful "Print"
Message-Id: <b2unaf$mhu$1@wisteria.csv.warwick.ac.uk>


"Walter Roberson" <roberson@ibd.nrc-cnrc.gc.ca> wrote in message
news:b2udg7$jhq$1@canopus.cc.umanitoba.ca...
> In article <b2uauu$fi9$1@wisteria.csv.warwick.ac.uk>,
> Mikey <PleaseDontThrowSpam@Me.com> wrote:
> :I am trying to run a Perl file on a Unix machine.
>
> :The following command successfully runs on a windows machine
>
> :print "Incorrect Usage\n";
>
> :But on the Unix machine nothing happens, the program doesn't error or
> :anything, it just fails to print.
>
> And is that -all- there is in the program?
>
> :The weird thing is that when I give an invalid option to the Perl file
the
> :following is successfully output:
>
> :Unknown option: x
>
> Clearly not, then.
>
>
> :So what is happening? Why are somethings being out put whilst others
aren't?
>
> Insufficient information.
>
> $ perl
> print "Incorrect Usage\n";
> Incorrect Usage
>
>
> What I would suspect is that something in the code select's a
> different handle.
>
> $ perldoc -f select
>           select FILEHANDLE
>           select  Returns the currently selected filehandle.  Sets the
>                   current default filehandle for output, if FILEHANDLE
>                   is supplied.  This has two effects: first, a "write"
>                   or a "print" without a filehandle will default to
>                   this FILEHANDLE.  Second, references to variables
>                   related to output will refer to this output channel.
>

I'm having trouble with this FileHandle concept. I assume I need to redirect
it somehow but have no idea how to do this, even after researching

Could I have some help please?

Thank-you,

Mikey




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

Date: Wed, 19 Feb 2003 02:02:39 -0000
From: "Mikey" <PleaseDontThrowSpam@Me.com>
Subject: Re: Unsuccesful "Print"
Message-Id: <b2uohb$n25$1@wisteria.csv.warwick.ac.uk>

"Tony Curtis" <tony_curtis32@yahoo.com> wrote in message
news:87isvhuk41.fsf@limey.hpcc.uh.edu...
> >> On Wed, 19 Feb 2003 01:34:39 -0000,
> >> "Mikey" <PleaseDontThrowSpam@Me.com> said:
>
> >> > I am trying to run a Perl file on a Unix machine.
> >> > The following command successfully runs on a windows
> >> machine
> >> > print "Incorrect Usage\n";
> >> > But on the Unix machine nothing happens, the program
> >> doesn't error or > anything, it just fails to print.
> >> > The weird thing is that when I give an invalid option
> >> to the Perl file
> > the
> >> > following is successfully output:
> >> >
> >> > Unknown option: x
> >>
> >> By turning on autoflush on the selected filehandle
> >> (stdout usually). Add this to the top of your script:
> >>
> >> $| = 1;
> >>
>
> > I simply added this to the first line of my code and it
> > didn't work.  Results were exactly as before.
> > What is going wrong?
>
> Show us the *real* code.  If the program was just
>
>     print "Incorrect Usage\n";
>
> then it wouldn't be parsing command-line options.
>
> hth
> t

This is a cut down version that has the exact same problems - it wont output
anything!

(perl perlfile.pl -h yields nothing, as does the -h anything option)
(perl perlfile.pl -x will give Unknown option: x)

use strict;

use Getopt::Std;

my($opt_h, $opt_a);


getopts('ha:');


if ( $opt_h ) {

 print "\nUsage: perlfile [ options ] arg\n";

}

if ( $opt_a ) {

 print "\nYou entered $opt_a\n";
}




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

Date: 18 Feb 2003 15:58:45 -0800
From: the_game_is_never_over@yahoo.co.uk (g)
Subject: Uploading a file
Message-Id: <2059e247.0302181558.30889f6c@posting.google.com>

I have created a simple script (below) to upload files on my server.
Is there a way checking if the file been uploaded is a text file and
reject if it is not. Any help will be greatly appreciated.





use CGI qw/:standard/;
use CGI::Carp 'fatalsToBrowser';

$in = new CGI();
$INPUT = $in->param('original');
$outtie = $in->param('newname');
$OUTPUT = ">./$outtie";

open (OUTPUT) || die "Unable to open file for writing";

print $in->header();
print $in->start_html("Thank You");
print "<h2>Thank You For Sending a review $INPUT</h2>";

while($line = <$INPUT>) {
   print $line; # display contents back in browser
   print OUTPUT $line; # save in a file
}

close OUTPUT;

print $in->end_html();

exit(0);




html
HTML>
<HEAD>
      <TITLE>Review Uploader in perl</TITLE>
</HEAD>
<BODY>
      <h1>Review  Uploader</h1>

      <FORM METHOD="POST" 
        ENCTYPE="multipart/form-data"  
        action="../cgi-bin/upload.cgi">

  <table border="0" align="center">
    <tr>
      <th>Enter A File Name: </th>
      <td>
        <INPUT TYPE="file" 
                NAME="original"  
                VALUE="starting" 
                SIZE="120" 
                MAXLENGTH="120">
  </td>
      <tr>
        <th>the name of the album reviewed </th>
        <td>
          <input type="texfield" 
            name="newname" length="36" maxlength="36">
        </td>
        <tr>
          <td><input type="submit" value="Submit File"></td>
          <td><input type="reset" value="Reset Form"></td>
        </tr>
	
  </table>
</FORM>
</BODY>
</HTML>


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

Date: Wed, 19 Feb 2003 02:18:00 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: Uploading a file
Message-Id: <pan.2003.02.19.01.07.59.579535@aursand.no>

On Tue, 18 Feb 2003 15:58:45 -0800, g wrote:
> Is there a way checking if the file been uploaded is a text file
> and reject if it is not.

Run the file through a spell checker.  If there are too many errors in it,
it most probably should be rejected anyway. :)


-- 
Tore Aursand - tore@aursand.no - http://www.aursand.no/



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

Date: Wed, 19 Feb 2003 01:29:14 GMT
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Uploading a file
Message-Id: <K5B4a.718$ID6.2161@newsc.telia.net>

g wrote:
> Is there a way checking if the file been uploaded is a text file and
> reject if it is not.

     if (-T $file) {
         do something;
     } else {
         don't do it;
     }

See also http://www.perldoc.com/perl5.6/pod/func/X.html

/ Gunnar

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



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

Date: Tue, 18 Feb 2003 16:20:47 -0700
From: Ron Reidy <rereidy@indra.com>
Subject: Re: use DBI;
Message-Id: <3E52BFCF.5040604@indra.com>

Hmmm, when I download the archive from 
http://ppm.activestate.com/PPMPackages/zips/6xx-builds-only/ and look at 
the file DBD-MySQL.ppd, I see the following:

SOFTPKG NAME="DBD-Mysql" VERSION="1,2200,0,0">
   <IMPLEMENTATION>
     <CODEBASE HREF="MSWin32-x86-multi-thread/DBD-Mysql.tar.gz" />
     <DEPENDENCY NAME="DBI" VERSION="1,08,0,0" />
     <ARCHITECTURE NAME="MSWin32-x86-multi-thread" />
     <OS NAME="MSWin32" />
   </IMPLEMENTATION>
   <ABSTRACT>DBI driver for Mysql datasources</ABSTRACT>
   <TITLE>DBD-Mysql</TITLE>
   <AUTHOR>Jochen Wiedmann (joe@ispsoft.de)</AUTHOR>
</SOFTPKG>


Looks like it will work on Win32 to me.  So I tried it as follows:

ppm install DBD::MySQL

And I received the same error as you.  So I tried this:

ppm install DBD::MySQL.ppd

And it installed fine.

Maybe you should send an email to AS and let them know about this.

--
Ron Reidy
Oracle DBA

g wrote:
> Thanks for your help guys, I have now installed dbi but when to
> install DBD::Mysql though active perl it says its not indented for
> this build of perl.:((
> 
>  I use windows 2000, perl 5.6   any1 have any ideas



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

Date: 18 Feb 2003 17:14:23 -0800
From: goldstonrumpke@hotmail.com (Adam Rumpke)
Subject: Using Perl For My Printer Status ???
Message-Id: <13c3ff37.0302181714.58b4ea66@posting.google.com>

I am currently trying to build a homemade-small intranet project for
my fathers business. This job requires the web/file server to send the
users a message telling them the status. FOR EXAMPLE: If I want to
print and the printer is jammed a user at home will need to know the
printer is not working. I would like the system to send a message via
the browser. Although, I am computer literate I wont be writing the
script myself. I like perl as an option since I would have to pay a
programmer to make the script. Having a programmer use the perl option
should reduce the cost. Could this job be done in Perl?

ADAM-san


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

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


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