The use function happens at compile time and must take a bareword, but it
is functionally equivalent to
BEGIN { require Module; Module->import( LIST ); }
And the require function allows you to pass a string, but be aware there
are lots of differences in behavior when passing a string
d all goes well. However,
> I want to know if / how I can use a string variable in the 'use' clause.
>
> In PHP I have a simple system of turning on/off debugging and version
> control. Any file *1.html is development version. I then have
>
> $DEBUG=(preg_match('/1.htm
I've written my first re-usable modules in Perl, and all goes well.
However, I want to know if / how I can use a string variable in the
'use' clause.
In PHP I have a simple system of turning on/off debugging and version
control. Any file *1.html is development version. I then have
$DEBUG
to some improvements and have shown that, while
somewhat inconclusive, there is no other way to do it in perl because
the data type I would need does not exist in perl. That will have to
suffice.
perl doesn't have data typing as such. a scalar can hold an integer, a
float or a string. the string
nt to use something like
> >>>>
> >>>>
> >>>> my $binary_data = `curl -k "https://www.example.com/some.jpg"`;
> >>>>
> >>>
> >>> Perl distinguishes between 8-bit/binary strings and unicode ones. See
ry strings and unicode ones. See
https://perldoc.perl.org/perlunitut.html .
What kind of string do I get when using backticks like in the above
example?
> [...]
Perhaps use open "-|" with an encoding - see
https://perldoc.perl.org/functions/binmode.html .
I didn't know I cou
lification, strings are very complicated
things. You might imagine a "binary string" as a number of
consecutive bytes, with "consecutive" meaning that one byte comes
after the other, and the order in which they come is relevant. You
could describe a string like that, bu
--- and never in lines unless they get in the way and force me to
consider them.
A string is not a single value. And when you keep reading until you get
to the "Discussion" section, you would have to conclude that there are
no characters in perl, and I'm getting back to basically th
or example, noting that
print 4;
and
print 0b100;
both output 4, would you refer to 0b100 as a binary string?
On Thu, May 16, 2019 at 5:51 PM hwilmer wrote:
>
> Hi,
>
> since I'm trying to use "binary strings", the question comes up if there
> is a definition of
So I would want to use something like
> >>
> >>
> >> my $binary_data = `curl -k "https://www.example.com/some.jpg"`;
> >>
> >
> > Perl distinguishes between 8-bit/binary strings and unicode ones. See
> > https://perldoc.perl.org/perlun
Hi,
since I'm trying to use "binary strings", the question comes up if there
is a definition of what is a string in perl, and what is it?
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
nitut.html .
What kind of string do I get when using backticks like in the above
example? One that perl considers as a text string I could use stuff
like uc or lc on, or as a binary string I could use pack or unpack on?
Variables are without types, so there is no way to tell. If I was using
curl
DBI in
> such a way that the image can be restored as it was.
>
> Will string conversions or something prevent this from working?
>
> What is the usual way to do this? It is certainly not ideal to have no
> check on the amount of data that might be retrieved from t
something like
my $binary_data = `curl -k "https://www.example.com/some.jpg"`;
The image then needs to be inserted into a LONGBLOB field via DBI in
such a way that the image can be restored as it was.
Will string conversions or something prevent this from working?
What is the usual
On Thu, Mar 02, 2017 at 04:50:32PM +, mailing lists via beginners wrote:
>
>
> just to clarify, the real purpose of the script is output the hash to a json
> object, so the json output for the script:
So you have to "numify" your number:
https://metacpan.org/pod/JSON::PP#PERL-%3E-JSON
See docs https://metacpan.org/pod/JSON::PP#simple-scalars
You do print Dumper on hash, it stringifies all hash values, so you see
such an obscure result for encode_json.
If don't dump $hash before encode json you get what you want -
work_hours_to_float_try2 is json valid number
meric values) and not floats. So the real question is how to
> output float numbers in this case.
Perl automatically converts from number to string and back.
When I try it, I get the following, which seems to be correct.
$VAR1 = {
'work_hours' => '4.1',
'work_hours_
just to clarify, the real purpose of the script is output the hash to a json
object, so the json output for the script:
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use JSON::PP;
my ($input_string, %job_task);
sub sanitize_data{
my $data = shift;
$data->{'work_hours'} =
Helo all,
what I am trying to do is convert a value contained whitin a hash from string
to float, but I fail to find the error, this is that I have tried:
$ cat test.pl
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my ($input_string, %job_task);
sub sanitize_data{
my $data
On Wed, Jan 4, 2017 at 12:22 AM, Chris Fedde wrote:
> my ($condition, @fields) = parse_data($source_item);
> print sprintf $formats[ $condition ], @fields;
>
> Or something.
Well, I've simplified the example and effectively, in my code, the
formats is an hash instrumented
On Tue, Jan 3, 2017 at 5:58 PM, Shlomi Fish wrote:
> Perhaps try looking at this page about generating text in Perl -
> http://perl-begin.org/uses/text-generation/ (note that Perl-Begin is a site
> which I maintain). This page on my personal website, which is not
>
:
my ($condition, @fields) = parse_data($source_item);
print sprintf $formats[ $condition ], @fields;
Or something.
if this works then $condition could be some string from the $source_item.
Then @formats could be %formats and $condition is the key and the printf
format is the value. Here
t; for something more elegant.
> What I do is something like the following:
>
> print sprintf $formats[ $condition ], @fields;
>
> where $condition is the condition used to select a sprintf format
> string out of an array (@formats) that contains something like:
>
> my @fo
;
where $condition is the condition used to select a sprintf format
string out of an array (@formats) that contains something like:
my @formats = (
qw( %09d %-1s %03d ... )
, qw(%-4s %1s %09d %1s %-150s %-4s %011d)
, ...
);
Now, while this approach is working really fine, it is a little hard
On Tue, Sep 6, 2016 at 3:24 PM Shawn H Corey wrote:
> > #Change the value to the maximum you want
> > my %HEXCODES = map{$_ => sprintf("%03X", $_)} (0..128);
>
> my %HexCodes = map { ord($_) => sprintf '%02X', $_ } ( 0 .. 128 );
>
Just your friendly reminder that
On Tue, 6 Sep 2016 22:08:40 +0200
David Emanuel da Costa Santiago wrote:
>
>
> Thanks :-)
>
> A little bug:
>
> > my %HexCodes = map { ord($_) => sprintf '%02X', $_ } ( 0 .. 128 );
> my %HexCodes = map { chr($_) => sprintf '%02X', $_ } ( 0 .. 128 );
>
>
>
>
Oops. :)
On Tue, 6 Sep 2016 17:01:52 -0400
Uri Guttman wrote:
> On 09/06/2016 04:42 PM, X Dungeness wrote:
> > It's kinda hard to see but I included the /x switch because
> > I inserted blanks on the pattern as well as the replacement
> > side. Without /x, the match will fail.
> >
>
On 09/06/2016 04:42 PM, X Dungeness wrote:
It's kinda hard to see but I included the /x switch because
I inserted blanks on the pattern as well as the replacement
side. Without /x, the match will fail.
$str =~ s{ ([^[:print:]]) }{ sprintf( "(%#2X)", ord $1) }gex;
^
It's kinda hard to see but I included the /x switch because
I inserted blanks on the pattern as well as the replacement
side. Without /x, the match will fail.
$str =~ s{ ([^[:print:]]) }{ sprintf( "(%#2X)", ord $1) }gex;
^ ^
On Tue, Sep 6, 2016 at 1:06 PM,
Thanks :-)
A little bug:
> my %HexCodes = map { ord($_) => sprintf '%02X', $_ } ( 0 .. 128 );
my %HexCodes = map { chr($_) => sprintf '%02X', $_ } ( 0 .. 128 );
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
On 09/06/2016 03:59 PM, X Dungeness wrote:
$str = "ab\rcd\nef\ngh\fij";
$str =~ s{ ([^[:print:]]) }{ sprintf( "(%#2X)", ord $1) }gex;
> ab(0XD)cd(0XA)ef(0XA)gh(0XC)ij
that is a nice use of /e (don't think you need /x when you already have
/e as code can handle blanks. but the #
$str = "ab\rcd\nef\ngh\fij";
$str =~ s{ ([^[:print:]]) }{ sprintf( "(%#2X)", ord $1) }gex;
> ab(0XD)cd(0XA)ef(0XA)gh(0XC)ij
On Tue, Sep 6, 2016 at 9:11 AM, Matt <matt.mailingli...@gmail.com> wrote:
> I am receiving log entries as a string
EXCODES = map{$_ => sprintf("%03X", $_)} (0..128);
my %HexCodes = map { ord($_) => sprintf '%02X', $_ } ( 0 .. 128 );
>
> my $s="This is my string! \r\n the end";
>
> say "String before: $s";
>
> #Change the character class you want
>
Hi!
You can use "chomp" to remove the $/ from the end of the line.
If you want to replace all non printable characters you can do
something like:
### START
#Change the value to the maximum you want
my %HEXCODES = map{$_ => sprintf("%03X", $_)} (0..128);
my $s=&
On Tue, Sep 6, 2016 at 9:11 AM, Matt <matt.mailingli...@gmail.com> wrote:
> I am receiving log entries as a string and then writing them to a file
> with the date tacked on beginning. Problem is that sometimes the
> string I receive contains \n and it makes parsing the file w
I am receiving log entries as a string and then writing them to a file
with the date tacked on beginning. Problem is that sometimes the
string I receive contains \n and it makes parsing the file with grep
more difficult. Looking for a simple way to replace all \n in the
string with text
downsides of using this method more
> > generally (other than double-quotes being two characters shorter)?
> > For example, is it "faster" for Perl to parse a double-quoted
> > string or does the compiler optimise this out so the methods are
> > fundamentally equival
ng two characters shorter)? For example, is it "faster"
for Perl to parse a double-quoted string or does the compiler optimise
this out so the methods are fundamentally equivalent?
In that regards you can get a reasonable look at how perl interprets
your string with B::Deparse, partly bec
rter)? For example, is it "faster"
> for Perl to parse a double-quoted string or does the compiler optimise
> this out so the methods are fundamentally equivalent?
In that regards you can get a reasonable look at how perl interprets
your string with B::Deparse, partly because
the deparse rever
On Wed, Apr 06, 2016 at 08:20:24PM +0100, Jonathon Fernyhough wrote:
> Hi,
>
> I'm working my way through Learning Perl (6th) and Modern Perl (4th) and
> was wondering whether there are any (non-obvious) drawbacks to the
> different string quoting methods.
>
> First up,
On Wed, 6 Apr 2016 15:29:26 -0400
Uri Guttman <u...@stemsystems.com> wrote:
> my rule is for the reader and not the computer. i try to use '' when
> i know there is no interpolation and "" when there is. i am telling
> the reader to either not look or to look inside th
On 04/06/2016 03:20 PM, Jonathon Fernyhough wrote:
Hi,
I'm working my way through Learning Perl (6th) and Modern Perl (4th) and
was wondering whether there are any (non-obvious) drawbacks to the
different string quoting methods.
First up, double-quoted strings. The "usual method"
Hi,
I'm working my way through Learning Perl (6th) and Modern Perl (4th) and
was wondering whether there are any (non-obvious) drawbacks to the
different string quoting methods.
First up, double-quoted strings. The "usual method" of double-quoting
has an alternative of qq{Fo
rt { $a <=> $b } @a; say
join("\n",@b)'
12 hi
37 b
123 c
187 a
You can scope this if you like:
my @result;
{
no warnings 'numeric';
@result = sort { $a <=> $b } @source;
}
You could also force the string to a number using a thing fr
On Tue, 8 Mar 2016 13:29:40 -0800
Kenneth Wolcott <kennethwolc...@gmail.com> wrote:
> How do I call the built-in Perl sort function on an array of strings
> where the string is composed of one or more digits, followed by a tab
> which is followed by a string and I want the resul
Hi Ken
I just wrote this
https://gist.github.com/andrewsolomon/65b795be10da569f878d
and then realised it could be simpler because you'll have a tab between the
number and string. Does this give you enough to work off?
Andrew
On Tue, Mar 8, 2016 at 9:29 PM, Kenneth Wolcott <kennethw
Hi;
How do I call the built-in Perl sort function on an array of strings
where the string is composed of one or more digits, followed by a tab
which is followed by a string and I want the results to be sorted in
reverse numeric order?
I looked at http://perldoc.perl.org/functions/sort.html
mail.com> wrote:
> Re-sending with CC to OP since it didn't make the group.
>
> On 11/3/2015 14:03, David Emanuel da Costa Santiago wrote:
> > -BEGIN PGP SIGNED MESSAGE-
> > Hash: SHA256
> >
> >
> > Hello all.
> >
> > I'm trying to interpo
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256
Hello all.
I'm trying to interpolate a hash value in a string but i got stuck.
I already tried with eval, without any success...
I have two conf files in the form
conf file 1:
option=value
option2=value2
conf file 2:
property=propertyValue
> On Nov 3, 2015, at 2:03 PM, David Emanuel da Costa Santiago
> <deman...@gmail.com> wrote:
>
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA256
>
>
> Hello all.
>
> I'm trying to interpolate a hash value in a string but i got stuck.
> I already tried
of split?
Perhaps something like:
$example_string =~ m|'($1)'|;
$shared_folder = $1;
Is there a better way to do this?
What kind of string format is this called?
Thanks,
Ken Wolcott
Rather than attempting to parse the human-readable output from
VBoxManage, have you instead tried
)'|;
$shared_folder = $1;
Is there a better way to do this?
What kind of string format is this called?
Thanks,
Ken Wolcott
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
this?
What kind of string format is this called?
Thanks,
Ken Wolcott
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional
:
$example_string =~ m|'($1)'|;
$shared_folder = $1;
Is there a better way to do this?
What kind of string format is this called?
Thanks,
Ken Wolcott
Well, I had to look at
http://perldoc.perl.org/perlrequick.html#Extracting-matches to find
out how much I had forgotten about extracting matches from
On Tue, Dec 16, 2014 at 4:29 PM, Kenneth Wolcott
kennethwolc...@gmail.com wrote:
Well, I had to look at
http://perldoc.perl.org/perlrequick.html#Extracting-matches to find
out how much I had forgotten about extracting matches from a regex :-)
This might be inefficient, but it seems to work:
I am trying to extract a table (table class=trtd.. until
/table) and its content from an HTML file.
With the file I have something like this
div id=product class=product
table border=0 cellspacing=0 cellpadding=0 class=prodc
title=Product
.
.
.
/table
/div
There could be more that one
perldoc HTML::Element
--Octavian
- Original Message -
From: mimic...@gmail.com
To: beginners@perl.org
Sent: Tuesday, November 18, 2014 10:22 PM
Subject: Match HTML div .. /dv string over multiple
I am trying to extract a table (table class=trtd.. until
/table
On Tue, Nov 18, 2014 at 12:22 PM, mimic...@gmail.com mimic...@gmail.com wrote:
I am trying to extract a table (table class=trtd.. until
/table) and its content from an HTML file.
With the file I have something like this
div id=product class=product
table border=0 cellspacing=0
On Tue, Nov 18, 2014 at 12:22 PM, mimic...@gmail.com
mimic...@gmail.com wrote:
I am trying to extract a table (table class=trtd..
until /table) and its content from an HTML file.
Because there can be nested tables and other elements that can throw off
simple regex parsing, I would try
I currently have something like this
use MyFoo::ABCBar;
use MyFoo::DEFBar;
use MyFoo::HIJBar;
my $fooABC = MyFoo::ABCBar-new();
…
What I would like to do is
foreach $pgm ( ‘ABC’ , ‘DEF’ , ‘HIJ’) {
my $foo = MyFoo::{$pgm}Bar-new;
…
}
This gives me an error.
What is the correct syntax?
Patton, Billy N wrote:
I currently have something like this
use MyFoo::ABCBar;
use MyFoo::DEFBar;
use MyFoo::HIJBar;
my $fooABC = MyFoo::ABCBar-new();
â¦
What I would like to do is
foreach $pgm ( âABCâ , âDEFâ , âHIJâ) {
my $foo = MyFoo::{$pgm}Bar-new;
â¦
}
This
Hi Billy,
please reply to all recipients.
On Fri, 7 Nov 2014 13:17:19 +
Patton, Billy N billy.pat...@h3net.com wrote:
I currently have something like this
use MyFoo::ABCBar;
use MyFoo::DEFBar;
use MyFoo::HIJBar;
my $fooABC = MyFoo::ABCBar-new();
…
What I would like to do is
= MyFoo::{$pgm}Bar-new;
…
}
This gives me an error.
What is the correct syntax?
I don't see any valid reason why you'd want to do that, but if that's what
you want, you could accomplish it with the use of eval.
my $foo = eval MyFoo::${pgm}Bar-new;
ewww. never use string eval for something
Uri Guttman wrote:
On 11/08/2014 10:40 AM, Ron Bergin wrote:
you could accomplish it with the use of eval.
my $foo = eval MyFoo::${pgm}Bar-new;
ewww. never use string eval for something as simple as that.
my $foo = MyFoo::${pgm}Bar-new() ;
that is just fine there. the class in a class
On 9 November 2014 05:27, Ron Bergin r...@i.frys.com wrote:
In fact, I
almost never use or suggest using eval.
eval itself is not evil. Its just *string* eval becuase that involves
arbitrary code interpolation.
Non-string eval is of course potentially written as try in other
languages
On Sat, 8 Nov 2014 17:48:31 +0200
Shlomi Fish shlo...@shlomifish.org wrote:
The correct syntax is simply (untested):
my $foo = MyFoo::${pgm}Bar-new;
FYI: That is called a symbolic reference. For more information, see
`perldoc perlref` and search for /Symbolic references/
BTW, symbolic
` and search for /Symbolic references/
BTW, symbolic references are not considered good practice. But if you
need them, you need them.
actually that is not a symref. it is just a class method call with a
string. strings are allowed as class names and this works under strict.
it is not generating
Thanks all, and thanks Nathan for your detailed explanation.
Now I know the list got flattened before passing into subroutine.
Cheers.
---
Regards !
Alex Chiang
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
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
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: character
39 # passing array into sub
40 my @s = @_[0]; my $c = $_[1];
41 for my
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: character
39 # passing array into sub
40 my @s = @_[0]; my $c = $_[1];
41 for my $i (@s) { if ($c eq $i) {return 1
On Tue, Mar 11, 2014 at 11:58 PM, Alex Chiang pigfly...@gmail.com wrote:
sub is_in_string {
38 # @s: string array, $c: character
39 # passing array into sub
40 my @s = @_[0]; my $c = $_[1];
snip...
44 my @ar = qw(t d s);
45 my $c = d;
46 my $res = is_in_string( @ar, $c
Is @_[0] even legit?
On 12 Mar 2014, at 04:58, Alex Chiang pigfly...@gmail.com 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
/2014 10:15 AM, Jing Yu wrote:
Is @_[0] even legit?
On 12 Mar 2014, at 04:58, Alex Chiang pigfly...@gmail.com
mailto:pigfly...@gmail.com 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
Having trouble making this work.
my @alarm = (xyz, abc);
my $name = ab;
unless (grep {/$name/} @alarm) { # do this }
Since ab is contained in the array I want it to NOT 'do this'. What
have I got wrong?
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail:
On Thu, 20 Feb 2014 13:04:56 -0600, Matt wrote:
Having trouble making this work.
my @alarm = (xyz, abc);
my $name = ab;
unless (grep {/$name/} @alarm) { # do this }
Since ab is contained in the array I want it to NOT 'do this'.
What
have I got wrong?
Use word boundaries
#!/usr/bin/perl -w
use
On 02/20/2014 02:04 PM, Matt wrote:
Having trouble making this work.
my @alarm = (xyz, abc);
my $name = ab;
unless (grep {/$name/} @alarm) { # do this }
Since ab is contained in the array I want it to NOT 'do this'. What
have I got wrong?
can you show this not working? it looks good to me.
Having trouble making this work.
my @alarm = (xyz, abc);
my $name = ab;
unless (grep {/$name/} @alarm) { # do this }
Since ab is contained in the array I want it to NOT 'do this'. What
have I got wrong?
If I set 'my $name = abc;' it seems to match. But I want to match
on ab as well.
On Thu, 20 Feb 2014 15:05:42 -0600, Matt wrote:
my @alarm = (xyz, abc);
my $name = ab;
unless (grep {/$name/} @alarm) { # do this }
If I set 'my $name = abc;' it seems to match. But I want to match
on ab as well.
It appears to do this already.
#!/usr/bin/perl -w
use 5.14.0;
my @alarm = (xyz,
Hi Parys,
Your statement $joinedDNA =~ s/\R//g; will remove new line in the string.
You may remove this statement.
thanks,
Kimi
On 14 February 2014 15:48, Parysatis Sachs parysatissa...@gmail.com wrote:
Hi everyone!
I'm new to this mailing list as well as to programming and Perl
Dear Parys,
Here is one way to do it
[code]
use strict;
use warnings;
my $str = agctagccgagctaNNatggctaNNNatgtgaNNatg;
$str =~ s/N+/\n/g;
###
#Print the string as is (commented out)
#print $str, \n;
###
print '-' x 40,\n;
#Split the string
a very long string with lots of Ns in it, like this:
agctagccgagctaNNatggctaNNNatgtgaNNatg
So, I want to get rid of the Ns and get ONE SINGLE newline for each
group of Ns
So far I've managed to do this:
if ($joinedDNA =~ s/N+/\n/g) {
$joinedDNA =~ s/\R//g;
}
But now I have
On Fri, Feb 14, 2014 at 2:14 PM, Bill McCormick wpmccorm...@gmail.comwrote:
Is this your homework?
Does it matter? They've shown their work, what they expected to happen and
what happened instead. I think the only missing bit would've been I
checked in X documentation and couldn't find the
On 2/14/2014 3:39 AM, kimi ge(巍俊葛) wrote:
Hi Parys,
Your statement $joinedDNA =~ s/\R//g; will remove new line in the string.
You may remove this statement.
Yea, I don't see that you need that either.
maybe you were just trying to get a new line at then end?
$joinedDNA =~ s/N+|$/\n/g
Parysatis Sachs wrote:
Hi everyone!
Hello,
I'm new to this mailing list as well as to programming and Perl in general.
So there is a chance I might ask relatively stupid questions with very
obvious answers... Please bear with me!
So, here it goes:
I have a very long string with lots of Ns
Hi everyone!
I'm new to this mailing list as well as to programming and Perl in general.
So there is a chance I might ask relatively stupid questions with very
obvious answers... Please bear with me!
So, here it goes:
I have a very long string with lots of Ns in it, like
$s=ab;
$s=~s/a/AA/; # $s is now AAb
I would like to achieve the same with something similar to the x multiplier:
$n=2;
$s=Ax$n.b; # $s is AAb
$s=ab;
$n=2;
$s=~s/a/Ax$n/; # doesn't work, of course; $s is Ax2b
Is it possible at all?
Thanks
Jorge Almeida
--
To unsubscribe, e-mail:
On Wed, 5 Feb 2014 19:52:07 +
Jorge Almeida jjalme...@gmail.com wrote:
$s=ab;
$s=~s/a/AA/; # $s is now AAb
I would like to achieve the same with something similar to the x
multiplier:
$n=2;
$s=Ax$n.b; # $s is AAb
$s=ab;
$n=2;
$s=~s/a/Ax$n/; # doesn't work, of course; $s is
On 02/05/2014 02:52 PM, Jorge Almeida wrote:
$s=ab;
$s=~s/a/AA/; # $s is now AAb
I would like to achieve the same with something similar to the x multiplier:
$n=2;
$s=Ax$n.b; # $s is AAb
$s=ab;
$n=2;
$s=~s/a/Ax$n/; # doesn't work, of course; $s is Ax2b
you need the /e modifier on s///. it
On Wed, Feb 5, 2014 at 8:11 PM, Uri Guttman u...@stemsystems.com wrote:
On 02/05/2014 02:52 PM, Jorge Almeida wrote:
$s=ab;
$s=~s/a/AA/; # $s is now AAb
I would like to achieve the same with something similar to the x
multiplier:
$n=2;
$s=Ax$n.b; # $s is AAb
you need the /e modifier
with a text string
you haven't thought of, or an update to the device firmware.
Rob
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
-
From: Natxo Asenjo natxo.ase...@gmail.com
To: beginners@perl.org
Sent: Wednesday, August 21, 2013 11:32 AM
Subject: Re: string match question
*snip*
I agree with Rob Dixon I should be parsing
: Re: string match question
*snip*
I agree with Rob Dixon I should be parsing the html, but unfortunately
getting it was proving more complicated than this.
*snip*
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http
On 21/08/2013 18:32, Natxo Asenjo wrote:
hi,
thanks all for your advice. I have just used one of your suggested
regex to accomplish this task:
if ( $text =~ /.*(critical alarm.*?)\./i ) {
my $message = $1;
print $message, \n;
}
This captures everything starting with critical alarm
the submit_form method, by the way).
Then I save the text of the website in a variable like this:
my $text = $mech-text();
if ( $text =~ /critical alarm/i ) {
print Bingo\n;
}
This works, if I unplug something I get the critical alarm, I replug
the stuff and the string does not match anymore
the critical alarm, I replug
the stuff and the string does not match anymore.
$text has this (very long line):
APC | UPS Network Management Card 2Skip to Main ContentUPS Network
Management Card 2Smart-UPS/Matrix Application 1user | English | Log
Off | Help
-
From: Natxo Asenjo natxo.ase...@gmail.com
To: beginners@perl.org
Sent: Tuesday, August 20, 2013 8:02 AM
Subject: string match question
hi,
for a nagios (monitoring system) check I need to scrape a web site
(this is for a network device, a UPS, whatever). This particular
On Tue, 20 Aug 2013 16:02:50 +0200
Natxo Asenjo natxo.ase...@gmail.com wrote:
I am only interested in the text '1 Critical Alarm PresentA site
wiring fault exists'; is it possible to match this is a simple way (in
fact, the text after 'Critical Alarm Present' may vary, it would be
awesome to
is absolutely the right way to do this. It's not that
hard. If you put a sample of the HTML up (perhaps on pastebin?) then
someone will code it for you. Better that way than writing some
unreliable regular expression that may fail one day with a text string
you haven't thought of, or an update to the device
1 - 100 of 2693 matches
Mail list logo