[18760] in Perl-Users-Digest
Perl-Users Digest, Issue: 928 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 18 03:05:31 2001
Date: Fri, 18 May 2001 00: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)
Message-Id: <990169507-v10-i928@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 18 May 2001 Volume: 10 Number: 928
Today's topics:
Re: \n Woes <wyzelli@yahoo.com>
Re: An Example Of A Polite FAQ (5-i's)
Re: check if file exists with different extensions (Bernard El-Hagin)
Closure: which variable does it refer to? <johnlin@chttl.com.tw>
Re: Closure: which variable does it refer to? (Rafael Garcia-Suarez)
Re: cookie implementation (Rafael Garcia-Suarez)
Re: cookie implementation <serg@pbox.ttn.ru>
Re: HTTP Login (Rafael Garcia-Suarez)
Re: Match Parsing Glitch (Jay Tilton)
Re: Match Parsing Glitch <nospam@xx.com>
Re: Multipage Perl CGI script <goldbb2@earthlink.net>
Nettiquete (Re: Help with File Upload -CGI.pm) <goldbb2@earthlink.net>
Re: Posting Guidelines for comp.lang.perl.misc ($Revisi (Bernard El-Hagin)
Re: timeout after STDIN ? (Bernard El-Hagin)
Transliteration Creates A \r Character Accidently?? <godzilla@stomp.stomp.tokyo>
Re: Transliteration Creates A \r Character Accidently?? <godzilla@stomp.stomp.tokyo>
Re: URGENT: CGI program wanted! <mikecook@cigarpool.com>
Re: using MS Access (*.mdb) w/perl? <mikecook@cigarpool.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 18 May 2001 15:48:25 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: \n Woes
Message-Id: <E73N6.19$wM1.5009@vic.nntp.telstra.net>
"Samuel Kilchenmann" <skilchen@swissonline.ch> wrote in message
news:9e07b6$cka9$1@ID-13368.news.dfncis.de...
<SNIP>
> I like your approach with some modifications:
>
> > open (IN, 'd:/perl/scripts/test/temp.txt') or die "Cant $!";
> > open (OUT, '>d:/perl/scripts/test/newtemp.txt') or die "Wont $!";
> > my $last;
> > my @lines = <IN>; # The file is only 461k
>
> No need to slurp the entire file into @lines
>
> > for (@lines){
>
> while (<IN>) {
That is true, but I commented that I chose this approach because I knew the
file was only 461k. That 461k however is made up of many lines, and
performance is significantly improved on particular file by doing the slurp.
This is certainly not true for the general case, which is why I made my
comment.
> > chomp;
> > if ($last){ #make sure we have 'a' line
>
> Here you are skipping empty lines which might be a feature. But if you
> want to keep empty lines you have to check for defined($last)
Once again, I scanned the file beforehand and saw no empty lines. I would
have to consider that for the general case, but not for this specific case.
> > if (m/^&&/){ # If the next line starts with &&
<SNIP>
> > else {
> > $last = $_; # store the first line
> > }
> > }
> >
> Here you miss the last line.
I'm not sure I follow that, but I might have to review my logic cycle if
that is the case. I certainly don't want to miss the last line.
> if ($last) {
> print OUT "$last\n";
> }
>
I like your comments. Thanks for your input.
Wyzelli
--
push@x,$_ for(a..z);push@x,' ';
@z='092018192600131419070417261504171126070002100417'=~/(..)/g;
foreach $y(@z){$_.=$x[$y]}y/jp/JP/;print;
------------------------------
Date: Fri, 18 May 2001 06:29:52 GMT
From: fiveyes@iiiii.com (5-i's)
Subject: Re: An Example Of A Polite FAQ
Message-Id: <3b04c081.114138359@news.msy.bellsouth.net>
When your song is written, I'm certain it will include the verse:
"how bitter the good medicine"
5-i's
------------------------------
Date: Fri, 18 May 2001 05:32:57 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: check if file exists with different extensions
Message-Id: <slrn9g9cfg.6co.bernard.el-hagin@gdndev25.lido-tech>
On Thu, 17 May 2001 14:45:20 GMT, Lex <nospam@peng.nl> wrote:
>
>"Tad McClellan" <tadmc@augustmail.com> wrote in message
>news:slrn9g7lki.pvh.tadmc@tadmc26.august.net...
>
><snip>
>
>>
>> What should be done if there is more than one file with
>> a common "basename"?
>>
>In this case there can be only one
This is off-topic here. You should go to alt.fan.highlander. :-)
Cheers,
Bernard
------------------------------
Date: Fri, 18 May 2001 11:41:15 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Closure: which variable does it refer to?
Message-Id: <9e25gh$cst@netnews.hinet.net>
Dear all,
Guess the results of the following programs.
my($print,$index);
$print = sub { print $index };
$index = 1;
$print->();
The result is 1 as I can expect. But
my($print,$index);
for $index (1..3) {
$print = sub { print $index };
}
$index = 1;
$print->();
The result is... 3 (not 1 as I expected)!!!
my($print,$index);
$print = sub { print $index };
for $index (1..3) { $print->() }
Use of uninitialized value in print at line 3.
Use of uninitialized value in print at line 3.
Use of uninitialized value in print at line 3.
Not "123" as I expected. It seems the "for" creates a ghost variable
Maybe it refers to the "global" (or "dynamic scoped") $index. But
I think it's not reasonable because if it is "global", "use strict" should warn
Global symbol "$index" requires explicit package name
It also violates my purpose of declaring "my $index" to make it "lexical".
Otherwise (if it is "lexical") why the results are not the same as I expected?
Thank you very much.
John Lin
------------------------------
Date: 18 May 2001 06:57:20 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Closure: which variable does it refer to?
Message-Id: <slrn9g9i0t.uej.rgarciasuarez@rafael.kazibao.net>
John Lin wrote in comp.lang.perl.misc:
} Dear all,
}
} Guess the results of the following programs.
}
} my($print,$index);
} $print = sub { print $index };
} $index = 1;
} $print->();
}
} The result is 1 as I can expect. But
}
} my($print,$index);
} for $index (1..3) {
} $print = sub { print $index };
} }
} $index = 1;
} $print->();
}
} The result is... 3 (not 1 as I expected)!!!
The answer is in perlsyn (section on foreach loops) :
The "foreach" loop iterates over a normal list value and sets the
variable VAR to be each element of the list in turn. If the variable
is preceded with the keyword "my", then it is lexically scoped, and is
therefore visible only within the loop. Otherwise, the variable is
implicitly local to the loop and regains its former value upon exit
ing the loop. If the variable was previously declared with "my", it
uses that variable instead of the global one, but it's still localized
to the loop.
Try with a while() loop :
my($print,$index);
$index = 1;
while ($index < 4) {
$print = sub { print $index };
++$index;
}
$index = 1;
$print->();
--> outputs '1'.
--
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: 18 May 2001 06:49:05 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: cookie implementation
Message-Id: <slrn9g9hhe.uej.rgarciasuarez@rafael.kazibao.net>
Craig Berry wrote in comp.lang.perl.misc:
} Troy Boy (troyr@vicnet.net.au) wrote:
} : Does anyone have a perl cookie implementation on the web?
}
} CGI.pm includes good cookie-handling tools.
CGI::Cookie is also a module of choice.
} : I want to see if it saves the cookie on my browser..as a particular
} : browser of mine will not save perl cookies!
}
} That's impossible as stated. There's no way for an agent to distinguish a
} perl cookie from a java cookie, or a FORTRAN cookie, or a cookie
} hand-typed by a human well versed in http who is emulating a server.
Except cookies set via javascript. The most unreliable ones.
--
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/perl/biscuit.html
------------------------------
Date: Fri, 18 May 2001 10:47:51 +0400
From: "Serg Vasilev" <serg@pbox.ttn.ru>
Subject: Re: cookie implementation
Message-Id: <9e2gha$1sid$1@pbox.ttn.ru>
Hi, All
"Troy Boy" <troyr@vicnet.net.au> wrote in message
news:H8_M6.82$Ld4.2097@ozemail.com.au...
[skip]
> $the_cookie = cookie(-name=>'sid',
> -value=>$session_id,
> -expires=>'+1m',
> -domain=>'.vicnet.net.au',
> -path=>'/');
How do you generate $session_id?
------------------------------
Date: 18 May 2001 06:03:28 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: HTTP Login
Message-Id: <slrn9g9ert.tua.rgarciasuarez@rafael.kazibao.net>
Mike Mesarch wrote in comp.lang.perl.misc:
} I would like to download some files from an web site, but the site requires
} me to pass my username and password. How can I have perl pass this
} information when prompted?
Use the LWP::UserAgent class, and it's credentials() method.
--
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: Fri, 18 May 2001 04:05:42 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Match Parsing Glitch
Message-Id: <3b049d9c.415350929@news.erols.com>
On Thu, 17 May 2001 20:41:16 -0700, Eric <nospam@xx.com> wrote:
>OK...tnx again, Jay...I redid the $writestatsfile per above but it is
>still not working. I'm dumbfounded!!! Using it with the substr
>suggestion.
I've gone this far, so I'm not giving up just yet.
One more thing (which really should have been mentioned earlier) is to
be sure the input and output files are being opened correctly.
open (INFILE, "$filename")
or die "Could not open $filename for read: $!";
open (FILE ,">>$statsfile")
or die "Could not open $statsfile for append: $!";
The program should work, dammit. :)
------------------------------
Date: Thu, 17 May 2001 23:35:54 -0700
From: Eric <nospam@xx.com>
Subject: Re: Match Parsing Glitch
Message-Id: <3B04C2CA.16E2E415@xx.com>
Thanks to all of you for your help. Umpteen versions later...and with a
record counter I added to verify all lines were read & written, this one
F-I-N-A-L-L-Y works!
#!/usr/bin/perl -w
# stats7.pl
#
# DATA FILE FORMAT LINES TO PARSE (complete file contains blank lines &
other stuff)
# 003 046926 MXF 08 1/1/5 $2,400,000 22/NO/00 4285 AN ADDRESS
HERE C5D5
# 005 948573 AQPT392 1/1/5 $1,755,500 13/SE/99 44283 SOME NAME
HERE C5D5
# 007 453981 RVQA 02 1/1/5 $835,000 19/OC/99 314 WHATEVER
HERE C5D5
#
# Address is 25 or less characters after the single space following the
dd/mm/yy date
#
# START OF PERL SCRIPT
$R=1;
print "Enter File Name To Parse: "; #instructions for entering file
name
$filename = <STDIN>; #enter file name to parse
print "Enter Output File Name: "; #instructions
for entering output file name
$statsfile = <STDIN>; #enter output
file name
open (INFILE, "$filename")
or die "Could not open $filename as read:
$!"; #open input file
while ($line = <INFILE>) #primary loop
{
if ($line =~ m/.*\d{6}/)
{
my ( $vendor, $price, $addr ) =
unpack 'x11 A7 x10 A10 x11 A25', $line;
$price =~ tr/$,//d; #remove $ and
comma on price
$addr =~ s/^\s+|\s+$//g; #whitespace cleanup on
address
#and skip all other lines
&writestatsfile ($vendor, $price, $addr)
unless $line !~ m/.*\d{6}/; #only call subroutine if valid
line to prase
}
}
close (INFILE); #close input file
### SUBROUTINE TO PRINT VENDOR ID, PRICE & ADDRESS TO ASCII .CSV FILE
sub writestatsfile
{
my ($vendor, $price, $addr ) = @_;
open (FILE ,">>$statsfile"); #open output file for
append
print FILE "$R,$vendor,$price,\"$addr\"\n"; #write data to file
$R++;
close (FILE); #close output file
}
# END OF PERL SCRIPT
------------------------------
Date: Fri, 18 May 2001 03:01:52 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Multipage Perl CGI script
Message-Id: <3B04C8E0.49402038@earthlink.net>
I believe that using content-type: multipart/x-mixed-replace might do
the job. However, it has some special syntax. Fortunatly, CGI.pm does
provide support for it. Here's an untested example which assumes the
work can be split into 10 parts, and does each part with a new
'working...' page in between. You will of course need to write the subs
my_do_part and my_print_results.
use CGI qw(:push);
$| = 1;
print multipart_init;
for (0..9) {
print multipart_start("text/plain");
printf 'Working... %d0%% done', $_;
print multipart_end;
my_do_part($_);
}
print multipart_start("text/html");
print "<H1>Here are the results:</H1>\n";
my_print_results();
print_multipart_final();
__END__
Of course, it might [or might not] be preferable to do this with
client-pull rather than server-push. You'll need to include a refresh
header (printed via the CGI::header method), or else an http-equiv item
inside the <head> of your html document.
Server push has the advantage that the browser can easily close the
connection. With client pull, there's no easy way for the human user to
tell the browser to ignore the 'refresh' field, except by closing the
window or by forcing the browser to a different page.
--
Customer: "I would like to try on that suit in the window."
Salesman: "Sorry sir, you will have to use the dressing room."
------------------------------
Date: Fri, 18 May 2001 05:26:44 GMT
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Nettiquete (Re: Help with File Upload -CGI.pm)
Message-Id: <3B04B3F5.FFD46B7@earthlink.net>
[recieved as html email, then posted and mailed]
> Reji Alex wrote:
>
> Hi,
>
> Hope you don't mind me using your email address just once to ask a
> question on CGI scripting. I noticed that you replied to another
> posting at the comp.lang.perl.misc and described the script making
> suggestions all the way thru the code.
>
> I hope you can help me with my little problem as well....
>
> I created a File Upload script to upload files, both binary and text,
> to a UNIX filesystem. The script works fine except all by binary files
> are getting corrupted. Files such as powerpoint slides, MS Word
> documents, PDF files etc are all getting corrupted. It gets uploaded
> but I can not reopen the files from the server using its respective
> programs such as Powerpoint or Word. My script runs on a UNIX machine
> with Apache webserver. But the script will be accessed by both Unix
> users and PC users thru their web browser of choice.
>
> Here is a snipplet of the code where I perform the file save.
>
> use File::Basename;
> use
> strict; #
> Prevent undeclared variables.
> use
> CGI;
> # Retrieve the CGI.pm module.
> use CGI::Carp qw(fatalsToBrowser); # Show
> errors in web browser.
>
> # Commentout above line when using this script IRL.
> use vars qw($cgi $fh $fn $type @dirs $newdir @ndirs); # Declare
> variables that are used by the script
> use vars qw($filename $bytesread $buffer @fileparts); # And a couple
> of more variables.
> use CGI qw(:standard);
> ;;;
> ;;;
>
> $fh = $cgi->upload('file');
> my $Mime = $cgi->uploadInfo($fh)->{'Content-Type'};
> print $cgi->header(-type=>$Mime);
> ;;;
> ;;;
> # Save the file to the server:
> open (OUTFILE, ">$SAVE_DIR/$filename");
> if($Mime !~ /text/ ) {
> binmode($fh);
> binmode (OUTFILE);
> }
> while( read($fh, $buffer, 1024) ) {
> print OUTFILE $buffer;
> }
> close (OUTFILE);
>
> Would you please look at the code and see if I am making any obvious
> mistake. What is the trick involved in getting CGI.pm
> to Upload files properly without corrupting it.
>
> Any help would be greatly appreciated. Thank you.
>
> Reji_Alex
First: *please* post your questions to the newsgroup, not to individuals
who have answered posts in the past.
I read the NG when I have free time (every few days), but read mail as
it comes in (within a day or two). I have work to do. Answering posts
is a low priority. If you post your message to the group, and noone
else gives you help, then maybe I'll help you.
Second: Send/post in text, not html. Most people's readers only
understand text. Many of those who's browsers understand html prefer
reading text anyway, especially for code. Indenting is much more
readable in a fixed width font.
Third: You should use a more accurate subject line. What you have seems
to indicate that you are having trouble uploading files at all, as
opposed to being able to upload, but the files appear to be corrupted.
Something like "File corruption in CGI.pm Upload."
Fourth: Read the faq and old posts. The problem you have is one which
people have had before. Others may have given solutions to this
problem.
Now, some comments and suggestions:
1) It's better to use "my" rather than "use vars" for local variables,
and the other way around for globals. Declare your variables in the
scope they're used in, so they go out of scope and free up memory.
2) ALWAYS check the return value of open, even if you are in a situation
where it should succeed 100% of the time.
Replace:
open (OUTFILE, ">$SAVE_DIR/$filename");
With:
open (OUTFILE, ">$SAVE_DIR/$filename") or die $!;
3) Using a fixed maximum for the size of the buffer can result in IO
that is slower than than fastest your system can handle.
I would replace:
while( read($fh, $buffer, 1024) ) { print OUTFILE $buffer; }
with either:
{ my $blocksize = (stat($fh))[11] or 1024;
while( read($fh, $buffer, $blocksize ) { print OUTFILE $buffer; }
}
Or:
{ my $blocksize = (stat($fh))[11] or 1024; local $/ = \$blocksize;
while( defined $buffer = <$fh> ) { print OUTFILE $buffer; }
}
Or possibly:
{ local $/ = undef; print OUTFILE scalar <$fh>; }
The above line reads the whole file in, and prints it all out. From the
point of view of the server, that last item will be fastest, but most
memory intensive, but will be slightly slower from the point of view of
the browser. Understanding why is left as an exercise for the reader.
4) Why are you using what is essentially a global variable for your
filehandle? It's not exactly *harmful* here, but good programming style
is to use local variables whenever possible, and global variables as
infrequently as possible.
To fix this, replace:
open (OUTFILE, ">$SAVE_DIR/$filename");
With:
my $outfile = gensym;
open( $outfile, ">", "$SAVE_DIR/$filename" ) or die;
Don't forget to put "use Symbol;" at the top of your program, and to
replace instances of OUTFILE with $outfile. You probably don't *really*
need to put a value in $outfile before the open, as open should do that
for you, but it's better style.
5) Why bother extracting the mimetype to a temp variable, if you're only
going to use it in one place?
You can replace:
my $Mime = $cgi->uploadInfo($fh)->{'Content-Type'};
print $cgi->header(-type=>$Mime);
With
print $cgi->header(-type => $cgi->uploadInfo($fh)->{'Content-Type'});
Actually, you could compact it slightly to:
print $cgi->header( $cgi->uploadInfo($fh)->{'Content-Type'});
The reason why this third form can be done is left as an exercise for
the reader.
Determining when this SHOULD be done is based on how likely it is that
people looking at the code will be able to understand what is happening.
Actually... I (and most users of CGI.pm) know that $cgi->header with one
parameter will result in it using that parameter as the content type.
Other CGI methods also have meanings for the first, second, etc
parameters when there is no leading "-" (as on the "-type" string) on
the first parameter. When to use the position instead of name/value
pairs is a matter of style.
6) There is no real *need* to create an instance of a CGI object, unless
you're dealing with more than one of them (for instance if you are using
mod_perl). Accessing the methods without using the OO forms makes it
easier to read and understand the code.
Eliminate the call to new, and then replace all OO calls of the form:
$cgi->whatever(blah);
With:
whatever(blah);
Note however that you MUST be consistent. The second form will result
in the CGI package creating a an internal instance of a CGI object, and
uses that in the same manner as what you would pass yourself. So if you
are going to switch, do it all the way through the code (or else it will
sometimes use your instance, and sometimes its internal instance).
--
Customer: "I would like to try on that suit in the window."
Salesman: "Sorry sir, you will have to use the dressing room."
------------------------------
Date: Fri, 18 May 2001 05:27:48 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.1 $)
Message-Id: <slrn9g9c5q.6co.bernard.el-hagin@gdndev25.lido-tech>
On Thu, 17 May 2001 17:08:44 GMT, Mark Jason Dominus <mjd@plover.com> wrote:
[snip]
>However, I think that from what you originally wrote, nobody could
>reasonably be expected to understand what you meant. You originally
>said:
>
> "This section describes things that you *must* do before posting to
> clpmisc."
>
>with no qualification whatsoever. If what Bernard said above is what
>you intended to say with this, I do not think people will understand
>you correctly. I suggest you change this section to read:
>
> "Many of the posters to this group will ignore your message unless
> you do these things:"
>
>and omit the word 'must', which, unless qualified somehow, is wrong.
Yes, now I'm convinced you're right. I think the problem is that
we know what Tad means by 'must', but someone new to the group
doesn't necessarily have to.
Cheers,
Bernard
------------------------------
Date: Fri, 18 May 2001 05:14:16 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: timeout after STDIN ?
Message-Id: <slrn9g9bce.6co.bernard.el-hagin@gdndev25.lido-tech>
On Thu, 17 May 2001 17:28:23 GMT, Mark Jason Dominus <mjd@plover.com> wrote:
>In article <slrn9g7de5.pk3.bernard.el-hagin@gdndev25.lido-tech>,
>Bernard El-Hagin <bernard.el-hagin@lido-tech.net> wrote:
>>alarm (10) or $input = <STDIN>;
>
>That 'or' does not make any sense to me. What is it doing there, and
>why is it not a semicolon?
Because I'm an idiot who was thinking of something else when posting
that. It should be a semicolon, of course.
Cheers,
Bernard
------------------------------
Date: Thu, 17 May 2001 22:49:25 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Transliteration Creates A \r Character Accidently??
Message-Id: <3B04B7E5.2790390E@stomp.stomp.tokyo>
I believe this is only my third or fourth "question" posted
to this newsgroup.
You will recognize the data in my test script from another
thread. In testing different methods to extract data, I have
come across something odd which I cannot understand.
Would someone mind helping me understand what is happening?
Look at my printed results. You will notice an extra blank
line where it should not be. This blank consists only of
a carriage return \r character, not a \n newline.
You will probably wig-out on me for this. This odd
glitch only shows up in a browser. You have to run
this as a cgi script. It does not show in document
source. I've only encountered this glitch once before.
This cures the glitch, as a stand alone when inserted
just before the final print at bottom:
$field4 =~ s/\r//;
Clearly a carriage return is being created somehow.
I have removed as much data as possible, I think, and still
have this extra blank line appear. I have used as many same
variable names as possible and still have this glitch show.
Here are other tests I have tried:
Comment out the transliteration - effect stops.
Remove the "r" from Vendor, both - effect stops.
Remove one digit from 2400000 - effect stops.
Remove one trailing space from the first string - effect stops.
Change:
$field6 = substr ($string, 49, 22);
To:
$field6 = substr ($string, 49, 21);
For one less space character - effect stops.
Change from a browser to a DOS command line - effect stops!!
I am sure there are lots of other minor changes which would
effect this. However, I am beginning to wonder if I will be
able to effectively narrow this down and pinpoint the cause
of this extra \r character appearing when it shouldn't.
During my testing, I wrote lots of simplified code to
replicate this oddity. No luck at all. I have only
been able to replicate this when "two test scripts"
are run as one, as you see in my code.
What is there about my code which is creating
a carriage return \r character?
Anyone have suggestions or ideas on what is happening?
Godzilla!
--
#!perl
print "Content-type: text/plain\n\n";
## $string should be one long line - watch word warp!
$string = '003 046926 MXF 08 1/1/5 $2,400,000 22/NO/00 4285 AN ADDRESS HERE
';
$field2 = substr ($string, 11, 7);
$field4 = substr ($string, 29, 10);
$field6 = substr ($string, 49, 22);
$field4 =~ tr/,//d;
print "Vendor : $field2\n",
"Field : $field4\n",
"Field : $field6\n\n";
$string = '003 046926¦MXF 08¦1/1/5¦2400000¦22/NO/00¦4285 AN ADDRESS HERE';
($field1, $field2, $field3, $field4, $field5, $field6) = split (/¦/, $string);
print "Vendor : $field2\n",
"Field : $field4\n",
"Field : $field6\n\n";
exit;
PRINTED RESULTS:
________________
Vendor : MXF 08
Field : 2400000
Field : 4285 AN ADDRESS HERE
Vendor : MXF 08
Field : 2400000
Field : 4285 AN ADDRESS HERE
------------------------------
Date: Thu, 17 May 2001 23:01:15 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Transliteration Creates A \r Character Accidently??
Message-Id: <3B04BAAB.DB6D2E49@stomp.stomp.tokyo>
"Godzilla!" wrote:
(snipped)
> ## $string should be one long line - watch word warp!
> $string = '003 046926 MXF 08 1/1/5 $2,400,000 22/NO/00 4285 AN ADDRESS HERE
> ';
Darn it. I reset my reader to print 86 characters and in my reader,
this line is split in two. I am concerned you might not be able to
replicate this line correctly. There are seven spaces right after,
AN ADDRESS HERE
Should end like this:
AN ADDRESS HERE ';
^^^^^^^ seven spaces.
This is really important because removal of the last
trailing space causes the glitch to stop.
Godzilla!
------------------------------
Date: Thu, 17 May 2001 21:53:55 -0700
From: "Michael Cook" <mikecook@cigarpool.com>
Subject: Re: URGENT: CGI program wanted!
Message-Id: <9W1N6.1547$XB5.382899@news.uswest.net>
I have to beg to differ on one program - Webmin can be found there & it is a
huge timesaver (plus I can administer my box through a proxy, not that I
would do that on work time ;-)
Michael
--
== CigarPool ==
http://www.cigarpool.com
"Uri Guttman" <uri@sysarch.com> wrote in message
news:x766f2a5fr.fsf@home.sysarch.com...
> >>>>> "P" == Perlzagame <www@nospam.com> writes:
>
> P> if this is off topic then 95% of the messages here are off-topic..
> P> Try www.cgi-resources.com
>
> that web site is off limits. you just marked yourself as a disciple of
> the matt wright school of bad perl programming.
>
> as for the OP request being off topic, this group is about discussing
> the perl language and not about finding free programs.
>
> uri
>
> --
> Uri Guttman --------- uri@sysarch.com ----------
http://www.sysarch.com
> SYStems ARCHitecture and Stem Development ------
http://www.stemsystems.com
> Learn Advanced Object Oriented Perl from Damian Conway - Boston, July
10-11
> Class and Registration info:
http://www.sysarch.com/perl/OOP_class.html
------------------------------
Date: Thu, 17 May 2001 21:50:09 -0700
From: "Michael Cook" <mikecook@cigarpool.com>
Subject: Re: using MS Access (*.mdb) w/perl?
Message-Id: <fU1N6.1546$XB5.382425@news.uswest.net>
If you know any SQL, you can use the Perl DBI (look on CPAN for the
modules). It allows you to access (virtually) any type of database via Perl.
Michael
--
== CigarPool ==
http://www.cigarpool.com
"fiat_lux" <dab727@yahoo.com> wrote in message
news:tfivl4j3dgf660@corp.supernews.com...
> I'm in hot water to get a class project done. Basically I need to be able
to
> add/delete/query a MS Access 2000 database with perl. I told them not to
use
> Access, but they wouldn't listen and now there's no other choice.
>
> The extent of my perl/cgi knowledge is only manipulating HTML forms (ie.
> emailing the data somewhere, or making "mad-libs" out of the form fields).
I
> have no clue how to access a database, let alone an MS Access *.mdb one. I
> would most grateful if someone had some pointers for me. Even some sample
> code would be a life-saver.
>
> Many thanks in advance. This is perl running on Windows, for the record.
I'm
> using the sambar web server and it's executing perl scripts just fine.
>
>
------------------------------
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 928
**************************************