C.DeRykus wrote:
If you're permitted a one-liner:
perl -pi.bak -e '$c=s/Dood\/Dude/ if !$c++' file
$ perl -c -pi.bak -e '$c=s/Dood\/Dude/ if !$c++'
Substitution replacement not terminated at -e line 1.
John
--
Any intelligent fool can make things bigger and
more complex... It takes a t
On Aug 21, 4:33 am, xecro...@yahoo.com (Ron Weidner) wrote:
> Recently, I was asked to find the first occurrence of a word in a text file
> and replace it with an alternate word. This was my solution. As a new Perl
> programmer, I feel like this solution was too C like and not enough Perl
> li
>> "Bryan" == Bryan R Harris writes:
>
> Bryan> How can I use the "safe" 3-argument open and still be able to read off
> a
> Bryan> pipe?
>
> You don't. 2-arg open has to be good for something.
>
> And 2-arg open is perfectly safe if the second arg is a literal:
>
> open OTHER, "<-" o
On 11-08-22 07:37 PM, Randal L. Schwartz wrote:
"anant" == anant mittal writes:
anant> $ln[$i]=;
I'd swear that lowercase "stdin" was deprecated already, but I can't
find any record of it in the deltas, and it still works in 5.12 (I don't
have 5.14 compiled here).
In any case, you should s
> "Bryan" == Bryan R Harris writes:
Bryan> How can I use the "safe" 3-argument open and still be able to read off a
Bryan> pipe?
You don't. 2-arg open has to be good for something.
And 2-arg open is perfectly safe if the second arg is a literal:
open OTHER, "<-" or die;
open my $handl
> "anant" == anant mittal writes:
anant> $ln[$i]=;
I'd swear that lowercase "stdin" was deprecated already, but I can't
find any record of it in the deltas, and it still works in 5.12 (I don't
have 5.14 compiled here).
In any case, you should shift to the proper STDIN, as everyone else's
a
> "John" == "John W Krahn" writes:
John> ?Dood? && s/Dood/Dude/;
Deprecated in 5.14. Replace with m?Dood? and you're good though.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technica
Danny Wong (dannwong) wrote:
Hi All,
Hello,
I'm moving from perl version 5.8 to 5.12. In 5.8 code, I use the
dbmopen function to read a perl db, but that function doesn't seem to
work with version 5.12. any ideas if the function name changed or I need
to use something else? Thanks.
Hi All,
I'm moving from perl version 5.8 to 5.12. In 5.8 code, I use the
dbmopen function to read a perl db, but that function doesn't seem to
work with version 5.12. any ideas if the function name changed or I need
to use something else? Thanks.
--
To unsubscribe, e-mail: beginners-unsubs
Hi Rob ,
Sorry my mistake didn't see that.
Thanxs
if ($found eq $search) {
#!/usr/bin/perl
> use strict;
> use warnings;
>
> my @arr=qw(fry ring apple law);
> print "Enter the string you are searching for:";
> chomp(my $search=); # you may have to check, if input is not string
>
I don't u
How can I do a 3-argument open on STDIN? This doesn't work because the
3-argument open won't open STDIN when you tell it to open "-".
**
@files = ("-");
for (@files) {
print reverse readfile($_);
}
sub readfile {
open(my $fh,"<",$_[0]) or die "$me
On 11-08-22 09:19 AM, Uri Guttman wrote:
the comment was still off as he seems to
imply data that isn't a string. eof isn't data.
It's meta-data. :)
--
Just my 0.0002 million dollars worth,
Shawn
Confusion is the first step of understanding.
Programming is as much about organization
> "SHC" == Shawn H Corey writes:
SHC> On 11-08-22 08:23 AM, Uri Guttman wrote:
>> it can only be a string as it comes from stdin. what else do you think
>> it could be?
SHC> 1. The empty string (not really a string)
it is a string that also called the null string. and it is hard to
On 11-08-22 08:23 AM, Uri Guttman wrote:
it can only be a string as it comes from stdin. what else do you think
it could be?
1. The empty string (not really a string)
2. eof( *STDIN );
--
Just my 0.0002 million dollars worth,
Shawn
Confusion is the first step of understanding.
Prog
> "ta" == timothy adigun <2teezp...@gmail.com> writes:
ta> Hi Rob,
ta> my @arr=qw(fry ring apple law);
ta> print "Enter the string you are searching for:";
ta> chomp(my $search=); # you may have to check, if input is not string
>>> I don't understand your comment. The input from std
On 11-08-22 02:25 AM, anant mittal wrote:
Hi!
I want to search whether a scalar '$a' contains any one of value of an array
'@arr'.
How it may be done?
as its not correct : print "found" if $a =~ /@arr/;
First of all, don't use $a or $b as a variable name. `sort` uses them
and although `perl`
Hi Rob,
my @arr=qw(fry ring apple law);
print "Enter the string you are searching for:";
chomp(my $search=); # you may have to check, if input is not string
>>I don't understand your comment. The input from stdin has to be a
>>string - it cannot be anything else.
the input from stdin could be
Hi Rob,
my @arr=qw(fry ring apple law);
print "Enter the string you are searching for:";
chomp(my $search=); # you may have to check, if input is not string
>>I don't understand your comment. The input from stdin has to be a
>>string - it cannot be anything else.
the input from stdin could be a
On 11-08-22 05:03 AM, Shlomi Fish wrote:
It's a good idea to always use "last LABEL;" instead of "last;" (as well as
"next LABEL;" etc. in case more loops are added in between.
Good idea but try to choose meaningful names. Also, the else clause is
not needed.
[CODE]
use strict;
use warnings
On 22/08/2011 12:03, AKINLEYE wrote:
Hi anant
On Mon, Aug 22, 2011 at 8:42 AM, timothy adigun<2teezp...@gmail.com> wrote:
Hi Anant,
I want to search whether a scalar '$a' contains any one of value of an
array
'@arr'.
How it may be done?
as its not correct : print "found" if $a =~ /@arr/;
On 22/08/2011 08:42, timothy adigun wrote:
Hi Anant,
I want to search whether a scalar '$a' contains any one of value of an
array
'@arr'.
How it may be done?
as its not correct : print "found" if $a =~ /@arr/;
#!/usr/bin/perl
use strict;
use warnings;
my @arr=qw(fry ring apple law);
pr
Hi anant
On Mon, Aug 22, 2011 at 8:42 AM, timothy adigun <2teezp...@gmail.com> wrote:
> Hi Anant,
>
> >>I want to search whether a scalar '$a' contains any one of value of an
> array
> >>'@arr'.
> >>How it may be done?
> >>as its not correct : print "found" if $a =~ /@arr/;
>
> #!/usr/bin/perl
>
Hi Alan,
On Mon, 22 Aug 2011 14:43:48 +0530
Alan Haggai Alavi wrote:
> Hello Shlomi,
>
> > It's a good idea to always use "last LABEL;" instead of "last;" (as well as
> > "next LABEL;" etc. in case more loops are added in between.
> > ⋮
> > http://perl-begin.org/tutorials/bad-elements/#flow-stm
Hello Shlomi,
> It's a good idea to always use "last LABEL;" instead of "last;" (as well as
> "next LABEL;" etc. in case more loops are added in between.
> ⋮
> http://perl-begin.org/tutorials/bad-elements/#flow-stmts-without-labels
Now I understand why it is always good to label loops that use `l
Hi Alan,
On Mon, 22 Aug 2011 13:10:05 +0530
Alan Haggai Alavi wrote:
> Hello Anant,
>
> > i want to input some numbers via in while loop.And loop should be
> > broken if any nonnumeric character is entered.So how it can be checked.
> >
> >
> >
Hi Anant,
One more query:-
> HOW TO REMOVE ANY ELEMENT FROM AN ARRAY.
> I mean if i have allocated till arr[5]. Now I want to remove the value
> arr[4] and arr[5]. So how it can be done so that $#arr would tell 3.
>
#!/usr/bin/perl -l
use strict;
use warnings;
my @arr=qw( home father son sun mot
Hi Anant,
>>I want to search whether a scalar '$a' contains any one of value of an
array
>>'@arr'.
>>How it may be done?
>>as its not correct : print "found" if $a =~ /@arr/;
#!/usr/bin/perl
use strict;
use warnings;
my @arr=qw(fry ring apple law);
print "Enter the string you are searching for
Hello Anant,
> i want to input some numbers via in while loop.And loop should be
> broken if any nonnumeric character is entered.So how it can be checked.
>
>
> .
> my @ln;
> my $i=0;
> print"Give line numbers you want to put into array.\n";
> whi
Hello Anant,
Please read:
perldoc -q 'certain element is contained in a list or array'
or
http://bit.ly/o9uKat
Regards,
Alan Haggai Alavi.
--
The difference makes the difference.
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.o
29 matches
Mail list logo