Hi,
Yes, they are the same.
I like to use $_ only when the data comes in $_ naturally. Like in a for loop:
for (qw< abc >)
{
if ( !/\w+\d+/ )
{
print "not matched";
}
}
Otherwise, I have to write $_, then I prefer to name the variable something
descriptive instead.
Makes the code
Hello list,
are these statements the same in perl?
$ perl -le '$_="abc";if (!/\w+\d+/){print "not matched"}'
not matched
$ perl -le '$_="abc";if ($_ !~ /\w+\d+/){print "not matched"}'
not matched
or which is the better one?
Thanks.
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
Fo
On Sat, 2 Jun 2018 07:30:48 -0500
p...@reason.net wrote:
> Very useful advice, Shlomi; thanks!
>
you are welcome! Also see http://perl-begin.org/tutorials/bad-elements/ , which
I also maintain.
>
> > On Jun 2, 2018, at 3:57 AM, Shlomi Fish wrote:
> >
> > On Fri, 1 Jun 2018 15:54:55 -0500
> >
ith it like this you can at least
figure out what it is doing, but maybe not why. The
manpages will probably be needed to answer that.
Please let us know what you find out.
Mike
On 6/1/2018 3:55 PM, beginners-digest-h...@perl.org wrote:
Subject:
difficulty with matching
From:
Rick T
Date:
Very useful advice, Shlomi; thanks!
> On Jun 2, 2018, at 3:57 AM, Shlomi Fish wrote:
>
> On Fri, 1 Jun 2018 15:54:55 -0500
> Rick T mailto:p...@reason.net>> wrote:
>
>> This is a newbie question, I’m sure. But I get perplexed easily!
>>
>> The follow code segment expects to receive a $student
On Fri, 1 Jun 2018 15:54:55 -0500
Rick T wrote:
> This is a newbie question, I’m sure. But I get perplexed easily!
>
> The follow code segment expects to receive a $student_id consisting of a
> surname followed by a hyphen followed by a number. The die is for testing
> what I’m doing.
>
> If I
> If I feed it 'jones-123’ it dies with ‘jones, - , 123’ as I expected.
But if I feed it ‘jones-‘ omitting the number on the end, it dies with no
matches at all (or blanks): ‘ , , ‘ and I cannot figure out why it does not
die with ‘jones, -, ' and would appreciate an explanation. Many thanks!
[0-9]+ means at least one digit in range 0-9.
If there is no digit, the string won't match.
You want [0-9]* instead.
--Octavian
- Original Message -
From: Rick T
To: Perl Beginners
Sent: Friday, June 01, 2018 11:54 PM
Subject: difficulty with matching
This is a n
This is a newbie question, I’m sure. But I get perplexed easily!
The follow code segment expects to receive a $student_id consisting of a
surname followed by a hyphen followed by a number. The die is for testing what
I’m doing.
If I feed it 'jones-123’ it dies with ‘jones, - , 123’ as I expect
On Sat, 05 Nov 2016 21:30:12 +
Aaron Wells wrote:
> True. It could get hairy. Unicode is a pretty vast landscape, and I
> think if you only want ASCII word characters to count as things that
> could be in a filename, your original [A-Za-z0-9_] is your best bet.
> Thanks to the others for thei
From: Aaron Wells
True. It could get hairy. Unicode is a pretty vast landscape, and I think if
you only want ASCII word characters to count as things that could be in a
filename, your original [A-Za-z0-9_] is your best bet. Thanks to the others for
their comments. As Ken says: there are pro
ly ASCII, use the /a modifer,
eg, /\w+/a
>From perlre:
/a
is the same as "/u", except that "\d", "\s", "\w", and the Posix
character classes are restricted to matching in the ASCII range only.
That is, with this modifier, "\d&
ed m/[A-Za-z0-9\_]+(?!\.)/ but I still get both strings
> > captured.
>
> Alternatively, if your use case allows it, it might be more viable to
> use negative matching.
>
> $file !~ /[.]/ and print "$file has no extension"
>
> There's probably a reason w
se case allows it, it might be more viable to
use negative matching.
$file !~ /[.]/ and print "$file has no extension"
There's probably a reason why you're not doing this already, but can't
tell from the context.
NB: Clearly defining what an "extension&quo
Hi Jovan,
On Sat, Nov 5, 2016 at 1:14 PM, Jovan Trujillo
wrote:
> Hi All,
> I thought I could use a simple regex to match files like this:
>
> 1207003PE_GM_09TNPLM2
>
> and ignore files with extensions like this:
>
> 1207003PE_GM_09TNPLM2.csv
>
> I originally though m/[A-Za-z0-9\_]+/ wou
Hi Aaron,
In perlre I read that \w
"
- \w[3] Match a "word" character (alphanumeric plus "_", plus
- other connector punctuation
chars plus Unicode
- marks)
"
So since I didn't know what these 'other' con
*predefined
On Sat, Nov 5, 2016, 10:27 AM Aaron Wells wrote:
> Hi Jovan. \w is a presidents character classes that is equivalent to
> [A-Za-z0-9_], so this works also:
> m/^\w+$/
>
> On Sat, Nov 5, 2016, 10:24 AM Jovan Trujillo
> wrote:
>
> Ah, I figured it out.
> m/^[A-Za-z0-9_]+$/ works beca
Hi Jovan. \w is a presidents character classes that is equivalent to
[A-Za-z0-9_], so this works also:
m/^\w+$/
On Sat, Nov 5, 2016, 10:24 AM Jovan Trujillo
wrote:
> Ah, I figured it out.
> m/^[A-Za-z0-9_]+$/ works because it will only match if the entire string
> follows the pattern. Thanks!
>
Ah, I figured it out.
m/^[A-Za-z0-9_]+$/ works because it will only match if the entire string
follows the pattern. Thanks!
On Sat, Nov 5, 2016 at 10:14 AM, Jovan Trujillo
wrote:
> Hi All,
> I thought I could use a simple regex to match files like this:
>
> 1207003PE_GM_09TNPLM2
>
> and
Hi All,
I thought I could use a simple regex to match files like this:
1207003PE_GM_09TNPLM2
and ignore files with extensions like this:
1207003PE_GM_09TNPLM2.csv
I originally though m/[A-Za-z0-9\_]+/ would work, but it captures both
strings.
So then I tried m/[A-Za-z0-9\_]+(?!\.)/ but
That makes sense, thanks.
On 05/13/2014 01:46 PM, Shlomi Fish wrote:
Hi Mike,
please reply to the list.
On Tue, 13 May 2014 12:49:42 -0500
Mike Dunaway wrote:
Actually, can you tell me what's going on here:
my %words_lookup = (map { $_ => 1 } @words_to_look_for);
I build a hash called %w
Hi Mike,
please reply to the list.
On Tue, 13 May 2014 12:49:42 -0500
Mike Dunaway wrote:
> Actually, can you tell me what's going on here:
>
> my %words_lookup = (map { $_ => 1 } @words_to_look_for);
>
I build a hash called %words_lookup whose keys are the entries of
@words_to_look_for and
t of words and
increase a counter every time a word in the given list appears in what
I'm matching against, what might a possible solution look like for that?
The only thing I could think of is a nasty mess of a ton of for loops
restarted until you get to the end of the user provided list w
in what
> I'm matching against, what might a possible solution look like for that?
> The only thing I could think of is a nasty mess of a ton of for loops
> restarted until you get to the end of the user provided list which may
> end up being very slow depending on the size of the li
Hello everyone. Let's say I have a user provide @list of words and I
want to match each words against a file or a another @list of words and
increase a counter every time a word in the given list appears in what
I'm matching against, what might a possible solution look like for that?
On Feb 28, 2014, at 9:13 PM, Bill McCormick wrote:
> Can somebody help me understand this? Given this loop, and the logged output
> following ...
>
> my $found;
> for( @$products ) {;
> $found = $$_ =~ m|$project|;
> $dump = Data::Dumper->Dump([$_, $project, $$_, $found]);
> $logger->trace(
On 2014-03-01 06:13, Bill McCormick wrote:
$found = $$_ =~ m|$project|;
Alternative:
$found = ( index( $project, $$_ ) >= 0 );
or rather use:
$found = $project =~ /\b\Q$$_\E\b/;
Always add escaping and anchors, or you will match the unmatchable.
--
Ruud
--
To unsubscribe, e-mail: be
On 3/1/2014 6:19 AM, Paul Johnson wrote:
On Fri, Feb 28, 2014 at 11:13:05PM -0600, Bill McCormick wrote:
Can somebody help me understand this? Given this loop, and the
logged output following ...
my $found;
for( @$products ) {;
$found = $$_ =~ m|$project|;
I think you might have meant:
On Fri, Feb 28, 2014 at 11:13:05PM -0600, Bill McCormick wrote:
> Can somebody help me understand this? Given this loop, and the
> logged output following ...
>
> my $found;
> for( @$products ) {;
> $found = $$_ =~ m|$project|;
I think you might have meant:
$found = $project =~ m|$$_|;
>
Can somebody help me understand this? Given this loop, and the logged
output following ...
my $found;
for( @$products ) {;
$found = $$_ =~ m|$project|;
$dump = Data::Dumper->Dump([$_, $project, $$_, $found]);
$logger->trace(qq(dump=$dump));
}
I can't explain why $found is not true on the
On Sun, Feb 10, 2013 at 8:05 AM, Chris Stinemetz
wrote:
> To take this a step further.
>
> How would you go about creating a hash to sum up all the values in group
> $3 utilizing the flip/flop operator and print the results of the key and
> value with the key being group $2?
>
>
This is what I cam
To take this a step further.
How would you go about creating a hash to sum up all the values in group $3
utilizing the flip/flop operator and print the results of the key and value
with the key being group $2?
Thank you,
Chris
while( ) {
if ( /0x3\|68\|/ .. /^#END/ ) {
print if /\|
Thank you everyone for you help.
-Chris
On Sat, Feb 9, 2013 at 5:15 PM, Uri Guttman wrote:
> On 02/09/2013 03:59 PM, John W. Krahn wrote:
>
>
>> Let's re-factor that down to its essence:
>>
>> while ( ) {
>> print if /\|68\|/;
>> print "$1\t$2\t$3\n" if /(\|\d)\|(\d+)\|(\d+)/;
>>
On 02/09/2013 03:59 PM, John W. Krahn wrote:
Let's re-factor that down to its essence:
while ( ) {
print if /\|68\|/;
print "$1\t$2\t$3\n" if /(\|\d)\|(\d+)\|(\d+)/;
}
Now we need to add something that starts at |68| and stops at #END:
while ( ) {
if ( /\|68\|/ .. /^#EN
Hi,
On Sat, Feb 9, 2013 at 6:06 PM, Chris Stinemetz wrote:
> I would like to only work with the data that has a line with |68| in it
>
Does it mean even, that |68| can be anyway in the your data before any of
the #END is reached?
If yes, then I think you have been given a good solution. If not,
Chris Stinemetz wrote:
I would like to only work with the data that has a line with |68| in it
print that line and then print each subsequent lines in that match
/\|7\|\d+\|\d+/ until #END is reached and then repeat for the rest of the
input data.
Below is what I have attempted.
Thanks in adva
On Sat, 9 Feb 2013 11:06:46 -0600
Chris Stinemetz wrote:
> I would like to only work with the data that has a line with |68| in
> it print that line and then print each subsequent lines in that match
> /\|7\|\d+\|\d+/ until #END is reached and then repeat for the rest of
> the input data.
OTTOMH
I would like to only work with the data that has a line with |68| in it
print that line and then print each subsequent lines in that match
/\|7\|\d+\|\d+/ until #END is reached and then repeat for the rest of the
input data.
Below is what I have attempted.
Thanks in advance.
Chris
#!/usr/bin/p
On 2012-12-28 21:32, twle...@reagan.com wrote:
I hope this is a simple fix. I want to check the beginning characters of items in a
hash, and compare that to a scalar variable. I do not need for the entire value to
match; just the first couple of characters. Here is a simple example of what I
"timothy adigun" wrote in message
news:CAEWzkh6mZohVJn__LRL60AGoqbHkmTPyn=JM=cewcmmftpj...@mail.gmail.com...
Hello Chris,
Please see my comment below.
On Fri, Dec 28, 2012 at 10:24 PM, Chris Charley
wrote:
[snip]
I only answered the question using a for loop. Am not the one who
origi
matching to hash
Chris Charley"" wrote in message news
>Tim wrote in message news:1356726727.215915...@webmail.reagan.com...
>>I hope this is a simple fix. I want to check the beginning characters
>>of items in a hash, and compare that to a scalar variable.
>>I do n
@perl.org
Subject: Re: Pattern matching to hash
Hi,
my $prefix_search_list = '03S,04S';
my @prefix_array = split /\,/,$prefix_search_list;
my %prefix_hash = map {$_ => 1 } @prefix_array;
#compare 05S to 03S and 04S
my $input_field = "05S885858"; #should not match
Chris Charley"" wrote in message news
Tim wrote in message news:1356726727.215915...@webmail.reagan.com...
I hope this is a simple fix. I want to check the beginning characters of
items in a hash, and compare that to a scalar variable.
I do not need for the entire value to match; just the
Hello Chris,
Please see my comment below.
On Fri, Dec 28, 2012 at 10:24 PM, Chris Charley wrote:
>
>
> Tim wrote in message news:1356726727.215915216@**webmail.reagan.com...
>
> I hope this is a simple fix. I want to check the beginning characters of
>> items in a hash, and compare that to a s
Tim wrote in message news:1356726727.215915...@webmail.reagan.com...
I hope this is a simple fix. I want to check the beginning characters of
items in a hash, and compare that to a scalar variable.
I do not need for the entire value to match; just the first couple of
characters.
Tim
my $p
Hi,
> my $prefix_search_list = '03S,04S';
> my @prefix_array = split /\,/,$prefix_search_list;
> my %prefix_hash = map {$_ => 1 } @prefix_array;
>
> #compare 05S to 03S and 04S
> my $input_field = "05S885858"; #should not match
>
1. using stricts and warnings pragma, shows clearly that there i
I hope this is a simple fix. I want to check the beginning characters of items
in a hash, and compare that to a scalar variable. I do not need for the entire
value to match; just the first couple of characters. Here is a simple example
of what I want, but it does not work. Both "if" statemen
"foo=$foo\n";
print "bar=$bar\n";
print "baz=$baz\n";
sub parse_sequence {
my ($sequence) = @_;
# We don't want the leading > character.
$sequence =~ s/^>//;
my @parts = split /\|/, $sequence;
# We're interested in the first two fields.
Alright, thanks for your answers! I think I know what my mistake was: although
I realised that * means 0 or more I thought that it would prefer to match as
often as possible - but it seems that the matching stops as soon as the regex
is successful, that's why.
Thanks again.
nt "ENSG0112365 ENST0230122"
>
> without the sequence. Originally I had .* before the ([ACGT]) so I figured
> it's greedy and will eat the sequence away. ? makes it nongreedy, doesn't
> it? Still doesn't work.
>
Greed here don't mean eating, its h
112365 ENST0230122"
>
> without the sequence. Originally I had .* before the ([ACGT]) so I figured
> it's greedy and will eat the sequence away. ? makes it nongreedy, doesn't it?
> Still doesn't work.
You are not realizing that [AGCT]* means "zero or more charac
say
for sure what is going on (though we can speculate; see below).
Note that you should be using the strict and warnings pragmas
(see below). The lack of 'my' here suggests that you probably
aren't.
But when I do
$string =~ /[ACGT]/;
it matches only the last letter, i.e. &q
hen I do
>
> $string =~ /[ACGT]/;
>
> it matches only the last letter, i.e. "G". Why doesn't it start
> at the beginning?
It isn't matching the last letter. You are probably making the
wrong assumption. This is common when you're having trouble with
code. A
On Mon, Oct 1, 2012 at 5:15 PM, Florian Huber wrote:
>
> My confusion was complete when I tried
>
> $string =~ /[ACGT]{5}/;
>
> now it matches 5 letters, but this time from the beginning, i.e.: ACGAC.
>I'm trying to extract a DNA sequence out of a larger string, i.e. the string
>is of the follow
$string,
that should be 'A'. Can you show us a minimal program that demonstrates
matching the 'G' at the end of the string? We need to see the whole program to
explain something so inexplicable.
>
> But it gets even better, I figured that adding the greedy * should help:
Dear all,
I'm trying to extract a DNA sequence out of a larger string, i.e. the
string is of the following structure:
$string = "/NOTNEEDED/*ACGACGGGTTCAAGGCAG*/NOTNEEDED/"
But when I do
$string =~ /[ACGT]/;
it matches only the last letter, i.e. "G". Why doesn't it start at the
beginning?
On 2012-08-20 00:18, John W. Krahn wrote:
print map exists $stud{ $_ } ? "$_ = $stud{ $_ }\n" : (), @names;
A map using a ternary with (), is like a grep:
print "$_ = $stud{ $_ }\n" for grep exists $stud{ $_ }, @names;
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For
Hi Andy,
On 8/20/12, Andy Bach wrote:
> On Sun, Aug 19, 2012 at 4:48 PM, timothy adigun <2teezp...@gmail.com>
> wrote:
>> foreach my $match_value ( sort keys %stud ) {
>> print $match_value, "=", $stud{$match_value},
>> $/ if $match_value ~~ @names;
>> }
>
> "smart match" is a Perl
Hi,
> Hi Tim,
>
> Thanks, i tried to run the code, but get the error as below. Any thing i am
> missing line 17.
What version of Perl are you using?
For smart matching to work you must have Perl 5.10.1 Up (the 5.10.0
version behaved differently).
> syntax error at ./match2.p
The "smart match" operator (~~) was introduced in Perl 5.10. If you are using a
Perl earlier than that, you will get a syntax error.
See
perldoc perl5100delta
perldoc perlsyn
and search for "Smart".
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: b
On Sun, Aug 19, 2012 at 4:48 PM, timothy adigun <2teezp...@gmail.com> wrote:
> foreach my $match_value ( sort keys %stud ) {
> print $match_value, "=", $stud{$match_value},
> $/ if $match_value ~~ @names;
> }
"smart match" is a Perl 6 (though it probably back ported to a Perl 5
modul
Thanks John, worked as a treat. Appreciate it.
On Sun, Aug 19, 2012 at 11:18 PM, John W. Krahn wrote:
> jet speed wrote:
>
>> Hi All,
>>
>
> Hello,
>
>
> Is there a way to find matching array elements from hash.
>>
>> ex:
>>
>> @n
On Sun, Aug 19, 2012 at 10:48 PM, timothy adigun <2teezp...@gmail.com>wrote:
> Hi,
>
> Please, Check my comments below.
>
> On 8/19/12, jet speed wrote:
> > Hi All,
> >
> > Is there a way to find matching array elements from hash.
> >
> > ex:
jet speed wrote:
Hi All,
Hello,
Is there a way to find matching array elements from hash.
ex:
@names = ( abc. def. ghi, jky; );
%stud = (
" abc" =>" 34",
"nba" =>"99",
"def" =>"24",
"ghi"=> "33&quo
Hi,
Please, Check my comments below.
On 8/19/12, jet speed wrote:
> Hi All,
>
> Is there a way to find matching array elements from hash.
>
> ex:
>
> @names = ( abc. def. ghi, jky; );
The above should be @names=("abc","def","ghi",&qu
Hi All,
Is there a way to find matching array elements from hash.
ex:
@names = ( abc. def. ghi, jky; );
%stud = (
" abc" =>" 34",
"nba" =>"99",
"def" =>"24",
"ghi"=> "33");
How can i go through
Christian wrote:
Hi,
Hello,
is there easy way to capture more than one matching and print this
out?
In the example below the first matching is suppressed.
cat file | perl -nle '/p2=(.+)(?=&p3)/&& /p13=(.+)(?=&p14)/&&
print $. . ";" . $1 .
Hi,
is there easy way to capture more than one matching and print this
out?
In the example below the first matching is suppressed.
cat file | perl -nle '/p2=(.+)(?=&p3)/ && /p13=(.+)(?=&p14)/ &&
print $. . ";" . $1 . ";". $2'
Thank
following patter matching logic but it does not get me the 1st
number (2552) .
@devs = $output =~ m/New symdev:\s*([0-9A-Fa-f]{4})/gis;
print $output,"\n";
print "Devices>>>> @devs<<<<<<<<<
get those numbers like 2552 , 2553 .
>
> I am applying following patter matching logic but it does not get me the 1st
> number (2552) .
>
> @devs = $output =~ m/New symdev:\s*([0-9A-Fa-f]{4})/gis;
> print $output,"\n";
> pri
OMMITDone.
New symdev: 2552
New symdev: 2553
Terminating the configuration change session..Done." ;
I need to get those numbers like 2552 , 2553 .
I am applying following patter matching logic but it does not get m
ey occur in two unique formats throughout the whole document (which
should match \w- and -\w- ).
Thomas
Van: Brian Fraser [frase...@gmail.com]
Verzonden: donderdag 29 september 2011 16:59
Aan: John Delacour
CC: beginners@perl.org
Onderwerp: Re: Matching G
On Thu, Oct 6, 2011 at 03:10, Shlomi Fish wrote:
> Furthermore, I think you can only put when inside given and not arbitrary
> code,
> and that "when()" operates on the datum that was given to given().
I don't think there's any restriction on what code can be inside the
'given' block -- at least
Hi Chris,
I think you will need to work on your code to make it better or maybe this
is just a dirty codes for practice. If not, there are some stuff you may
have to weed out...some of which Shlomi Fish mentioned.
However, to make your code work as you suppose, please check this little
addition a
On Wed, 5 Oct 2011 23:44:21 -0500
Chris Stinemetz wrote:
> trying to learn smart matching in an exercise.
>
> Why does this program output "odd" when I input an even number?
>
A few comments on your code.
> Thank you,
>
> Chris
>
> #!/usr/bin/perl
>
trying to learn smart matching in an exercise.
Why does this program output "odd" when I input an even number?
Thank you,
Chris
#!/usr/bin/perl
use warnings;
use strict;
use 5.010;
say "Checking the number <$ARGV[0]>";
my $favorite = 62;
given( $ARGV[0] ) {
At 17:29 -0300 29/9/11, Brian Fraser wrote:
On Thu, Sep 29, 2011 at 4:03 PM, John Delacour wrote:
Nitpick: Why the upper-case charset name?
Uppercase is UTF-8-strict, while lowercase is the lax version that
perl uses internally. Unless you are passing data from one perl
program to anothe
On Thu, Sep 29, 2011 at 4:03 PM, John Delacour wrote:
>
>
Nitpick: Why the upper-case charset name?
>
Uppercase is UTF-8-strict, while lowercase is the lax version that perl uses
internally. Unless you are passing data from one perl program to another,
and you are using illegal-UTF8-but-legal-UT
At 11:59 -0300 29/9/11, Brian Fraser wrote:
On Thu, Sep 29, 2011 at 10:58 AM, John Delacour
wrote:
use encoding 'utf-8';
Nitpick: Please don't use this, as encoding is broken. use utf8; and
use open qw< :std :encoding(UTF-8) >; should make do for a
replacement.
Nitpick: Why the upper-c
there's a bit of a difference in
case-insensitive matching (i.e. using /i) -- newer versions of Perl do full
casefolding (so \N{GREEK CAPITAL LETTER ALPHA WITH PSILI AND PROSGEGRAMMENI}
matches \N{GREEK SMALL LETTER ALPHA WITH PSILI}\N{GREEK SMALL LETTER IOTA}),
whereas older versions do
At 11:42 + 29/9/11, Hamann, T.D. (Thomas) wrote:
I need to write a regex that matches any single Greek letter
followed by a hyphen in a UTF-8 text file that is otherwise in
English.
How can I match the Greek alphabet (lower and upper case)?
#!/usr/local/bin/perl
use strict;
use utf8;
us
Hi,
I need to write a regex that matches any single Greek letter followed by a
hyphen in a UTF-8 text file that is otherwise in English.
How can I match the Greek alphabet (lower and upper case)?
Thanks,
Thomas
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands
On 11-09-27 05:30 PM, Chris Stinemetz wrote:
Trying to match the what is contained in $what 3 consecutive times.
But I am getting the followoing error:
Use of uninitialized value $_ in pattern match (m//) at ./ex9-1.pl line 7.
The program:
#!/usr/bin/perl
use warnings;
use strict;
my $what
Trying to match the what is contained in $what 3 consecutive times.
But I am getting the followoing error:
Use of uninitialized value $_ in pattern match (m//) at ./ex9-1.pl line 7.
The program:
#!/usr/bin/perl
use warnings;
use strict;
my $what = 'fred|barney';
if (/($what){3}/) {
print $wha
On Apr 9, 1:04 pm, alanhag...@alanhaggai.org (Alan Haggai Alavi)
wrote:
> > ...
> > #!usr/bin/perl
>
> For increased portability, use the shebang #!/usr/bin/env perl
>
Hm, portable only in limited situations, risky,
and always slower.
From:
http://www.webmasterkb.com/Uwe/Forum.aspx/perl/3968/
Mariano Loza Coll wrote:
Hello everyone,
Hello,
Here's what I need to do: I need to take each of the words in one
List1, search for their presence (or not) in a second List2 and make a
new list with all the words in both. These are lists of gene names,
which can often include numbers and symb
Hello Mariano,
use List::MoreUtils qw( any each_array );
I was experimenting and forgot to take off `each_array` from the import
list. `each_array` is not used in the alternative solution and is hence
not required.
Regards,
Alan Haggai Alavi.
--
The difference makes the difference
--
To uns
Hello Mariano,
I realize that there may be a number of ways to do what I need to do
(most of them better, I bet), and I'd love to learn about them. But
now I'm mostly curious about why grep// cannot "see" words with
parentheses in either (or both lists). I suspect the trick may be
somehow escapi
Hello everyone,
Here's what I need to do: I need to take each of the words in one
List1, search for their presence (or not) in a second List2 and make a
new list with all the words in both. These are lists of gene names,
which can often include numbers and symbols in addition to letters.
The very
19.01.2011 0:43, Brian Fraser пишет:
The smart match is no longer commutative - That was removed after 5.10.1, I
think.
http://www.learning-perl.com/?p=32
http://perldoc.perl.org/perlsyn.html#Smart-matching-in-detail
Brian.
Thank you!
--
To unsubscribe, e-mail: beginners-unsubscr
The smart match is no longer commutative - That was removed after 5.10.1, I
think.
http://www.learning-perl.com/?p=32
http://perldoc.perl.org/perlsyn.html#Smart-matching-in-detail
Brian.
19.01.2011 0:09, Uri Guttman пишет:
but why don't you just call exists on the hash key? there is no win to
using smart matching for that. it is included for consistancy but it
isn't needed for hash keys.
I just want to understand how does it work :)
--
To unsubscribe, e-mail:
>>>>> "VDB" == Vladimir D Belousov writes:
VDB> I'm trying to check whether the given key exists in the hash.
smart matching is powerful and cool but why don't you just call exists
on the hash key? there is no win to using smart matching for that. it is
I'm trying to check whether the given key exists in the hash.
The simple example:
use feature ':5.10';
my %a = (a => 1, b => 2);
say %a ~~ 'a' ? 'YES' : 'NO';# says NO -- why?
say %a ~~ 'c' ? 'YES' : 'NO';# says NO
say 'a' ~~ %a ? 'YES' : 'NO';# says YES
say 'c' ~~ %a ? 'YES' : 'NO';
From: "Uri Guttman"
"AM" == Alexey Mishustin writes:
AM> I used brackets not for storing but for combining in order to use the
AM> combined patterns in alternation.
the point is parens (the correct term. brackets are []) is they will
grab the match inside them and store it in $1 and friend
1/18/2011, "Uri Guttman" вы писали:
>> "AM" == Alexey Mishustin writes:
>
> AM> 1/18/2011, "Uri Guttman" вы писали:
>
> >>> "AM" == Alexey Mishustin writes:
> >>
> AM> I used brackets not for storing but for combining in order to use the
> AM> combined patterns in altern
> "AM" == Alexey Mishustin writes:
AM> 1/18/2011, "Uri Guttman" вы писали:
>>> "AM" == Alexey Mishustin writes:
>>
AM> I used brackets not for storing but for combining in order to use the
AM> combined patterns in alternation.
>>
>> the point is parens
>> (the corre
> "AM" == Alexey Mishustin writes:
AM> 1/18/2011, "Alexey Mishustin" вы писали:
>> I meant
>>
>> (imgres)
>>
>> OR
>>
>> (images)
>>
>> OR
>>
>> (products)
AM> Uri wrote the correct alternation for that:
AM> (imgres|images|products)
AM> So, I should wri
1/18/2011, "Uri Guttman" вы писали:
>> "AM" == Alexey Mishustin writes:
>
> AM> I used brackets not for storing but for combining in order to use the
> AM> combined patterns in alternation.
>
>the point is parens
>(the correct term. brackets are [])
Eh... Useful correction.
And what is
1/18/2011, "Uri Guttman" вы писали:
>> "AM" == Alexey Mishustin writes:
> AM> /(www.){0,1}(google\.).*\/(imgres)|(images)|(products)\?{0,1}/
> >>
> >> {0,1} is just ? by itself.
>
> AM> Yes, I know. But I like the {a,b} syntax more :) It's more uniform than
> AM> ?,+,* etc.
>
>it is
1 - 100 of 1511 matches
Mail list logo