[12200] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5800 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 27 05:07:15 1999

Date: Thu, 27 May 99 02:00:20 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 27 May 1999     Volume: 8 Number: 5800

Today's topics:
    Re: ? collecting data from URL, then save as text-file  <PrinsPaul@DELETETHIShotmail.com>
        ? form with binary attachment ? <PrinsPaul@DELETETHIShotmail.com>
    Re: flock and string search. (Tim Herzog)
        how can i produce graphical invoices using perl? smnayeem@my-deja.com
        How to write htaccess? (Austin Ming)
        IO::Pty && syswrite <edsys@my-deja.com>
        Meeting Amsterdam Perl Mongers, June 1st, 1999 (Johan Vromans)
    Re: Perl on Win32 - How can I hide the process? <xrxoxtxhxdx@xrxoxtxhx.xnxextx>
    Re: perl script as an executable (Tim Herzog)
    Re: perl script as an executable <uri@sysarch.com>
    Re: please test my new site.. <fruffet@kaptech.com>
    Re: please test my new site.. (Arnaud Limbourg)
    Re: please test my new site.. (Nick Meredith)
        Problem with a program to translate character <jplaux@easynet.fr>
    Re: Problem with a program to translate character <fruffet@kaptech.com>
        Q. about pattern matching ()
    Re: Reading text file (Tim Herzog)
    Re: Reading text file (Larry Rosler)
        regexp (?{...}) bug ? <marian.kelc@ruhr-uni-bochum.de>
    Re: req: directional help <office@asc.nl>
    Re: unexponentialize field from text file (Larry Rosler)
    Re: why doesn't my first program work?? (ok , third or  <office@asc.nl>
    Re: why doesn't my first program work?? (ok , third or  (Tim Herzog)
    Re: why doesn't my first program work?? (ok , third or  (Tim Herzog)
    Re: writing binary stuff back to a browser, funky forma (Larry Rosler)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Thu, 27 May 1999 08:09:17 +0200
From: "Paolo" <PrinsPaul@DELETETHIShotmail.com>
Subject: Re: ? collecting data from URL, then save as text-file ?
Message-Id: <7iinc5$od9k$1@reader2.wxs.nl>

Thanks Randal, it worked.
Greetings
Paolo




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

Date: Thu, 27 May 1999 09:55:49 +0200
From: "Paolo" <PrinsPaul@DELETETHIShotmail.com>
Subject: ? form with binary attachment ?
Message-Id: <7iitjt$ofma$1@reader2.wxs.nl>

Hi,

My ISP provides me a script I can use to create(send)  forms.
But I can't let people send binary attachments with these provided scripts.
Can someone tell me where I can find a script with which I can do this ?
Xcuse my English but I hope the question is clear.
Can someone give me a clear or rather satisfying answer ?

Thanx in advance.
Paolo





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

Date: Thu, 27 May 1999 01:56:08 -0500
From: therzog@knotech.com (Tim Herzog)
Subject: Re: flock and string search.
Message-Id: <therzog-2705990156080001@therzog-host105.dsl.visi.com>

In article <374ccb44.1@news1.starnetinc.com>, "$Richy Rich$"
<rich_guy@hotmail.com> wrote:

>hi,
>
>    i can't find an in-depth answer to this question, so i'll go ahead
>and ask. if you can point me to a URL or info file regarding the flock
>command, then that would do, rather then repeating some text. my
>question is, i know how to implement the flock command for locking a
>file, but i don't understand how it works with the 'wait' i guess. if
>the file is locked and my isp i am running a cgi script on is deathly
>slow (which is usually is!), then if another user tries to create a
>session file (by the same name - there's a reason for this which is
>irrelevant to my question), does this user's process just wait as long
>as it takes for the file to be unlocked? i only ask, because i
>understand this is how it works, but i mean, will the second user's
>process time out, go zombie or error if it takes too long? i need to use
>exclusive locks, as it creates a new file for each user, in order and
>increments by one each time - until it reaches a limit. do i have to be
>concerned about users getting 500 errors or timing out and getting a
>document contains no data error a lot, or will it simply wait until the
>time needed? if not, what's the way around this? i have earlier versions
>of this program that use badly written code, where it has manual locks
>by checking to see if they exist, which is a bad idea already and worse
>seeing that this isp is so bogged down for other people's bad ideas. :)
>(and yes, i've checked man flock, etc.)

As far as I know, flock(FILE, $LOCK_EX) will loop forever or until the
file can be locked.

What you might consider is flock(FILE, $LOCK_EX | $LOCK_NB), which make
flock return 0 if the file can't be locked right away (i.e., someone else
locked it).  You can then sleep for awhile and try again, or bail if
you've been waiting too long.

>The other question i have, is how to best implement a block for foul
>words for people's names within their session. i take the string and
>check in a sub routine for matches. i first changed the string to lower
>case only by saying
>sub Check {
>my ($string) = shift;
>$text = lc($string);
>$bad_word = 1 if ($test =~ m!badword1! || $test =~ m!badword2!
>            || $test =~ m!badword3!); #etc. (there's more of course!).
>return(string); #return result for printing/adding info once
>processed/checked.
>}
>
>this is called by
>
> $string = Check($string);
>
>and then saying
>
> if ($ban_word == 1) {
>   print "sorry, try again, that contains a bad word!\n";
>   exit;
>} else {
> submit info.
>}
>
>how can i have it so it stops searching at the first bad word it finds?
>i've checked all the info i can about it (with my limited knowledge),
>but i can't find that. i'm desperately trying to get my scripts to run
>faster and not do any more work then needed, but i can't find the info i
>seek in any of my perl books, well at least not yet. i've looked but i
>think it's going to be a while before i get to that area, but i find i
>need that info now. until then, i kindly ask for any advice or direction
>to the proper area. i have learning perl, programming perl, the perl
>cookbook (the right one), effective perl and some others and i still
>can't find the info i need. did i overlook a page?
>
>thanks and sorry for the rambling!

Actually, the code you wrote will stop checking at the first bad word.  OR
expressions evaluate from left to right, and stop evaluating as soon as
one clause evaluates true.


A cleaner approach might be:

$badWords = "darn|fooey|dagnabit";

if( $string =~ /($badWords)/ ) {
  $firstBadWord = $1;
  $bad_word = 1;
}

-- 
Tim Herzog


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

Date: Thu, 27 May 1999 08:09:35 GMT
From: smnayeem@my-deja.com
Subject: how can i produce graphical invoices using perl?
Message-Id: <7iiuju$8cm$1@nnrp1.deja.com>

I need to produce reports using perl, say with different font size and
then also using symbols etc. does anyone how i can do this, i cant seem
to be able to print anything other than ordinary big text using perl.
can anyone help?
thanks
nayeem


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


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

Date: 27 May 1999 07:17:54 GMT
From: austin95002887@yahoo.com (Austin Ming)
Subject: How to write htaccess?
Message-Id: <7iirj2$78k$2@justice.csc.cuhk.edu.hk>


How to write htaccess?



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

Date: Thu, 27 May 1999 05:50:34 GMT
From: ColinM <edsys@my-deja.com>
To: gbarr@ti.com
Subject: IO::Pty && syswrite
Message-Id: <7iimfa$24q$1@nnrp1.deja.com>

[AIX 4.2.1 && Perl 5.004_04]

Hoping someone out there can steer me in the right direction...

We have a news-routing program written in C that wants to get it's input
from /dev/$DEV - until now $DEV = tty[1-9].

I have captured a continuous news-feed from a wire service using a perl
TCP socket & hope to feed the data to a device in /dev/pts/[1-9] in the
hope that the news-routing program will take it's input from
/dev/pts/[1-9].

I've installed IO::Pty and found that $ttyname = /dev/pts/[1-9] (where
[1-9] is the next available slave).

Questions:
==========

* How do I write unbuffered output to $pty using syswrite?
===============================<snip>=================================
use Socket;
use FileHandle;
use IO::Pty;
### Socket setup ommitted to save space...
connect(SOCK, $paddr) or &BARF("connect: $!");
SOCK->autoflush(1);
$pty = new IO::Pty;
$pty->autoflush(1);
$blksize = (stat SOCK)[11] || 16384;
while (1) {
         $len = sysread SOCK, $buf, $blksize;
         if (!defined $len) {
            next if $! =~ /^Interrupted/;
            die "System read error: $!";
         }
         $offset = 0;
         while ($len) {
               $written = syswrite $pty, $buf, $len, $offset;
               die "System write error: $!" unless defined $written;
               $len -= $written;
               $offset += $written;
#              $pty->print("$buf\n"); ### Swapping this line for the
#                                     ### above 4 lines writes every
#                                     ### character read from SOCK
#                                     ### to $pty (on a separate line).
        }
}
###
### I want to syswrite each character sysread from SOCK to $pty ###
###
### Switching $pty for a regular file works fine. ###
###
#############################################
### Also tried the following to no avail..
### use IO::Handle '_IONBF';
### $pty->setvbuf($buffer_var, _IONBF, 1024);
#############################################
===============================<snip>=================================

* Is there any means of controlling the value of $ttyname so the
news-routing program knows where to go looking for it's input (which
needs to be pre-set in it's startup file)?

* Are there likely to be sharing issues with $ttyname?

Any advice will be greatly appreciated.

--
ColinM


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


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

Date: 27 May 1999 09:42:08 +0200
From: JVromans@Squirrel.nl (Johan Vromans)
Subject: Meeting Amsterdam Perl Mongers, June 1st, 1999
Message-Id: <wl33e0jdkmn.fsf@plume.nl.compuware.com>

[Nederlandstalige versie volgt de engelse tekst]

Amsterdam.pm stands for the Amsterdam Perl Mongers. We're basically a
Perl user group. Despite its name, it is not local to the Amsterdam
environment, but it welcomes Perl mongers from all over the
Netherlands. 

Amsterdam.pm organises informal meetings where Perl users can meet,
and exchange information and experiences with regard to using Perl.
The meetings are normally held every first Tuesday of the month.
Although the preferred language for communication is Dutch, English
will be spoken if necessary.

Our next meeting is June 1st, 1999.
It will have the following informal agenda:

  18:00-18:30   Gathering at Maximiliaan's on the Nieuwmarkt
  19:00-20:30   Dinner in a restaurant somewhere near the Nieuwmarkt
  21:00-.....   Discussions and such at Maximiliaan's

See http://www.Amsterdam.pm.org for more details.

[Nederlands]

Amsterdam.pm staat voor de "Amsterdamse Perl Mongers", een groep van
gebruikers van Perl. In tegenstelling tot wat de naam suggereert is
Amsterdam.pm niet beperkt tot alleen Amsterdam, maar functioneert, tot
er meer gebruikersgroepen in Nederland zijn, als Nederlandse
gebruikersgroep.

Amsterdam.pm organiseert informele bijeenkomsten waar Perl gebruikers
kunnen samenkomen en informatie en gebruikservaringen met betrekking
tot Perl kunnen uitwisselen. Deze bijeenkomsten vinden normaliter
plaats op elke eerste dinsdag van de maand. De voertaal binnen
Amsterdam.pm is in pricipe Nederlands, maar indien nodig zal Engels
worden gebruikt, b.v. om te communiceren met niet-Nederlandssprekende
aanwezigen. 

De eerstvolgende bijeenkomst vindt plaats op 1 juni 1999.
De agenda voor deze bijeenkomst is, zoals gewoonlijk, informeel:

  18:00-18:30   Verzamelen bij Maximiliaan op de Nieuwmarkt
  19:00-20:30   Etentje in een restaurant ergens in de buurt
  21:00-.....   Voortzetting bij Maximiliaan's -- discussies, etc.

Bezoek onze Web site http://www.Amsterdam.pm.org voor meer details.



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

Date: Wed, 26 May 1999 23:21:35 -0700
From: "Dave Roth" <xrxoxtxhxdx@xrxoxtxhx.xnxextx>
Subject: Re: Perl on Win32 - How can I hide the process?
Message-Id: <ts533.11562$Gm1.987029@news1.giganews.com>

Thomas/Shurflo wrote in message <37477A2A.5A07C702@shurflo.com>...
>Anyone know how I can hide the process (dos box) that starts when I run
>a Perl script? It could take a while to run and I don't want users
>seeing it.

Aldo Calpini's Win32::GUI allows you to hide the dos box. It does
not minimize it, it literally hides it using the Win32 API's
ShowWindow( hWnd, SW_HIDE ).
You can enable a script using something like:

BEGIN
{
  ( $hWnd, $hInstance ) = GUI::GetPerlWindow();
  GUI::Hide( $hWnd );
}

END
{
  GUI::Show( $hWnd );
}

It is rather important to specify the END{} block to unhide the
script. If the script terminates without an explicit call to Show()
then the dos box will remain hidden even though perl has termianted!!

You could also simulate this using Win32::API. The trick Aldo uses
in Win32::GUI is by temporarily changing the title of the dos box,
enumerating all windows until you find the window with the temp title--
this would give you the window handle (hWnd). Change the title back
to it's original name then execute the ShowWindow() function.
Using Win32::GUI is a tad bit easier.

Anyhow, using Win32::API you can do this as the following code
illustrates:

use Win32::API;

$TIMEOUT = 1;
%WIN = (
    hide        =>  0,
    normal      =>  1,
    showmin     =>  2,  # Window becomes focus then is minimized
    showmax     =>  3,  # Window becomes focus then is maximized
    shownoactive=>  4,  # Window is shown but does not get the focus
    show        =>  5,  # Show the window (unhide it)
    minimize    =>  6,  # Window is minimized
    minnoactive =>  7,  # Window is minimized but not activated (given
focus)
    restore     =>  9
);

$ShowWindow = new Win32::API( "user32.dll", "ShowWindow", [ L, I ], I );
$GetConsoleTitle = new Win32::API( "kernel32.dll", "GetConsoleTitle", [ P,
L ], L );
$SetConsoleTitle = new Win32::API( "kernel32.dll", "SetConsoleTitle", [ P ],
I );
$FindWindow = new Win32::API( "user32.dll", "FindWindow", [ P, P ], L );

$hWnd = GetWindowHandle();
if( $hWnd )
{
    $ShowWindow->Call( $hWnd, $WIN{hide} );
    sleep( $TIMEOUT );
    $ShowWindow->Call( $hWnd, $WIN{show} );
}

print "Finished.\n";

END
{
    $ShowWindow->Call( $hWnd, $WIN{show} );
}

sub GetWindowHandle
{
    my $Title, $OrigTitle, $hWnd, $Count;

    $Title = "My Temp Perl Window: " . localtime();
    $Title =~ s/(.)*/$1\x00/gs if( Win32::API::IsUnicode() );
    $OrigTitle = "\x00" x ( 256 * ( 1 + Win32::API::IsUnicode() ) );
    $Count = $GetConsoleTitle->Call( $OrigTitle, 256 );
    $SetConsoleTitle->Call( $Title );

    $hWnd = $FindWindow->Call( 0, $Title );
    $SetConsoleTitle->Call( $OrigTitle );

    return( $hWnd );
}

Notice that there is an END{} block just in case something goes wrong the
dos
box will be shown just before termination of the script.

dave
--
=================================================================
Dave Roth                                ...glittering prizes and
Roth Consulting                      endless compromises, shatter
<rothd at roth dot net>                 the illusion of integrity
http://www.roth.net
Win32, Perl, C++, ODBC, Training

Our latest Perl book is now available:
"Win32 Perl Programming: The Standard Extensions"
http://www.roth.net/books/extensions/






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

Date: Thu, 27 May 1999 01:26:37 -0500
From: therzog@knotech.com (Tim Herzog)
Subject: Re: perl script as an executable
Message-Id: <therzog-2705990126380001@therzog-host105.dsl.visi.com>

In article <3750aa44.70100469@news.cyberway.com.sg>,
pigs_can_fly@mindless.com (Jason Q.) wrote:

>Hi
>
>For a project of mine, one of the servers I am using requires that
>perl scripts be in executable (.exe) format. I have converted the
>script using perl2exe. The script involved is a search script.
>
>My question is, how do I pass the search parameters (keywords etc) to
>the script? I need to do this via the html->form->post command.
>
>
>My apologies that this problem is cgi-related but I have had no luck
>in the other newgroups. I would appreciate if someone could point me
>in the right direction.

For POST operations, you read form data from STDIN and translate it,
depending on the type of content (which you can determine from
$ENV{'CONTENT_TYPE'}).  Here's a common stub for decoding
application/x-www-form-urlencoded, which is the default and most common
type:


if( $ENV{'REQUEST_METHOD'} eq 'POST' &&
$ENV{'CONTENT_TYPE'} eq 'application/x-www-form-urlencoded' ) {
   read STDIN, $_, $ENV{'CONTENT_LENGTH'};
   @fields = split /&/;
   
   for $_(@fields) {
      ($key,$value) = split /=/;
      $value =~ tr/+/ /;
      $value =~ s/%(..)/pack('c', hex($1))/ge;
      $form{$key} = $value;
   }
}

-- 
Tim Herzog


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

Date: 27 May 1999 02:39:40 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: perl script as an executable
Message-Id: <x73e0jdnir.fsf@home.sysarch.com>

>>>>> "TH" == Tim Herzog <therzog@knotech.com> writes:

  TH> if( $ENV{'REQUEST_METHOD'} eq 'POST' &&
  TH> $ENV{'CONTENT_TYPE'} eq 'application/x-www-form-urlencoded' ) {
  TH>    read STDIN, $_, $ENV{'CONTENT_LENGTH'};
  TH>    @fields = split /&/;
   
  TH>    for $_(@fields) {
  TH>       ($key,$value) = split /=/;
  TH>       $value =~ tr/+/ /;
  TH>       $value =~ s/%(..)/pack('c', hex($1))/ge;
  TH>       $form{$key} = $value;
  TH>    }
  TH> }

well, you got upset at a proper comment about your push( @INC, '.' )
being useless, so you will love my comments here.

please don't post broken cgi parsing snippets. this is a dark area best
left for the tried and true modules (CGI.pm, CGI::Lite.pm and
friends). this code is cut and paste excrement emanating from the bowels
of matt's scripts. for a simple problem, what does it do when duplicate
keys come from the post with different values?

the cgi in perl problem has been solved. please use those solutions
rather than moonshine from your cousin's still.

uri 

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Thu, 27 May 1999 09:16:02 +0200
From: "Fred Ruffet" <fruffet@kaptech.com>
Subject: Re: please test my new site..
Message-Id: <7iirfq$tq$1@gatekeeper.ornano.kapt.com>

Dan,

I think it works well, except two little things

 . I saw a link telling me, in its marvellous blue colour : "click here". I
tried, but I couldn't resist. I've clicked. Problem is that I was clicking
here, because it had told me it would explain me as it works, and it answer
me :
"Error 404
Not found - file doesn't exist or is read protected [even tried multi] "
Is it really the way it works ?!?

 . I'm not a young american student using the web to spend his precious time.
In fact, I'm a young french student using the web to spend his precious
time. So, when it tells me "please enter your zip code correctly", what
should I do ? (I've none, or more exactly, it doesn't works there)...

Don't worry, I think I'm a young french student using the web to spend his
precious time. Everyone won't be boring you like me... :-)

Regards,

Fred

Dan Foley a icrit dans le message
<7iimor$g8t$1@usenet01.srv.cis.pitt.edu>...
>Made with javascript/html/perl
>
>(that is why i am posting on these 3 newsgroups)
>
>it's a simple survey.. to figure out who says soda and who says pop. can
>everyone please take a few seconds to answer this one question survey and
>also to let me know if u find any bugs along the way.
>
>Currently i am just gathering data.. soon i wish to display the results
>graphically on a map of the us.. (i guess demographically).. if u might be
>able to help out with that. let me know..
>
>to take the survey and test my site go to
>
>www.pitt.edu/~djfst34/surveys/sodapop.html
>
>
>
>--
>------------------------------------------------------------
>- Dan Foley                                         -
>- music, resume, more on me              -
>- www.pitt.edu/~djfst34                      -
>------------------------------------------------------------
>
>




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

Date: Thu, 27 May 1999 08:22:11 GMT
From: haytounet@my-dejanews.com (Arnaud Limbourg)
Subject: Re: please test my new site..
Message-Id: <374cfdaa.64002330@news.bull.fr>

it works fine.
On Thu, 27 May 1999 01:57:11 -0400, "Dan Foley" <djfst34@pitt.edu>
wrote:

>Made with javascript/html/perl
>
>(that is why i am posting on these 3 newsgroups)
>
>it's a simple survey.. to figure out who says soda and who says pop. can
>everyone please take a few seconds to answer this one question survey and
>also to let me know if u find any bugs along the way.
>
>Currently i am just gathering data.. soon i wish to display the results
>graphically on a map of the us.. (i guess demographically).. if u might be
>able to help out with that. let me know..
>
>to take the survey and test my site go to
>
>www.pitt.edu/~djfst34/surveys/sodapop.html
>
>
>
>--
>------------------------------------------------------------
>- Dan Foley                                         -
>- music, resume, more on me              -
>- www.pitt.edu/~djfst34                      -
>------------------------------------------------------------
>
>



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

Date: Thu, 27 May 1999 07:24:46 GMT
From: nmeredit@ford.com (Nick Meredith)
Subject: Re: please test my new site..
Message-Id: <374cf2ed.958691@news.ford.com>

On Thu, 27 May 1999 01:57:11 -0400, "Dan Foley" <djfst34@pitt.edu>
wrote:

>
>www.pitt.edu/~djfst34/surveys/sodapop.html

Very jolly - shame that on the WWW it doesn't accept that people live
outside of the USA, and doesn't warn them before they enter data that
only Americans are welcome.


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

Date: Thu, 27 May 1999 09:05:15 +0200
From: Jean-Pascal LAUX <jplaux@easynet.fr>
Subject: Problem with a program to translate character
Message-Id: <374CEEAB.D08B7B8F@easynet.fr>

I wrote a program that translate french character to HTML equivalent
character but it don't run correctly (some translate are correct, other
no).

My script (not all)  :

%translateur=("i" => "&eacute;",
              "h" => "&egrave;",
              "j" => "&ecirc;",
              "`" => "&agrave;",
              "y" => "&ugrave;",
              "n" => "&icirc;",
              "b" => "&acirc;",
              "t" => "&ocirc;",
              "g" => "&ccedil;");

sub Translate
{
 my ($script)=@_;
 my $buffer;

 foreach $buffer (keys (%translateur)) {
   $script=~s/$buffer/$translateur{$buffer}/ge;
 }

  $script;
}

Some suggestion ?

Jean-Pascal LAUX



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

Date: Thu, 27 May 1999 09:21:58 +0200
From: "Fred Ruffet" <fruffet@kaptech.com>
Subject: Re: Problem with a program to translate character
Message-Id: <7iirqu$un$1@gatekeeper.ornano.kapt.com>

Jean-Pascal,

Could you tell us what happens when translates are not correct ? Hein ? S'il
te plait ? Tu peux ? Merci. (Excuse me for this but it's so rare to find a
french guy there... I couldn't resist...)

Regards,

Fred




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

Date: 27 May 1999 08:21:10 GMT
From: book@pc89153.cse.cuhk.edu.hk ()
Subject: Q. about pattern matching
Message-Id: <7iiv9m$3eo$1@eng-ser1.erg.cuhk.edu.hk>

Hi all, there are strings with square bracket([]) needed to be matched.
It may be as: 
(1) "[abc [testing] ]"       or 
(2) "[abc] testing [hello]"

What I want is the strings inside the brackets, but pair by pair(?),
which means i want "abc [testing] " in (1) but 
"abc" and "hello" in (2).

how to do that ? The problem is that: 
If I use: (@test) = $string =~ /\[.+\]/g 
to do the matching,
(2) will come up with "abc] testing [hello" ;

If I use: (@test) = $string =~ /\[.+?\]/g
(1) will come up with "abc [testing" ;

so, how to have the matching function as the '%' function in Vi ?

Thank you very much, it seems a bit long.


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

Date: Thu, 27 May 1999 01:18:40 -0500
From: therzog@knotech.com (Tim Herzog)
Subject: Re: Reading text file
Message-Id: <therzog-2705990118400001@therzog-host105.dsl.visi.com>

In article <374ca81d@carrera.intergate.ca>, "Robert"
<ducott@geocities.com> wrote:

>Iam trying to write code that will read a text file and print it's contents
>to an html file. I have this code working however, it prints all the text on
>a single line rather than reading the paragraphs and printing the data on
>separate line as it's written in the text file. sample code below. Does
>anyone know how I can tell the code to read the text file and print it's
>contents in the same format as it's written in the text file.

Wrap the file in <PRE> tags, like this:

print<<TOHERE;
Content-type:  text/html

<HTML><PRE>
TOHERE

# Print your file to STDOUT here

print "</PRE></HTML\n";

-- 
Tim Herzog


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

Date: Wed, 26 May 1999 23:30:46 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Reading text file
Message-Id: <MPG.11b6866443a57423989b0d@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <374ca81d@carrera.intergate.ca> on Wed, 26 May 1999 19:09:24 
-0700, Robert <ducott@geocities.com> says...
> Iam trying to write code that will read a text file and print it's contents
> to an html file. I have this code working however, it prints all the text on
> a single line rather than reading the paragraphs and printing the data on
> separate line as it's written in the text file. sample code below. Does
> anyone know how I can tell the code to read the text file and print it's
> contents in the same format as it's written in the text file.

Several possibilities:

1.  Send "Content-Type: text/plain\n\n"  instead of text/html (but then 
you won't have titles or fancy formatting).

2.  Surround the body text with <PRE> ... </PRE> tags (but then you may 
not like the type font).

3.  Map each newline in the body text to "<BR>\n".

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 27 May 1999 10:20:39 +0200
From: Marian Kelc <marian.kelc@ruhr-uni-bochum.de>
Subject: regexp (?{...}) bug ?
Message-Id: <374D0057.FE36E6FD@ruhr-uni-bochum.de>

Hi folks,
this is my question:
assume $a= "23 3434 45 32 2132 2332 4";
when I now do the following:

1 while $a=~/(\d+)(?{print "$1 "})/g;

it prints out only

 3434 45 32 2132 2332 4

without the leading 23. So, backreferences of this kind ($1,$2...) dont
work with (?{...})
correctly? Who can help me? (I'm using perl 5.005_2)


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

Date: Thu, 27 May 1999 10:08:31 +0200
From: "Bastiaan S van den Berg" <office@asc.nl>
Subject: Re: req: directional help
Message-Id: <7iiuk5$4ik$1@zonnetje.NL.net>

yeah!!!!!!!

it now works fine!!! but when you posted it , i was sure it was offline..

tnx anyways!
buZz

>I just checked, and it's up.  Maybe it's my karma.  :-)
>
>You did try this URL with no typos, right?
>
>http://www.perlmonth.com/articles//rtfm.html
>
>That's a double-slash after 'articles'.




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

Date: Thu, 27 May 1999 00:08:03 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: unexponentialize field from text file
Message-Id: <MPG.11b68f3248e53768989b0e@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <7ii6p4$b3c$1@mathserv.mps.ohio-state.edu> on 27 May 1999 
01:22:44 GMT, Ilya Zakharevich <ilya@math.ohio-state.edu> says...
+ [A complimentary Cc of this posting was sent to Larry Rosler
+ <lr@hpl.hp.com>],
+ who wrote in article <MPG.11b6274e1829f2f9989b08@nntp.hpl.hp.com>:
+ > > I would really appreciate any help. I have a tab file with a field
+ > > in exponential form. I was wondering how I can convert this to a
+ > > floating point number in normal notation through regexp. thanks.
+ > > 
+ > > 0.20161E-01  to 0.020161
+ > > 0.49279E-02  to 0.004928
+ > 
+ > #!usr/bin/perl -w
+ > use strict;
+ > 
+ > while (<DATA>) {
+ >     s/((?:\d+(?:\.\d*)?|\.\d+)[Ee][+-]?\d+)/$1 + 0/eg;
+ >     print;
+ > }
+ > __END__
+ > 0.20161E-01 1e0 -.5e+1
+ > 0.49279E-02
+ 
+ Prints
+ 
+ 	2.0161e-02 1 -5
+ 	4.9279e-03
+ 
+ here.
+ 
+ Hope this helps,

Well, not really.  Where is 'here'?

I checked this code on perl 5.002, 5.003, 5.004_03 and 5.005_03, and on 
every one it produced what I expected:

0.020161 1 -5
0.0049279

I thought that adding 0 was pretty reliable.  I like it better than 
Zenin's suggestion (sprintf '%f') because that produces only six decimal 

digits (0.004928 for the last value).

sprintf '%g' produces the same result as adding 0 in my tests 
(0.0049279).

Perhaps you have a value of $# that is strange.  In the 5.005_03 
(ActivePerl) implementation, it is undefined, which is strange enough!

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 27 May 1999 10:06:38 +0200
From: "Bastiaan S van den Berg" <office@asc.nl>
Subject: Re: why doesn't my first program work?? (ok , third or something)
Message-Id: <7iiugk$4gn$1@zonnetje.NL.net>

ok ..

let's clear some stuff up ..

first , i use .cgi extensions because my webserver can't run .pl scripts for
some weird reason..
second , i haven't gotten a clue about what modules are allready written ,
so i'd rather write them myself and learn something while doing so ..

i don't want to read that unreadable perlbook.pdf , and i've ordered some
books , but they haven't arrived yet.

cul8r
buZz




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

Date: Thu, 27 May 1999 03:23:01 -0500
From: therzog@knotech.com (Tim Herzog)
Subject: Re: why doesn't my first program work?? (ok , third or something)
Message-Id: <therzog-2705990323010001@therzog-host105.dsl.visi.com>

In article <7iiugk$4gn$1@zonnetje.NL.net>, "Bastiaan S van den Berg"
<office@asc.nl> wrote:

>ok ..
>
>let's clear some stuff up ..
>
>first , i use .cgi extensions because my webserver can't run .pl scripts for
>some weird reason..
>second , i haven't gotten a clue about what modules are allready written ,
>so i'd rather write them myself and learn something while doing so ..
>
>i don't want to read that unreadable perlbook.pdf , and i've ordered some
>books , but they haven't arrived yet.

Bravo! Personally, I'm getting really sick of the lack of civility and
decency in this forum.  The volume of perl documentation doesn't mean that
the language is accessible.  Quite the contrary.

No need to respond.  Just wanted to pat you on the back.

-- 
Tim Herzog


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

Date: Thu, 27 May 1999 03:27:29 -0500
From: therzog@knotech.com (Tim Herzog)
Subject: Re: why doesn't my first program work?? (ok , third or something)
Message-Id: <therzog-2705990327290001@therzog-host105.dsl.visi.com>

In article <therzog-2705990323010001@therzog-host105.dsl.visi.com>,
therzog@knotech.com (Tim Herzog) wrote:


>Bravo! Personally, I'm getting really sick of the lack of civility and
>decency in this forum.  The volume of perl documentation doesn't mean that
>the language is accessible.  Quite the contrary.

Before I get massively flamed, I apologize to the group at large for that
last post.  I meant to email it only to the author, but it's 3:30 AM and I
accidently posted it as well.  The time of day may also have influenced my
comments.

-- 
Tim Herzog


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

Date: Wed, 26 May 1999 23:10:28 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: writing binary stuff back to a browser, funky format
Message-Id: <MPG.11b68198a0fc4101989b0c@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <374C9E43.33CE583D@norcov.com> on Wed, 26 May 1999 18:22:11 -
0700, Mauricio Baiocchi <meatzio@norcov.com> says...
 ...
+ binmode STDOUT;
+ $PAIR_X = "STATUS";
+ $PAIR_Y = "ERROR";
+ $sizeX = length $PAIR_X;
+ $sizeY = length $PAIR_Y;
+ $PACKAS = 'A2 A2 A16 A16';
+ 
+ print OUT pack($PACKAS , $sizeX, $sizeY, $PAIR_X, $PAIR_Y);
+ 
+ but I'm not sure if this is how you feed binary stuff back to the
+ browser or if appeases the format below. I throw myself at the mercy
+ of perl masters.
+ 
+ Here's the format
+  
+ >>content type:application/x-netscape-autoconfigure-dialer
+ When Navigator sees this MIME type, it expects data in the format
+ described below. The binary file format used by this MIME type is
+ simple, yet extensible. It
+ consists of consecutive name/value pairs separated by 2 bytes of size
+ information: 
+ 
+ | 2 bytes | ------ x bytes ------ | 2 bytes | ------ y bytes ------ | 
+ (x)              (name)            (y)             (value)
+ 
+ The parser iterates as follows until it reaches the end of the stream:
+ 
+      Read 2 bytes of binary data and cast to int for size of Name in
+ bytes (x) 
+      Read (x) bytes of ASCII data for the name 
+      Read 2 bytes of binary data and cast to int for size of Value in
+ bytes (y) 
+      Read (y) bytes of ASCII data for the value

Neither the argument sequence nor the formats seem to match this 
specification.  'A2' produces two ASCII characters, not a two-byte 
binary number.  For that you may need format 's' or 'n' or 'v' depending 
on byte-ordering.  Probably 'n'.

Try this (UNTESTED by me):

  $PACKAS = "v A$sizeX v A$sizeY";
  
  print OUT pack($PACKAS, $sizeX, $PAIR_X, $sizeY, $PAIR_Y);

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 5800
**************************************

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