[22518] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4739 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 21 11:07:35 2003

Date: Fri, 21 Mar 2003 08:05:08 -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           Fri, 21 Mar 2003     Volume: 10 Number: 4739

Today's topics:
    Re: Am I asking too much of "map"? (Anno Siegel)
    Re: Am I asking too much of "map"? (Sara)
        Best editor for perl scripts <sbour@niaid.nih.gov>
    Re: Best editor for perl scripts <dorward@yahoo.com>
    Re: Best editor for perl scripts <usenet@dwall.fastmail.fm>
    Re: Chopping of everything after a certain word <barryk2@SPAM-KILLER.mts.net>
    Re: creating an error box (Helgi Briem)
    Re: doubts on \n <fxn@hashref.com>
        foreach element in a hasharray (IDid)
    Re: Getting list of files from Win32 clipboard (Phil Hibbs)
    Re: Getting list of files from Win32 clipboard (Phil Hibbs)
    Re: Getting list of files from Win32 clipboard <noreply@gunnar.cc>
    Re: help (Helgi Briem)
        How can I localize a $i at a expreg? (i5513)
    Re: How can I localize a $i at a expreg? (Anno Siegel)
    Re: How to use Net::FTP - FTP Client class (Joe Kamenar)
    Re: new Perl feature request: call into shared libs <kevin@-nospam-pcug.org.au>
    Re: perl2exe question (Randal L. Schwartz)
        print to file safley <blnukem@hotmail.com>
    Re: print to file safley <tassilo.parseval@rwth-aachen.de>
    Re: Problem using CGI.pm and SSL. <shah@typhoon.xnet.com>
    Re: Problem using CGI.pm and SSL. <shah@typhoon.xnet.com>
    Re: Problem using CGI.pm and SSL. <shah@typhoon.xnet.com>
    Re: Problem with Getopt::Std and getopts().... <barryk2@SPAM-KILLER.mts.net>
        Simple regular expression question (Stephane Gregoire)
    Re: Simple regular expression question <bernard.el-hagin@DODGE_THISlido-tech.net>
        socket- and pseudo-tty-problem <michael@binaervarianz.de>
        Using an Environment variable in a regexp match (Chris)
    Re: Using an Environment variable in a regexp match <josef.moellers@fujitsu-siemens.com>
    Re: Using an Environment variable in a regexp match <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: Using an Environment variable in a regexp match <barryk2@SPAM-KILLER.mts.net>
    Re: Wanted: exetype.pl and related info (Malcolm Dew-Jones)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 21 Mar 2003 12:31:58 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Am I asking too much of "map"?
Message-Id: <b5f0nu$jnq$1@mamenchi.zrz.TU-Berlin.DE>

Keith Keller  <kkeller-spammmm@wombat.san-francisco.ca.us> wrote in comp.lang.perl.misc:
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
> 
> In article <x7y939ekjd.fsf@mail.sysarch.com>, Uri Guttman wrote:
> >>>>>> "KK" == Keith Keller <kkeller-spammmm@wombat.san-francisco.ca.us> writes:
> > 
> >  KK> my %h = map { /$regexhere/; $h{$3}=$1 } @array;
> > 
> >  KK> ?
> > 
> > if you are not sure, why post a guess?
> 
> The guess was for what the OP wanted, not the code.  (Though, as
> you point out, the code is wrong, too.  It happens sometimes.)
> 
> > what you might have been thinking of is:
> > 
> > my %h = map { /$regexhere/; ($3, $1) } @array;
> 
> No, but close enough:
> 
> my %h;
> map { /$regexhere/; $h{$3} = $1 } @array;

Why use map then?  It collects an array of values that is never used.

    do { /$regexhere/; $h{$3} = $1 } for @array;

Anno


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

Date: 21 Mar 2003 05:30:55 -0800
From: genericax@hotmail.com (Sara)
Subject: Re: Am I asking too much of "map"?
Message-Id: <776e0325.0303210530.43c8fb63@posting.google.com>

genericax@hotmail.com (Sara) wrote in message news:<776e0325.0303201302.16d626c9@posting.google.com>...
> I love the perl map function, in the words of the immortal "Butthead",
> "It kicks ass!".. I commonly populate hashes from fields in arrays
> with things like:
> 
>  my %h = map /(\d+)\s\w+\s(\w+)/, @array;
> 
> .
  . 
  .

VERY nice solutions everyone thanks so much. I also have occasion to
want to extract say 2 or 3 key-value pairs from each row, perhaps with
keys and values reversed. I WAS going to ask about that in a followup-
but I can figure out some nice ways to do that do based on the tips
you all provided.

Thanks again, nice weekend All!

-Gx


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

Date: Fri, 21 Mar 2003 10:07:03 -0500
From: Stephan Bour <sbour@niaid.nih.gov>
Subject: Best editor for perl scripts
Message-Id: <BAA094C7.6554%sbour@niaid.nih.gov>

Hi,
My script is getting large enough that I'd like a little help to keep track
of bracket pairs and syntax errors and to have more flexibility in
indentation and alignment of code. I'm using BBEdit right now but it's more
of an HTML editor. Any suggestion for a good Perl editor for Macintosh OS X?

Thank you,

Stephan.



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

Date: Fri, 21 Mar 2003 15:16:58 +0000
From: David Dorward <dorward@yahoo.com>
Subject: Re: Best editor for perl scripts
Message-Id: <b5fadm$anq$1$8300dec7@news.demon.co.uk>

Stephan Bour wrote:
> My script is getting large enough that I'd like a little help to keep
> track of bracket pairs and syntax errors and to have more flexibility in
> indentation and alignment of code. I'm using BBEdit right now but it's
> more of an HTML editor. Any suggestion for a good Perl editor for
> Macintosh OS X?

I use emacs with CPerl-mode. It does syntax highlighting, auto indentation
of code (which is pretty configurable), and will flash matching bracket
pairs (if you turn that minor mode on).

Available for Windows, Mac OSX, and various other systems.

-- 
David Dorward                                   http://david.us-lot.org/
"You cannot rewrite history, not one line."
                                      - The Doctor (Dr. Who: The Aztecs)


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

Date: Fri, 21 Mar 2003 15:55:44 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Best editor for perl scripts
Message-Id: <Xns93456F2C64C53dkwwashere@216.168.3.30>

Stephan Bour <sbour@niaid.nih.gov> wrote on 21 Mar 2003:

> My script is getting large enough that I'd like a little help to keep
> track of bracket pairs and syntax errors and to have more flexibility
> in indentation and alignment of code. I'm using BBEdit right now but
> it's more of an HTML editor. Any suggestion for a good Perl editor
> for Macintosh OS X? 

Check the google archives for this group, or just plain google for it.  
It's been discussed a number of times, and the answers haven't changed 
since the last time it was discussed.  (Not a flame, just a (probably 
futile) attempt to head off yet another "my favorite editor" dicussion.  
Besides, you can go to comp.editors for that. <g>)

-- 
David K. Wall - usenet@dwall.fastmail.fm
WWJD? JWRTFM.


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

Date: Fri, 21 Mar 2003 08:17:48 -0600
From: Barry Kimelman <barryk2@SPAM-KILLER.mts.net>
Subject: Re: Chopping of everything after a certain word
Message-Id: <MPG.18e4db03a6c40869989754@news.mts.net>

[This followup was posted to comp.lang.perl.misc]

In article <wqpea.22132$Vq.1570@afrodite.telenet-ops.be>, bandb 
(babydesmet@hotmail.com) says...
> Hello,
> 
> I have a maybe easy question, but haven't found the answer yet.
> 
> How can I make perl chop of everything that comes after a given word in a
> data-entry?
> E.g. blablabla/blablabla/work_this have to disappear has to become
> blablabla/blablabla/
> 
> Who can help?
> Thx,

if ( $data_entry =~ m/(^.*?${given_word})/ ) {  # look for word
    $data_entry = $1;
}

-- 
---------

Barry Kimelman
Winnipeg, Manitoba, Canada
email : bkimelman@hotmail.com


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

Date: Fri, 21 Mar 2003 11:27:39 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: creating an error box
Message-Id: <3e7af555.3627238252@news.cis.dfn.de>

On Thu, 20 Mar 2003 15:31:13 -0500, Ben
<ben_altman@deadspam.com> wrote:

>I have a perl script called by several applications that currently logs 
>errors to a log (when one occurs) but does not inform the user about the 
>error. What I would like to do is to pop up an error window that the 
>user can click "ok" on aside from the logging of the error that is 
>currently happening.

You can either use Perl/Tk to create a simple GUI, 
something like:

#!perl
use strict;
use warnings;
use Tk;
my $top = new MainWindow;
my $label = $top->Label
  (-text=>"An error occurred\n")->pack; 
my $button = $top->Button
   (-text=>"OK",-command=>"exit")->pack; 

MainLoop;
__END__

or if you are on Windows, this will work:

#!perl
use strict;
use warnings;
my $message = 'some text';
my $user = $ENV{USERNAME};
system ("net send $user $message") == 0 
   or die "Cannot net send to $user:$?";
__END__

If this is a stealth CGI question, it is off topic
but what you want is probably 

use CGI::Carp qw(fatalsToBrowser);
-- 
Regards, Helgi Briem
helgi DOT briem AT decode DOT is


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

Date: Fri, 21 Mar 2003 11:15:36 +0000 (UTC)
From: Xavier Noria <fxn@hashref.com>
Subject: Re: doubts on \n
Message-Id: <b5es8o$qsf$1@news.ya.com>

In article <3e7aeec8.3625561521@news.cis.dfn.de>, Helgi Briem wrote:

: On Thu, 20 Mar 2003 18:15:36 +0000 (UTC), Xavier Noria
:<fxn@hashref.com> wrote:
: 
:>I am not programming nothing diretly related to that, just
:> trying to understand that corner of Perl well.
: 
: But linebreaks have nothing whatsoever to do with Perl
: and everything to do with operating systems and their
: conventions.  

I think there is a little Perl to know about this issue, which is what I am
trying to clarify. You have to know how to use the language correctly to
write portable code that involves "\n" somehow.

On the one hand you need the general picture about conventions in operating
systems. That's not Perl. But on the other hand you need to know, for
instance, that in Perl and C portable newlines are written with "\n", and if
you are writing Java you need to know that the idiom there is println() (and
that "\n" is in fact not portable). That's part of the language.

It's good to now that in Perl "\n" has always length 1 but that its ASCII
code depends on the platform. And some other things I've learnt in this
thread.

In the end, it's a matter of studying Perl.

: For myself, I wish the linefeed were standardised

So do I.

-- fxn


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

Date: 21 Mar 2003 03:46:12 -0800
From: didrikse@stud.ntnu.no (IDid)
Subject: foreach element in a hasharray
Message-Id: <f370705d.0303210346.267972bc@posting.google.com>

Hi!
I'm new to perl and desperately need some advice.
I've got a web-interface that interacts with a database, and by using
SQL I'm collecting a number of scripts from one table (NO) and trying
to count the number of empty textfields in several other tables where
script=[NO].[script].

I would like the result to look like this:
        EN    IR     
script1 0     0      
script2 5     6       
script3 0     0      
script4 0     0      
 ..
with hyperlinked numbers 
f.i  
$lang=EN&$script=script1   $lang=IR&$script=script1   
$lang=EN&$script=script2   $lang=IR&$script=script2   
$lang=EN&$script=script3   $lang=IR&$script=script3   
$lang=EN&$script=script4   $lang=IR&$script=script4 
    

For the moment I get:

        EN    IR    
script1 0     0     0     0     0     0     
script2 5     6     5     6     5     6     
script3 0     0     0     0     0     0     
script4 0     0     0     0     0     0     

with hyperlinked numbers 
$lang=EN&$script=script1   $lang=EN&$script=script1  
$lang=IR&$script=script1
$lang=EN&$script=script2   $lang=EN&$script=script2  
$lang=IR&$script=script2
$lang=EN&$script=script3   $lang=EN&$script=script3  
$lang=IR&$script=script3
$lang=EN&$script=script4   $lang=EN&$script=script4  
$lang=IR&$script=script4
 ..

Regards
-ingrid

Here is my code:

use strict;
use Win32::ODBC;

print "Content-type: text/html\n\n";
	
my @tablenames; #array
my @scriptArray; #array

my $database = new ODBC( "translate" ) or die "Could not open db.\n";
my $database2 = new ODBC( "translate" ) or die "Could not open db.\n";
my $db = new ODBC("translate") or die "Could not open db.\n";

my %resulthash; #hash array
my %resulthash2; #hash array

my $sqlq = "SELECT DISTINCT Lang.langID AS Language ".
		"FROM Lang ".
		"WHERE (((Lang.langID) Not Like 'NO')) ".
		"ORDER BY Lang.langID; ";

unless( $db->Sql( $sqlq) ) {
	while ( $db->FetchRow() )  {
		my $lang = $db->Data('Language');
		#print $lang, "\n";
		push( @tablenames, $lang ); 
	}
}
	
else {
	print $db->error(), "\n\n";	
	print $sqlq;
}
	
#print "\n";

my $sqlquery = "SELECT DISTINCT [NO].script AS scriptName FROM [NO];"
;

unless( $database->Sql( $sqlquery ) ) {	
	while ( $database->FetchRow() )  { 
		my %data = $database->DataHash(); 
		my $script = $data{'scriptName'}; 
		push( @scriptArray, $script ); 
	}
}

else {	
	print $database->error(), "\n\n";	
	print $sqlquery;
}
	
	
foreach my $tablename ( @tablenames ) { 
		
	foreach my $script ( @scriptArray ) { 
					
		my $sqlquery2 = "SELECT Count([$tablename].tekst) ".
                                "AS NumOfText FROM [$tablename] WHERE 
".
                                "script='".$script."' AND len(tekst) <
1; ";
			
		unless( $database2->Sql( $sqlquery2 ) ) { 
			while ( $database2->FetchRow() )  { 
				my %data = $database2->DataHash(); 
				my $count = $data{'NumOfText'}; 
		
				if( exists $resulthash2{$script} ) {
				my @innerlist2 = @{$resulthash2{$script}};
					push( @innerlist2, $count ); 
					$resulthash2{$script} = \@innerlist2; 
				}	
		
				else {
					$resulthash2{$script}	= [$count];
				}
				
			} 		
		} 	
			
		else {
			print $database2->error(), "\n\n";
			print $sqlquery2;
		}
									
	} 		
} 

print "<HTML><HEAD>";
print "<TITLE>Count missing explanations </TITLE>";
print "<link REL='stylesheet' HREF='/risk/static/list-style.css'
TYPE='text/css' MEDIA='ALL'>";
print "</HEAD>";
print '<BODY BGCOLOR="White" topmargin="10" leftmargin="10">';
		
print '<form name="ScriptTexts", ACTION="./listForUpdate.pl"
method="POST">';
print '<table border="0">';	
print "<tr>";
print "<TD  CLASS='tdHeading' >Oversikt over script og antall tomme
felter for hvert språk </td>";
print "</tr>";

print "\n";
print "<tr>";
print "</tr>";
print "<td>";
print '<table border="1" cellpadding="2" cellspacing="2">';  
print "<thead>";      
print "<tr>"; 
print "</tr></thead><tbody>";
print "<tr><td><Font size=2><td>";

#***********************
#PROBLEMAREA
	
foreach my $tablename ( @tablenames ) {
	print $tablename, "</td><td>";
}
	
print '</font></td></tr>';
print "\n";

	my @keys = sort keys %resulthash2; 

	for( my $i = 0; $i < @keys; $i++ ) {
		print "<tr><td><Font size=2>", $keys[$i], "</td>" ;
		 
		for( my $j = 0; $j < @tablenames; $j++ ) {

		        my @innerlist = @{$resulthash2{$keys[$i]}};
			foreach my $listelement ( @innerlist ) {
#here is my problem!

print "<td><Font size=2><a
href=./listForUpdate.pl?sLang=$tablenames[$j]&scriptName=$keys[$i]>";
			        print $listelement, "</a></td>"; 			        } 
		}
		print "</tr>\n";
	}
	
#/PROBLEMAREA
#***************
	
print "</table>";
print '</form>';

$database -> Close();
$database2 -> Close();
$db -> Close();

print "</BODY></HTML>";


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

Date: 21 Mar 2003 04:10:20 -0800
From: gg@snark.freeserve.co.uk (Phil Hibbs)
Subject: Re: Getting list of files from Win32 clipboard
Message-Id: <a9ec249e.0303210410.7bbfb5a6@posting.google.com>

tiltonj@erols.com (Jay Tilton) wrote in message news:<3e7335b0.24356457@news.erols.com>...
> : statement, which seems to be executed only when the clipboard does *not* 
> : contain files.
> 
> I misread the comment.  Yes, that part does seem a bit of a no-op.

If the clipboard contains rich text or html, then it converts it to
plain text. Useful for copying text from one document to another,
where you want to paste it in using the default format for the
destination document.

Phil Hibbs.


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

Date: 21 Mar 2003 04:16:39 -0800
From: gg@snark.freeserve.co.uk (Phil Hibbs)
Subject: Re: Getting list of files from Win32 clipboard
Message-Id: <a9ec249e.0303210416.3e5007a2@posting.google.com>

Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in message news:<b4sqto$2332mb$1@ID-184292.news.dfncis.de>...
> $CLIP->GetFiles is an array. Maybe you may want to try:
>      $CLIP->Set(join "\n", $CLIP->GetFiles);

Thanks! Works a treat.

> > } else {
> >   $CLIP->Set($CLIP->GetText);
> 
> What's the point with that? As far as I understand, it just pastes the 
> very same text string to the clipboard as was just copied from the 
> clipboard...

Converts formatted text to plain text. Useful for URLs copied via
Internet Explorer right-click, if I ever have to resort to using IE.
You can then paste it into an email as text, rather than as a ".url"
attachment. I also use it for text copied from the 3270 emulator that
I use, which adds formatting.

Phil Hibbs.


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

Date: Fri, 21 Mar 2003 15:34:20 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Getting list of files from Win32 clipboard
Message-Id: <b5f883$2864kt$1@ID-184292.news.dfncis.de>

Phil Hibbs wrote:
> Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
> 
>>$CLIP->GetFiles is an array. Maybe you may want to try:
>>     $CLIP->Set(join "\n", $CLIP->GetFiles);
> 
> Thanks! Works a treat.

Good.

>>>} else {
>>>  $CLIP->Set($CLIP->GetText);
>>
>>What's the point with that? As far as I understand, it just pastes the 
>>very same text string to the clipboard as was just copied from the 
>>clipboard...
> 
> Converts formatted text to plain text. Useful for URLs copied via
> Internet Explorer right-click, if I ever have to resort to using IE.
> You can then paste it into an email as text, rather than as a ".url"
> attachment. I also use it for text copied from the 3270 emulator that
> I use, which adds formatting.

Thanks for letting us know. It obviously does make sense, after all. ;-)

/ Gunnar

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Fri, 21 Mar 2003 11:16:51 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: help
Message-Id: <3e7af40b.3626908418@news.cis.dfn.de>

On 20 Mar 2003 11:40:37 -0800, ajc1234@yahoo.com
(nonsparker) wrote:

>i need to know what is wrong with this script

<Snip lots of bad code>

Everything.  

Do yourself a favour and get some decent code
if you don't have the skill to write it yourself.

Try http://nms-cgi.sourceforge.net/
-- 
Regards, Helgi Briem
helgi DOT briem AT decode DOT is


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

Date: 21 Mar 2003 04:42:31 -0800
From: i5513@hotmail.com (i5513)
Subject: How can I localize a $i at a expreg?
Message-Id: <a657ec02.0303210442.4f155c57@posting.google.com>

Hi! I have a new problem :(

Imagine (this is only a example, i'd like it was general):

$er = "(a) (b\w*) (b\w*) (c)";
$word = "d a b b c d a b b c d";

while ($word =~ /($er)/g)
{
  I want to know how many words are there before second b
}

How can I obtain the pos of ($4)?

Thath is to say, I'd like can get :
"d a b" / "b" / "c d a b b c d" at first iteration 
there are 3 words before second "b"
and get 
"d a b b c d a b" / "b" / "c d" at second iteration
there are 8 words before "second" "b"

I haven't got more ideas :(
Have you got any idea? Thanks


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

Date: 21 Mar 2003 13:15:30 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How can I localize a $i at a expreg?
Message-Id: <b5f39i$nt8$1@mamenchi.zrz.TU-Berlin.DE>

i5513 <i5513@hotmail.com> wrote in comp.lang.perl.misc:
> Hi! I have a new problem :(
> 
> Imagine (this is only a example, i'd like it was general):
> 
> $er = "(a) (b\w*) (b\w*) (c)";
> $word = "d a b b c d a b b c d";
> 
> while ($word =~ /($er)/g)
> {
>   I want to know how many words are there before second b
> }
> 
> How can I obtain the pos of ($4)?

That would be $-[4]. (perldoc perlvar)

> Thath is to say, I'd like can get :
> "d a b" / "b" / "c d a b b c d" at first iteration 
> there are 3 words before second "b"
> and get 
> "d a b b c d a b" / "b" / "c d" at second iteration
> there are 8 words before "second" "b"

Seven, or do you count them differently?  Please take some care when
preparing example data.  Inconsistencies make it unnecessary hard
to make sense of your questions.

> I haven't got more ideas :(
> Have you got any idea? Thanks

Here is a sketch.  It could use a lot of refinement, but it should
give you an idea:

    $_ = 'd a b b c d a b b c d';

    my $i = 1;
    while ( /(b b)/g ) {
        my $n = split ' ', $`;
        print "there are $n words before the $i-th occurrence of 'b b'\n";
        $i++;
    }

Anno



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

Date: 21 Mar 2003 06:03:42 -0800
From: joey19020@aol.com (Joe Kamenar)
Subject: Re: How to use Net::FTP - FTP Client class
Message-Id: <fca4c27e.0303210603.480de921@posting.google.com>

"Josh McAdams" <jmcada@hotmail.com> wrote in message news:<KMqea.98$6Y.35595308@newssvr30.news.prodigy.com>...
> Your script was allowed to execute, so Perl must have found found Net::FTP.
> Try temporarily turning debugging on {Debug=>1} to get some diagnostic
> messages.  Also, it wouldn't hurst to permanently change your script to look
> something like:
> 
> $ftp = Net::FTP->new("ftp.fund.xxxxx.com", Debug => 0) or die("Unable to
> create ftp object");
> 
OK, I did that, but simply got the die message. I turned the debug to
1 but no messages were displayed. If I am behind a firewall, could
this be the problem?

- Joe


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

Date: Fri, 21 Mar 2003 11:27:12 GMT
From: Kevin Easton <kevin@-nospam-pcug.org.au>
Subject: Re: new Perl feature request: call into shared libs
Message-Id: <newscache$pqj3ch$ufb$1@tomato.pcug.org.au>

In comp.lang.c Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote:
> [A complimentary Cc of this posting was sent to
> Martien Verbruggen 
> <mgjv@tradingpost.com.au>], who wrote in article <slrnb7kpfs.8eh.mgjv@verbruggen.comdyn.com.au>:
>> [F'ups set away from both current groups]
> 
> Well, since I do not read c.l.c, this would be a one-way-street.
> 
>> > Given that no useful program can be written in limits of ANSI-C, I
>> > hardly see why this is relevent to the discussion at hand.
>> 
>> That, of course, is nonsensical without the qualification of what
>> _you_ mean by "useful". I have many large slabs of code, some
>> libraries
> 
> Note that I did not discuss "code", only "programs".  Of course one
> can write some very useful code in ANSI-C.  E.g., I use an equivalent of
> 
>  long addl(long a, long b) { return a+b; }
> 
> almost dayly.  ;-)
> 
>> and some programs, written in compliance with the ISO C
> 
> Did not know that this was possible. I got an impression that it does
> not allow I/O.

It does.  This is what the functions declared in the stdio.h header are
all about.  fopen(), fprintf(), fscanf(), fread(), fwrite(), fgetc(),
fputc(), fclose() et al.

Many of the standard unix utilities can be written entirely in ISO C
(things like cat, wc, gzip).

	- Kevin.



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

Date: Fri, 21 Mar 2003 11:08:24 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
To: itodd <itodd@org.itodd>
Subject: Re: perl2exe question
Message-Id: <0da849f54aa635387ab2c5b9d335a02c@news.teranews.com>

>>>>> "itodd" == itodd  <itodd@org.itodd> writes:

itodd> I'm using perl2exe to convert my perl script into an exe so I can
itodd> distribute it easily.

Please don't.  Use PAR, found in the CPAN.

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


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

Date: Fri, 21 Mar 2003 12:43:06 GMT
From: "Blnukem" <blnukem@hotmail.com>
Subject: print to file safley
Message-Id: <uNDea.158141$b8.31004270@news4.srv.hcvlny.cv.net>

Hi all

I'm working an a msg board for my site and I was just wondering if this is
acceptable (safe) way to add to the data base without the chance of loosing
any data. One of my other concerns is what if two users hit the submit ant
the same time and the @new_post is changed to the data other file any ideas?

snipped:

open (REPLY, "<data/msgboard/$FORM{'forum'}/$FORM{'file'}.dat");
my @new_post = <REPLY> ;
close(REPLY);

my $posted =
"$FORM{'file'}|FORM{'poster'}|FORM{'email'}|$date|$time|$FORM{'reply_msg'}\r
";
push( @new_post, $posted);

open (REPLY, ">data/msgboard/$FORM{'forum'}/$FORM{'file'}.dat");
flock(REPLY, 2);

print REPLY @new_post;

flock(REPLY, 8);
close(REPLY);

Thanx In Advance
Blnukem




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

Date: 21 Mar 2003 13:27:38 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: print to file safley
Message-Id: <b5f40a$a4j$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Blnukem:

> I'm working an a msg board for my site and I was just wondering if this is
> acceptable (safe) way to add to the data base without the chance of loosing
> any data. One of my other concerns is what if two users hit the submit ant
> the same time and the @new_post is changed to the data other file any ideas?
> 
> snipped:
> 
> open (REPLY, "<data/msgboard/$FORM{'forum'}/$FORM{'file'}.dat");
> my @new_post = <REPLY> ;
> close(REPLY);

It can't hurt to add a LOCK_SH to this handle. You wont corrupt data by
reading from a handle, but it might result in some incosistencies when
you read a file that is also written to in another process.

> my $posted =
> "$FORM{'file'}|FORM{'poster'}|FORM{'email'}|$date|$time|$FORM{'reply_msg'}\r
> ";
> push( @new_post, $posted);
> 
> open (REPLY, ">data/msgboard/$FORM{'forum'}/$FORM{'file'}.dat");
> flock(REPLY, 2);

Please use the symbolic names here. They are more portable:

    use Fcntl qw(:flock);
    ...
    flock REPLY, LOCK_EX;
    
> print REPLY @new_post;
> 
> flock(REPLY, 8);
> close(REPLY);

You shouldn't manually do a LOCK_UN. flock() will probably flush the
handle, but better drop it nonetheless. The close() will release the
lock for you.

Since you asked about safety: This is safe as long as you are sure that
only processes that respect advisory locks write into these files. There
could still be a program that simply opens one of the files and writes
into it. But since the above script is probably the only program working
with these files, it should be reasonably safe.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Fri, 21 Mar 2003 15:22:04 +0000 (UTC)
From: Hemant Shah <shah@typhoon.xnet.com>
Subject: Re: Problem using CGI.pm and SSL.
Message-Id: <b5fams$n2l$1@flood.xnet.com>

While stranded on information super highway Tintin wrote:
:)
:)"Hemant Shah" <shah@typhoon.xnet.com> wrote in message
:)news:b5dmfs$3ea$1@flood.xnet.com...
:)>
:)> Folks,
:)>
:)>   We have apache server installed with SSL support. When I use
:)>   https://www.mysite.com, it brings up standard apache intro page. So SSL
:)>   seems to work.
:)>
:)>   I wrote a web page using perl CGI.pm and can display it via
:)>   http://www.mysite.com/myscript.pl. When I run the same script using
:)>   https://www.mysite.com/myscript.pl I get server error displayed in the
:)>   browser. When I looked at the apache error_log, it following message
:)>
:)>    Premature end of script headers: /full/path/to/myscript.pl
:)>
:)>    What am I missing?
:)>
:)>
:)>    I have print $q->header; in my script.
:)
:)This has nothing to do with Perl, although I suspect you may have two
:)versions of the script, as it is highly unlikely that the http https
:)directory paths are the same.

  For testing purposes I soft linked https directory to http directory, so 
  the file is same.

:)
:)

-- 
Hemant Shah                           /"\  ASCII ribbon campaign
E-mail: NoJunkMailshah@xnet.com       \ /  --------------------- 
                                       X     against HTML mail
TO REPLY, REMOVE NoJunkMail           / \      and postings      
FROM MY E-MAIL ADDRESS.           
-----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
I haven't lost my mind,                Above opinions are mine only.
it's backed up on tape somewhere.      Others can have their own.


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

Date: Fri, 21 Mar 2003 15:23:30 +0000 (UTC)
From: Hemant Shah <shah@typhoon.xnet.com>
Subject: Re: Problem using CGI.pm and SSL.
Message-Id: <b5fapi$n2l$2@flood.xnet.com>

While stranded on information super highway Chris Lowth wrote:
:)Tintin wrote:
:)
:)> 
:)> "Hemant Shah" <shah@typhoon.xnet.com> wrote in message
:)> news:b5dmfs$3ea$1@flood.xnet.com...
:)>>
:)>> Folks,
:)>>
:)>>   We have apache server installed with SSL support. When I use
:)>>   https://www.mysite.com, it brings up standard apache intro page. So SSL
:)>>   seems to work.
:)>>
:)>>   I wrote a web page using perl CGI.pm and can display it via
:)>>   http://www.mysite.com/myscript.pl. When I run the same script using
:)>>   https://www.mysite.com/myscript.pl I get server error displayed in the
:)>>   browser. When I looked at the apache error_log, it following message
:)>>
:)>>    Premature end of script headers: /full/path/to/myscript.pl
:)>>
:)>>    What am I missing?
:)>>
:)>>
:)>>    I have print $q->header; in my script.
:)> 
:)> This has nothing to do with Perl, although I suspect you may have two
:)> versions of the script, as it is highly unlikely that the http https
:)> directory paths are the same.
:)
:)check the error log - if the script wrote anything to stderr, that's where 
:)you'll see the message.

  I checked error log, the Premature end of script headers is the only error
  in it.

:)
:)chris
:)-- 
:)My real address is: chris at lowth dot sea oh em
:)Author of "protector" (http://protector.sourceforge.net)
:) -- OpenSource (free) e-mail virus protection

-- 
Hemant Shah                           /"\  ASCII ribbon campaign
E-mail: NoJunkMailshah@xnet.com       \ /  --------------------- 
                                       X     against HTML mail
TO REPLY, REMOVE NoJunkMail           / \      and postings      
FROM MY E-MAIL ADDRESS.           
-----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
I haven't lost my mind,                Above opinions are mine only.
it's backed up on tape somewhere.      Others can have their own.


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

Date: Fri, 21 Mar 2003 15:42:41 +0000 (UTC)
From: Hemant Shah <shah@typhoon.xnet.com>
Subject: Re: Problem using CGI.pm and SSL.
Message-Id: <b5fbth$nem$1@flood.xnet.com>

While stranded on information super highway Hemant Shah wrote:
:)
:)Folks,
:)
:)  We have apache server installed with SSL support. When I use
:)  https://www.mysite.com, it brings up standard apache intro page. So SSL
:)  seems to work.
:)
:)  I wrote a web page using perl CGI.pm and can display it via
:)  http://www.mysite.com/myscript.pl. When I run the same script using
:)  https://www.mysite.com/myscript.pl I get server error displayed in the 
:)  browser. When I looked at the apache error_log, it following message
:)
:)   Premature end of script headers: /full/path/to/myscript.pl
:)
:)   What am I missing?
:)
:)
:)   I have print $q->header; in my script.

  The next question may not be for this news group, but when I searched 
  google groups for "Premature end of script headers", most of the hits came 
  from this news group.

  O.K. I created a simple perl script as follows:

#!/usr/local/bin/perl -w

print "Content-Type: text/html


<HTML>
<HEAD>
</HEAD>
<BODY>
<H1>This is a test <H1>
</BODY>
</HTML>

";
exit(0);


If I use http://www.mysite.com/tst.pl it displays the header "This is a test"
If I use https://www.mysite.com/tst.pl I get "Premature end of script headers".
error.

If I take the above HTML code and put it in a html file, it works with
http and https.

Did the sys admin miss something while configuring Apache or perl CGI.pm?

Thanks.


:)
:)
:)-- 
:)Hemant Shah                           /"\  ASCII ribbon campaign
:)E-mail: NoJunkMailshah@xnet.com       \ /  --------------------- 
:)                                       X     against HTML mail
:)TO REPLY, REMOVE NoJunkMail           / \      and postings      
:)FROM MY E-MAIL ADDRESS.           
:)-----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
:)I haven't lost my mind,                Above opinions are mine only.
:)it's backed up on tape somewhere.      Others can have their own.

-- 
Hemant Shah                           /"\  ASCII ribbon campaign
E-mail: NoJunkMailshah@xnet.com       \ /  --------------------- 
                                       X     against HTML mail
TO REPLY, REMOVE NoJunkMail           / \      and postings      
FROM MY E-MAIL ADDRESS.           
-----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
I haven't lost my mind,                Above opinions are mine only.
it's backed up on tape somewhere.      Others can have their own.


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

Date: Fri, 21 Mar 2003 08:23:25 -0600
From: Barry Kimelman <barryk2@SPAM-KILLER.mts.net>
Subject: Re: Problem with Getopt::Std and getopts()....
Message-Id: <MPG.18e4dc5d5c72dcc7989755@news.mts.net>

[This followup was posted to comp.lang.perl.misc]

In article <500f84f3.0303201636.7582a09f@posting.google.com>, John Smith 
(clearguy02@yahoo.com) says...
> Hi all,
> 
> Below is the interested part of my code: (script name is test.pl)
> ------------------------------------
> 
> #! C:/perl/bin/perl -w
> 
> use Getopt::Std;
> 
> getopts('1:2:3:');
> 
> if ($opt_1)
> {
> 	$count = 1;
> }
> elsif ($opt_2)
> {
> 	$count = 2;
> }
> elsif ($opt_3)
> {
> 	$count = 3;
> }
> else
> {
> 	$count = 4;
> }
> 
> --------------------------------------
> 
> Now when I run the following command at CMD,
> 
> C:\>test.pl 1
> 
> It compiles with no errors, but it is taking 4 as $count value (from
> else statement).
> 
> Similary, when I give 2 or 3 as switch arguments to test.pl, it always
> gets 4 for $count variable.
> 
> What is wrong here? I want $count =1, when I give 1 as switch and
> $count =2, when I give 2 as switch and so on.
> 
> Thanks,
> John
> 

You have several problems :

(1) Optional parameters must be preceeded by a minus sign as in
    test.pl -1

(2) When an option character is followed by a ":" in a call to getopts()
    it means that that option character requires a string value as in
    test.pl -1 string_one

-- 
---------

Barry Kimelman
Winnipeg, Manitoba, Canada
email : bkimelman@hotmail.com


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

Date: 21 Mar 2003 06:02:30 -0800
From: stephanegregoire@hotmail.com (Stephane Gregoire)
Subject: Simple regular expression question
Message-Id: <9ed209ed.0303210602.1e2d6fd7@posting.google.com>

I need to build a regular expression that matches the following
sentences:

This is a sentence with some words
-or-
This is a sentence containing some words


I want to be able to tell the regexp that you can choose the word
"with" or "containing" in the middle of the sentence.

I know I can use the OR operator(|) and put it between two regexp
like:

/^This is a sentence with some words/|/^This is a sentence containing
some words/

but is there a way to shorten the regex? Something like 
/^This is a sentence (containing|with) some words/ ?


Thanks.


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

Date: Fri, 21 Mar 2003 14:03:46 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Simple regular expression question
Message-Id: <Xns9345986CEB0FBelhber1lidotechnet@62.89.127.66>

Stephane Gregoire wrote:

> I need to build a regular expression that matches the following
> sentences:
> 
> This is a sentence with some words
> -or-
> This is a sentence containing some words
> 
> 
> I want to be able to tell the regexp that you can choose the word
> "with" or "containing" in the middle of the sentence.
> 
> I know I can use the OR operator(|) and put it between two regexp
> like:
> 
> /^This is a sentence with some words/|/^This is a sentence containing
> some words/
> 
> but is there a way to shorten the regex? Something like 
> /^This is a sentence (containing|with) some words/ ?


What happened when you tried that?


-- 
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'



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

Date: Fri, 21 Mar 2003 12:46:24 +0100
From: Michael Pradel <michael@binaervarianz.de>
Subject: socket- and pseudo-tty-problem
Message-Id: <20030321124624.4a961482.michael@binaervarianz.de>

Hi,

i am writing a kind of remote shell. Therefore a pseudo-tty is created with IO::Pty on the remote machine. In it the bash is started.
Its output should be sent to the local machine using a tcp-connection.
In the other direction, the local STDIN should be sent to the remote machine, which gives it to the pseudo-tty.

That's my approach (sorry for the length):


client.pl:
----------

#!/usr/bin/perl -w
use strict;
use IO::Socket;
use Term::ReadKey;

my ($host, $port, $handle);

$host = "localhost";
$port = 1234;

$handle = IO::Socket::INET->new (
                                  Proto    => "tcp",
                                  PeerAddr => $host,
                                  PeerPort => $port)
     or die "Could not connect to $host on Port $port: $!";

$handle->autoflush();

print STDERR "[Connected with $host:$port]\n";

defined (my $child = fork()) or die "Could not fork: $!";
my $char;
ReadMode(4);
if ($child) {
     while (defined($char = getc($handle))) {
         print STDOUT $char;
     }
} else {
     while (defined($char = getc(STDIN))) {
         print $handle $char;
     }
}


#############################


server.pl:
----------

#!/usr/bin/perl -w
use strict;
use IO::Pty;
use IO::Socket;
use POSIX 'setsid';
use Term::ReadKey;

my $server_port = "1234";
my $server_address = "localhost";

my $server = IO::Socket::INET->new(
                                    LocalPort => $server_port,
                                    LocalAddr => $server_address,
                                    Type      => SOCK_STREAM,
                                    Reuse     => 1,
                                    Listen    => 5)
     or die "Cannot be a server on $server_port: $@\n";

my $client = $server->accept();

sub do_cmd {
     my ($cmd, @args) = @_;
     my $pty = IO::Pty->new or die "Could not create pty: $!";
     defined (my $child = fork) or die "Could not fork: $!";
     return $pty if $child;

     POSIX::setsid();
     my $tty = $pty->slave;
     close $pty;

     STDIN->fdopen($tty, "<") or die "STDIN: $!";
     STDOUT->fdopen($tty, ">") or die "STDOUT: $!";
     STDERR->fdopen(\*STDOUT, ">") or die "STDERR: $!";
     close $tty;
     $| = 1;
     exec $cmd, @args;
     die "Could not execute program: $!";
}

my $bash = do_cmd('bash');
defined (my $child = fork()) or die "Could not fork: $!";
my $char;
ReadMode(4);
if ($child) {
     while (defined($char = getc($bash))) {
         print $client $char;
     }
} else {
     while (defined($zeichen = getc($client))) {
         print $bash $zeichen;
     }
}


##########################

For testing you first have to start server.pl and after that client.pl.

As you can (hopefully) see, it doesn't work really good. E.g. you have to press enter to see the first output (like user@hostname:~$) and using the mc you also have to press enter a lot of times when it shouldn't be necessary.

I am happy about any ideas how it could work correctly. Thank you.


Michael Pradel.


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

Date: 21 Mar 2003 05:48:30 -0800
From: c_campise@hotmail.com (Chris)
Subject: Using an Environment variable in a regexp match
Message-Id: <cf545555.0303210548.d188c5@posting.google.com>

I have a simple text file that contains data similar to the following
(each line is preceded with a space).

 ...
 ...
 c:\vss\diamond\firmware\i960\h\flshfile.h \
 c:\vss\diamond\firmware\i960\h\rw.h \
 c:\vss\diamond\firmware\i960\h\global.h \
 c:\vss\diamond\firmware\i960\h\ispiport.h \
 c:\ctools65/include\stdarg.h \
 c:\vss\diamond\firmware\i960\h\resvarea.h \
 c:\vss\diamond\firmware\i960\h\slednvr.h \
 c:\vss\diamond\firmware\i960\h\device.h \
 c:\vss\diamond\firmware\i960\h\devkind.h \
 ...
 ...

I'm trying to extract the 5th line : c:\ctools65/include/stdarg.h \

Thing is, I have the DOS environment variable 
        $G960BASE  defined to be = c:\ctools65

Now I figured all I would do is loop through the file like :

while( <FILE> )
{
   if ( /$G960BASE/ )
   {
      print "Found it!\n";
   }
}

But that doesn't work!  But if I strip off the leading 'c:\' from
$G960BASE, it does work :

$G960BASE =~ s/.*\\(\w+)/$1/;
while( <FILE> )
{
   if ( /$G960BASE/ )
   {
      print "Found it!\n";
   }
}

Does the parser not like the 'c:\' in the original $G960BASE?? 
Because if I
do :

while( <FILE> )
{
   if ( /c:\\ctools65/ )
   {
      print "Found it!\n";
   }
}

that also works.

Any thoughts??

Thanks in advance!

Chris


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

Date: Fri, 21 Mar 2003 15:08:06 +0100
From: Josef =?iso-8859-1?Q?M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: Using an Environment variable in a regexp match
Message-Id: <3E7B1CC6.A9200924@fujitsu-siemens.com>

Chris wrote:
> =

> I have a simple text file that contains data similar to the following
> (each line is preceded with a space).
> =

> ...
> ...
>  c:\vss\diamond\firmware\i960\h\flshfile.h \
>  c:\vss\diamond\firmware\i960\h\rw.h \
>  c:\vss\diamond\firmware\i960\h\global.h \
>  c:\vss\diamond\firmware\i960\h\ispiport.h \
>  c:\ctools65/include\stdarg.h \
>  c:\vss\diamond\firmware\i960\h\resvarea.h \
>  c:\vss\diamond\firmware\i960\h\slednvr.h \
>  c:\vss\diamond\firmware\i960\h\device.h \
>  c:\vss\diamond\firmware\i960\h\devkind.h \
> ...
> ...
> =

> I'm trying to extract the 5th line : c:\ctools65/include/stdarg.h \
> =

> Thing is, I have the DOS environment variable
>         $G960BASE  defined to be =3D c:\ctools65
> =

> Now I figured all I would do is loop through the file like :
> =

> while( <FILE> )
> {
>    if ( /$G960BASE/ )
>    {
>       print "Found it!\n";
>    }
> }
> =

> But that doesn't work!  But if I strip off the leading 'c:\' from
> $G960BASE, it does work :
> =

> $G960BASE =3D~ s/.*\\(\w+)/$1/;
> while( <FILE> )
> {
>    if ( /$G960BASE/ )
>    {
>       print "Found it!\n";
>    }
> }
> =

> Does the parser not like the 'c:\' in the original $G960BASE??
> Because if I
> do :
> =

> while( <FILE> )
> {
>    if ( /c:\\ctools65/ )
>    {
>       print "Found it!\n";
>    }
> }
> =

> that also works.
> =

> Any thoughts??

Hmmm, you have done a very thorough analysis but you fail to draw the
final conclusion:

It is indeed the \ in the pattern you are trying to match!
You need to tell the regex not to match any of the meta characters like
\:

if ( /\Q$G960BASE\E/ )

-- =

Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett


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

Date: Fri, 21 Mar 2003 14:16:17 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Using an Environment variable in a regexp match
Message-Id: <Xns93459A8C6EBFCelhber1lidotechnet@62.89.127.66>

Chris wrote:

> I have a simple text file that contains data similar to the following
> (each line is preceded with a space).
> 
> ...
> ...
>  c:\vss\diamond\firmware\i960\h\flshfile.h \
>  c:\vss\diamond\firmware\i960\h\rw.h \
>  c:\vss\diamond\firmware\i960\h\global.h \
>  c:\vss\diamond\firmware\i960\h\ispiport.h \
>  c:\ctools65/include\stdarg.h \
>  c:\vss\diamond\firmware\i960\h\resvarea.h \
>  c:\vss\diamond\firmware\i960\h\slednvr.h \
>  c:\vss\diamond\firmware\i960\h\device.h \
>  c:\vss\diamond\firmware\i960\h\devkind.h \
> ...
> ...
> 
> I'm trying to extract the 5th line : c:\ctools65/include/stdarg.h \
> 
> Thing is, I have the DOS environment variable 
>         $G960BASE  defined to be = c:\ctools65
> 
> Now I figured all I would do is loop through the file like :
> 
> while( <FILE> )
> {
>    if ( /$G960BASE/ )
>    {
>       print "Found it!\n";
>    }
> }
> 
> But that doesn't work!  But if I strip off the leading 'c:\' from
> $G960BASE, it does work :


This happens because the '\' character is special in a regex. You have to 
tell the m// operator not to treat characters such as '\' as special 
either by manually escaping them (like you did in your example) or by 
using \Q:


if ( m/\Q$G960BASE/ ) {

  print "Found it!\n";

}


For more information:


   perldoc perlretut
   perldoc perlre
   perldoc perlop


-- 
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'



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

Date: Fri, 21 Mar 2003 08:27:17 -0600
From: Barry Kimelman <barryk2@SPAM-KILLER.mts.net>
Subject: Re: Using an Environment variable in a regexp match
Message-Id: <MPG.18e4dd3cc771b72d989756@news.mts.net>

[This followup was posted to comp.lang.perl.misc]

In article <cf545555.0303210548.d188c5@posting.google.com>, Chris 
(c_campise@hotmail.com) says...
> I have a simple text file that contains data similar to the following
> (each line is preceded with a space).
> 
> ...
> ...
>  c:\vss\diamond\firmware\i960\h\flshfile.h \
>  c:\vss\diamond\firmware\i960\h\rw.h \
>  c:\vss\diamond\firmware\i960\h\global.h \
>  c:\vss\diamond\firmware\i960\h\ispiport.h \
>  c:\ctools65/include\stdarg.h \
>  c:\vss\diamond\firmware\i960\h\resvarea.h \
>  c:\vss\diamond\firmware\i960\h\slednvr.h \
>  c:\vss\diamond\firmware\i960\h\device.h \
>  c:\vss\diamond\firmware\i960\h\devkind.h \
> ...
> ...
> 
> I'm trying to extract the 5th line : c:\ctools65/include/stdarg.h \
> 
> Thing is, I have the DOS environment variable 
>         $G960BASE  defined to be = c:\ctools65
> 
> Now I figured all I would do is loop through the file like :
> 
> while( <FILE> )
> {
>    if ( /$G960BASE/ )
>    {
>       print "Found it!\n";
>    }
> }
> 
> But that doesn't work!  But if I strip off the leading 'c:\' from
> $G960BASE, it does work :
> 
> $G960BASE =~ s/.*\\(\w+)/$1/;
> while( <FILE> )
> {
>    if ( /$G960BASE/ )
>    {
>       print "Found it!\n";
>    }
> }
> 
> Does the parser not like the 'c:\' in the original $G960BASE?? 
> Because if I
> do :
> 
> while( <FILE> )
> {

Change your IF stmt to look like the following :

    if ( /${G960BASE}/ ) {
    }

-- 
---------

Barry Kimelman
Winnipeg, Manitoba, Canada
email : bkimelman@hotmail.com


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

Date: 21 Mar 2003 07:25:11 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Wanted: exetype.pl and related info
Message-Id: <3e7b2ed7@news.victoria.tc.ca>

Jürgen Exner (jurgenex@hotmail.com) wrote:
: Malcolm Dew-Jones wrote:
: > This is most frustrating since I have played around with this axact
: > issue in the past.  I'm sure it's even a faq, but which one?
: >
: > I want to touch perl.exe to convert it into a non-console program so
: > it does not display the dos window.

: If you are running ActiveState Perl just use wperl.exe instead of perl.exe.

I am and it does not have wperl.exe or exetype.pl, which is mentioned in
various posts.  In fact I also re installed an earlier version of perl I
had on hand and it also doesn't have this.  That is why I asked.

However, I have realized that last night I was doing a newsgroup search in
google instead of a regular search which is why lots of interesting but
not directly useful stuff was coming up.  I now have what I need thanks. 



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

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


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