[26611] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8723 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Dec 2 14:05:19 2005

Date: Fri, 2 Dec 2005 11: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, 2 Dec 2005     Volume: 10 Number: 8723

Today's topics:
        Exec/System call with spaces in exec path problem ... <Random@Task.be>
    Re: Exec/System call with spaces in exec path problem . <Random@Task.be>
    Re: Matching escaped delimiter chars <wadew_NOSPAM@ti.com>
    Re: Matching escaped delimiter chars <wadew_NOSPAM@ti.com>
        Perl script for scanning files <anton.vandersteen@chello.nl>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 02 Dec 2005 13:41:57 -0500
From: Random Task <Random@Task.be>
Subject: Exec/System call with spaces in exec path problem ...
Message-Id: <Tz0kf.5761$Et5.370510@news20.bellglobal.com>

Hi i am writing perl on windows ... i am having a hard time executing a 
path with spaces ... can someone help ?

my $command = "C:\\Documents and Settings\\jgdon\\My Documents\\run.exe";

system ("$command 1>C:\\JIMTEST.TXT 2>C:\\JIMTEST.TXT");

Thanks,
Jim
www.gomba.ca


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

Date: Fri, 02 Dec 2005 13:45:45 -0500
From: Random Task <Random@Task.be>
Subject: Re: Exec/System call with spaces in exec path problem ...
Message-Id: <43909659.6030601@Task.be>

Sorry here is the error message i am getting ...

'C:\Documents' is not recognized as an internal or external command,
operable program or batch file.


Jim
www.gomba.ca


Random Task wrote:
> Hi i am writing perl on windows ... i am having a hard time executing a 
> path with spaces ... can someone help ?
> 
> my $command = "C:\\Documents and Settings\\jgdon\\My Documents\\run.exe";
> 
> system ("$command 1>C:\\JIMTEST.TXT 2>C:\\JIMTEST.TXT");
> 
> Thanks,
> Jim
> www.gomba.ca


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

Date: Fri, 02 Dec 2005 11:07:20 -0600
From: Wade Whitaker <wadew_NOSPAM@ti.com>
Subject: Re: Matching escaped delimiter chars
Message-Id: <dmpv08$lpu$1@home.itg.ti.com>

Witold Rugowski wrote:
> Hi!
> I want to match with regexp substring, which is delimited by, let's say 
> ". It is trivial, but I don't know how to match escaped quotes with \. 
> OK, example will be better ;-))
> 
> Let's take string such:
> AAAAAAA "blah blah \" blah blah" BBBBBB
> 
> How to match all what is in between quotes, not counting escaped quote. 
> In this case it should match to:
> blah blah \" blah blah
> 
> How it can be done????
> 
> Best regards,
> Witold Rugowski

Try:

/"(|.*?[^\\])"/ or /("(?|.*?[^\\])")/

This says try the null case first.  i.e. ""
Then if it is not null slurp 0 characters and one more that is not a 
backslash, which you can because it is not a null case.  Then check for ".
Then try slurp 1 char and one more that is not a backslash. etc.  The Idea is 
that after checking for null first you can slurp past a backslash which will 
always put the following " in the [^\\] position so you can't stop on it.

See what a year of learning can get you.

Regards,

Wade


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

Date: Fri, 02 Dec 2005 11:18:34 -0600
From: Wade Whitaker <wadew_NOSPAM@ti.com>
Subject: Re: Matching escaped delimiter chars
Message-Id: <dmpvla$m1u$1@home.itg.ti.com>

Wade Whitaker wrote:
> Witold Rugowski wrote:
> 
>> Hi!
>> I want to match with regexp substring, which is delimited by, let's 
>> say ". It is trivial, but I don't know how to match escaped quotes 
>> with \. OK, example will be better ;-))
>>
>> Let's take string such:
>> AAAAAAA "blah blah \" blah blah" BBBBBB
>>
>> How to match all what is in between quotes, not counting escaped 
>> quote. In this case it should match to:
>> blah blah \" blah blah
>>
>> How it can be done????
>>
>> Best regards,
>> Witold Rugowski
> 
> 
> Try:
> 
> /"(|.*?[^\\])"/ or /("(?|.*?[^\\])")/
> 
> This says try the null case first.  i.e. ""
> Then if it is not null slurp 0 characters and one more that is not a 
> backslash, which you can because it is not a null case.  Then check for ".
> Then try slurp 1 char and one more that is not a backslash. etc.  The 
> Idea is that after checking for null first you can slurp past a 
> backslash which will always put the following " in the [^\\] position so 
> you can't stop on it.
> 
> See what a year of learning can get you.
> 
> Regards,
> 
> Wade
second one should have been /("(?:|.*?[^\\])")/

Thats what I get for just typing it in. :)

Regards,

Wade


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

Date: Fri, 2 Dec 2005 19:40:34 +0100
From: "Anton van der Steen" <anton.vandersteen@chello.nl>
Subject: Perl script for scanning files
Message-Id: <8008e$43909525$d4bb4dfa$30433@news.chello.nl>

Hey guys,

Here a script for searching for words or phrases in files.
The lines cna be shown with one press on the button.

I have tested this program on a text file of 2 Gb and it took 8 minutes to 
present a result scannin on the letter 'e'.

I use Perl from www.ActiveState.com .
No extra Perl Modules have to be installed.

Success and have fun with. I use it a lot.

Scoon


#!/perl/bin/perl
use Tk;

my $mw = new MainWindow; # Main Window

my $frm_name = $mw -> Frame() -> pack();
my $lab1 = $frm_name -> Label(-text=>"Phrase :") -> pack();
my $ent1 = $frm_name -> Entry(-width=>100) -> pack();

my $lab2=$frm_name->Label(-text=>"File :")->pack();
my $ent2=$frm_name->Entry(-width=>100)->pack();


my $but1 = $mw -> Button(-text=>"Count Appearance Phrase", -command 
=>\&push_button1) -> pack();

my $but2 = $mw -> Button(-text=>"Show text", -command =>\&push_button2) -> 
pack();

my $but3 = $mw -> Button(-text=>"Clear Text Area", -command 
=>\&push_button3) -> pack();

#Text Area
my $txt = $mw -> Text(-width=>130, -height=>40) -> pack();


MainLoop;

sub push_button1 {

 use Getopt::Std;

 my $name1 = $ent1 -> get();
 my $name2 = $ent2 -> get();
 #$txt -> insert('end',"Hello, $name1, $name2");
 @ARGV= ($name1, $name2);
 #print @ARGV;

 $i=0;

 my $pattern = shift @ARGV;


 foreach $file (@ARGV)
 {
 open (FILE, $file);
 while ($line = <FILE>)
 {
  if ($line =~m"$pattern")
 {
  $i++;
  last if ($opt_1);
  #print "Het woord is gevonden in het document\n";
  #print "$file: $line\n" if (!$opt_1);
  #$txt-> insert ('end', "$file, $line");

 }

 }
  #print "$file" if ($opt_1);
  print "The phrase $pattern is $i times found!!\n";


  $txt-> insert ('0.0',"The phrase $pattern is $i times found in file 
$file.");
  #$txt-> insert ('0.0', "$file, $line");
  close (FILE);
  $i=0;

 }


 sub push_button2 {

 use Getopt::Std;

 my $name1 = $ent1 -> get();
 my $name2 = $ent2 -> get();
 #$txt -> insert('end',"Hello, $name1, $name2");
 @ARGV= ($name1, $name2);
 #print @ARGV;

 $i=0;

 my $pattern = shift @ARGV;


 foreach $file (@ARGV)
 {
 open (FILE, $file);
 while ($line = <FILE>)
 {
  if ($line =~m"$pattern")
 {
  $i++;
  last if ($opt_1);
  #print "Het woord is gevonden in het document\n";
  #print "$file: $line\n" if (!$opt_1);
  #$txt-> insert ('end', "$file, $line");
  $txt-> insert ('end', "$line");
 }

 }
  #print "$file" if ($opt_1);
  #print "Het woord $pattern is $i keer gevonden\n";


  #$txt-> insert ('end',"Het woord $pattern is $i keer gevonden in bestand 
$file.");
  #$txt-> insert ('end', "$file, $line");
  close (FILE);
  $i=0;

 }

 }


  sub push_button3 {
  $txt-> delete ('0.0', 'end');


 }

 }; 




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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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