[22643] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4864 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Apr 19 11:06:52 2003

Date: Sat, 19 Apr 2003 08:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 19 Apr 2003     Volume: 10 Number: 4864

Today's topics:
        Flushing output? <mikeother@comcast.net>
    Re: Flushing output? (David Efflandt)
    Re: foreach how do I get out of the loop? sthg like "br (milka)
        French ascii characters? <kemal644@yahoo.com>
    Re: French ascii characters? (Walter Roberson)
    Re: French ascii characters? <nmihai_2000@yahoo.com>
    Re: French ascii characters? <flavell@mail.cern.ch>
        Help needed understanding bitwise operations <scottjk@softhome.net>
    Re: Help needed understanding bitwise operations (Randal L. Schwartz)
    Re: How to read one line from a text file <bongie@gmx.net>
    Re: How to read one line from a text file <bongie@gmx.net>
    Re: How to use split function to split on a backslash <Jodyman@hotmail.com>
    Re: Metadot Portal Server v5.5.2.1 (GPL) <abigail@abigail.nl>
    Re: Metadot Portal Server v5.5.2.1 (GPL) <mgjv@tradingpost.com.au>
    Re: MIME::Lite images and attachments <bongie@gmx.net>
    Re: my cgi works but won't execute external commands su <jollyjoejimbob@hotmail.com>
    Re: Need advice on my first Perl script (Tad McClellan)
        need help with snmptraps in perl <20020531antispam@gmx.net>
        perl/tk and fork command on windows (Scott)
    Re: perl/tk and fork command on windows <bob@nowhere.com>
    Re: Remembering previous values of the form. ($$$)
    Re: Trouble with Variable Interpolation while executing <wksmith@optonline.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 19 Apr 2003 09:06:09 -0400
From: "Michael L. Artz" <mikeother@comcast.net>
Subject: Flushing output?
Message-Id: <nZOdnRyL4P_r0TyjXTWcqw@comcast.com>

I am having a problem that I believe is related to some sort of output 
flushing/race condition, but I have not been in the perl world long 
enough to know how to fix it.  Basically, my problem comes from the fact 
that I would like to print a filename to an opened pipe, and then rename 
the file after it has been processes by the pipe.  For example (untested 
simplification):

open PIPE, "| process_files -";
open FILELIST, "ls -tr |";

my $filename
while ($filename = <FILELIST>) {
     print PIPE $filename;
}
my $new_filename = $filename;
$new_filename =~ s/foo/bar/;
rename $filename, $new_filename;

The tar PIPE bombs out because it can't find the file because it has 
already been renamed before it gets processes by the PIPE.  I have tried 
turning autoflush on the PIPE handle, but that seems to do nothing.  i.e.:

while ($filename = <FILELIST>) {
     $oldfh = select(PIPE);
     $| = 1;
     print $filename;
     select($oldfh);
}

Any ideas on how to make sure that the PIPE has finished processing the 
input before I rename the file?

Any help would be appreciated
Thanks
-Mike



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

Date: Sat, 19 Apr 2003 14:09:23 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Flushing output?
Message-Id: <slrnba2m4i.54m.efflandt@typhoon.xnet.com>

On Sat, 19 Apr 2003, Michael L. Artz <mikeother@comcast.net> wrote:
> I am having a problem that I believe is related to some sort of output 
> flushing/race condition, but I have not been in the perl world long 
> enough to know how to fix it.  Basically, my problem comes from the fact 
> that I would like to print a filename to an opened pipe, and then rename 
> the file after it has been processes by the pipe.  For example (untested 
> simplification):
> 
> open PIPE, "| process_files -";
> open FILELIST, "ls -tr |";
> 
> my $filename
> while ($filename = <FILELIST>) {
>      print PIPE $filename;
> }
> my $new_filename = $filename;
> $new_filename =~ s/foo/bar/;
> rename $filename, $new_filename;
> 
> The tar PIPE bombs out because it can't find the file because it has 
> already been renamed before it gets processes by the PIPE.  I have tried 
> turning autoflush on the PIPE handle, but that seems to do nothing.  i.e.:

I suspect that process_files does not begin its processing until it
receives the complete list of files to process.  So you need to feed it
the complete list, and save the filenames to a list so you can change the
file names after you close process_files and wait for it to complete its 
task.

If you want to handle each file at a time, you would need to fork a
process to handle each file, wait for that to finish, change the name, and
then go on to the next.  Or you can fork a number of children at a time, 
but just need to keep track of them.

-- 
David Efflandt - All spam ignored  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: 19 Apr 2003 06:08:43 -0700
From: milka5000@yahoo.com (milka)
Subject: Re: foreach how do I get out of the loop? sthg like "break;" exists?
Message-Id: <28fddbd4.0304190508.b244842@posting.google.com>

Thank you very much guys! I didn't use foreach after all. The only
issue that troubled me in the end was that

split(/|/, $st);

didn't seem to work. Finally I realized | is a special character.

split(/\|/, $st); 

works though!

Cheers,
milka

P.S.: As for wrap, I copied it from another subroutine, part of the
ready code I used as a template. You're right -it doesn't exist- What
I was looking for was

$title =~ s/8T8/\|/g;
$image =~ s/8T8/\|/g;
$comment =~ s/8T8/\|/g;

Thanks again!


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

Date: Fri, 18 Apr 2003 21:51:58 -0700
From: "tony76" <kemal644@yahoo.com>
Subject: French ascii characters?
Message-Id: <b7qkl5$1vua$1@nntp6.u.washington.edu>

I have a program that works with files of french text..  Of course many
words contain accented characters that I entered using ALT and the various
codes.

When I first wrote the program the output was accurate, showing the correct
French characters.  But recently it started outputting garbage in place of
these characters.

Any advice on what I need to do?

(the output is a command line DOS program)





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

Date: 19 Apr 2003 06:15:36 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: French ascii characters?
Message-Id: <b7qpi8$a97$1@canopus.cc.umanitoba.ca>

In article <b7qkl5$1vua$1@nntp6.u.washington.edu>,
tony76 <kemal644@yahoo.com> wrote:
:I have a program that works with files of french text..  Of course many
:words contain accented characters that I entered using ALT and the various
:codes.

:When I first wrote the program the output was accurate, showing the correct
:French characters.  But recently it started outputting garbage in place of
:these characters.

:Any advice on what I need to do?

Although this may sound petty at first, there are no
"French ASCII characters". ASCII is a 7 bit data encoding, and the
small number of "national symbols" of variation allowed in it
was never large enough to include the standard French accented
characters.

It may just sound as if I'm arguing over semantics, but the semantics
are potentially important to your difficulty. You can't be using
French ASCII because French ASCII doesn't exist -- so you must
be using some other way of encoding those French characters.

If you were using a Unix system, I would guess that you were using
one of the ISO 8896 encodings, possibly even just ISO 8896-1, which is
pretty much the default character set on most UNIX machines now.
[The first 127 positions of ISO 8896-1 are the same as the old
US-ASCII, so most people don't notice any difference.]

As, though, you mention entering characters using ALT, and you
mentioned DOS, it sounds as if you are using a PC. On a PC you could
be using any of a number of "Code Pages", or you might even have
gotten slipped into one of the Unicodes. And what -might- be
the source of your problem is that you might now have somehow changed
Code Pages or changed encoding representations. We'd need you more
details from you as to what exactly is the output now in order
to be more sure of this possibility.


There are other possibilities, of course, such as that you might
have changed versions of perl and your program broke because of it;
or you might have installed some completely unrelated software that
replaced one of your DLL's... or you might have acquired a virus
that's corrupted something on your system.

You didn't really give us much to go on. Please don't just
tell us that it "started outputing garbage": do a forensic
analysis of the garbage and tell us more about it.

For example, if you capture the output to a file and
examine that file with a hex editor, then does the "garbage"
turn out to be the right characters but showing up with the
wrong graphical symbols?

-- 
   Oh, yeah, an African swallow maybe, but not a European swallow.
   That's my point.


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

Date: Sat, 19 Apr 2003 07:40:04 GMT
From: "Mihai N." <nmihai_2000@yahoo.com>
Subject: Re: French ascii characters?
Message-Id: <Xns93626D469352MihaiN@216.148.227.77>

>:When I first wrote the program the output was accurate, showing the
>:correct French characters.  But recently it started outputting garbage
>:in place of these characters.
> 
>:Any advice on what I need to do?

> Although this may sound petty at first, there are no
> "French ASCII characters". ASCII is a 7 bit data encoding, and the
> small number of "national symbols" of variation allowed in it
> was never large enough to include the standard French accented
> characters.
ASCII 7 bit has no "national symbols" at all.

> but the semantics are potentially important to your difficulty.
If we are talking semantics, I have to make some observations:

> You can't be using French ASCII because French ASCII doesn't exist
Especialy if you consider that AS in ASCII stands for "American Standard"

> If you were using a Unix system, I would guess that you were using
> one of the ISO 8896 encodings, possibly even just ISO 8896-1, which is
> pretty much the default character set on most UNIX machines now.
This fammily of encodings is called iso-8859
ISO-8859-1 is the encoding for western european languages (including 
French). The other iso8859 are for Eastern Europe, Greek, Hebrew, Arabic,
Cyrilic, Turkish, Baltic, then extensions including Euro and so on.
So let's not mess up things more than they are.

> There are other possibilities, of course, such as that you might
> have changed versions of perl and your program broke because of it;
Possible if you moved to perl 5.8 recently. The new Perl uses utf8
much more than before and now the IO is encoding-aware
(see Encode::PerlIO)

> or you might have installed some completely unrelated software that
> replaced one of your DLL's... or you might have acquired a virus
> that's corrupted something on your system.
And the full moon may also affect the hi-bites.

> For example, if you capture the output to a file and
> examine that file with a hex editor, then does the "garbage"
> turn out to be the right characters but showing up with the
> wrong graphical symbols?
Good idea.

Since a PC seems to be the most probable guess about your system,
another option may be mixing ANSI and OEM code pages.
In the old days, DOS used a set of proprietary code pages (IBM)
for foreign languages. Windows another set of code pages, also
proprietary, based on iso-8859. The old DOS cp are now called 
"OEM code pages" and are used in the console, and the new encodings
are called "ANSI code pages" and are used by the GUI applications.

As a result, a file showing French characters in notepad will not not show
French characters in the console (from the Perl print, for example).

Think what you need to output (ANSI or OEM) and what kind of data you are
processing (encoded ANSI or OEM).

Mihai


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

Date: Sat, 19 Apr 2003 11:23:46 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: French ascii characters?
Message-Id: <Pine.LNX.4.53.0304191113440.26061@lxplus072.cern.ch>

On Sat, Apr 19, Walter Roberson inscribed on the eternal scroll:

> Although this may sound petty at first,

I wouldn't say so.  The first step to a clear understanding of
character coding problems is to learn how to talk about them.

> there are no "French ASCII characters". ASCII is a 7 bit data
> encoding, and the small number of "national symbols" of variation
> allowed in it was never large enough to include the standard French
> accented characters.

[To be pedantic;]

See 'National ISO-646' 7-bit codings; Google suggests

http://www.terena.nl/library/multiling/euroml/section04.html

However, this could be classed as archaeology nowadays.

> It may just sound as if I'm arguing over semantics, but the semantics
> are potentially important to your difficulty. You can't be using
> French ASCII because French ASCII doesn't exist -- so you must
> be using some other way of encoding those French characters.

us-ascii _was_ one of the national flavours of iso-646, but became the
IRV ('international reference version') in 1991.

I'm sure none of this is directly relevant to the hon. Usenaut's
problem, but occasionally it seems good to review the history.

> You didn't really give us much to go on. Please don't just
> tell us that it "started outputing garbage": do a forensic
> analysis of the garbage and tell us more about it.

Absolutely.



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

Date: Sat, 19 Apr 2003 13:07:23 GMT
From: Dark Over Lord <scottjk@softhome.net>
Subject: Help needed understanding bitwise operations
Message-Id: <94i2avkntf5tpbkhcs4mdvp2j6shqa25vp@4ax.com>

Hello gang.

I'm plowing through a book learning perl. But, I'm getting hung up
understanding the use of bitwise operators. I just can't seem to
visualize it. Other operators are easy for me to understand because
they are easily demonstrated, but bitwise operations seem a tad too
abstract to me. Can anyone help?

Scott



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

Date: Sat, 19 Apr 2003 13:58:51 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
To: Dark Over Lord <scottjk@softhome.net>
Subject: Re: Help needed understanding bitwise operations
Message-Id: <a219ee41bffec9c9a1a82998b3e75213@news.teranews.com>

>>>>> "Dark" == Dark Over Lord <scottjk@softhome.net> writes:

Dark> Hello gang.
Dark> I'm plowing through a book learning perl. But, I'm getting hung up
Dark> understanding the use of bitwise operators. I just can't seem to
Dark> visualize it. Other operators are easy for me to understand because
Dark> they are easily demonstrated, but bitwise operations seem a tad too
Dark> abstract to me. Can anyone help?

Perhaps we should have more clearly marked that section "optional, and
only if you already understand bitwise things from other places".
Sorry. :)

Here's the short version.

10 decimal is 1010 binary
12 decimal is 1100 binary

if I were to "bitwise and" them, the result would have a "1" bit
only everywhere that *both* of them had a "1" bit.  So, in vertical
columns... it's "1 ... 0 ... 0 ... 0".  Now convert that back
to a decimal... it's "8".

Similarly, if I were to "bitwise or" them, the result would
have a "1" bit only everywhere *either* of them had a "1" bit.
That's "1 ... 1 ... 1 ... 0".  That's decimal 14.

Does that help?  Look at each column.  And/or/whatever it.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Sat, 19 Apr 2003 02:54:43 +0200
From: "Harald H.-J. Bongartz" <bongie@gmx.net>
Subject: Re: How to read one line from a text file
Message-Id: <1194040.N17Ev2CN7r@nyoga.dubu.de>

Francesco Moi wrote:
> I'm trying to read one unique line from a text file.
[...]
> $filename= 'foo.txt';
> $count = trim(str_replace($filename,'',`wc -l $filename`));
[...]

So, in fact you want to read the *last* line of a file?

# Using File::ReadBackwards from CPAN
use strict;
use warnings;
use File::ReadBackwards;

my $bw = File::ReadBackwards->new('foo.txt') or die "horribly: $!";
print ((split /\t/, $bw->readline)[4]);

----- or -----
# Using Tie::File from Perl 5.8.0 or CPAN
use strict;
use warnings;
use Tie::File;

tie my @contents, 'Tie::File', 'foo.txt' or die "horribly: $!";
print ((split /\t/, $contents[-1])[4]);


(both untested)

Ciao,
        Harald
-- 
Harald H.-J. Bongartz <bongie@gmx.net>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
How do I set my laser printer on stun?



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

Date: Sat, 19 Apr 2003 02:56:59 +0200
From: "Harald H.-J. Bongartz" <bongie@gmx.net>
Subject: Re: How to read one line from a text file
Message-Id: <5260362.dauQqFfIYj@nyoga.dubu.de>

Harald H.-J. Bongartz wrote:
> tie my @contents, 'Tie::File', 'foo.txt' or die "horribly: $!";
> print ((split /\t/, $contents[-1])[4]);
  untie @contents;    # forgot that


Ciao,
        Harald
-- 
Harald H.-J. Bongartz <bongie@gmx.net>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Lazlo's Chinese Relativity Axiom:
No matter how great your triumphs or how tragic your defeats --
approximately one billion Chinese couldn't care less.


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

Date: Fri, 18 Apr 2003 23:07:19 GMT
From: "Jodyman" <Jodyman@hotmail.com>
Subject: Re: How to use split function to split on a backslash
Message-Id: <Hy%na.29549$ey1.2668838@newsread1.prod.itd.earthlink.net>


"Jim Boyan" <jboyan@qwest.net> wrote in message :

> I am trying to split a string which contains a backslash.
>
> I have tried:
>
> @words = split '\', $string;
> @words = split "\", $string;
> @words = split "\\", $string;
> @words = split '\\', $string;
>
> nothing seems to work I get errors from "search pattern not terminated" to
> "syntax error".
>
> $string contains something like "domainName\userName"
>
> and I would like to end up with:
> $words[0] = "domainName"
> $words[1] = "userName"
>

use strict;
use warnings;
use diagnostics;

my $string = 'How\about\matching\it\the\correct\way\?';
my @words = split /\\/, $string;
foreach (@words) { print "$_\n";}

HTH,

Jodyman




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

Date: 18 Apr 2003 23:16:39 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Metadot Portal Server v5.5.2.1 (GPL)
Message-Id: <slrnba11qn.3mf.abigail@alexandra.abigail.nl>

Daniel Guermeur (daniel@metadot.com) wrote on MMMDXVII September MCMXCIII
in <URL:news:88b62c96.0304180921.13c9f127@posting.google.com>:
##  Austin, TX – April 18, 2003 – Metadot Corporation, the maker of
##  Metadot Portal Server software is proud to announce the availability
##  of its open source Metadot Portal Server v5.5.2.1. providing numerous
##  new features and usability enhancements, as well as a number of bug
##  fixes.


Just because it's "open source" doesn't mean spam like this isn't
as annoying as viagra, penis enlargement and random porn crap.



Abigail
-- 
map{${+chr}=chr}map{$_=>$_^ord$"}$=+$]..3*$=/2;        
print "$J$u$s$t $a$n$o$t$h$e$r $P$e$r$l $H$a$c$k$e$r\n";


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

Date: Sat, 19 Apr 2003 11:10:59 +1000
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Metadot Portal Server v5.5.2.1 (GPL)
Message-Id: <slrnba18h3.5s4.mgjv@martien.heliotrope.home>

On Fri, 18 Apr 2003 15:09:31 -0500,
	Tad McClellan <tadmc@augustmail.com> wrote:
> Daniel Guermeur <daniel@metadot.com> wrote:
> 
>> availability
>> of its open source 
> 
> [snip]
> 
>>  Metadot Corporation brings the low
>> cost
> 
> 
> So which one is it, no cost or low cost?

Where do you see it saying "no cost"? Note that Open Source does not
necessarily imply that it is free.

Martien
-- 
                        | 
Martien Verbruggen      | Since light travels faster than sound, isn't
                        | that why some people appear bright until you
                        | hear them speak?


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

Date: Sat, 19 Apr 2003 03:26:05 +0200
From: "Harald H.-J. Bongartz" <bongie@gmx.net>
Subject: Re: MIME::Lite images and attachments
Message-Id: <95526353.yYyrTnFY1U@nyoga.dubu.de>

David Alyea wrote:

> I'm trying to write a script to send
> HTML files.  So far, so good- except
> that:
> 
> 1. the images I define in the body
>    show up as broken

Your code works like a charm for me.
(Perl 5.8.0 with MIME::Lite 2.117 on Linux 2.4.20)

I always wanted to check how my MUA displays HTML with inlined images,
so thanks for the test code. ;-)

> 2. the images I attach are actual
>    attachments on the email

Well, they are a kind of attachment.  It's in the responsibility of the
MUA how to represent them to the user.  Are you sure yours handles
inlines images?


Ciao,
        Harald
-- 
Harald H.-J. Bongartz <bongie@gmx.net>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
I don't suffer from insanity, I enjoy every minute of it.



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

Date: Fri, 18 Apr 2003 23:45:18 GMT
From: "Jolly Joe Jim Bob" <jollyjoejimbob@hotmail.com>
Subject: Re: my cgi works but won't execute external commands such as 'system(mkdir fred)' or 'open (filefandle, ">myfile.txt")'
Message-Id: <i60oa.79706$Vzu.37054@news02.bloor.is.net.cable.rogers.com>

thank you so much for your input, did i forget to mention that this is my
first ever perl program ?

i do greatly respect your opinion on helping others first but at this stage
in my developement i would only mess them up.

thank you again ;-)

a note to others using OS X...

this delema that i have been forced into is a direct result of all my
AppleScript applications being messed up due to the lates Apple upgrade
10.2.5.


"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrnba0njo.akm.tadmc@magna.augustmail.com...
> Jolly Joe Jim Bob <jollyjoejimbob@hotmail.com> wrote:
>
> > below you will find a junk of my code that...
>
>
> You said it bubba.
>
>
> > my problem...
> > - when executing my script at the command line everything works great,
of
> > course it doesn't collect any data.
>
>
> Why not?
>
> If you had used the CGI module, you could test it at the command line
> and provide form values too.
>
>
> > any suggestions to a solution or a good source of information.
>
> > #!/usr/bin/perl
> > require "get_form_data.pl";
>
>
> If you expect people to volunteer to help you, then you should as
> much as you can yourself *before* resorting to asking for their time.
>
> Enable warnings.
>
> Enable strictures.
>
> Use the CGI module.
>
> Check the return value from Perl functions.
>
> Use native Perl functions when possible instead of resorting
> to "shelling out" via system().
>
> Write Perl code rather than sed code.
>
>
> > my $JobNumber = $FORM{'JobNumber'};
> > my $DocketNumber = $FORM{'DocketNumber'};
>
>
> You don't need to copy all of those from one scalar variable to
> another scalar variable.
>
> You can use them from the hash directly.
>
>
> > my $tempname1 = "$JobNumber-$DocketNumber-$Description";
> > my $tempname2 = substr($tempname1,0,30);
>
>
> You do not need the 1st temporary variable:
>
>     my $tempname2 = substr("$JobNumber-$DocketNumber-$Description", 0,
30);
>
> > system (mkdir "$myfolder");
>
>
> You should use Perl's mkdir() function rather than shelling out.
>
>
> > ########################################################################
> > #
> > # Parsing the Illustratore Template
> > #
> > ########################################################################
> >
> > my $myBIGScript = "sed -e 's/Description_Data/$Description/g' -e
> > 's/PartID_Data/$JobNumber-$DocketNumber/g' -e
> > 's/Creation_Date_Data/Date/g' -e 's/Modification_Date_Data/Date/g' -e
> > 's/Sales_Rep_Data/$SalesRepID/g' -e
's/Sales_Order_Data/$SalesOrder/g' -e
> > 's/Fabric_Data/$ProductFabricType/g' -e 's/Ship_Date_Data/$Ship/g'
> > '/gfx_data/Live/templates/mocktemplate' >
> > '$myfolder/Mockup/$DocketNumber-Mockup'";
>
>
> Do that with Perl:
>
>     my $myBIGScript = "perl -pe 's/Description_Data/$Description/g;
s/PartID_Data/$JobNumber-$DocketNumber/g ...
>
>
> > system ($myBIGScript);
>
>
> Or, even better, do it in your main Perl program rather than shelling
> out to another perl process:
>
>    open TEMPLATE, '/gfx_data/Live/templates/mocktemplate' or die ...
>    open MOCKUP, ">$myfolder/Mockup/$DocketNumber-Mockup" or die ...
>    while ( <TEMPLATE> ) {
>       s/Description_Data/$Description/g;
>       s/PartID_Data/$JobNumber-$DocketNumber/g;
>       ...
>       print MOCKUP;
>    }
>    close TEMPLATE;
>    close MOCKUP;
>
>
> > open (OUTPUTFILE1, ">$outputfile");
>
>
> You should always, yes *always*, check the return value from open():
>
>   open(OUTPUTFILE1, ">$outputfile") or die "could not open '$outputfile'
$!";
>
>
> --
>     Tad McClellan                          SGML consulting
>     tadmc@augustmail.com                   Perl programming
>     Fort Worth, Texas




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

Date: Fri, 18 Apr 2003 16:48:17 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Need advice on my first Perl script
Message-Id: <slrnba0sl1.b9k.tadmc@magna.augustmail.com>

Optional <bob@aol.com> wrote:
> I've heard a rumor that on 18 Apr 2003 06:49:58 -0700,
> scott@doppelgangerdesign.com (Scott Spencer) wrote the following:
> 
>>Thank you both for the great advice. Im sorry I didnt read the posting
>>guidelines...

>>tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrnb9v2r2.96s.tadmc@magna.augustmail.com>...
>>> Scott Spencer <scott@doppelgangerdesign.com> wrote:
>>> 
>>> > keep only every 5th or 6 th file deleting the ones in between.


[snip full-quote]


> Also, please don't top-post...


And don't full-quote either!


> if ($file =~ /0.tif/ || $file =~ /5.tif/) {


   if ($file =~ /[05]\.tif$/ ) {


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sat, 19 Apr 2003 14:09:24 +0800
From: Arne Goetje <20020531antispam@gmx.net>
Subject: need help with snmptraps in perl
Message-Id: <b7qp1p$gbf@netnews.hinet.net>

Hi,

I want to write an snmptrap receiver in perl and want to process the
received traps to do some actions.
Currently I receive the UDP packets on port 162, but I don't know how to
decode them. Does anyone have an example on how to do this?

Thanx in advance.
-- 
Arne Goetje <20020531antispam@gmx.net> 
(Spam catcher.  Address might change in future!)
PGP/GnuPG key: 1024D/685D1E8C
Fingerprint: 2056 F6B7 DEA8 B478 311F  1C34 6E9F D06E 685D 1E8C
Key available at wwwkeys.pgp.net.   Encrypted e-mail preferred.



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

Date: 18 Apr 2003 17:40:43 -0700
From: scottaazz@yahoo.com (Scott)
Subject: perl/tk and fork command on windows
Message-Id: <a7a08292.0304181640.3073981f@posting.google.com>

Can anyone tell me why the following does not work (using Activeperl
5.6 on W2K machine).  Windows produces an error when the fork is
commanded.

use Tk;

$| = 1;
$mw = MainWindow->new;
$mw->Button(-text=>"Push Me",-command=>\&DO_IT)->pack();
MainLoop;

sub DO_IT {
   if ($pid=fork()) {
      print "Parent\n";
      waitpid($pid,0);
   } else {
      print "child\n";
      CORE::exit;
   }
}


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

Date: Sat, 19 Apr 2003 08:40:37 -0500
From: bob <bob@nowhere.com>
Subject: Re: perl/tk and fork command on windows
Message-Id: <3ea151c8$1_1@127.0.0.1>

Suport for fork() in windows is relatively recent, at least in 5.6.  If I were in your
shoes, I'd try updating the latest perl. AS has 5.6.1 and 5.8.0.

Of course this could be altogether wrong, just my guess.


On Fri, 18 Apr 2003 19:40:43 -0500, Scott wrote:

> Can anyone tell me why the following does not work (using Activeperl 5.6
> on W2K machine).  Windows produces an error when the fork is commanded.
> 
> use Tk;
> 
> $| = 1;
> $mw = MainWindow->new;
> $mw->Button(-text=>"Push Me",-command=>\&DO_IT)->pack(); MainLoop;
> 
> sub DO_IT {
>    if ($pid=fork()) {
>       print "Parent\n";
>       waitpid($pid,0);
>    } else {
>       print "child\n";
>       CORE::exit;
>    }
> }


----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---


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

Date: 18 Apr 2003 15:36:30 -0700
From: googleGroups@yinti.com ($$$)
Subject: Re: Remembering previous values of the form.
Message-Id: <92e28453.0304181436.3fd7d7fd@posting.google.com>

Hi,

 Attached is the sample code that should get you started for the
option 2.

<html>
<head>
<script>
	function createSQL ()
	{
		if (document.getElementById ("visible1").value ==
document.getElementById ("invisible1").value)
			alert ("Value not changed");
		else
			alert ("Value changed");
	}
</script>
</head>
<body>
	<input type="text" id="visible1" value="current" />
	<input type="hidden" id="invisible1" value="current" />
	<img alt="save" src="save.jpg" onclick="javascript: createSQL ()" />
</body>
</html>

yinti
~For the best DHTML Grid visit http://dhtmlgrid.sourceforge.net/



Hemant Shah <shah@typhoon.xnet.com> wrote in message news:<b7k5k2$9of$1@flood.xnet.com>...
> Folks,
> 
>    I am writing timesheet entry system using perl CGI.pm and Javascript,
>    on Linux.
> 
>    I have completed the form that displays time already entered, and allows
>    the user to add/chage/delete time. My problem is trying to remember what
>    the timesheet looked like when it was displayed, so that I can somehow
>    compare it with the new values when user presses "Save" button.
> 
>    The time sheet grid looks similar to:
> 
> +--------+-------+----+------------+-----+-----+-----+-----+-----+-----+-----+
> |Contract|Project|Task|Description | Mon | Tue | Wed | Thu | Fri | Sat | Sun |
>  +--------+-------+----+------------+-----+-----+-----+-----+-----+-----+-----+
> |        |       |    |            |     |     |     |     |     |     |     |
>  +--------+-------+----+------------+-----+-----+-----+-----+-----+-----+-----+
> |        |       |    |            |     |     |     |     |     |     |     |
>  +--------+-------+----+------------+-----+-----+-----+-----+-----+-----+-----+
> |        |       |    |            |     |     |     |     |     |     |     |
>  +--------+-------+----+------------+-----+-----+-----+-----+-----+-----+-----+
> |        |       |    |            |     |     |     |     |     |     |     |
>  +--------+-------+----+------------+-----+-----+-----+-----+-----+-----+-----+
> |        |       |    |            |     |     |     |     |     |     |     |
>  +--------+-------+----+------------+-----+-----+-----+-----+-----+-----+-----+
> |        |       |    |            |     |     |     |     |     |     |     |
> +--------+-------+----+------------+-----+-----+-----+-----+-----+-----+-----+
> 
>         +------+    +------+    +------+
>         | Prev |    | Next |    | Save |
>         +------+    +------+    +------+
> 
> 
> When I display the grid, it may have few entries previously entered. I want to 
> store current values. When user presses "Save" button, I would like to compare
> it with previous values so that I would know which entries were Added/Removed/
> Changed. I could then run SQL statementsto update the database.
> 
> How can I do it? Preferably without using files. Ther are 2 options I am
> thinking about.
> 
> 1) When building the HTML form, perl script would Write the existing values to
>    a file on the server, and add hidden variables to the HTML form. When 
>    the user updates the entries in the form, the javascript would update
>    the values of the hidden variables. When user presses "Save" button,
>    another perl script would be executed. The second perl script would
>    retrieve the hidden variables using param() and compare it with the
>    previous values stored in the file.
> 
> 2) When building the HTML form, perl script would add hidden variables to the 
>    HTML form. When the user updates the entries in the form, the javascript 
>    would generate psuedo SQL code based on the changes made by the user.
>    When user presses "Save" button, another perl script would be executed. 
>    The second perl script would retrieve the hidden variable using param() 
>    and build SQL statement and execute it.
> 
>    I started with option 1, but I am not sure if it is the best way of doing
>    it, I do not like to store state in the file on the server, what happens if
>    it gets deleted?
> 
>    I am not sure how to implement option 2?
> 
>    Is there another (better) way?
> 
> 
>    Thanks in advance.
> 
> 
> -- 
> Hemant Shah                           /"\  ASCII ribbon campaign
> E-mail: NoJunkMailshah@xnet.com       \ /  --------------------- 
>                                        X     against HTML mail
> TO REPLY, REMOVE NoJunkMail           / \      and postings      
> FROM MY E-MAIL ADDRESS.           
> -----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
> I haven't lost my mind,                Above opinions are mine only.
> it's backed up on tape somewhere.      Others can have their own.


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

Date: Sat, 19 Apr 2003 03:41:33 GMT
From: "Bill Smith" <wksmith@optonline.net>
Subject: Re: Trouble with Variable Interpolation while executing a dbi string handle
Message-Id: <Nz3oa.38193$MB4.15791891@news4.srv.hcvlny.cv.net>


"Liberty Belle" <libertybelle2112@yahoo.com> wrote in message
news:d9cbd61e.0304172108.7375906@posting.google.com...
> Steve May <stevenm@bogus.blackwater-pacific.com> wrote in message
news:<b7k1f1$co9$1@quark.scn.rain.com>...
> > Liberty Belle wrote:
> > > Working on a quick little script to load some data off of a page
of
> > > text.  These pages have a column header(variable name) and some
wanted
> > > information, as well as some garbage.  I want to keep this script
as
> > > general as possible since there are at least 3, and more coming
> > > variations.
> > >
> > > Everytime it recognizes a column header, it collects it and
appends it
> > > to a var, $columnheads, as well as a comma.  Additionally, I
append a
> > > ', ?' to $columnqmks, so that the number of ? is equal to the
number
> > > of columns.  When it finds information, it does likewise to
another
> > > var, $inputdata.
> >
> > Is the above a typo? If you feed a scalar to the prepared query
instead
> > of a list it will break when there is more than one placeholder...
> >
> >
> > So far, so good.  If I print this, I get exactly
> > > what I want.  So, head over to DB angle.
> > >
> > > My DB Handle works fine, no prob there
> > >
> > > This part works fine as well.  For the one I test, it interpolates
> > > properly, which I know when I get the execute error
> > >
> > >        $sth_loadstmt = $dbh->prepare(qq{ INSERT INTO BalSheet (
> > > $columnheads ) VALUES ($columnqmks) }) || die "Problem sth
> > > loadstmt\n";
> > >
> > > This is the problem.
> > >
> > > $sth_loadstmt->execute($inputdata);
> >
> >
> > $sth_loadstmt->execute(@inputdata);
> >
> >
> > s.
>
> Well, not so much a typo as a contextual error.  It isn't a list,
> where list means array.  It is a var with all my values comma
> separated
>
> To wit:
>
> $inputdata = 'value1,value2,value3'; # et cetera
>
> Sorry for the confusion


If your SQL does not require quotes around your values (e.g. they are
all numbers)  you need a list of values.

$sth_loadstmt->execute(split (/,/, $inputdata);

Otherwise, you will probably need additional processing to add quote
marks to each of the value strings.


foreach (split /,/, $inputdata){
 s/(.*)/\'$1\'/;
 push @inputdata, $_;
}
$sth_loadstmt->execute(@inputdata);


Keeping rack of what quotes are for perl and which are for SQL can be
confusing.
Good Luck,
Bill








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

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


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