> On Jun 29, 2016, at 09:20, Uri Guttman wrote:
>
> since you are correct about modules being already there, why do you write
> your own versions of
> slurp_file and write_file? the module File::Slurp has those functions which
> are stable, fast and debugged.
Please don’t use File::Slurp. Se
Op 29-06-16 om 19:26 schreef Uri Guttman:
On 06/29/2016 01:17 PM, Eric de Hont wrote:
Op 29-06-16 om 18:20 schreef Uri Guttman:
since you are correct about modules being already there, why do you
write your own versions of
slurp_file and write_file? the module File::Slurp has those
functions w
On 06/29/2016 01:17 PM, Eric de Hont wrote:
Op 29-06-16 om 18:20 schreef Uri Guttman:
On 06/29/2016 06:03 AM, Eric de Hont wrote:
sub slurp_file {
my $file = shift;
local $/;
open my $fh, '<', $file or die "Can't open $_: $!\n";
$_ is not set anywhere. you likely meant to use $f
Op 29-06-16 om 18:20 schreef Uri Guttman:
On 06/29/2016 06:03 AM, Eric de Hont wrote:
sub slurp_file {
my $file = shift;
local $/;
open my $fh, '<', $file or die "Can't open $_: $!\n";
$_ is not set anywhere. you likely meant to use $file
O, dear. Just a bit too quick and dirty.
On 06/29/2016 06:03 AM, Eric de Hont wrote:
Op 29-06-16 om 06:35 schreef Danny Wong:
Hi Perl GURUs,
I have a json file that needs parsing.
Here is a typical string I’m searching for. I want to delete
everything but the last 2 character “],”.
],
[
"ansible",
ers@perl.org>>
Subject: Re: search and replace
Op 29-06-16 om 06:35 schreef Danny Wong:
Hi Perl GURUs,
I have a json file that needs parsing.
Here is a typical string I’m searching for. I want to delete everything but the
last 2 character “],”.
],
[
"a
Op 29-06-16 om 06:35 schreef Danny Wong:
Hi Perl GURUs,
I have a json file that needs parsing.
Here is a typical string I’m searching for. I want to delete
everything but the last 2 character “],”.
],
[
"ansible",
"2.1.0.0-1ppa~trusty",
false
],
Here is wh
Hi Danny,
Please reply to all recipients. See below for my reply.
On Wed, 29 Jun 2016 04:35:22 +
Danny Wong wrote:
> Hi Perl GURUs,
> I have a json file that needs parsing.
>
Why not use a JSON parser? See http://perl-begin.org/uses/text-parsing/ .
> Here is a typical string I’m searchin
On 03/12/2014 05:14 AM, Alex Chiang wrote:
Thanks for your reply.
I know the built-in index function, but I just can't figure out why it gives me
the answer I don't expect :D
you shouldn't expect some answer without checking the documentation.
index is well documented so you must be looking
Thanks for your reply.
I know the built-in index function, but I just can't figure out why it gives me
the answer I don't expect :D
---
Regards !
Alex Chiang
Thanks all, and thanks Nathan for your detailed explanation.
Now I know the list got flattened before passing into subroutine.
Cheers.
---
Regards !
Alex Chiang
First: @_[0] is "legit", in that it is a 1 element slice of the array
@_.. but most likely is not at all what you really want.
When an array is passed as a parameter to a subroutine in perl, it is
"unrolled". In other words, each element of the array is passed as a
single parameter. In ord
Is @_[0] even legit?
On 12 Mar 2014, at 04:58, Alex Chiang wrote:
> Hi there,
>
> I got a wired bug with the following perl script:
>
> 35 # return non-negative value if particular character is in string array
> 36 # otherwise, return -1
>
> sub is_in_string {
> 38 # @s: string array, $c
On Tue, Mar 11, 2014 at 11:58 PM, Alex Chiang wrote:
> sub is_in_string {
> 38 # @s: string array, $c: character
> 39 # passing array into sub
> 40 my @s = @_[0]; my $c = $_[1];
> 44 my @ar = qw(t d s);
> 45 my $c = "d";
> 46 my $res = &is_in_string( @ar, $c);
This is a good example of how
Mornin' --
Take a look at the index() function, unless you have a real need to
reinvent one of the Perl builtin functions. (i.e. your home work
assignment from your tescher demands it.)
B
On Tue, Mar 11, 2014 at 9:58 PM, Alex Chiang wrote:
> Hi there,
>
> I got a wired bug with the following
Hi Omega,
On Sat, 1 Feb 2014 11:36:20 -0500
Omega -1911 <1911...@gmail.com> wrote:
> Good advice Shlomi. Thank you again. I should have caught that with fresh
> eyes!
You're welcome! ☺
Regards,
Shlomi Fish
--
-
Shlomi Fis
On Sat, Feb 1, 2014 at 4:57 AM, Shlomi Fish wrote:
> Hi Omega,
>
> On Sat, 1 Feb 2014 03:40:01 -0500
> Omega -1911 <1911...@gmail.com> wrote:
>
> > Hello List: I am trying to go through a folder of php scripts to add a
> > database prefix to lines that have a select statement. Since the database
Hi Omega,
On Sat, 1 Feb 2014 03:40:01 -0500
Omega -1911 <1911...@gmail.com> wrote:
> Hello List: I am trying to go through a folder of php scripts to add a
> database prefix to lines that have a select statement. Since the database
> prefix will differ, I am simply trying to add:
>
> ".$database
What error?
(Sent from iPhone, so please accept my apologies in advance for any spelling or
grammatical errors.)
> On Feb 1, 2014, at 2:40 AM, Omega -1911 <1911...@gmail.com> wrote:
>
> Hello List: I am trying to go through a folder of php scripts to add a
> database prefix to lines that have
Hi Irfan Sayed,
Please check my comments below.
On 8/18/12, Irfan Sayed wrote:
> hi,
>
> i have string like this :
> $a = '$(workspace)\convergence\trunk';
>
> i need to replace $(workspace) with 'c:\p4\abc'
> i wrote regex like this :
>
> $a =~ s/$\(workspace)/c:\\p4\\abc/;
> however, the stri
thanks a lot
regards
irfan
From: Shawn H Corey
To: beginners@perl.org
Cc: Irfan Sayed
Sent: Saturday, August 18, 2012 6:50 AM
Subject: Re: search and replace
On Fri, 17 Aug 2012 18:02:23 -0700 (PDT)
Irfan Sayed wrote:
> i have string like this :
&
On Fri, 17 Aug 2012 18:02:23 -0700 (PDT)
Irfan Sayed wrote:
> i have string like this :
> $a = '$(workspace)\convergence\trunk';
>
> i need to replace $(workspace) with 'c:\p4\abc'
> i wrote regex like this :
>
> $a =~ s/$\(workspace)/c:\\p4\\abc/;
The easy way is to quote it:
$a =~ s/\Q$
On Thu, 16 Aug 2012 10:55:03 +0200
Gergely Buday wrote:
> Notice that in order to put a literal backslash into a perl string,
> you should escape it. In your original program, you have put a \b, a
> bell character into the string.
Actually, "\b" is the backspace character. The bell or alarm char
Awesome
thanks all for reply . got it
regards
irfan
From: midhun
To: Rob Coops
Cc: Gergely Buday ; Irfan Sayed ;
"beginners@perl.org"
Sent: Thursday, August 16, 2012 2:41 PM
Subject: Re: search and replace
The issue is
$cs_project = &qu
The issue is
$cs_project = "C:\build.txt"; ## In Double quotes takes the string as
C:build.txt.since its an escape character
That's the reason why Rob suggested to put the string in Single quotes.
Both Gergely and Rob are right.
Cheers,
Midhun
On Thu, Aug 16, 2012 at 2:29 PM, Rob Coops wrote
On Thu, Aug 16, 2012 at 10:55 AM, Gergely Buday wrote:
> Here is the correct version:
>
> #!/usr/bin/perl
>
> $csproj_text = "C:\\build.txt";
>
> $csproj_text =~ s/\\//g;
> print "$csproj_text\n";
>
> Notice that in order to put a literal backslash into a perl string,
> you should escape it.
Here is the correct version:
#!/usr/bin/perl
$csproj_text = "C:\\build.txt";
$csproj_text =~ s/\\//g;
print "$csproj_text\n";
Notice that in order to put a literal backslash into a perl string,
you should escape it. In your original program, you have put a \b, a
bell character into the stri
Wang, Li wrote:
Dear list members
Hello,
I am a very beginner of perl programming.
Welcome to the Perl beginners mailing list.
I am trying to write a script to search all scalers of one array
(geneIDFile) in another file (annotationFile). If it is found and
matched, output the whole lin
On Jun 21, 2012, at 4:47 PM, Wang, Li wrote:
> Dear list members
>
> I am a very beginner of perl programming.
> I am trying to write a script to search all scalers of one array (geneIDFile)
> in another file (annotationFile). If it is found and matched, output the
> whole line of the annotat
On 12-02-21 11:37 AM, Adams Paul wrote:
Sent from my LG phone
Is this is what is called a bum dial?
--
Just my 0.0002 million dollars worth,
Shawn
Programming is as much about organization and communication
as it is about coding.
It's Mutual Aid, not fierce competition, that's the dom
Sent from my LG phone
"John W. Krahn" wrote:
>Chris Stinemetz wrote:
>> I am trying ot find a way to use an array as a reference to remove
>> lines from a file.
>> The array @keyFields has the elements "rcsm and cdmno". My objective
>> is to remove any line from the input that matches the regex
Thank you everyone that replied.
Your suggestions helped me with finding a solution.
Take care,
Chris
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
Chris Stinemetz wrote:
I am trying ot find a way to use an array as a reference to remove
lines from a file.
The array @keyFields has the elements "rcsm and cdmno". My objective
is to remove any line from the input that matches the regex /rcsm\d/
and cdmno\d/.
AND means matching BOTH in the sam
> -Original Message-
> From: Chris Stinemetz [mailto:chrisstinem...@gmail.com]
> Sent: Monday, February 20, 2012 3:51 PM
> To: beginners@perl.org
> Subject: Re: search and replace with an array
>
> Looks like I was able to figure it out with the below:
>
>
>-Original Message-
>From: Chris Stinemetz [mailto:chrisstinem...@gmail.com]
>Sent: Monday, February 20, 2012 13:51
>To: beginners@perl.org
>Subject: Re: search and replace with an array
>
>Looks like I was able to figure it out with the below:
>
>But how do I
Looks like I was able to figure it out with the below:
But how do I remove all the blank lines?
Output:
cdmno=1
rdnt_cdmno=1
cdmno=2
rcsm=801
rcsm=801
rcsm=802
#!/usr/bin/perl
use warnings;
use strict;
my $file = "nonKeys.txt";
my $newFile = "cleanKeys.txt";
my @keyFields
hi,
thank you for your solution which works perfect for the data i have
given.
the trouble is: my data looks a little more complex as I have lots of
accented characters so with your code I need to specify each of those
characters in the tr/// part. I reckon the other way around would be
more useful
Frank Müller wrote:
dear all,
Hello,
i want to make some search and replace within a string where I can
define a set of characters, especially parenthesis, brackets etc.,
which are to be ignored.
For example, I have the following string:
sdjfh sdf sjkdfh sdkjfh sdjkf f[o]o(bar) hsdkjfh sdkl
From: Noah Garrett Wallach
> okay a step further - is there a way to make the following a one liner?
>
> (my $filename_cmd = $cmd[-1]) =~ s/\|//g;
> $filename_cmd =~ s/\s+/\./g;
> $filename_cmd =~ s/save.*//g;
There's no point in making it a one liner. Plus anything may be
writen
> "NGW" == Noah Garrett Wallach writes:
NGW> what is the cleanest way to search a multi-line single scalar variable
NGW> full of configuration information. I want match on specific criteria
NGW> and then save a portion of the matched information in a hash or hashes
NGW> variable.
> "NGW" == Noah Garrett Wallach writes:
NGW> Jim Gibson wrote:
>> At 7:22 PM -0700 9/2/09, Noah Garrett Wallach wrote:
>>> Hi there,
>>>
>>> what is the way to collapse this search/replace to one line?
>>>
>>> my $filename_cmd = $cmd[-1];
>>> my $filename_cmd =~ s/\s/\./;
Jim Gibson wrote:
At 7:22 PM -0700 9/2/09, Noah Garrett Wallach wrote:
Hi there,
what is the way to collapse this search/replace to one line?
my $filename_cmd = $cmd[-1];
my $filename_cmd =~ s/\s/\./;
(my $filename_cmd = $cmd[-1]) =~ s/\s/\./;
thanks,
okay a step further -
At 7:22 PM -0700 9/2/09, Noah Garrett Wallach wrote:
Hi there,
what is the way to collapse this search/replace to one line?
my $filename_cmd = $cmd[-1];
my $filename_cmd =~ s/\s/\./;
(my $filename_cmd = $cmd[-1]) =~ s/\s/\./;
--
Jim Gibson
jimsgib...@gmail.com
--
To unsubscribe
> I m working on Net::LDAP module in perl to manage ldap database,
>
> but i dont know how can i get all the uid's and names of the groups,
> i have try the Search function of Net::LDAP but still not able to get it,
>
Alpesh, take a look on http://www.linuxjournal.com/article/7086
Is your LDAP di
On Nov 12, 6:55 am, [EMAIL PROTECTED] (Rob Dixon) wrote:
> [EMAIL PROTECTED] wrote:
> > Hi I am new to this group and to Perl.
>
> > I am having trouble with searching and replacing a pattern in a file
> > and then
> > copying to a new file. I am trying to write an interactive program to
> > do th
On Wed, 2008-11-12 at 13:00 -0800, [EMAIL PROTECTED] wrote:
> I think I understand most of your suggestions but I'm not very clear
> in this line:
>
> print $out $_;# in the while loop below.
>
> while (<$in>) {
> s/\Q$search/$replace/g;
> print $out $_;
>
>
> What is the $_ variable?
Th
On Nov 12, 6:55 am, [EMAIL PROTECTED] (Rob Dixon) wrote:
> [EMAIL PROTECTED] wrote:
> > Hi I am new to this group and to Perl.
>
> > I am having trouble with searching and replacing a pattern in a file
> > and then
> > copying to a new file. I am trying to write an interactive program to
> > do th
On Tue, Nov 11, 2008 at 9:52 AM, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> Hi I am new to this group and to Perl.
>
[snip]
> #!/usr/bin/perl -w
> use strict;
>
If you really have warnings enabled, you should be seeing lots of
warnings like "bareword found where operator expected" pointing a
On Tue, Nov 11, 2008 at 09:52, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> Hi I am new to this group and to Perl.
>
> I am having trouble with searching and replacing a pattern in a file
> and then
> copying to a new file. I am trying to write an interactive program to
> do this
> where I input
[EMAIL PROTECTED] wrote:
> Hi I am new to this group and to Perl.
>
> I am having trouble with searching and replacing a pattern in a file
> and then
> copying to a new file. I am trying to write an interactive program to
> do this
> where I input the file name for the search and replace and the
Irfan J Sayed (isayed) wrote:
> Hi All,
>
> I want to search whether specific value/data is there are not in Array.
> For example lets say i have array as follows.
>
> @test = (1,2,3,4,5);
> $rel1=4;
>
> I need to check whether 4 is there or not. I have one method as follows.
>
> if (grep /
Hi Irfan,
Irfan J Sayed (isayed) wrote:
if (grep /^$rel1$/, @test)
{
print "Result = $rel1\n";
}
but i think this is not the proper way because if i use grep then it
would be a platform dependant.
The grep you are using is not the grep provided by the operating system,
but the
On Aug 13, 4:44 pm, [EMAIL PROTECTED] wrote:
> Hi,
>
> I am trying to search & replace a string in a file using the below
> perl command on unix.
>
> perl -pi -e 's/OLD/NEW/g' repltest.txt
>
> But I want the above command to display what lines were replaced. Is
> it possible using some switch opti
On Aug 13, 4:44 pm, [EMAIL PROTECTED] wrote:
> Hi,
>
> I am trying to search & replace a string in a file using the below
> perl command on unix.
>
> perl -pi -e 's/OLD/NEW/g' repltest.txt
>
> But I want the above command to display what lines were replaced. Is
> it possible using some switch opti
On Aug 13, 1:44 pm, [EMAIL PROTECTED] wrote:
> Hi,
>
> I am trying to search & replace a string in a file using the below
> perl command on unix.
>
> perl -pi -e 's/OLD/NEW/g' repltest.txt
>
> But I want the above command to display what lines were replaced. Is
> it possible using some switch opti
El Thursday 14 August 2008 17:30:43 [EMAIL PROTECTED] va escriure:
> Xavier,
>
> Thanks for the tip but can you help me by pasting the code too? It
> might take 2 mins for you but I will have to fiddle with it longer :(
>
> Regards.
>
> On Aug 14, 6:02 am, [EMAIL PROTECTED] (Xavier Mas) wrote:
> >
Xavier,
Thanks for the tip but can you help me by pasting the code too? It
might take 2 mins for you but I will have to fiddle with it longer :(
Regards.
On Aug 14, 6:02 am, [EMAIL PROTECTED] (Xavier Mas) wrote:
> El Wednesday 13 August 2008 22:44:11 [EMAIL PROTECTED] va escriure:
>
> > Hi,
>
>
El Wednesday 13 August 2008 22:44:11 [EMAIL PROTECTED] va escriure:
> Hi,
>
> I am trying to search & replace a string in a file using the below
> perl command on unix.
>
> perl -pi -e 's/OLD/NEW/g' repltest.txt
>
> But I want the above command to display what lines were replaced. Is
> it possible
On Wed, 2008-08-13 at 13:44 -0700, [EMAIL PROTECTED] wrote:
> Hi,
>
> I am trying to search & replace a string in a file using the below
> perl command on unix.
>
> perl -pi -e 's/OLD/NEW/g' repltest.txt
>
> But I want the above command to display what lines were replaced. Is
> it possible usin
> > > mv $TMP_FILE $FILE_NAME
> >
> > Be careful, the 192.168.0.0 can also match a line with 192.168.010 in
> > it. See also the -F option of grep.
> >
> > --
> > Affijn, Ruud
> >
> > "Gewoon is een tijger."
> >
>
> Good point, bad example (although natural continuation of previous
> discuss
On Fri, 2007-10-19 at 01:55 +0200, Dr.Ruud wrote:
> yitzle schreef:
>
> > If you are on a Linux machine, it might just be easier
> > to use the grep command with a shell script.
> >
> > FILE_NAME="./log"
> > TMP_FILE="./tmp"
> > IP_TO_REMOVE="192.168.0.0|192.168.0.255"
> >
> > COUNT=`grep $IP_TO_R
yitzle schreef:
> If you are on a Linux machine, it might just be easier
> to use the grep command with a shell script.
>
> FILE_NAME="./log"
> TMP_FILE="./tmp"
> IP_TO_REMOVE="192.168.0.0|192.168.0.255"
>
> COUNT=`grep $IP_TO_REMOVE $FILE_NAME | wc -l`
> echo "The IPs occur $COUNT times"
>
> grep
FreeBSD, and that's actually what I ended up doing basically using
cat and grep -v.
Thanks,
On Oct 17, 2007, at 9:14 PM, yitzle wrote:
If you are on a Linux machine, it might just be easier to use the grep
command with a shell script.
FILE_NAME="./log"
TMP_FILE="./tmp"
IP_TO_REMOVE="192.16
If you are on a Linux machine, it might just be easier to use the grep
command with a shell script.
FILE_NAME="./log"
TMP_FILE="./tmp"
IP_TO_REMOVE="192.168.0.0|192.168.0.255"
COUNT=`grep $IP_TO_REMOVE $FILE_NAME | wc -l`
echo "The IPs occur $COUNT times"
grep -v $IP_TO_REMOVE $FILE_NAME > $TMP_
On 10/18/07, Phillip Gonzalez <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm trying to search a .txt file for matching ip addresses. I then want to
> delete those ip >addresses.
>
The better way for finding an IP from given list is to use Net::IP
module from CPAN rather than using regex I think.
--
T
They have all been helpful.
Thanks,
On Oct 17, 2007, at 4:40 PM, Matthew Whipple wrote:
Matthew Whipple wrote:
yitzle wrote:
Take a look at the grep function
http://perldoc.perl.org/functions/grep.html
Also of potential use is the qr// quote operator:
http://perldoc.perl.org/perlop.html#
Matthew Whipple wrote:
> yitzle wrote:
>
>> Take a look at the grep function
>> http://perldoc.perl.org/functions/grep.html
>>
>> Also of potential use is the qr// quote operator:
>> http://perldoc.perl.org/perlop.html#Regexp-Quote-Like-Operators
>>
>> This lets you do:
>>
>> my $ip_search = qr/
yitzle wrote:
> Take a look at the grep function
> http://perldoc.perl.org/functions/grep.html
>
> Also of potential use is the qr// quote operator:
> http://perldoc.perl.org/perlop.html#Regexp-Quote-Like-Operators
>
> This lets you do:
>
> my $ip_search = qr/$ip_string/;
> my @lines_with_ip = grep
Take a look at the grep function
http://perldoc.perl.org/functions/grep.html
Also of potential use is the qr// quote operator:
http://perldoc.perl.org/perlop.html#Regexp-Quote-Like-Operators
This lets you do:
my $ip_search = qr/$ip_string/;
my @lines_with_ip = grep /$ip_search/, @raw_data; # or
Thanks very much - this works
Jon
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
jrpfinch wrote:
I would like to execute the following regex on a file:
s/(\$Revision:\s+)(\d+\.\d+)(\s+\$.+use constant VERSION\s+=> ")(.+?)
(")/$1$2$3Revision $2$5/gs
I am doing this in bash as follows:
REGEX='s/(\$Revision:\s+)(\d+\.\d+)(\s+\$.+use constant VERSION\s+=> ")
(.+?)(")/$1$2$3Rev
Chas Owens wrote:
Eh, writing "join version" was confusing. I am surprised no one
called me on the real error: @LIST and @list aren't the same variable.
That's because most people who read the mailing list do not run code as
presented.
You will find that most of the arguments here are about
On 7/14/07, Rob Dixon <[EMAIL PROTECTED]> wrote:
Chas Owens wrote:
>
> On 7/14/07, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote:
>>
>> Chas Owens wrote:
>>>
>>> By the way, an easier way to write the join version is
>>>
>>> print map { "$_\n" } @list;
>>>
>>
>> BTW, that's not the same. Join ins
Rob Dixon wrote:
Chas Owens wrote:
On 7/14/07, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote:
Chas Owens wrote:
By the way, an easier way to write the join version is
print map { "$_\n" } @list;
BTW, that's not the same. Join inserts its string between each element,
map (in this case)
Chas Owens wrote:
On 7/14/07, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote:
Chas Owens wrote:
By the way, an easier way to write the join version is
print map { "$_\n" } @list;
BTW, that's not the same. Join inserts its string between each element,
map (in this case) appends it to the e
Chas Owens wrote:
The code I am referring to is
print +(join "\n", @LIST), "\n" ;
Which does the same thing as
print map { "$_\n" } @list;
The only difference between them is if $, is set.
True, in this case they are.
But the way you stated your preferences implied they are the same, or a
On 7/14/07, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote:
Chas Owens wrote:
> By the way, an easier way to write the join version is
>
> print map { "$_\n" } @list;
>
BTW, that's not the same. Join inserts its string between each element,
map (in this case) appends it to the end. A subtle diff
Chas Owens wrote:
By the way, an easier way to write the join version is
print map { "$_\n" } @list;
BTW, that's not the same. Join inserts its string between each element,
map (in this case) appends it to the end. A subtle difference that may
lead to confusion and errors.
--
Just my 0
On 7/14/07, Dr.Ruud <[EMAIL PROTECTED]> wrote:
snip
> Never use multiple print statements when you can use just one.
In general that's true, but because of the "Never" I have to object. :)
Sometimes multiple print statements look like only one, I am thinking of
the "print for LIST" construct.
Joseph L. Casale wrote:
OK, I saw your example and noted it. I intended on using next time as I know
there will be:)
But now I am convinced, as the lack of error checking in my script worries me.
I'll take yours and fit it in!
I do need to read up on what you're doing as I am not clear on its
"Chas Owens" schreef:
> print $out
> "X$x Y$y\n",
> "Z[$z+DPad]\n",
> "M98PDRILL.SUBL1\n",
> "G90\n",
> "G00 Z[CPlane]\n";
>
> Never use multiple print statements when you can use just one.
In general that's true, but because of the "Never" I have to ob
Joseph L. Casale wrote:
From: Rob Dixon
Joseph L. Casale wrote:
One of these scripts has a loop like this:
for my $line (@lines){
my $line2 = $line;
$line =~ s/(\S+)\s+(\S+)\s+(\S+)/X$1 Y$2/;
print FILEOUT $line;
$line2 =~ s/(\S+)\s+(\S+)\s+(\S+)/Z[$3+DPad]/;
print FILEOUT $line2;
prin
On 7/13/07, Joseph L. Casale <[EMAIL PROTECTED]> wrote:
snip
open (FILEIN, "< $ARGV[0]") or die $!;
my @lines = ;
snip
In list context the <> operatot returns all lines, but in scalar
context it returns on line at a time. This can be used with a while
loop to walk over the file in pieces (a ne
$!;
So using your syntax escapes me at the moment:)
Thanks!
jlc
-Original Message-
From: Rob Dixon [mailto:[EMAIL PROTECTED]
Sent: Friday, July 13, 2007 7:09 PM
To: beginners@perl.org
Cc: Joseph L. Casale
Subject: Re: Search and Replace
Joseph L. Casale wrote:
> One of these scripts has a loop
Joseph L. Casale wrote:
One of these scripts has a loop like this:
for my $line (@lines){
my $line2 = $line;
$line =~ s/(\S+)\s+(\S+)\s+(\S+)/X$1 Y$2/;
print FILEOUT $line;
$line2 =~ s/(\S+)\s+(\S+)\s+(\S+)/Z[$3+DPad]/;
print FILEOUT $line2;
print FILEOUT "M98PDRILL.SUBL1\n";
print FILEOU
Joseph L. Casale wrote:
One of these scripts has a loop like this:
for my $line (@lines){
my $line2 = $line;
$line =~ s/(\S+)\s+(\S+)\s+(\S+)/X$1 Y$2/;
print FILEOUT $line;
$line2 =~ s/(\S+)\s+(\S+)\s+(\S+)/Z[$3+DPad]/;
print FILEOUT $line2;
print FILEOUT "M98PDRILL.SUBL1\n";
print FILEOU
On 7/13/07, Joseph L. Casale <[EMAIL PROTECTED]> wrote:
What would be a wise way of trapping a condition such as the line read and
passed
into the loop is not 3 sets of numbers and if so, skip?
Use the 'next' operator. It's documented in perlfunc.
Hope this helps!
--Tom Phoenix
Stonehenge P
One of these scripts has a loop like this:
for my $line (@lines){
my $line2 = $line;
$line =~ s/(\S+)\s+(\S+)\s+(\S+)/X$1 Y$2/;
print FILEOUT $line;
$line2 =~ s/(\S+)\s+(\S+)\s+(\S+)/Z[$3+DPad]/;
print FILEOUT $line2;
print FILEOUT "M98PDRILL.SUBL1\n";
print FILEOUT "G90\n";
print FILEOUT
On 7/12/07, Joseph L. Casale <[EMAIL PROTECTED]> wrote:
Hi All,
How can I make this expression:
$line =~ s/(\S+)\s+(\S+)\s+(\S+)/X$1 Y$2 Z$3/
Add some numerical value to the Z$3 part, so if $3 was 3.14, I want it to be
Z4.14 for example by adding 1 to it.
Use the e option to turn the replace
Ok Rob,
I'll have a look.
Thanks!
jlc
-Original Message-
From: Rob Dixon [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 12, 2007 1:22 PM
To: beginners@perl.org
Cc: Joseph L. Casale
Subject: Re: Search and Replace
Joseph L. Casale wrote:
>
> How can I make this expression:
&
Joseph L. Casale wrote:
How can I make this expression:
$line =~ s/(\S+)\s+(\S+)\s+(\S+)/X$1 Y$2 Z$3/
Add some numerical value to the Z$3 part, so if $3
was 3.14, I want it to be Z4.14 for example by adding 1 to it.
May I reply amending my original solution to your problem, which seems to me
: Wednesday, July 11, 2007 4:52 PM
To: Joseph L. Casale
Cc: beginners@perl.org
Subject: Re: Search and Replace
Joseph L. Casale wrote:
> Paul,
> Reading the perlre doc I am starting to understand this line:
> $line =~ s/(\S+)\s+(\S+)\s+(\S+)/X$1 Y$2 Z$3/;
>
> I have a few questions.
&
Joseph L. Casale wrote:
Paul,
Reading the perlre doc I am starting to understand this line:
$line =~ s/(\S+)\s+(\S+)\s+(\S+)/X$1 Y$2 Z$3/;
I have a few questions.
1. What is the tilde for?
From `perldoc perlop`:
Binding Operators
Binary "=~" binds a scalar expression to a patte
hanks!
jlc
-Original Message-
From: Paul Lalli [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 11, 2007 12:30 PM
To: beginners@perl.org
Subject: Re: Search and Replace
On Jul 11, 1:50 pm, [EMAIL PROTECTED] (Joseph L. Casale)
wrote:
> Hi,
> Know that I am learning perl, I am expected t
Joseph L. Casale wrote:
Hi,
Know that I am learning perl, I am expected to use it at work :)
Problem is I am still to green for the current problem I have. The data is
always left justified and has a space between each value.
I have a text file of about ~500 lines like this:
-11.67326 23.95923
PM
To: beginners@perl.org
Subject: Re: Search and Replace
On Jul 11, 1:50 pm, [EMAIL PROTECTED] (Joseph L. Casale)
wrote:
> Hi,
> Know that I am learning perl, I am expected to use it at work :)
> Problem is I am still to green for the current problem I have. The data is
> always left
On Jul 11, 1:50 pm, [EMAIL PROTECTED] (Joseph L. Casale)
wrote:
> Hi,
> Know that I am learning perl, I am expected to use it at work :)
> Problem is I am still to green for the current problem I have. The data is
> always left justified and has a space between each value.
>
> I have a text file o
From: Joseph L. Casale [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 11, 2007 1:51 PM
To: beginners@perl.org
Subject: Search and Replace
Hi,
Know that I am learning perl, I am expected to use it at work :)
Problem is I am still to green for the current problem I have. The data
is always left ju
--- Jeff Pang <[EMAIL PROTECTED]> wrote:
>
> >I want to read some information about AUTOLOAD in
> POD.
>
> Hi,
>
> Got these pieces from Schwartz's book and hope it
> helps.
Hi Jeff,
Thank you very much,
Li
__
Do You Yahoo!?
Tired of spam? Ya
--- "John W. Krahn" <[EMAIL PROTECTED]> wrote:
> > I want to read some information about AUTOLOAD in
> POD.
> > But I get nothing when I type "perldoc -f/-q
> > AUTOLOAD".
> > Any comments?
>
> perlsub has an "Autoloading" section:
>
> perldoc perlsub
>
> Also the "AUTOLOAD: Proxy Methods" s
1 - 100 of 303 matches
Mail list logo