[23458] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5673 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 17 00:07:54 2003

Date: Thu, 16 Oct 2003 21: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           Thu, 16 Oct 2003     Volume: 10 Number: 5673

Today's topics:
    Re: Archive::Tar and write to an open filehandle <ahamm@mail.com>
        combining regular expressions <karigna@verizon.net>
    Re: Emacs syntax highlight of Perl comments <michael.p.broida@boeing_oops.com>
    Re: Emacs syntax highlight of Perl comments <michael.p.broida@boeing_oops.com>
    Re: Emacs syntax highlight of Perl comments <nospam-abuse@ilyaz.org>
    Re: help chdir UNC path ( newbie ) (Jay Tilton)
    Re: help chdir UNC path ( newbie ) (Bill)
    Re: How can i write the values of a form through a cgi  <tore@aursand.no>
    Re: How to propagate -w and use strict? (James Willmore)
    Re: How to propagate -w and use strict? (Jay Tilton)
    Re: How to propagate -w and use strict? <lusol@Pandora.cc.lehigh.edu>
    Re: Junior attempts binary data manipulation <krahnj@acm.org>
    Re: line to array convertion <REMOVEsdnCAPS@comcast.net>
    Re: line to array convertion <michael.p.broida@boeing_oops.com>
    Re: line to array convertion <krahnj@acm.org>
        Novell File structure format for reading (Thomas B)
    Re: Perl book for learning interface programming under  <mikeflan@earthlink.net>
    Re: Perl scripts for Unix on my windows machine (Ren Patterson)
    Re: Perl scripts for Unix on my windows machine <michael.p.broida@boeing_oops.com>
    Re: Perl scripts for Unix on my windows machine <michael.p.broida@boeing_oops.com>
    Re: Perl scripts for Unix on my windows machine <ebohlman@earthlink.net>
    Re: Perl scripts for Unix on my windows machine (James Willmore)
    Re: Q: Problem figuring out versions of DBI <dpetrou@ece.cmu.edu>
    Re: Q: Problem figuring out versions of DBI (James Willmore)
    Re: Q: Problem figuring out versions of DBI <dpetrou@ece.cmu.edu>
    Re: Q: Problem figuring out versions of DBI <invalid-email@rochester.rr.com>
        script removes too many lines <spedwards@qwest.net>
    Re: Unexpected alteration of array's content <uri@stemsystems.com>
    Re: Unexpected alteration of array's content <uri@stemsystems.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 17 Oct 2003 11:45:23 +1000
From: "Andrew Hamm" <ahamm@mail.com>
Subject: Re: Archive::Tar and write to an open filehandle
Message-Id: <bmnhl9$osta2$1@ID-79573.news.uni-berlin.de>

Jens M. Felderhoff wrote:
>
> I have 0.22, however...
>[SNIP]
> I don't know why you'll want to write to a pipe.

[evil grin] that's part of the business rools i'm working with. It's
legitimate but yeah, unusual. Most tars are written to file and then
delivered...

> Try something like the following:
>
>     $tar->add_files("foo", "bar", "froz", "foobar");
>     open TARFILE, ">foo.tar" or die "Cannot open tarfile:$!\n";
>     $tar->write(*TARFILE{IO}); # or \*TARFILE or *TARFILE{FILEHANDLE}
>     close TARFILE;
>
> That should give you a foo.tar file including the four archive
> members.

Hmmm - I *thought* I tried that one, but maybe not... So, I'll try now.
However, I need to replace the ">foo.tar" with "| process"; after that, your
alternative suggestion \*TARFILE is syntactically identical to one of my
previous tries. I guess if all else fails I'll have to dive into the source
and try to figure it out.

I tried posting to c.l.p.modules first, but Ned has been strangely silent.
Maybe he's on holidays.

Thanks for your reply anyway; I've been elsewhere for a week hence my
delayed response.

cheers.




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

Date: Fri, 17 Oct 2003 02:52:08 GMT
From: "Kev" <karigna@verizon.net>
Subject: combining regular expressions
Message-Id: <sPIjb.14350$fv4.8095@nwrdny02.gnilink.net>

I have two regular expressions that work fine individually but not together
can I get help to combine them?

( /(\w[\w'-]*)/g) - I'm using this one to pull words from a text file

/\b\w(3,)\b/g - this one pulls out words of 3 or more characters

K.




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

Date: Thu, 16 Oct 2003 22:19:27 GMT
From: "Michael P. Broida" <michael.p.broida@boeing_oops.com>
Subject: Re: Emacs syntax highlight of Perl comments
Message-Id: <3F8F196F.7116E5EF@boeing_oops.com>

"Eric J. Roode" wrote:
> 
> Are you using perl-mode or cperl-mode?  cperl-mode is far better than
> perl-mode.  Also, be sure to use the latest version.  cperl-mode 5.0 is
> quite excellent -- I don't think I've come across a situation yet where
> it highlights incorrectly.

	OOOH!  I just tried cperl-mode and it does look nicer than
	perl-mode.  :)  Might take some getting used to, though.

	Now, how do I make that the default for .pl and .pm files?
	(I can ask in comp.emacs if you would rather not deal with
	Emacs questions here.)

		Mike


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

Date: Thu, 16 Oct 2003 22:15:46 GMT
From: "Michael P. Broida" <michael.p.broida@boeing_oops.com>
Subject: Re: Emacs syntax highlight of Perl comments
Message-Id: <3F8F1892.558ADA5@boeing_oops.com>

Anno Siegel wrote:
> 
> All syntax hilighters have glitches like that, some more, some less.
> If you look closer at your specific one, you'll probably find others.

	Yep, Emacs sometimes colorizes a non-comment "#" character
	and all after it as though it were a comment.  At least it
	does that in the version I'm using.

		Mike


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

Date: Thu, 16 Oct 2003 23:43:57 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Emacs syntax highlight of Perl comments
Message-Id: <bmnaft$2gmo$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Anno Siegel
<anno4000@lublin.zrz.tu-berlin.de>], who wrote in article <bmlo9l$nvg$1@mamenchi.zrz.TU-Berlin.DE>:
> The saying is "Only perl can parse Perl", which means you need a full
> Perl interpreter just to analyze the syntax.  Since typical editors
> don't have a Perl interpreter, all they can do is guesswork.

The problem is not that they do not have a Perl interpreter.  The
problem is that you need to *run* the script to parse it.

> > Any info on how to pathc this?
> 
> Don't sweat it.  Use syntax hilighting as far as it goes, but don't
> try fixing marginal glitches.  You'll never see the end of it.

Do not think CPerl will have any problem with "normal" Perl programs
(not specially designed to work around heuristics used by CPerl).

Hope this helps,
Ilya




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

Date: Thu, 16 Oct 2003 23:46:38 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: help chdir UNC path ( newbie )
Message-Id: <3f8f2db0.391845726@news.erols.com>

"Didier FRAISSE" <dfraisse@free.fr> wrote:

: i'm trying to convert this small ruby script into perl script
: 
: Reporting.rb
: ========
:     Dir.chdir('\\\Bureautique\Reporting France')
:     system( 'C:\Program Files\Microsoft Office\Office\Excel.exe "Reporting
: France.xls"')
:     Dir.chdir('\\\Bureautique\Reporting Export')
:     system( 'C:\Program Files\Microsoft Office\Office\Excel.exe "Reporting
: Export.xls"')
: 
: Reporting.pl
: ========
:     chdir('\\\Bureautique\Reporting France')
:     system( 'C:\Program Files\Microsoft Office\Office\Excel.exe "Reporting
: France.xls"')
:     chdir('\\\Bureautique\Reporting Export')
:     system( 'C:\Program Files\Microsoft Office\Office\Excel.exe "Reporting
: Export.xls"')
: 
: but it seems that UNC path are not welcome !!!

Perl gets along just fine with UNC paths.

You can get a better picture of what's going wrong with some extra
diagnostic output.

    use Cwd;
    chdir '\\\\Bureautique\\Reporting France'
        or die "Could not chdir: $!";
    print "current directory:", getcwd, "\n";
    system( .... );

Personally, I'd just cut out the chdir() and pass the filename to excel
with its complete UNC path.



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

Date: 16 Oct 2003 18:01:21 -0700
From: wherrera@lynxview.com (Bill)
Subject: Re: help chdir UNC path ( newbie )
Message-Id: <239ce42f.0310161701.36e89aca@posting.google.com>

Dan Rawson <daniel.rawson.take!this!out!@asml.nl> wrote in message news:<bmm1at$o1mfu$1@ID-122008.news.uni-berlin.de>...
> Brian McCauley wrote:
> > "Didier FRAISSE" <dfraisse@free.fr> writes:
> > 
> > 
> >>i'm trying to convert this small ruby script into perl script

Does this work with ruby? Ruby's directory module must be doing a lot
of the shell stuff on its own, then, rather than using high-level
system calls. Nice.

> >>but it seems that UNC path are not welcome !!!
> > 
> > 
> > You are using system(STRING).
> > 
> > The string contains shell meta characters.
> > 
> > It is therfore passed to the Win32 shell (CMD.EXE) to be parsed.
> > 
> > The Win32 shell does not support UNC paths for the CWD. (This, of
> > course, is a feature of CMD.EXE and has nothing to do with Perl).
> > 
> Didier -
> 
> Actually, this does work (at least on my NT system).


check out:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcn7/html/vbconintroductiontofilesystemobjectmodel.asp


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

Date: Fri, 17 Oct 2003 01:54:18 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: How can i write the values of a form through a cgi script in a	txt file.
Message-Id: <pan.2003.10.16.20.26.44.319093@aursand.no>

On Thu, 16 Oct 2003 12:57:41 -0700, JR wrote:
>>> How can i write the values of a form through a cgi script in a txt file.

>> What have you tried so far?  What doesn't work?

> #!/usr/bin/perl

Should be:

  #!/usr/bin/perl
  #
  use strict;
  use warnings;

> print "Content-type:text/html\n\n";
> 
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> @pairs = split(/&/, $buffer);
> foreach $pair (@pairs) {
>     ($name, $value) = split(/=/, $pair);
>     $value =~ tr/+/ /;
>     $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>     $FORM{$name} = $value;
> }

Should be:

  use CGI;

  my $cgi = CGI->new();
  print $cgi->header(-type => 'text/html');

> open (EEP,"passwords.txt");foreach $key (keys(%FORM)) {
>     print EEP "$key = $FORM{$key}<br>";
> }

Should be:

  my $params = $cgi->Vars();
  open( EEP, '>passwords.txt' ) || die "$!";
  foreach my $key ( keys %$params ) {
      print EEP $key . ' = ' . $params{$key} . '<br';
  }
  close( EEP );

But why do you want to write some HTML to STDOUT, while the form data gets
written to a text file?

Summary:

  perldoc CGI
  perldoc -f open


-- 
Tore Aursand <tore@aursand.no>


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

Date: 16 Oct 2003 16:30:18 -0700
From: jwillmore@myrealbox.com (James Willmore)
Subject: Re: How to propagate -w and use strict?
Message-Id: <d61170e5.0310161530.1b774413@posting.google.com>

Steve Lidie <lusol@cube0.CC.Lehigh.EDU> wrote in message news:<bmmi39$19ue@fidoii.CC.Lehigh.EDU>...
> James Willmore <jwillmore@remove.adelphia.net> wrote:
> > On 16 Oct 2003 12:21:50 GMT
> > Steve Lidie <lusol@cube0.CC.Lehigh.EDU> wrote:
<snip>
> > Just throwing out an untested idea - would using a BEGIN block with
> > 'use warnings' inside work?  I haven't tried it, but I'm curious to
> > see if anyone has or thinks this might work.
> > 
> 
> I've reduced it to this - here's file w-test:
> 
> BEGIN {
>     $^W=1;
>     use warnings;
> }
> print "w-test, \$^W=$^W.\n";
> $cow = 1;
> 
> Run the above and a warning re $cow is displayed.
> 
> Now run w-test2, below, which includes w-test, and no warning.  Here's
> w-test2:
> 
> BEGIN {
>     $^W=1;
>     use warnings;	
> }
> print "w-test2, \$^W=$^W.\n";
> do './w-test';
> 
> 
> 
> [lusol@cube0:~/Desktop/TRACE3] perl w-test 
> Name "main::cow" used only once: possible typo at w-test line 6.
> w-test, $^W=1.
> [lusol@cube0:~/Desktop/TRACE3] perl w-test2
> w-test2, $^W=1.
> w-test, $^W=1.

Okay - it this doesn't work as I expected.  Now I've learned something :-)

Sorry I could not offer something of more substance :-(

Jim


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

Date: Thu, 16 Oct 2003 23:49:17 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: How to propagate -w and use strict?
Message-Id: <3f8f2e38.391981981@news.erols.com>

James Willmore <jwillmore@remove.adelphia.net> wrote:

: On 16 Oct 2003 12:21:50 GMT
: Steve Lidie <lusol@cube0.CC.Lehigh.EDU> wrote:
: 
: > I have this template code (wptk.template):
: > 
: > use Tk;
: > use vars qw/ $mw /;
: > use strict;
: > 
: > $mw = MainWindow->new;
: > 
: > print "wptk.template ARGV=@ARGV!\n";
: > 
: > $^W = 1;
: > my $stat = do "$ARGV[0]";
: > if ( not defined $stat ) {
: >     print $@ if $@;
: >     print $! if $!;
: >     $mw->destroy;
: >     exit 1;
: > };
: > 
: > MainLoop;
: > 
: > This code is invoked via execl() from a C program, specifying -w as
: > one of the arguments:
: > 
: >   execl( "/usr/local/bin/perl", "/usr/local/bin/perl", "-w",
: >          "./wptk.template", file, (char *)0);
: > 
: > The purpose of the execed Perl code is to require/eval user code,
: > but I'd like -w and use strict to propagate to the included code so
: > I/the user doesn't have to specify it each time.  I have yet to find
: > a way to do that ...is it possible?
: 
: Just throwing out an untested idea - would using a BEGIN block with
: 'use warnings' inside work?  I haven't tried it, but I'm curious to
: see if anyone has or thinks this might work.

The effects of "use warnings;" or "use strict;" are lexically scoped.
Putting either inside a BEGIN{} block would only influence what goes on
inside the block.

The only solution that comes to mind is to devolve "do $ARGV[0]" into
"eval `cat $ARGV[0]`", so you can graft the pragmas onto the code before
it's run.  Like, say,

    my $code = `cat $ARGV[0]`;
    eval "{use warnings;use strict;$code}";



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

Date: 17 Oct 2003 00:22:57 GMT
From: "Stephen O. Lidie" <lusol@Pandora.cc.lehigh.edu>
Subject: Re: How to propagate -w and use strict?
Message-Id: <bmncp1$oh6@fidoii.CC.Lehigh.EDU>

Jay Tilton <tiltonj@erols.com> wrote:
> James Willmore <jwillmore@remove.adelphia.net> wrote:

> : On 16 Oct 2003 12:21:50 GMT
> : Steve Lidie <lusol@cube0.CC.Lehigh.EDU> wrote:
> : 
> : > I have this template code (wptk.template):
> : > 
> : > use Tk;
> : > use vars qw/ $mw /;
> : > use strict;
> : > 
> : > $mw = MainWindow->new;
> : > 
> : > print "wptk.template ARGV=@ARGV!\n";
> : > 
> : > $^W = 1;
> : > my $stat = do "$ARGV[0]";
> : > if ( not defined $stat ) {
> : >     print $@ if $@;
> : >     print $! if $!;
> : >     $mw->destroy;
> : >     exit 1;
> : > };
> : > 
> : > MainLoop;
> : > 
> : > This code is invoked via execl() from a C program, specifying -w as
> : > one of the arguments:
> : > 
> : >   execl( "/usr/local/bin/perl", "/usr/local/bin/perl", "-w",
> : >          "./wptk.template", file, (char *)0);
> : > 
> : > The purpose of the execed Perl code is to require/eval user code,
> : > but I'd like -w and use strict to propagate to the included code so
> : > I/the user doesn't have to specify it each time.  I have yet to find
> : > a way to do that ...is it possible?
> : 
> : Just throwing out an untested idea - would using a BEGIN block with
> : 'use warnings' inside work?  I haven't tried it, but I'm curious to
> : see if anyone has or thinks this might work.

> The effects of "use warnings;" or "use strict;" are lexically scoped.
> Putting either inside a BEGIN{} block would only influence what goes on
> inside the block.

> The only solution that comes to mind is to devolve "do $ARGV[0]" into
> "eval `cat $ARGV[0]`", so you can graft the pragmas onto the code before
> it's run.  Like, say,

>    my $code = `cat $ARGV[0]`;
>    eval "{use warnings;use strict;$code}";


Hmm, still no luck );

[lusol@Ray:~/Desktop/TRACE4] perl w-test 
Name "main::cow" used only once: possible typo at w-test line 5.
w-test, $^W=1.
[lusol@Ray:~/Desktop/TRACE4] perl w-test3
w-test3, $^W=1.
w-test, $^W=1.

Where w-test is before, and w-test3 is a modified version of w-test2:

BEGIN {
    $^W=1;
}
print "w-test3, \$^W=$^W.\n";
#do './w-test';

my $code = `cat ./w-test`;
eval `cat w-test`;


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

Date: Thu, 16 Oct 2003 22:49:31 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Junior attempts binary data manipulation
Message-Id: <3F8F205A.7C927CE5@acm.org>

Dan Jacobson wrote:
> 
> Say, I'm going to be making this file, each line with a time() string,
> and a count,
> print time ." ". 257
> 1066329734 257
> I started thinking about space saving methods,
> printf "%x %x", time, 257
> 3f8ee6df 101
> why don't I just make the file
> [4 byte time][2 byte count][4 byte time][2 byte count]...
> that way, each time I append a time,count pair to the file, I only add
> 6 bytes.  Ok, so how do I write out such raw records, and how might I
> turn such a file back into ASCII? Something like chr,ord... Assume the
> file will not leave the machine, so byte order is not a problem.

$string = pack 'LS', time, 257;

( $time, $count ) = unpack 'LS', $string;



John
-- 
use Perl;
program
fulfillment


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

Date: Thu, 16 Oct 2003 17:06:38 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: line to array convertion
Message-Id: <Xns9416B81B41A65sdn.comcast@216.196.97.136>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

arctan@moonman.com (arctan) wrote in 
news:c6d76a1b.0310161328.7df445bc@posting.google.com:

> so if file looked like:
> 
> tokpsf
> 
> Then after script Id get:
> 
> t
> o
> k
> p
> s
> f

perl -i.bak -pe 's/./$&\n/g' file1 file2 file3...

- -- 
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBP48WPmPeouIeTNHoEQKLBQCfWcycuHLlxdaXwi5DakpJx+Z7SNMAoMcW
9scmR0UoUoPX3WvZRa3NBvpa
=AfvD
-----END PGP SIGNATURE-----


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

Date: Thu, 16 Oct 2003 22:24:40 GMT
From: "Michael P. Broida" <michael.p.broida@boeing_oops.com>
Subject: Re: line to array convertion
Message-Id: <3F8F1AA8.8F80C740@boeing_oops.com>

arctan wrote:
> 
> so if file looked like:
> 
> tokpsf
> 
> Then after script Id get:
> 
> t
> o
> k
> p
> s
> f
> 
> Thanks alot in advance for any suggestions

	Look at docs for "split".  It will work
	with an empty delimiter.

		Mike


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

Date: Thu, 16 Oct 2003 23:01:14 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: line to array convertion
Message-Id: <3F8F2319.D19C6838@acm.org>

arctan wrote:
> 
> I am facing a problem well beyond my perl skills, and I would greatly
> appreciate help or suggestions.
> 
> What I would like to do is start with a 1 line text file of n text
> charachters. (spaceless, tabless, with all \s white space removed)
> 
> Then I would like to transform that to a text file of n lines, each
> containing one text charachter, and no whitspace or special
> charachters except of course the newline.
> 
> so if file looked like:
> 
> tokpsf
> 
> Then after script Id get:
> 
> t
> o
> k
> p
> s
> f

perl -F// -lane'print for@F' text.file


John
-- 
use Perl;
program
fulfillment


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

Date: 16 Oct 2003 16:43:28 -0700
From: thomas@shurflo.com (Thomas B)
Subject: Novell File structure format for reading
Message-Id: <866f534e.0310161543.45ea9b41@posting.google.com>

Anyone know what the Novell file structure format for reading files
is?  I can't get this to work:

open(INPUT,"/PERL/WEB/security.txt") or die "Open sys:perl/web open
Failed!";
while (<INPUT>) {
	print $_," ",$count;
	$count ++;
}

I know the pipe is necessary for Linux, but I don't know if Novell
uses it - there are no text manipulation utilities in Novell.

I've also tried:
open(INPUT,"sys:/PERL/WEB/security.txt |");
open(INPUT,"sys:/PERL/WEB/security.txt");  # Without Pipe

open(INPUT,"sys:PERL/WEB/security.txt |");
open(INPUT,"sys:PERL/WEB/security.txt");   # Without Pipe

open(INPUT,"sys:\PERL/WEB/security.txt |");
open(INPUT,"sys:\PERL/WEB/security.txt");  # Without Pipe

Linux was so much easier...


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

Date: Fri, 17 Oct 2003 01:29:56 GMT
From: Mike Flannigan <mikeflan@earthlink.net>
Subject: Re: Perl book for learning interface programming under win32
Message-Id: <3F8F46C2.ADCE012F@earthlink.net>


Markus Praher wrote:

> Hello!
>
> I am seaching for a good perl book about programming USB-,  Fire wire-,
> rerial-, parallel-ports,... under windows.  It should also include examples.
>
> It would be very nice if you can help me.
>
> Thank you.

Closest thing I've seen for this is "Network Programming
with Perl".  But I don't think it quite has what you are
looking for.




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

Date: 16 Oct 2003 15:05:50 -0700
From: reneap@hotmail.com (Ren Patterson)
Subject: Re: Perl scripts for Unix on my windows machine
Message-Id: <2e13d330.0310161405.140f543c@posting.google.com>

James Willmore <jwillmore@remove.adelphia.net> wrote in message 

> The point Anno was making was this:
> if you code correctly (meaning, you enable warnings), you will get
> your answers.
> if you use the documentation, you will get your answers.


The scripts are not mine, I do not know how they are coded, I do not
even know how to code them. What documentation? I looked all over and
nothing gave me a clear answer. I kept on getting ambiguous
information, so I thought before doing something wrong I would ask
"human" beings.


> 
> Now, after that little bit of anger, why don't you go somewhere, count
> to 100, and then post.  That direction is included in the FAQ for this
> group -and- IMHO, good advise.
> 

Sure I can do that. Does the FAQ include a site to go when passive
aggression and unnecessary predisposed negative attitudes are
displayed?


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

Date: Thu, 16 Oct 2003 22:05:22 GMT
From: "Michael P. Broida" <michael.p.broida@boeing_oops.com>
Subject: Re: Perl scripts for Unix on my windows machine
Message-Id: <3F8F1622.70C8B275@boeing_oops.com>

Tad McClellan wrote:
> 
> Michael P. Broida <michael.p.broida@boeing_oops.com> wrote:
> > James Willmore wrote:
> >>
> >> The first line of your script _may_ present an issue.  Consider this:
> >> #!/usr/bin/perl -w
> >>
> >> This is no /usr/bin on many Windows boxes (unless you're using Cygwin,
> >> which it appears you're not).
> >
> >       I've had that line in many of my Windows Perl scripts and
> >       had NO problems with it.  Windows doesn't use that line
> >       in any way at all, so it's just another comment line.
> 
> Windows doesn't use it, but perl _does_, so it isn't really
> just another comment line.
> 
> perl parses that line looking for switches, such as -w

	Ah.  I hadn't thought of the switches part at all.
	AND I didn't know that perl would use them on windows.
	Now I know!  :)

> >       3) File path syntax has to be changed.  Windows wants drive
> >               letters; Unix uses "/" and mountpoints.  I don't know
> 
> Windows can use "/" as the directory separator too.

	Inconsistently, from my experience.  Within Perl code,
	yes, either way works well (most of the time) because
	Perl itself is handling it.  Though I did run into one
	case where my Perl script choked on mixed "/" and "\"
	in a single filespec.  Outside of Perl, Windows usually
	hates the forward slash (or maybe it hates ME when I
	use forward slashes!).

		Mike


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

Date: Thu, 16 Oct 2003 22:11:47 GMT
From: "Michael P. Broida" <michael.p.broida@boeing_oops.com>
Subject: Re: Perl scripts for Unix on my windows machine
Message-Id: <3F8F17A3.69E7019D@boeing_oops.com>

James Willmore wrote:
> 
> "Michael P. Broida" <michael.p.broida@boeing_oops.com> wrote in message news:<3F8D8FA5.8F3030FF@boeing_oops.com>...
> > James Willmore wrote:
> > >
> > > The first line of your script _may_ present an issue.  Consider this:
> > > #!/usr/bin/perl -w
> > >
> > > This is no /usr/bin on many Windows boxes (unless you're using Cygwin,
> > > which it appears you're not).
> >
> >       I've had that line in many of my Windows Perl scripts and
> >       had NO problems with it.  Windows doesn't use that line
> >       in any way at all, so it's just another comment line.
> <snip>
> 
> True - however, it is something to consider when writing a portable
> script.  When you try and go the other way (Windows to Unix) it _does_
> matter.  And is something the OP should be made aware of - especial in
> a mixed OS environment (something you should already know about, given
> your email address).

	Not obvious from my prior post, but I was trying to say
	that you SHOULD put the shebang line in the script even
	on Windows so it will work on Unix. I just said that it
	isn't really used on the Windows side (and Mr McClellan
	corrected me on that point).

> perlport is the FAQ I was eluding to in my previous post.

	Ah, thanks.  Is there some (simple) way to get a list of all
	the "xxxx" that can be used in "perldoc xxxx"?  I mean "perlre",
	"perltut", "perlop", etc, but is there one that will give a
	list of all the rest??  Without knowing the "xxxx", it's
	often hard (for me anyway) to find info with perldoc.

		Mike


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

Date: 16 Oct 2003 23:50:04 GMT
From: Eric Bohlman <ebohlman@earthlink.net>
Subject: Re: Perl scripts for Unix on my windows machine
Message-Id: <Xns9416C16EA3B2Debohlmanomsdevcom@130.133.1.4>

"Michael P. Broida" <michael.p.broida@boeing_oops.com> wrote in
news:3F8F1622.70C8B275@boeing_oops.com: 

>> Windows can use "/" as the directory separator too.
> 
>      Inconsistently, from my experience.  Within Perl code,
>      yes, either way works well (most of the time) because
>      Perl itself is handling it.  Though I did run into one
>      case where my Perl script choked on mixed "/" and "\"
>      in a single filespec.  Outside of Perl, Windows usually
>      hates the forward slash (or maybe it hates ME when I
>      use forward slashes!).

Specifically, the Windows file system has no problem at all with forward 
slashes, but the Windows shell does.  So you can't use them when typing at 
the command line or when invoking external programs from Perl (or any other 
language) code.



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

Date: 16 Oct 2003 18:46:08 -0700
From: jwillmore@myrealbox.com (James Willmore)
Subject: Re: Perl scripts for Unix on my windows machine
Message-Id: <d61170e5.0310161746.3f07b5@posting.google.com>

"Michael P. Broida" <michael.p.broida@boeing_oops.com> wrote in message news:<3F8F17A3.69E7019D@boeing_oops.com>...
> James Willmore wrote:
> > 
> > "Michael P. Broida" <michael.p.broida@boeing_oops.com> wrote in message news:<3F8D8FA5.8F3030FF@boeing_oops.com>...
> > > James Willmore wrote:

<snip>

> > perlport is the FAQ I was eluding to in my previous post.
> 
> 	Ah, thanks.  Is there some (simple) way to get a list of all
> 	the "xxxx" that can be used in "perldoc xxxx"?  I mean "perlre",
> 	"perltut", "perlop", etc, but is there one that will give a
> 	list of all the rest??  Without knowing the "xxxx", it's
> 	often hard (for me anyway) to find info with perldoc.

perldoc perl -or- perldoc perlfaq

Please read the FAQ for this group - it is mentioned somewhere in
there about how to get this information.

HTH

Jim


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

Date: 17 Oct 2003 00:53:13 GMT
From: David Petrou <dpetrou@ece.cmu.edu>
Subject: Re: Q: Problem figuring out versions of DBI
Message-Id: <bmnehp$9fo$1@nntp.ece.cmu.edu>

cp <cpryce@pryce.net> wrote:
> You probably want to have a look at the DBD::mysql installation guide.
> It's posted conveniently on line as
>
> http://search.cpan.org/src/RUDY/DBD-mysql-2.9002/INSTALL.html#configurat
> ion

thanks.

since this is an install time config, then i'm guessing my DBD is
using my /usr/local/bin mysql stuff, which is significantly older than
the mysql server i'm connecting to.

but, i have been using this setup successfully for a week or so.  i
wonder if there's a version compatibility chart somewhere.  or i guess
i could just hope that things would safely assert and die if the
version mismatch is too great.

> RTFM. This information took all of ten seconds to find.

10 seconds for you, because you're so smart.

> -- 
> cp

david


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

Date: 16 Oct 2003 18:36:32 -0700
From: jwillmore@myrealbox.com (James Willmore)
Subject: Re: Q: Problem figuring out versions of DBI
Message-Id: <d61170e5.0310161736.5291c5a8@posting.google.com>

David Petrou <dpetrou@ece.cmu.edu> wrote in message news:<bmmqth$3ia$3@nntp.ece.cmu.edu>...
> James Willmore <jwillmore@remove.adelphia.net> wrote:
> > To get the available drivers, there's a
> > different method.  Read the DBI documentation for more information.
> 
> i couldn't find the info in the DBI doc, but the following gave me the
> info on DBD::mysql, which is what i'm using:
> 
> perl -MDBI -MDBD::mysql -e 'print $DBD::mysql::VERSION;'

Just FYI - DBD::mysql is the _driver_ module, which is _used_ by the
DBI module (aka _D_atabase _I_nterface _M_odule).  DBD::mysql can
_not_ exist or be used _without_ the DBI module.  Again, just FYI :-)

> 
> > Ouch!  You're trying to install DBD::mysql on a machine that does
> > _not_ have MySQL installed on it?
> 
> no, that's not what i want to do.
> 
> i want to know how to tell DBD::mysql to look for my mysql
> installation which is in a non-standard place.
> 
> right now, i have an old version of mysql installed in
> /usr/local/mysql.  i cannot uninstall this copy.  i don't want
> DBD::mysql to use it.
> 
> i have a new version of mysql installed off my home dir.  it's before
> /usr/local/mysql in my path, but i just don't know whether DBD::mysql
> is in fact using it, or is using /usr/local/mysql.

1) Get the module (try http://search.cpan.org, search for mysql)
2) extract the source
3) actual _read_ the README and the INSTALL files

When you actual do 'make install', be sure to add 'UNINST=1' at the
end of the line - this will overwrite/uninstall/etc. the old install -
so, the command would be:
make install UNINST=1

This _may_ make the older version of MySQL that's installed on your
system inaccessable to DBD::mysql.  In other words, maybe you should
think about having just one version of MySQL on your system - if
possible.  Again, read the documentation for further details.

HTH

Jim


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

Date: 17 Oct 2003 03:08:58 GMT
From: David Petrou <dpetrou@ece.cmu.edu>
Subject: Re: Q: Problem figuring out versions of DBI
Message-Id: <bmnmga$bsp$1@nntp.ece.cmu.edu>

James Willmore <jwillmore@myrealbox.com> wrote:
> Just FYI - DBD::mysql is the _driver_ module, which is _used_ by the
> DBI module (aka _D_atabase _I_nterface _M_odule).  DBD::mysql can
> _not_ exist or be used _without_ the DBI module.  Again, just FYI :-)

thanks.  i already know this.
> 1) Get the module (try http://search.cpan.org, search for mysql)
> 2) extract the source
> 3) actual _read_ the README and the INSTALL files

> When you actual do 'make install', be sure to add 'UNINST=1' at the
> end of the line - this will overwrite/uninstall/etc. the old install -
> so, the command would be:
> make install UNINST=1

actually, i can't uninstall the old version.  i'd want to install a
private copy of DBD::mysql.  (see below.)

> This _may_ make the older version of MySQL that's installed on your
> system inaccessable to DBD::mysql.  In other words, maybe you should
> think about having just one version of MySQL on your system - if
> possible.  Again, read the documentation for further details.

i don't have root on this machine.  that's why i can't upgrade the old
version of mysql in /usr/local/mysql.

so, i've installed my own new mysql in my home dir.  and i would
install my own DBD that knows where to find the new mysql.

but...  as i said in a previous post, i seem to be getting along fine
with my current DBD that uses the /usr/local/mysql (v. 3) to access a
v. 4 server.  i'm hoping something would have died already if these
versions were incompatible.

> HTH

> Jim

thanks much,
david


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

Date: Fri, 17 Oct 2003 03:56:57 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Q: Problem figuring out versions of DBI
Message-Id: <3F8F6883.4090704@rochester.rr.com>

David Petrou wrote:

> Bob Walton <invalid-email@rochester.rr.com> wrote:
> 
>>New item in version 1.38, I guess -- it's not in 1.37.  What version of 
>>DBI are you actually running?
>>
> 
> 1.37 also.
> 
> thanks,
> david
> 

That's a good reason to always refer to the docs on your local system 
rather than on the net -- you get the right stuff for your version.

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



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

Date: Thu, 16 Oct 2003 20:58:51 -0600
From: "Shawn" <spedwards@qwest.net>
Subject: script removes too many lines
Message-Id: <7ZIjb.2297$pT1.56329@news.uswest.net>

Hi,

I use the below script to strip out all my headers and line separators on a
report (text file) I created.  The only problem is it strips out too much.
Every time the script encounters a line in the report that begins with the
word: Subset
I'd like it to skip or leave that line in the file as well as the next 4
lines that follows this line.  These 5 lines can appear multiple times in
the file depending on the
size of the file.

This script isn't mine and the creator is long gone so I have struggled in
my attempts to edit it.

Any suggestions would be greatly appreciated.  Thanks

#!/usr/local/bin/perl
if ($#ARGV < 0 ) {
   print "Usage $0 infile\n";
   exit(1);
}
$infile = $ARGV[0];
open(INFILE,"$infile") || die "Can't open file $infile $!\n";
while ($line = <INFILE>) {
   next if ($line =~/^Last Name/ || $line =~ /\|Service/ );
   if ($line =~ /\|/) {
      $next_line = <INFILE>;
      if ($next_line =~ /----/) {
         push(@my_list,$line)
      }
      else {
         chomp($line);
         $next_line =~ s/^ +//;
         $line_plus = $line . $next_line;
         push(@my_list,$line_plus);
      }
   }
}

close(INFILE);
@sort_mylist = sort(@my_list);
foreach $line (@sort_mylist) {
   $line =~ s/\|/\|/g ;
   print $line;
}






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

Date: Thu, 16 Oct 2003 22:28:56 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Unexpected alteration of array's content
Message-Id: <x7he28u8b1.fsf@mail.sysarch.com>

>>>>> "AS" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:

  AS> Uri Guttman  <uri@stemsystems.com> wrote in comp.lang.perl.misc:
  >> >>>>> "RJ" == Roy Johnson <rjohnson@shell.com> writes:
  >> 
  RJ> I don't consider @{[...]} to be horrible, just mildly distasteful. It
  RJ> gets worse depending on the size of the array.
  >> 
  >> i jumped in the middle of this thread (and i am not going back to the
  >> very beginning) but wouldn't a simple @foo = ( blah ) be enough? if you

  AS> Yes.  We're discussing the case where you don't want to do that for
  AS> some reason.

and that reason is? i can't see any reason where a simple copy won't work.

  >> have a reference already then @{$ref} is fine. so where would @{[ blah
  >> ]} be needed except to interpolate?

  AS> Well, abstractly speaking, when you want an anonymous copy of the list.
  AS> More concretely... uh, I don't think you really want to know, there
  AS> was nothing earth-shattering.  Post a followup and I'll make an excerpt
  AS> from the thread if you want one.

what is an anon copy? how would a regular copy not be anon? inquiring
minds want to know! :)

  >> i see the word 'copy' in the thread
  >> and no reason for using a full anon array and deref. it seems to be a
  >> waste of an extra copy (the anon array is tossed!).

  AS> Thread drift...

this still doesn't explain the need for @{[blah]} which what i want to
know.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Thu, 16 Oct 2003 22:50:36 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Unexpected alteration of array's content
Message-Id: <x7ekxcu79f.fsf@mail.sysarch.com>

>>>>> "BM" == Brian McCauley <nobull@mail.com> writes:

  >> > Another is a fix to a misbehaving map or grep.  "Oops, it's changing my
  >> > array!  Let's put @{[ ... ]} around it."
  >> 
  >> This is the best example,

  BM> And is indeed the subject of this thread!

i would fix the grep/map code. i just don't write them to do side
effects as that is not their purpose. i use for modifier or a real loop
if i want side effects.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

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


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