[22449] in Perl-Users-Digest
Perl-Users Digest, Issue: 4670 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 6 00:05:48 2003
Date: Wed, 5 Mar 2003 21:05:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 5 Mar 2003 Volume: 10 Number: 4670
Today's topics:
"Stupid File Difference" function/module (John Ramsden)
Adding Bookmarks to a PDF (Triniman)
Boolean statement which triggers on time (Jan Fure)
Re: Can Perl can have the include head file like c? (Clark Zhong)
file searching (Ronald)
Get directory only once and put it in array with File:: (benrog)
Re: Greedy regexps <jurgenex@hotmail.com>
Re: Greedy regexps (Tad McClellan)
How can I write this regex? (Sara)
Re: How can I write this regex? (aserbin)
Re: I want to know the line n umber of the error ! <jurgenex@hotmail.com>
Re: I want to know the line n umber of the error ! <jurgenex@hotmail.com>
Re: Moving on a grd. <flavell@mail.cern.ch>
New module proposed: Class::Accessor::NoviceArray (Ronald Schmidt)
perl locks up my win98 computer (Doglover)
Perl Module to do SSL encrypted FTP (Richard Diaz)
Re: Perl Mysql uploading a image in a database. (niels)
Re: Perl Script to Produce XML <hillmw@charter.net>
Print lines of file until certain string found? (A. M. Schaer)
Re: Print lines of file until certain string found? (Sara)
printing hash values (david)
Scripts in background (rsegovia)
tough regex problem (Domenico Discepola)
Using ? for Operator (Hunter)
Re: Using ? for Operator <s_grazzini@hotmail.com>
What is wrong with this piece of UDP server code? <wweng@play.cs.columbia.edu>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 5 Mar 2003 07:53:32 -0800
From: john_ramsden@sagitta-ps.com (John Ramsden)
Subject: "Stupid File Difference" function/module
Message-Id: <d27434e.0303050753.17c68212@posting.google.com>
Is there an easy way, that works the same on Unix and Windows,
of testing whether two files have identical contents?
I'm not interested in what any differences are, and to
streamline the code I'd rather not have to open the
files myself. So Algorithm::Diff seems like overkill.
I do realize this could be manually coded in a few lines;
but this seems silly if there is a standard module and/or
function.
Thanks in anticipation.
Cheers
John Ramsden (john_ramsden@sagitta-ps.com)
P.S. I tried searching on old c.l.p.m posts with various
keywords, and also:
perldoc -q difference
perldoc -q comparison
perldoc -q compare
:::::
but no luck.
------------------------------
Date: 5 Mar 2003 13:14:04 -0800
From: jason.alphonse@alum.dartmouth.org (Triniman)
Subject: Adding Bookmarks to a PDF
Message-Id: <3b7960ec.0303051314.7b74a5@posting.google.com>
Hi,
I'd like to add a bookmark to the bookmark panel
in an existing PDF document.
Is this at all possible using available modules,
like PDF::API2?
There isn't much documentation so I'm not sure.
But if anyone out there has done this already,
please let me know how I would go about the task.
Thanks in advance,
Jason
jason@nospum.quickbrowse.com
take out the spam.
------------------------------
Date: 5 Mar 2003 15:21:38 -0800
From: jan_may2002_fure@attbi.com (Jan Fure)
Subject: Boolean statement which triggers on time
Message-Id: <e47a84bf.0303051521.486b937@posting.google.com>
Hi;
I want to make a simple program which keeps track of which project I
am working on.
The functionallity should be similar to a chess-clock, but with an
arbitrary number of projects to which time can be allocated.
In case of computer crash or the application being intentionally or
accidentally terminated, I need a log file which gets updated every
minute.
I plan to use a tk radio button to keep track of which project is
active.
I would like some pointers to how I can trigger an event every minute
in Perl, and also how to restore an array which keeps track of
accumulated time from a logfile.
The code should be something like:
if ( ($present_time - $previous_time) > (1 minute)) {
$PROJECTS[$CURRENT] = $PROJECTS[$CURRENT] + $present_time -
$previous_time;
$previous_time = $present_time;
[Pseudocode: Save @PROJECTS to the logfile];
}
Another section would use a radio button to keep track of the
definition of $CURRENT.
I am happy for any pointers in how to pursue this program.
I am also planning to use some tk code which allows the user to add
projects, and additional logic to stop the time from accumulating
outside business hours, which will be user defined.
Jan
------------------------------
Date: 5 Mar 2003 06:01:31 -0800
From: unixfighter@163.com (Clark Zhong)
Subject: Re: Can Perl can have the include head file like c?
Message-Id: <265c2336.0303050518.6550f6cf@posting.google.com>
Thank you for your answer, Martien.
It is my duty to say clearly about my project. This time I have coded a
perl script to do some LDAP backup works, on TurboLinux, Perl 5.6. The code
is all in one script file, and it works well. But the client want a .conf file
for some reasons. May be he thought it can make the script more like linux
program. so I must split some code from the original file to get a .conf file.
That is what puzzle me. This my first Perl script, So I want to find some quick
solution from c, such C head file.
I have already try the "do" function, but I found it can include the variables
I defined in my "~.conf" file.
Hope you can again.
Here thank the guy on the up floor, I can get his/her ID in this window.
Martien Verbruggen <mgjv@tradingpost.com.au> wrote in message news:<slrnb6av3v.1ir.mgjv@verbruggen.comdyn.com.au>...
> On 4 Mar 2003 19:07:07 -0800,
> Clark Zhong <unixfighter@163.com> wrote:
> > Hai, can anyone help me?
> > I want to include a config file in a main perl file, How can I do?
>
> Look up (in the perlfunc documentation) do, require and use. Also have
> a read of the perlmod documentation. It depends on what you want to do
> exactly, which of these you should use. You are contradicting yourself
> a bit by stating that you "want to include a config file", and
> equating that with a "include head file like c". These two have
> nothing to do with each other. Perl has no direct equivalent of a
> C header file, but modules come closest. A "config file" is vague
> enough to not be able to comment too much on that.
>
> You should probably be more specific about what you want to achieve,
> instead of assuming that you already know the emchanism by which you
> would achieve it.
>
> Martien
------------------------------
Date: 5 Mar 2003 11:01:16 -0800
From: redronald@yahoo.com (Ronald)
Subject: file searching
Message-Id: <a845614c.0303051101.1c91b599@posting.google.com>
I have lots of files with a bunch of data in each file. I have to
look for two sentances in each file and compare the numbers after the
sentances. I dont know where to begin in writting the program to do
this and i am tired of looking for anyhting about array of files and
searching in them on the internet. Please help on this.
------------------------------
Date: 5 Mar 2003 12:10:44 -0800
From: ben.rogers@escalate.com (benrog)
Subject: Get directory only once and put it in array with File::Find
Message-Id: <1da5d446.0303051210.65aa7e44@posting.google.com>
I need an array that contains one element for each subdirectory found.
My sub below doesn't do this of course, as @dirs will have an element
for every $_ (file that's found). In other words, if Folder1 has 10
files, my @dirs array will have Path/Folder1 10 times.
I've thought of several possible hacks, but there has to be some
graceful way to do this.
use File::Find;
find (\&wanted, "$inputdir");
sub wanted(){
if ($_ =~ /$filetype/){
push (@files, $_); # Filename only
push (@dirs, $File::Find::dir); # Path only
push (@fullpath, $File::Find::name); # Path + filename
}
}
------------------------------
Date: Thu, 06 Mar 2003 02:30:32 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Greedy regexps
Message-Id: <cpy9a.28232$ES3.15776@nwrddc04.gnilink.net>
David K. Wall wrote:
> On the other hand, I use regexes on HTML myself, but always with HTML
> *I* wrote and (usually) pre-processed with HTML Tidy
> <http://tidy.sourceforge.net/> to get it into a predictable format.
Which on the other hand raises the question why - when you own sender and(!)
receiver- are you using such a complicated and unwieldy format as HTML for
transmitting the data?
Can't you use something more manageable like e.g. XML or a config file or
even a binary format?
HTML must be about the worst choice for a data format (except for maybe DOC
and XLS and their relatives).
jue
------------------------------
Date: Wed, 5 Mar 2003 17:48:07 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Greedy regexps
Message-Id: <slrnb6d35n.558.tadmc@magna.augustmail.com>
Steven Smolinski <steven.smolinski@sympatico.ca> wrote:
> I'm not very good at SGML applications,
Yet you were disbelieving of the implicit claim made in my .sig ?
<just kidding>
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 5 Mar 2003 06:37:02 -0800
From: genericax@hotmail.com (Sara)
Subject: How can I write this regex?
Message-Id: <776e0325.0303050637.101b59f6@posting.google.com>
Occasionally I need to change patterns which are NOT preceeded (or
followed, same difference) by certain other patterns. For example:
replace "dog" with "canine" if dog is not preceeded by "cat " or
"mouse ".
Some approaches come to mind such as
s/dog/canine/g unless /(cat dog|mouse dog)/;
but I think that will have a problem with more than one match, i.e.
cat dog eel dog
will not get substituted.
I think I'm missing some knowledge about regex features and I suspect
this may be pretty straightforward. Maybe some sort of
lookahead/lookbehind? To be honest, I sort of got lost in that section
of mastering regexes..
I wish to avoid any looping or conditionals, I'd lke the regex to work
with
s/(regex)/pattern/gsm;
and to work on entire paragraphs.
Thank-You for any guidance.
Regards,
Gx
------------------------------
Date: 5 Mar 2003 19:28:53 -0800
From: aserbin@yahoo.com (aserbin)
Subject: Re: How can I write this regex?
Message-Id: <21adf8db.0303051928.77f07cb5@posting.google.com>
> replace "dog" with "canine" if dog is not preceeded by "cat " or
> "mouse ".
i had to do something similar once and i just did this:
$a = "cat dog and monkey dog and mouse dog";
$a =~ s/(cat|mouse) (dog)/$1 nobodywouldeverusethisinputisurehope/g;
$a =~ s/(\w+) dog/$1 canine/g;
$a =~ s/nobodywouldeverusethisinputisurehope/dog/g;
print $a;
now i'm going to run and hide before the gurus yell at me.
$_=qq kycaens!k;reverse;s|c|k|;print;#drat!
------------------------------
Date: Thu, 06 Mar 2003 02:33:55 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: I want to know the line n umber of the error !
Message-Id: <nsy9a.28234$ES3.22190@nwrddc04.gnilink.net>
Eric Osman wrote:
> How can I convince the server to tell me what line number it detects
> my PERL error on ?
You don't. If you would have tested your code before posting it on a some
server you will never ever have a compilation error on the server.
> I only get the following general error :
>
> Software error:
>
> Execution of /htdocs/e/r/ericosman/cgi-bin/reFormat.pl
> aborted due to compilation errors.
>
> For help, please send mail to the webmaster
> (webmaster@rcn.com), giving this error message and the
> time and date of the error.
>
>
> I'd like it to tell me WHICH line number the error is detected on.
If you would have tested it locally without a web server then perl would
have told you all this.
jue
------------------------------
Date: Thu, 06 Mar 2003 02:36:22 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: I want to know the line n umber of the error !
Message-Id: <Guy9a.28237$ES3.827@nwrddc04.gnilink.net>
Eric Osman wrote:
> I cannot change the server. I'm an RCN customer. It's their server.
>
>
> So I want to know if there's something I can put in my perl script
> so that the line number will show up during debugging.
Is there a specific reason why you don't want to find syntax errors before
posting your script to the server?
jue
------------------------------
Date: Thu, 6 Mar 2003 02:45:50 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Moving on a grd.
Message-Id: <Pine.LNX.4.53.0303060241560.30404@lxplus070.cern.ch>
On Wed, Mar 5, Joe Creaney caused the following to appear:
Parts/Attachments:
1 Shown 83 lines Text
2 Shown 79 lines Text
then blurted out:
> Working the bugs out it pretty much works except for the grid printing
> function. Here is my code can I use nested foreach loops to print out
> the data in my grid?
and then quoted, apparently unread:
> ctcgag@hotmail.com wrote:
> >
> > You appear to be posting in some MIME or html format (although my
> > reader protects me from it until I try reply. Please don't
> > do that.
Please don't do that. Usenet is a plain-text medium. If you can't
post plain text, you can't use usenet. New users are welcome, but you
_do_ have to accommodate to the local customs, not vice-versa.
bye
------------------------------
Date: 5 Mar 2003 18:38:13 -0800
From: RonaldWS@software-path.com (Ronald Schmidt)
Subject: New module proposed: Class::Accessor::NoviceArray
Message-Id: <86f16f82.0303051838.3137813e@posting.google.com>
I am proposing to add a new module to CPAN as described by the POD
documentation below. I am interested in comments with regard to
the module name which is Class::Accessor::NoviceArray and comments
on the names of the utility modules which are
Class::Accessor::NoviceArrayManip and Class::Accessor::NoviceArrayReadonly.
I am also very much interested in comments regarding other modules that
may fill the same purpose and to what degree these modules fill a
significant need in Perl programming. From the POD:
[These modules allow] the class user to access the array element
of your class with only knowledge of the '->' dereferencing
operator; they never need to use @{} dereferencing. The point
of the module is to make it easier for novices who do not really
understand references to use modules that want to expose array
data members.
In case you are wondering I already have a PAUSE ID and these
modules are implemented but not 100% ready for uploading yet.
Ronald Schmidt
RonaldWS@software-path.com
NAME
Class::Accessor::NoviceArray - Automated array accessor generation
that does not require class/accessor user to understand references.
SYNOPSIS
# This documentation, in some cases, is copied from the documentation
# for Class::Accessor with minor modifications.
package Foo;
use base qw(Class::Accessor::NoviceArray);
Foo->mk_na_accessors(qw(array_el));
Foo->mk_na_ro_accessors(qw(array_el_ro));
my $foo = Foo->new;
$foo->array_el('el1', 'el2'); # sets array_el - nothing new
my @copy = $foo->array_el; # somewhet new but not that interesting
if ($foo->array_el == 2) { # get 'scalar' value of array_el
print "two elements\n"; # making access more "array like"
}
$foo->array_el->empty; # new and I think useful - empties array
$foo->array_el->[4] = 'el5'; # Works - array_el can return a list
# or a scalar or behave like an
# object reference or a list reference
$foo->array_el->push('el6', 'el7'); # ability to behave as object ref
# here removes need for user to understand @{} dereferencing
# pop, splice etc also implemented the same way
# initializing read only array by an expert who can break rules ...
@{scalar($ha->array_el_ro->peek)} = ('a00', 'a11', 'a12');
eval {
$ha->array_el_ro->push('a22');
};
if ($@ =~ /cannot alter/) {
print "Correctly threw exception: $@\n";
}
print "read only element 1 is ", $ha->array_el_ro->[1], "\n";
# prints "read only element 1 is a11\n"
DESCRIPTION
This module automagically generates accessor/mutators for elements of
your class that you want to hold arrays. It allows the class user to
access the array element of your class with only knowledge of the '->'
dereferencing operator; they never need to use @{} dereferencing.
There is one exception demonstrated above. The point of the module is to
make it easier for novices who do not really understand references to
use modules that want to expose array data members. In order to use
module methods one must be familiar with '->' dereferencing. This module
attempts to remove the need for any understanding of references beyond
that in accessing array class members.
There are a number of flaws in the illusion that $foo->array_el returns
an array including:
$foo->array_el->[1 .. 10]; # doesn't work and ..
$foo->array_el->[3] = 'biz'; # ok so far
print "element $foo->array_el->[3]"; # doesn't work
print 'element ', $foo->array_el->[3]; # works
I believe that if you coded your own methods for easy access to an array
element you would still have the above problems, and so I believe that
my module functionally gives you at least as good results as you
would get if you tried to use your own custom methods to accomplish
the same goal.
This technology is based on Class::Accessor and requires that module. It
is probably also well worth your trouble to look at the documentation
for that class.
Again, use of Class::Accessor::NoviceArray starts with making your class
a subclass of Class::Accessor::NoviceArray. A combined example with
Class::Accessor and Class::Accessor::NoviceArray follows:
package My::Class;
# since NoviceArray descends from Class::Accessor both are available
use base qw(Class::Accessor::NoviceArray);
My::Class->mk_accessors( qw(foo bar) );
My::Class->mk_na_accessors( qw(car_array) );
Done. My::Class now has foo(), bar() and car_array() accessors defined.
my $foo = Foo->new;
$foo->foo('abc'); # set foo
my $x = $foo->foo; # get foo
$foo->car_array('def', 'ghi'); # set car_array
foreach my $y ($foo->car_array) { # iterate through car_array
# you can't do this as easily with Class::Accessor
}
my $z = $foo->car_array->[1]; # same as Class::Accessor
while my $z1 ($foo->car_array->shift) {
# go through the array and empty it
}
Note that when $foo->car_array is accessed in scalar context and is not
expected to return a list, it returns an object reference with some
interesting properties. If used in the same contexts as a number would
be used, with the plus operator or compared to 3, $foo->carr_array will
return the number of elements in the list. It can also be used to access
individual elements of the list as in:
my $z = $foo->car_array->[1];
The returned object is, however, of class
Class::Accessor::NoviceArrayManip which provides useful methods
including shift, empty, peek, and many more. Please see
Class::Accessor::NoviceArrayManip for documentation on the many functions
that are available through the $foo->car_array->shift interface.
Regrettably this module does not also allow you to reference your array
foo as $foo->{foo}. Since $foo->foo returns, in scalar context, a
reference to an overloaded object that appears to behave in (hopefully)
appropriate cases as an element count, I need to be careful that what
appears to a novice as the number '2' does not, as a side effect,
interfere with the destruction of objects that should be destroyed when
the parent object is destroyed. In other words, if my novice writes
my $foo = Foo->new;
my $x = $foo->foo;
if ($x < 5) {
$foo = undef;
}
then this module needs to ensure that '$foo = undef;' triggers
destructors for all elements of foo including array elements. If $x
refers to $foo or $foo->{foo} the destructors will not be triggered
properly. I have had to add some complexity with extra indirection and
soft references to get destruction to work properly with this module. If
anyone can come to me with a good suggestion on how I can have my cake,
eat it too, and have $foo->{foo} safely reference array element foo, I
am interested.
Methods
mk_na_accessors
Class->make_na_accessors(@fields);
This creates accessor/mutator methods for each named field given in
@fields. Foreach field in @fields it will generate two accessors.
One called "field()" and the other called "_field_accessor()". For
example:
# Generates foo(), _foo_accessor(), bar() and _bar_accessor().
Class->make_na_accessors(qw(foo bar));
The above was mostly copied nearly verbatim from Class:Accessor. The
difference in Class::Accessor::NoviceArray is that foo() will now
allow fairly natural Perlish access to an array.
mk_na_ro_accessors
Class->mk_na_ro_accessors(@read_only_fields);
Same as mk_na_accessors() except it will generate read-only
accessors (ie. true accessors). If you attempt to set a value with
these accessors it will throw an exception.
package Foo;
use base qw(Class::Accessor::NoviceArray);
Class->mk_na_ro_accessors(qw(foo bar));
# Let's assume we have an object $foo of class Foo...
# initialize the array
@{$foo->foo->peek} = ('yy1', 'yy2');
print join('|', $foo->foo); # ok, prints formatted array
$foo->foo(42); # BOOM! Naughty you.
$foo->foo->[1] = 10; # still no good
$foo->foo->push('z'); # I prefer not to and will not.
mk_na_wo_accessors
Class->mk_na_wo_accessors(@write_only_fields);
Same as mk_accessors() except it will generate write-only accessors
(ie. mutators). If you attempt to read a value with these accessors
it will throw an exception.
This is handled in a degenerate sort of way for NoviceArray right
now and only allows for setting the value with:
$foo->foo('a1', 'b1', 'c1');
If there is demand for more sophistication like
$foo->foo->push('d1') then I will go ahead and implement it. It
should not be very difficult.
NAME
Class::Accessor::NoviceArrayManip - Utility class for
Class::Accessor::NoviceArray.
SYNOPSIS
In arithmetic contexts Class::Accessor::NoviceArrayManip
objects return the length of an array data member to
which they have been assigned. If dereferenced as
a list they access their assigned list as in $x->[3]
returns the fourth element of the array to which $x
was assigned. One may also call the list related
methods directly from a Class::Accessor::NoviceArrayManip
object as in $foo->baz->shift. Methods include shift, push,
pop and many others that are listed below.
Methods
count
Count of array elements.
exists
Test for existence of array element.
empty
Empty the array and delete all elements from it.
delete
If provided with number(s) for element(s) to delete it will remove
the elements from the array. If no elements are provided it removes
the array from the containing object
push
Just like native Perl push function except that array is implied so
that $foo->foo->push('a', 'b'); pushes 'a' and 'b' on the foo array
element of the object referred to by $foo. if you found the prior
sentence at all confusing please see the documentation for
Class::Accessor::NoviceArray.
pop Perl pop functionality of objects of class
Class::Accessor::NoviceArrayManip.
shift
Perl shift functionality of objects of class
Class::Accessor::NoviceArrayManip.
unshift
Perl unshift functionality of objects of class
Class::Accessor::NoviceArrayManip.
splice
Perl splice functionality of objects of class
Class::Accessor::NoviceArrayManip.
get The method more or less implicitly called by Class::NoviceArray
when you do 'my @a = $foo->foo;'. Gets the array.
set_alternating
Sets the contents of the assigned array element by interpreting the
passed parameters as alternating array indexes and values to be
placed at those indexes.
Example:
$foo->foo->set_alternating( 1 => 'element 1', 5 => 'element 5' );
set_slice
Sets the contents of the assigned array element by interpreting the
passed parameters as a list of indexes to be set followed the values
to be placed at those indexes.
Example:
$foo->foo->set_alternating( 1, 5, 'element 1', 'element 5' );
peek
Return reference to internal array used by
Class::Accessor::NoviceArray for unrestricted access to array.
Intended to allow initialization of read only array data members.
Other uses may exist but should be viewed with suspicion.
------------------------------
Date: 5 Mar 2003 16:15:07 -0800
From: imfhome1@yahoo.com (Doglover)
Subject: perl locks up my win98 computer
Message-Id: <2366d743.0303051615.4e305ca7@posting.google.com>
Hi. Does anyone know why Perl locks up my win98 machine when I do
simple things like type PPM, or perldoc perldoc? Can't even do
control-alt-delete. It is totally locked. Simple "hello world" scripts
run fine. Seems to be with both 5.6.1 and with 5.8.0, since I tried
both. Strange, because 5.6 used to work. Then I tried 5.8, and started
locking up. Uninstalled, and went back to 5.6, still locked up. So now
I am back at 5.8.
A google search revealed almost nothing.
------------------------------
Date: 5 Mar 2003 19:29:23 -0800
From: ridiz@hotmail.com (Richard Diaz)
Subject: Perl Module to do SSL encrypted FTP
Message-Id: <5c1535d5.0303051929.34582f4c@posting.google.com>
Hello,
I am new to Perl, but I have been happily gobbling up all things Perl
as fast as I can find it. I've written a few scripts that we are now
using in production to process EDI documents and it is going great.
This newsgroup is a godsend.
Now for the request, I need to send and receive files via SSL
encrypted FTP. Are there any modules that will allow me to do this
easily? Or does anyone have some code snippets that will do this?
I am currently using the Net::FTP module in one of my scripts with
great success, but I do not believe it supports SSL encrypted FTP.
Please note that this is different from SFTP, which is FTP over SSH.
I also cannot use SCP, as our partner is using SSL encrypted FTP to
communicate with other vendors, and I am quite sure they will not
switch just for us. I am currently using WS_FTP Pro, which supports
FTP with SSL, to do this manually. They have a scripting facility in
the application, but I don't want to use it. All our other functions
are being/have been written in Perl, why shouldn't this be? And
anyway, doesn't perl make hard things possible? ;)
Seriously, I really appreciate any advice anyone could offer.
Thank you,
Rich
ridizNO@SPAMhotmail.com
------------------------------
Date: 5 Mar 2003 10:40:55 -0800
From: niels_bond@hotmail.com (niels)
Subject: Re: Perl Mysql uploading a image in a database.
Message-Id: <6772e388.0303051040.3ccb0296@posting.google.com>
Thanks for your advice.
The execute_query I use to define the sort of method to use: DBI or
mysql direct. It depends on the location where the script is.
For now, i managed to save the image to the database. I don't get any
errors any more. But moreover I show the images. Some images show
themselves partly.
I'm sure that the placeholders aren't set well. I think perl thinks
that the end of the image is reached in the middle of the file.
Niels
------------------------------
Date: Thu, 6 Mar 2003 04:07:25 -0600
From: "Michael Hill" <hillmw@charter.net>
Subject: Re: Perl Script to Produce XML
Message-Id: <v6dibl57lbmt54@corp.supernews.com>
Peter also had me check on the path. He told me to change:
<?xml:stylesheet type='text/xsl' href='ops_rev.xsl'?>
to
<?xml:stylesheet type='text/xsl'
href='http://www.mydomain.com/the/full/path/stylesheet.xsl'?>
It didn't work, but since Sinan also told me the check the path I changed
the path of the stylesheet to:
<?xml:stylesheet type='text/xsl'
href='http://www.hulenbend.net/ops_rev.xsl'?>
and it worked !!!!!!!!!!
For some reason the stylesheets are not read from the cgi-bin directory,
even when I make changes to the .htacccess file.
Thank you very much Pete and Sinan.
Mike
"A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu> wrote in message
news:Xns9335965E12B07asu1cornelledu@132.236.56.8...
> "Michael Hill" <hillmw@charter.net> wrote in
> news:v6aruoclc73pea@corp.supernews.com:
>
> > I fixed the header and still was getting another problem. Based on
> > what I saw on that Apache site I added to my .htaccess
> > file "AddHandler cgi-script .cgi" in my html directory.
> >
> > So.... the same script xml.cgi runs in the /html directory, but not
> > in the /cgi-bin directory. Here are the links:
> >
> > http://www.hulenbend.net/xml.cgi
> > http://www.hulenbend.net/cgi-bin/xml.cgi
> >
> > Here is the cgi:
> >
> > print "Content-type: text/xml; charset=utf-8\n\n";
> > print "<?xml:stylesheet type='text/xsl' href='ops_rev.xsl'?>\n";
>
> is there a file called ops_rev.xsl in your cgi-bin? i am guessing not.
> what happens when you replace the line above with
>
> print "<?xml:stylesheet type='text/xsl' href='/ops_rev.xsl'?>\n";
> --
> A. Sinan Unur
> asu1@c-o-r-n-e-l-l.edu
> Remove dashes for address
> Spam bait: mailto:uce@ftc.gov
------------------------------
Date: 5 Mar 2003 07:25:44 -0800
From: mschaer@quantaservices.com (A. M. Schaer)
Subject: Print lines of file until certain string found?
Message-Id: <cad2e56c.0303050725.7cde98a4@posting.google.com>
What I am trying to do is have Perl open a file, print the lines of
the file until it encounters a marker, <!--perl-->, then stop
printing; however the code below doesn't do that; it just keeps
printing the first line of the file over and over again; I know
there's a flaw in my logic somewhere, but I just can't see it.
Thanks.
#!/usr/bin/perl
###this doesnt do what I thought
$file="calexample.html";
open (CURRFILE, $file) ||
die ("Cant open file");
$var='<!--perl-->';
while ($line= <CURRFILE>) {
#!~ does not match
#=~ matches
until ($line =~/$var/i)
{
print $line;
}
}
------------------------------
Date: 5 Mar 2003 10:16:26 -0800
From: genericax@hotmail.com (Sara)
Subject: Re: Print lines of file until certain string found?
Message-Id: <776e0325.0303051016.66d99dd9@posting.google.com>
mschaer@quantaservices.com (A. M. Schaer) wrote in message news:<cad2e56c.0303050725.7cde98a4@posting.google.com>...
> What I am trying to do is have Perl open a file, print the lines of
> the file until it encounters a marker, <!--perl-->, then stop
> printing; however the code below doesn't do that; it just keeps
> printing the first line of the file over and over again; I know
> there's a flaw in my logic somewhere, but I just can't see it.
>
> Thanks.
>
> #!/usr/bin/perl
> ###this doesnt do what I thought
> $file="calexample.html";
> open (CURRFILE, $file) ||
> die ("Cant open file");
> $var='<!--perl-->';
>
> while ($line= <CURRFILE>) {
> #!~ does not match
> #=~ matches
> until ($line =~/$var/i)
> {
> print $line;
> }
> }
Don' t think you really need that "until" clause inside a "while".
Also shoot that $line var too while you're at it? In fact, let's just
go with s nice tite once-liner:
print until ( ($_ = <CURRFILE>) =~ /$var/i);
-Gx
------------------------------
Date: 5 Mar 2003 19:22:43 -0800
From: dwlepage@yahoo.com (david)
Subject: printing hash values
Message-Id: <b09a22ae.0303051922.4654a4eb@posting.google.com>
If I have lexical values:
my ($keyname, $keyvalue, $search, $replace);
my %uid ();
What would be the best way to print the contents of my hash once it
has been populated? I am new to perl and am having a hard time
visualizing the whole hash concept. Any suggestions?
Thanks,
------------------------------
Date: 5 Mar 2003 08:38:40 -0800
From: rafasegovia@yahoo.com (rsegovia)
Subject: Scripts in background
Message-Id: <65fb86bd.0303050838.7e9516a8@posting.google.com>
Hi There,
I need a perl script which has to run 5 perl scripts in parallel. How
can I do that? Is it possible to handle the return codes of all of
them?
Thanks a lot,
Rafael
------------------------------
Date: 5 Mar 2003 11:01:17 -0800
From: joeminga@yahoo.com (Domenico Discepola)
Subject: tough regex problem
Message-Id: <698c67f.0303051101.5e6a253c@posting.google.com>
A text file I've been presented with is described as follows:
field seperator: \r\n\r\n\r\n\x07
row seperator: \r\n\r\n\r\n\r\n
I'm trying to replace the above field seperator with a single \x07 and
the row seperator with a single \r\n
I couldn't find answers on perldoc or in the newsgroups so any help
would be greatly appreciated.
Regards,
Dom
------------------------------
Date: 5 Mar 2003 06:06:27 -0800
From: dave_h4@yahoo.com (Hunter)
Subject: Using ? for Operator
Message-Id: <27ad91d2.0303050555.27605960@posting.google.com>
Hi Group - can someone tell me why this is not working ? Perhaps I'm
using illegal syntax? Thanks!
The forum colum is a single integer between 1 and 10:
my @operators = (["<"], [">"],["="]);
my $sth = $dbh->prepare('select count(*) from table where forum ?
5');
my $i = 0;
foreach (@operators) {
my ($ans) = @$_;
$sth->execute( $ans );
++$i;
my $one = $sth->fetchrow_array();
print " select $ans: $one<br>";
}
daver
------------------------------
Date: Thu, 06 Mar 2003 04:48:42 GMT
From: Steve Grazzini <s_grazzini@hotmail.com>
Subject: Re: Using ? for Operator
Message-Id: <KqA9a.54967$Mh3.20331407@twister.nyc.rr.com>
Hunter <dave_h4@yahoo.com> writes:
> Hi Group - can someone tell me why this is not working ? Perhaps
> I'm using illegal syntax? Thanks!
>
> The forum colum is a single integer between 1 and 10:
>
> my @operators = (["<"], [">"],["="]);
> my $sth = $dbh->prepare('select count(*) from table where forum ? 5');
It's actually in the DBI manpage -->
With most drivers, placeholders can't be used for any
element of a statement that would prevent the database
server from validating the statement and creating a
query execution plan for it. For example:
"SELECT name, age FROM ?" # wrong (will probably fail)
"SELECT name, ? FROM people" # wrong (but may not 'fail')
It's a bit like the difference between:
print $x * 3; # fine
print 2 $x 3; # gack
HTH
--
Steve
------------------------------
Date: 6 Mar 2003 04:39:40 GMT
From: Wei Weng <wweng@play.cs.columbia.edu>
Subject: What is wrong with this piece of UDP server code?
Message-Id: <b46jec$d2d$1@tornado.cs.columbia.edu>
I have the following simple code:
#!/usr/bin/perl -w
use IO::Socket;
$port = 5050;
$server = IO::Socket::INET->new(
LocalPort => $port,
Proto => "udp") ;
die "Can not establish a UDP server listening on port $port\n"
unless $server;
print "sucessfully set up UDP server on port $port\n";
# establish a UDP server, loop on accepting new connections
while ($sock = $server->accept()) {
print "accepting new connections\n";
while (my $msg = <$sock>) {
print($msg);
}
close $sock;
}
I was expecting the code goes into a loop and keep looking for connections
coming into port 5050, but it is not the case,
What did I do wrong?
Thanks
Wei
------------------------------
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 4670
***************************************