Tony,
You simply enclose your unix commands in ''.
i.e.
#!untested
'ls -la'
tim
Timothy B Booher, Lt USAF
Research Engineer
AFRL/MNAC
101 W. Eglin Blvd.
Eglin AFB, FL 32542-6810
Telephone: 850-882-8302 ext. 3360
Fax:
Hello - I am very frustrated - after quite a while I can't get my ActivePerl
to work on anything in windows. Say I want to find the word Good and change
it to Bad in the file MyFile.asc
I try:
C:\changeIt.pl -e s/Good/Bad/ MyFile.asc
Then open MyFile.asc and nothing happens - then I try
Hello - more trouble, I just can't seem to write a program that prints an
argument it's passed:
My script contains:
#not working
print $ARGV\n;
when I run this I get:
c:\work.pl this
c:\
confused by this but also confused that I can't run anything from the
command line in windows.
Hello. I am trying to run a simple command to remove all the leading spaces
from a file and it just isn't working. No errors, just no results - still a
lot of leading spaces on each line.
%perl -pi.bak -e 's/^\s+//' bomb1.txt
any ideas?
tim
One more while I am at it . . . what is the difference between the MSI and
the AS package distribution of ActivePerl 5.6.1 on the active state
web-site? I don't know which one to download . . .
Tim
are there . . . or am I just doing something silly . . .
tim
-Original Message-
From: Brett W. McCoy [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 01, 2002 9:47 AM
To: Booher Timothy B 1stLt AFRL/MNAC
Cc: [EMAIL PROTECTED]
Subject: Re: change all files in directory
On Fri, 1 Feb 2002
I have a bunch of files in the form below and I want to go through the list
and extract only the file name. The only way I can consistently see this is
to take the next line after the ).
ahmad73 __ exist: 0
K. Ahmad and I. J. Smalley, Powder Technol. 8, 69 (1973).
Observation of particle
Hello - I just loaded ActiveState perl onto my computer today . . . while I
normally use perl on my unix machine and modify the file using chmod +x
perlFile.pl - what can I do on dos or do I have to type perl PerlFile.pl
everytime to run PerlFile?
Thanks,
Tim
Hello out there - I have learned a lot of Perl today, but I am still trying
to figure one more thing out.
How can I go through a file and extract all the text between certain
delimiters - for example I have:
Bilbo, Why I like rings Freemont Press, 1998.
Frodo, Why I don't Bridgedale Freemans,
Hello - when printing out a lot of my c++ code I go from a nice color
syntaxed environment to a plain old black and white.
If there isn't already something else out there I would like to write a Perl
script that changes all comments to green for example and preserves the tab
spacing into the
Cool. I think I have an idea - what is your question?
tim
-Original Message-
From: Anand, Pankaj [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 30, 2002 2:18 PM
To: 'Beginners (E-mail)
Subject: change the format of file.
Hi ,
I want to make a perl script which can take the input
Wow -- that is really cool. I am going to go review hashes. How crazy
compact!
thanks a lot,
Tim
-Original Message-
From: Peter Scott [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 22, 2002 9:40 AM
To: Booher Timothy B 1stLt AFRL/MNAC; '[EMAIL PROTECTED]'
Subject: Re: Count Words
Hello all.
I want to be able to take the file name in as an argument of the function,
for example:
%Extract.pl MyFile.txt
I know that I could use:
#!/usr/bin/perl
while () {
}
But how could I take two arguments from the command line:
i.e. my guess:
%Test.pl Foo Bar
#/!/usr/bin/perl
$A =
I sent this out last tuesday and no responses so far, just about 5 people
emailing me to ask if I had gotten any answers which tells me there is a lot
of interest in this question. If anyone has any knowledge in this subject
matter, please do tell the rest of us as we are eager for an answer . .
Hello all,
At our lab we constantly have emails sent out in the form:
7-15 JanTesting of Product X (POC: Joe Smith) Room 265
2 Jan Leaders Meeting (POC: John Doe)Room 121
8 Jan Review (POC: Tom) Room 30
I am trying to take these word
Is it possible to use a simple perl script to do simple unix commands.
(similar to the shell scripts)?
For example I want to run a unix command on all files in a current
directory:
Shell script (just pick dos2unix for example):
Foreach f (*.*)
Dos2unix $f
Echo $f . cleaned
Thanks,
tim
Timothy B Booher, Lt USAF, AFRL/MNAC
101 West Eglin Blvd, Suite 339
Eglin AFB FL 32542-6810
Phone: 850-882-8302 Ext. 3360 (DSN 872-)
FAX: 850-882-2201
o.k. my program finally works (thanks for the help yesterday) . . . but I am
convinced I am doing this the long way . . . I am sure there is a more
elegant solution (prob a one-liner). Any thoughts . . .
thanks,
tim
#!/usr/bin/perl -w
# This program is just to test my ability to parse
Thanks so much, but I am still confused on one point. I have:
next if $line =~ (/^\*+/)|(/^\s*$/);
and it seems to work, but you say: next if $line =~ /^(\*|\s*$)/; wouldn't
this only find one * that the line starts with.
i.e.
* foo
foo
would both be skipped, what
Why can't I do something like this? Load everything to a buffer then cycle
through the buffer?
Thanks,
tim
#!/usr/bin/perl -w
open(MYFILE,'test2.txt');
while (MYFILE) {
$buffer .= $_;
}
$lnum = 1;
while ($buffer) {
chomp;
next if /^\*+/ or /^\s*$/;
my ($field, $value) = split
: Monday, December 31, 2001 1:21 PM
To: 'Booher Timothy B 1stLt AFRL/MNAC'; [EMAIL PROTECTED]
Subject:RE: question-beginner's programmer's block
I'm not sure that I completely understand, so this may or may not help.
Anyway, I hope it does.
If I understand correctly you want to grab each
o.k. here is another one:
I still have a text file I am trying to get into a csv line, for example:
cheese olives beans carrots
So I put this into an array like:
my @headers = split /\s+/;
But now I want to print this in csv format:
I can't get your implementation to work . . .
What about s/^\s+|\s+$//g ? shouldn't it be s/(^\s+)|(\s+$)//g ?
And why the if in:
$_ = \$_\ if ( $_ =~ /[,]/ );
aren't you trying to keep that trailing comma off - I don't see where you
add the comma.
Tim
When parsing a text file - what is the best way to skip a blank line -
when I find the length I get a length of 1 (perhaps the newline). I know
that I could chomp($_) and then if(length($_) != 0) {do something} else
{next} but I feel that there should be a way to have an if($_ = $blank)
To: 'Booher Timothy B 1stLt AFRL/MNAC'; [EMAIL PROTECTED]
Subject:RE: find blank line
One way is to do this...
while ( my $line = FILE ) {
next if ( /^\s*$/ );
}
Rob
-Original Message-
From: Booher Timothy B 1stLt AFRL/MNAC
[mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 02
to it. If you decide to use the
construct while ( MYFILE )... then it better be
while( defined(MYFILE) ) {
//...
}
[sathish]
-Original Message-
From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 02, 2002 2:44 PM
To: Booher Timothy B 1stLt AFRL/MNAC
Cc: Hanson, Robert
Why is ((/^\*+/) or (/^\s*$/)) improper?
It breaks down to:
(
(/^\*+/)
or
(/^\s*$/)
)
How is this different than: next if $line =~ /^\*+/ or $line =~ /^\s*$/;
except that it is less ambiguous?
tim
Hello - I am trying to figure out how to convert an output file to a comma
separated values file.
The original file is of this form:
* foo ***
thingA: 12
thingB: 23
thingC: 21
o.k. another regex issue . . . I want a one-liner that can remove everything
after a given character: i.e.
in this case everything after ! (fortran comment):
would this work:
perl -npe 's/\!.+$//'
my thinking is that \! Is the literal character and . would count for
anything + would represent
B 1stLt AFRL/MNAC; [EMAIL PROTECTED]
Subject:Re: quick regex question
--- Booher Timothy B 1stLt AFRL/MNAC [EMAIL PROTECTED] wrote:
o.k. another regex issue . . . I want a one-liner that can remove
everything
after a given character: i.e.
in this case everything after ! (fortran
(DSN 872-)
FAX: 850-882-2201
-Original Message-
From: Peter Scott [mailto:[EMAIL PROTECTED]]
Sent: Monday, December 10, 2001 12:09 PM
To: Booher Timothy B 1stLt AFRL/MNAC; [EMAIL PROTECTED]
Subject:Re: Use perl to change File names
At 11:28 AM 12/10/01 -0600, Booher
Hello - I have been trying to use perl to change filenames this morning, and
have been having a lot of luck, but have hit a stopping point. I have
lwall's code:
#!/usr/local/bin/perl
#
# Usage: rename perlexpr [files]
($regexp = shift @ARGV) || die Usage: rename perlexpr [filenames]\n;
if
Thanks a lot - I have set up an alias to make my life easier.
I am wondering how you would use the VB equivalents of Left$ and Right$ with
perl.
For example I have 'ABCDEFGH' and I want to get the right three letters:
Right('abcdefgh',3) = 'fgh'
Left can be done with substring (x,0) I am
I am looking for a simple way to go through my text file and remove all
spaces from the ends of lines. I have a feeling that this is real easy, but
don't know what function is best: does chomp do this? Is there a feature in
emacs that does this better?
Thanks for any information . . .
Tim,
I have what seems to be a persistent problem with all files that I import
from dos into emacs. I have those control M's all over the place.
Does anyone know of a perl script to 'clean' these files?
Thanks so much,
tim
Timothy B Booher, Lt
35 matches
Mail list logo