[23955] in Perl-Users-Digest
Perl-Users Digest, Issue: 6156 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 18 18:06:03 2004
Date: Wed, 18 Feb 2004 15:05:18 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 18 Feb 2004 Volume: 10 Number: 6156
Today's topics:
Re: Can't build SNMP... <ggershSNACK@CAKEctc.net>
Re: Can't build SNMP... <usenet@morrow.me.uk>
Re: Can't build SNMP... <ggershSNACK@CAKEctc.net>
Re: commandline version of this script. <usenet@morrow.me.uk>
Re: commandline version of this script. <exide@comcast.net>
Re: commandline version of this script. <gnari@simnet.is>
Re: configure, WIN32 <tmohr@s.netic.de>
Re: Dynamic Ref names (John McNamara)
Getopt::Long and <> problem (Daniel Berger)
Re: how to cut a text file in perl <tc@no.public.email>
I wish buy Perl book <gp@nospm.hr>
Re: I wish buy Perl book <dwall@fastmail.fm>
Re: I wish buy Perl book <usenet@c0s.org>
Launch popup for file load from perl script <Yves.Peysson@wanadoo.fr>
Re: Launch popup for file load from perl script <usenet@morrow.me.uk>
Re: Listbox and passing entries <usenet@morrow.me.uk>
Re: Listbox and passing entries <a@b.com>
Re: Listbox and passing entries <kkeller-usenet@wombat.san-francisco.ca.us>
Major bug in 5.8.2 debugger? Pager hangs <nospam@nospam.com>
Matching quoted strings (TonyShirt)
Re: Matching quoted strings <tc@no.public.email>
Re: Matching quoted strings <gnari@simnet.is>
Re: Matching quoted strings (Malcolm Dew-Jones)
Re: Matching quoted strings <invalid-email@rochester.rr.com>
Re: Matching quoted strings <usenet@morrow.me.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 18 Feb 2004 14:06:39 -0500
From: Greg G <ggershSNACK@CAKEctc.net>
Subject: Re: Can't build SNMP...
Message-Id: <poOdndLXIOQiKq7dRVn-uA@ctc.net>
Ben Morrow wrote:
> Greg G <ggershSNACK@CAKEctc.net> wrote:
>
>>Ben Morrow wrote:
>>
>>>Greg G <ggershSNACK@CAKEctc.net> wrote:
>>>
>>>
>>>>I get the following when trying to install the SNMP-4.2.0 into perl
>>>>5.8.2 on a Solaris 7 host. Note that I don't want to use Net::SNMP as I
>>>>can't quite decipher the docs and I plan to migrate to SNMP::Multi after
>>>>I migrate some old code that's making snmpget system calls.
>>>>
>>>>
>>>># perl Makefile.PL
>>>>WARNING: MAN3PODS takes a hash reference not a string/number.
>>>> Please inform the author.
>>>>Checking if your kit is complete...
>>>>Looks good
>>>>Processing hints file hints/solaris.pl
>>>>Can't use string ("SNMP") as a HASH ref while "strict refs" in use at
>>>>/usr/local/lib/perl5/5.8.2/ExtUtils/MM_Unix.pm line 503.
>>>
>>>
>>>This is a bug in the Makefile.PL of SNMP.pm... not a good sign. What
>>>does the line containing MAN3PODS say?
>>
>>my %Params = (
>> NAME => 'SNMP',
>> dist => { SUFFIX => "gz", COMPRESS => "gzip -9f"},
>> MAN3PODS => 'SNMP', # Pods will be built by installman.
>> XSPROTOARG => '-noprototypes', # XXX remove later?
>> VERSION_FROM => 'SNMP.pm',
>> realclean => { FILES => 'host' },
>> );
>>
>>I would never have correlated that error to this line. Thanks. I've
>>put curly braces around the 'SNMP' on the MAN3PODS line.
>
>
> Better would be to delete both that line and the 'dist' line: both are
> imply setting the default options.
Understood. I noticed that a lot of other modules don't have either
of these lines either, or if they do, they've got empty sets.
For fun, I went back and checked earlier versions of this, and they
all have the same lines in the Makefile.PL.
I'm somewhat confused as to how this is being built on any system at
all.
>
>>That has fixed
>>the makefile generation. Unforunately, it still doesn't build.
>>
>>AutoSplitting blib/lib/SNMP.pm (blib/lib/auto/SNMP)
>>/usr/bin/perl /usr/local/lib/perl5/5.8.2/ExtUtils/xsubpp -noprototypes
>>-typemap /usr/local/lib/perl5/5.8.2/ExtUtils/typemap -typemap typemap
>>SNMP.xs > SNMP.xsc && mv SNMP.xsc SNMP.c
>>/opt/SUNWspro/bin/cc -c -I/usr/local/include -I/usr/local/include
>>-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O -DVERSION=\"4.2.0\"
>>-DXS_VERSION=\"4.2.0\" -KPIC
>>"-I/usr/local/lib/perl5/5.8.2/sun4-solaris/CORE" SNMP.c
>>"SNMP.xs", line 224: invalid token in #define macro parameters: ...
>>"SNMP.xs", line 824: warning: argument #3 is incompatible with prototype:
>> prototype: pointer to uint :
>>"/usr/local/include/ucd-snmp/mib.h", line 274
>> argument : pointer to int
>>"SNMP.xs", line 998: warning: argument #4 is incompatible with prototype:
>> prototype: pointer to int : "SNMP.xs", line 141
>> argument : pointer to uint
>>"SNMP.xs", line 1450: undefined symbol: _debugx
>>"SNMP.xs", line 1451: warning: improper pointer/integer combination: arg #1
>
>
> Oh dear oh dear oh dear oh dear... I'd recommend using something else
> unless you fancy some XS debugging fun. You could try contacting the
> author.
Errr. What other options might I have? I'm looking at using
SNMP::Utils and SNMP::Multi, which depend on this. As I said, the docs
for Net::SNMP give me a complete headache, and I can't figure out how to
translate system calls to snmpget.
-Greg G
------------------------------
Date: Wed, 18 Feb 2004 19:26:30 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Can't build SNMP...
Message-Id: <c10e96$c2u$1@wisteria.csv.warwick.ac.uk>
Greg G <ggershSNACK@CAKEctc.net> wrote:
> > Better would be to delete both that line and the 'dist' line: both are
> > imply setting the default options.
>
> Understood. I noticed that a lot of other modules don't have either
> of these lines either, or if they do, they've got empty sets.
> For fun, I went back and checked earlier versions of this, and they
> all have the same lines in the Makefile.PL.
> I'm somewhat confused as to how this is being built on any system at
> all.
I'm not at all sure it is: search.cpan.pm says it was last updated in
2001, and it has no test results.
> > Oh dear oh dear oh dear oh dear... I'd recommend using something else
> > unless you fancy some XS debugging fun. You could try contacting the
> > author.
>
> Errr. What other options might I have?
None. If you must use this module, you'll either have to fix it yourself
or contact the author and see if he'll fix it for you.
> I'm looking at using
> SNMP::Utils and SNMP::Multi, which depend on this. As I said, the docs
> for Net::SNMP give me a complete headache, and I can't figure out how to
> translate system calls to snmpget.
Sorry, knowing nothing about SNMP I can't help you here.
Ben
--
I've seen things you people wouldn't believe: attack ships on fire off the
shoulder of Orion; I've watched C-beams glitter in the darkness near the
Tannhauser Gate. All these moments will be lost, in time, like tears in rain.
Time to die. |-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-| ben@morrow.me.uk
------------------------------
Date: Wed, 18 Feb 2004 14:42:23 -0500
From: Greg G <ggershSNACK@CAKEctc.net>
Subject: Re: Can't build SNMP...
Message-Id: <1oednfGIT5m9Xa7dRVn-jg@ctc.net>
Ben Morrow wrote:
> None. If you must use this module, you'll either have to fix it yourself
> or contact the author and see if he'll fix it for you.
Hmmm. It looks like the address given in
http://search.cpan.org/~gsm/ no longer exists.
>>I'm looking at using SNMP::Utils and SNMP::Multi, which depend on this.
SNMP::Utils hasn't been updated in forever.
Is there a way to alert CPAN and maybe have these marked as
deprecated or something?
>>As I said, the docs
>>for Net::SNMP give me a complete headache, and I can't figure out how to
>>translate system calls to snmpget.
>
>
> Sorry, knowing nothing about SNMP I can't help you here.
>
Thanks. You've been helpful anyway.
-Greg G
------------------------------
Date: Wed, 18 Feb 2004 19:12:31 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: commandline version of this script.
Message-Id: <c10dev$a0u$9@wisteria.csv.warwick.ac.uk>
news8080@yahoo.com (NNTP) wrote:
> #!/usr/bin/perl
> use Validate::Net;
> if ( Validate::Net->ip($ARGV[0]))
> {
> print "valid";
> exit 0;
> }
> print "invalid";
> #--done
>
> is it even doable?
err... (untested)
perl -MValidate::Net -le'print !Validate::Net->ip(shift) && "in", "valid"'
Ben
--
"If a book is worth reading when you are six, * ben@morrow.me.uk
it is worth reading when you are sixty." - C.S.Lewis
------------------------------
Date: Wed, 18 Feb 2004 11:13:32 -0800
From: Exide Arabellan <exide@comcast.net>
Subject: Re: commandline version of this script.
Message-Id: <d4ednaOQuZDAJK7dRVn-jA@comcast.com>
NNTP wrote:
> #!/usr/bin/perl
> use Validate::Net;
> if ( Validate::Net->ip($ARGV[0]))
> {
> print "valid";
> exit 0;
> }
> print "invalid";
> #--done
>
> is it even doable?
Worked for me. Here is the script i used:
#!/usr/bin/perl -w
use strict;
use Validate::Net;
if (Validate::Net->ip($ARGV[0])) {
print "valid\n";
exit 0;
}
print "invalid\n";
------------------------------
Date: Wed, 18 Feb 2004 20:18:23 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: commandline version of this script.
Message-Id: <c10h8t$53o$1@news.simnet.is>
[removing newsgroups from followup, among others an invalid one]
"NNTP" <news8080@yahoo.com> wrote in message
news:110fc16.0402181050.1a88d36a@posting.google.com...
> #!/usr/bin/perl
> use Validate::Net;
> if ( Validate::Net->ip($ARGV[0]))
> {
> print "valid";
> exit 0;
> }
> print "invalid";
> #--done
>
> is it even doable?
I am wondering what your problem is.
<mantra>
what did you try ?
what happened ?
what did you expect to happen ?
</mantra>
gnari
------------------------------
Date: Wed, 18 Feb 2004 22:54:01 +0100
From: Torsten Mohr <tmohr@s.netic.de>
Subject: Re: configure, WIN32
Message-Id: <c10mtp$51n$1@schleim.qwe.de>
Hi,
thanks for the hints.
>> Using "dmake" works fine, but i think i should somehow define that
>> i don't want to generate a DLL, just a LIB.
>
> This is what STATIC_EXT should do for you.
It didn't, I still get a LIB file of 2xx kB and a DLL of 7xx kB.
I looked through the makefile.mk, but didn't yet succeed to
find the necessary changes.
I think i'll try to just change the option "-dll" to "-lib", but
i'd really wonder if that would succeed.
>> I also need to tell XS and other tools to generate code that compiles
>> for a LIB? How can i do that?
>
> Everything gets its info from the perl binary it uses, also from its
> Config.pm. If both those are correct, you should be fine (assuming
> static builds work on Win32 at all).
So i'll try to remove dynamic loading in the configuration, hope that
works.
> See ExtUtils::Embed.
Looks really useful.
Thanks for those hints,
Torsten.
------------------------------
Date: 18 Feb 2004 12:27:33 -0800
From: jmcnamara@cpan.org (John McNamara)
Subject: Re: Dynamic Ref names
Message-Id: <8cceb2da.0402181227.2bb39059@posting.google.com>
Warrick FitzGerald wrote:
> This is what I tried.
>
> $date = $Fields[0]; <--- Get the date from the Logfile
>
> ${$date} = $workbook->addworksheet($date); <-- This created the workbook
> for each date. date is of course formatted to be excel friendly name.
>
> My problem come when trying to call the write method on my dynamic name.
Here is a short example:
#!/usr/bin/perl -w
use strict;
use Spreadsheet::WriteExcel;
my $workbook = Spreadsheet::WriteExcel->new("dates.xls");
my %worksheets;
my $date = '2004-02-18';
$worksheets{$date} = $workbook->addworksheet($date);
$worksheets{$date}->write("A1", "Hello world");
__END__
John.
--
# Count the number of lines in a file.
perl -le 'print $==()=<>' file
------------------------------
Date: 18 Feb 2004 13:53:02 -0800
From: djberg96@hotmail.com (Daniel Berger)
Subject: Getopt::Long and <> problem
Message-Id: <6e613a32.0402181353.74c26e85@posting.google.com>
Hi all,
Perl 5.8.3
Solaris 9
I'm trying to use the <> operator in Getopt::Long to call a sub when
an unknown option occurs. However, it doesn't seem to work. I read
the docs, found a few online examples, but nothing that would indicate
why this would fail. It's probably something obvious but I don't see
it.
Help appreciated.
Regards,
Dan
# getopttest.pl
use strict;
use Getopt::Long;
$Getopt::Long::debug = 9;
#Getopt::Long::config qw(permute); # tried both
$Getopt::Long::order = $PERMUTE;
my($qt_dir, $CC);
# never gets called afaict
sub foo{
my $arg = shift;
print "WTF?-> $arg\n";
}
# Why isn't <> working?
GetOptions(
"--with-qt=s" => \$qt_dir,
"--with-gcc=s" => \$CC,
"<>" => \&foo
);
$CC ||= $ENV{CXX};
print "QT dir: $qt_dir\n";
print "CC: $CC\n";
# Output
>perl getopttest.pl --foo
Getopt::Long 2.34 ($Revision: 2.68 $) called from package "main".
ARGV: (--foo)
autoabbrev=1,bundling=0,getopt_compat=1,gnu_compat=0,order=1,
ignorecase=1,requested_version=0,passthrough=0,genprefix="(--|-|\+)".
=> link "with-qt" to SCALAR(0x12cd14)
=> link "with-gcc" to SCALAR(0x12ccf0)
=> $opctl{with-gcc} = ARRAY(0x12ccb4) ["s","with-gcc",O,$,"<undef>"]
$opctl{with-qt} = ARRAY(0x1ca584) ["s","with-qt",O,$,"<undef>"]
=> arg "--foo"
=> find "--foo"
=> split "--"+"foo"
=> 0 hits () with "foo" out of 2
Unknown option: foo
QT dir:
CC: g++ -Wall -m64 -mcpu=ultrasparc -fno-strict-aliasing
------------------------------
Date: Wed, 18 Feb 2004 12:56:41 -0800
From: "Trent Curry" <tc@no.public.email>
Subject: Re: how to cut a text file in perl
Message-Id: <c10jeq$lc8$1@news.astound.net>
Joseph wrote:
> hi i have a log file that it is increasing to big, how can i keep this
> file of
> a certain size, in other words, how can i make sure that the file is
> only 200 lines long and delete the first lines if longer. i think it
> would be easier to write this in a shell script. but i have no idea
> in perl. can anyone tell me how to print the last 200 lines of a file
> and overwrite the ssame file. thanks.
You could always make a call to
`tail -n 200 myfile.txt`
That is, if you are only doing this for a Unix based system. Other wise
boyd's code is lot more portable, and probably a better way.
--
Trent Curry
perl -e
'($s=qq/e29716770256864702379602c6275605/)=~s!([0-9a-f]{2})!pack("h2",$1
)!eg;print(reverse("$s")."\n");'
------------------------------
Date: Wed, 18 Feb 2004 23:19:30 +0100
From: "PHP2" <gp@nospm.hr>
Subject: I wish buy Perl book
Message-Id: <c10oc7$rjd$1@ls219.htnet.hr>
I wish buy Perl book tomorrow by Amazon.. I am new in Perl development..
Pls. send to me advices..
------------------------------
Date: Wed, 18 Feb 2004 22:36:46 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: I wish buy Perl book
Message-Id: <Xns9493B32B35868dkwwashere@216.168.3.30>
PHP2 <gp@nospm.hr> wrote:
> I wish buy Perl book tomorrow by Amazon.. I am new in Perl development..
>
> Pls. send to me advices..
http://learn.perl.org/
http://books.perl.org/
http://www.perl.org/ for all things Perl.
------------------------------
Date: 18 Feb 2004 14:47:13 -0800
From: gabe anzelini <usenet@c0s.org>
Subject: Re: I wish buy Perl book
Message-Id: <867jykknta.fsf@tyler.c0s.org>
"PHP2" <gp@nospm.hr> writes:
> I wish buy Perl book tomorrow by Amazon.. I am new in Perl development..
>
> Pls. send to me advices..
the camel book is always a favorite, Progarmming Perl, 3rd edition
------------------------------
Date: Wed, 18 Feb 2004 23:26:43 +0100
From: Yves PEYSSON <Yves.Peysson@wanadoo.fr>
Subject: Launch popup for file load from perl script
Message-Id: <BC59A533.6885%Yves.Peysson@wanadoo.fr>
Hi may I launch a popup window (with OS X for example) for getting file name
and path from a perl script. At present time, path and file names are
written in the script, and I would like to have the flexibility to choose
any text file in any directory.
Many thanks
------------------------------
Date: Wed, 18 Feb 2004 22:36:39 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Launch popup for file load from perl script
Message-Id: <c10pdn$ijt$2@wisteria.csv.warwick.ac.uk>
Yves PEYSSON <Yves.Peysson@wanadoo.fr> wrote:
>
> Hi may I launch a popup window (with OS X for example) for getting file name
> and path from a perl script. At present time, path and file names are
> written in the script, and I would like to have the flexibility to choose
> any text file in any directory.
While there are likely OS-specific solutions for OSX, you may want to
look at the Tk module.
Ben
--
I've seen things you people wouldn't believe: attack ships on fire off the
shoulder of Orion; I've watched C-beams glitter in the darkness near the
Tannhauser Gate. All these moments will be lost, in time, like tears in rain.
Time to die. |-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-| ben@morrow.me.uk
------------------------------
Date: Wed, 18 Feb 2004 19:09:40 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Listbox and passing entries
Message-Id: <c10d9k$a0u$8@wisteria.csv.warwick.ac.uk>
[don't top-post]
"Old School" <a@b.com> wrote:
> I'm at the mercy of my hosting company,
Then find another.
> and cgi-lib.pl should be able to do
> the same as CGI.pm in this regard with lower overhead.
Nonsense. cgi-lib.pl is completely out-of-date and unmaintained.
> @lchar = &SplitParam($form{'LCHAR'});
Are you using strictures? Why not? Don't call subs with &.
Ben
--
I've seen things you people wouldn't believe: attack ships on fire off the
shoulder of Orion; I've watched C-beams glitter in the darkness near the
Tannhauser Gate. All these moments will be lost, in time, like tears in rain.
Time to die. |-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-| ben@morrow.me.uk
------------------------------
Date: Wed, 18 Feb 2004 20:19:29 GMT
From: "Old School" <a@b.com>
Subject: Re: Listbox and passing entries
Message-Id: <lNPYb.2388$J84.1931@fe1.texas.rr.com>
Ben, I have found your post didn't have any useful data. Sorry...
"Ben Morrow" <usenet@morrow.me.uk> wrote in message
news:c10d9k$a0u$8@wisteria.csv.warwick.ac.uk...
> [don't top-post]
>
> "Old School" <a@b.com> wrote:
> > I'm at the mercy of my hosting company,
>
> Then find another.
>
> > and cgi-lib.pl should be able to do
> > the same as CGI.pm in this regard with lower overhead.
>
> Nonsense. cgi-lib.pl is completely out-of-date and unmaintained.
>
> > @lchar = &SplitParam($form{'LCHAR'});
>
> Are you using strictures? Why not? Don't call subs with &.
>
> Ben
>
> --
> I've seen things you people wouldn't believe: attack ships on fire off the
> shoulder of Orion; I've watched C-beams glitter in the darkness near the
> Tannhauser Gate. All these moments will be lost, in time, like tears in
rain.
> Time to die. |-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-|
ben@morrow.me.uk
------------------------------
Date: Wed, 18 Feb 2004 14:33:48 -0800
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: Listbox and passing entries
Message-Id: <c8p01c.v33.ln@goaway.wombat.san-francisco.ca.us>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
On 2004-02-18, Old School <a@b.com> wrote:
> I'm at the mercy of my hosting company,
You should instead install *your own* CGI.pm.
perldoc -q module library
> and cgi-lib.pl should be able to do
> the same as CGI.pm in this regard with lower overhead.
cgi-lib.pl is no longer maintained, and has some fairly serious flaws,
security and otherwise.
If you choose to ignore the advice you've been given, that's your
prerogative. But cgi-lib.pl is not the Perl standard for CGI coding any
longer, so if your hosting company can't provide CGI.pm perhaps you
should switch hosting companies. And if you're not willing to switch to
CGI.pm, then perhaps your clients should reconsider whether they want
you to continue coding for them.
[TOFU snipped, yet again. Please refrain from top-posting.]
- --keith
- --
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
iD8DBQFAM+hLhVcNCxZ5ID8RAroTAJ9CAVb2gHeGUxqJaFYTeECrDI2y9gCZAQ7h
MhA45giSXnKy/oJV/7TnJa0=
=YFpn
-----END PGP SIGNATURE-----
------------------------------
Date: Wed, 18 Feb 2004 11:38:08 +0000 (UTC)
From: kj <nospam@nospam.com>
Subject: Major bug in 5.8.2 debugger? Pager hangs
Message-Id: <c0vir0$80a$1@reader2.panix.com>
I've found what seems to me to be a huge bug in the perldb (debugger)
that comes with Perl 5.8.2. If one tries the following:
DB<5> |x $some_variable
then either the pager hangs indefinitely (one never sees the pager's
prompt after it prints the first screenful), or the pager works
fine until one hits q to exit, in which case it hangs indefinitely.
Sometimes, upon hitting q, and before the pager hangs, a message
like the following is printed out
Can't close DB::OUT
Pager `|/bin/more' failed: shell returned -1
I've seen this behavior with both more and less. IMHO, this is a
MONGO bug, but I have not seen mention of it anywhere. What's
going on?
kj
------------------------------
Date: 18 Feb 2004 12:14:34 -0800
From: tonyshirt@hotmail.com (TonyShirt)
Subject: Matching quoted strings
Message-Id: <52d54c07.0402181214.4f3d9116@posting.google.com>
After an exaustive search on google groups I decided to post. I have
a line:
"FileVersion", "1, 2, 4, 17\0"
I want to match
FileVersion
1, 2, 4, 17\0
I tried $_ =~ /"(.*?)"/; but it only matches FileVersion. How do I
go on a match the other quoted string?
------------------------------
Date: Wed, 18 Feb 2004 12:49:45 -0800
From: "Trent Curry" <tc@no.public.email>
Subject: Re: Matching quoted strings
Message-Id: <c10j1r$l6u$1@news.astound.net>
TonyShirt wrote:
> After an exaustive search on google groups I decided to post. I have
> a line:
>
> "FileVersion", "1, 2, 4, 17\0"
>
> I want to match
> FileVersion
> 1, 2, 4, 17\0
>
> I tried $_ =~ /"(.*?)"/; but it only matches FileVersion. How do I
> go on a match the other quoted string?
Is this what you were looking for?
___Code___
#!/usr/bin/perl -w
use strict;
$_ = qq|"FileVersion", "1, 2, 4, 17\0"|;
# Note that $_, being the default, is implied here.
my @matches = /"(.*?)"/g; # Note the 'g' at the end.
print '[', join("]\n[", @matches), "]\n";
___Output___
[FileVersion]
[1, 2, 4, 17]
--
Trent Curry
perl -e
'($s=qq/e29716770256864702379602c6275605/)=~s!([0-9a-f]{2})!pack("h2",$1
)!eg;print(reverse("$s")."\n");'
------------------------------
Date: Wed, 18 Feb 2004 20:37:04 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: Matching quoted strings
Message-Id: <c10ibs$576$1@news.simnet.is>
"TonyShirt" <tonyshirt@hotmail.com> wrote in message
news:52d54c07.0402181214.4f3d9116@posting.google.com...
> After an exaustive search on google groups I decided to post. I have
> a line:
>
> "FileVersion", "1, 2, 4, 17\0"
>
> I want to match
> FileVersion
> 1, 2, 4, 17\0
>
> I tried $_ =~ /"(.*?)"/; but it only matches FileVersion. How do I
> go on a match the other quoted string?
this is csv-like. if you are parsing csv you might look at CVS modules
that know how to deal with thins like quotes/linefeeds in the strings.
if you just want what you say, you might look at the g modifier
like in my ($x,$y)=/"(.*)"/g;
you might also consider my ($x,$y)=/"(.*?)","(.*?)"/ if you prefer
gnari
------------------------------
Date: 18 Feb 2004 13:19:14 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Matching quoted strings
Message-Id: <4033d6d2@news.victoria.tc.ca>
TonyShirt (tonyshirt@hotmail.com) wrote:
: After an exaustive search on google groups I decided to post. I have
: a line:
: "FileVersion", "1, 2, 4, 17\0"
: I want to match
: FileVersion
: 1, 2, 4, 17\0
: I tried $_ =~ /"(.*?)"/; but it only matches FileVersion. How do I
: go on a match the other quoted string?
That depends on what you really mean to do.
Do you wish to get the second quoted string? How do you identify the
second one? Are there two quoted string always? perhaps
/".*?".*?"(.*)"/
Is the second half always after the first comma?
/,\s*"(.*)"/
Do you actually want both (and there's always two of them), perhaps
my @all = /"(.*?)"/g
If you know the complete format then I would be tempted to parse all of
exactly what I expected or warn myself
my ($version,$numbers)
= m/^"(\w+)", "([\d, \\]+)"$/ or die "unexpected format: $_";
(All re's were untested of course.)
--
Web Work Wanted, Perl Projects Programmed, Database Development Done.
I'm looking for telecommute projects. (Paying that is, various
arrangements possible.)
------------------------------
Date: Wed, 18 Feb 2004 22:37:41 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Matching quoted strings
Message-Id: <4033E87F.4040001@rochester.rr.com>
TonyShirt wrote:
> After an exaustive search on google groups I decided to post. I have
> a line:
>
> "FileVersion", "1, 2, 4, 17\0"
>
> I want to match
> FileVersion
> 1, 2, 4, 17\0
>
> I tried $_ =~ /"(.*?)"/; but it only matches FileVersion. How do I
$-----------------------^
Try inserting a $ as the last character of the regexp. That will force
it to match a pair of quotes that terminates at the end of the string.
But while you're at it, you'd probably better also replace .*? with
something like [^"]* so that you don't match any "'s other than the ones
you intend.
> go on a match the other quoted string?
Or you could try adding the /g switch to the end and saving
your results in an array. Maybe like:
@results = $_ =~ /"(.*?)"/g;
HTH.
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: Wed, 18 Feb 2004 22:52:54 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Matching quoted strings
Message-Id: <c10qc6$j7l$1@wisteria.csv.warwick.ac.uk>
see@sig.invalid wrote:
> TonyShirt wrote:
>
> > After an exaustive search on google groups I decided to post. I have
> > a line:
> >
> > "FileVersion", "1, 2, 4, 17\0"
> >
> > I want to match
> > FileVersion
> > 1, 2, 4, 17\0
> >
> > I tried $_ =~ /"(.*?)"/; but it only matches FileVersion. How do I
>
> $-----------------------^
> Try inserting a $ as the last character of the regexp. That will force
> it to match a pair of quotes that terminates at the end of the string.
> But while you're at it, you'd probably better also replace .*? with
> something like [^"]* so that you don't match any "'s other than the ones
> you intend.
That is the point of the *? minimal matching: not to match any "s other
than those intended.
Ben
--
If you put all the prophets, | You'd have so much more reason
Mystics and saints | Than ever was born
In one room together, | Out of all of the conflicts of time.
ben@morrow.me.uk |----------------+---------------| The Levellers, 'Believers'
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 6156
***************************************