Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

subsitute s/ and match m/ failure

by kp2a (Sexton)
on Jan 22, 2009 at 14:53 UTC ( #738178=perlquestion: print w/ replies, xml ) Need Help??
kp2a has asked for the wisdom of the Perl Monks concerning the following question:

someone please point out error
#! /usr/bin/perl -w use strict; my $test = "10.100.71.67.log:MikroTik v2.9.50"; my ($ip,$model) = split /:/,$test; $model =~ s/\.log$//; die if $model =~ /log/; print "<$ip> <$model>\n"; output [john@scan log]$ ./test.pl <10.100.71.67.log> <MikroTik v2.9.50> [john@scan log]$ perl -v This is perl, v5.8.8 built for i386-linux-thread-multi

I expected ".log" to be gone or die!

Update: sorry - obvious!

20090123 Janitored by Corion: Restored original content above the update

Comment on subsitute s/ and match m/ failure
Download Code
Re: subsitute s/ and match m/ failure
by svenXY (Deacon) on Jan 22, 2009 at 15:00 UTC
    Hi,
    since you split on ':' which is after .log,
    $ip =~ s/\.log$//;
    will do the trick.
    Regards,
    svenXY
Re: subsitute s/ and match m/ failure
by b10m (Vicar) on Jan 22, 2009 at 15:23 UTC

    You're trying to strip '.log' of $model, where clearly you want to strip it of $ip.

    --
    b10m
Re: subsitute s/ and match m/ failure
by Bloodnok (Vicar) on Jan 22, 2009 at 15:29 UTC
    As clarification of what's been said elsewhere, you are testing the wrong element of the split ... to use your original code, change
    $model =~ s/\.log$//; die if $model =~ /log/;
    to read
    $ip =~ s/\.log$//; die if $ip =~ /log/;

    A user level that continues to overstate my experience :-))
Re: subsitute s/ and match m/ failure
by matze77 (Friar) on Jan 22, 2009 at 16:35 UTC

    Hmm. What is obvious, i dont understand a word. Am I too silly? What is the failure? Or is there another context i might have missed?

    Thanks MH
      The OP replaced his original question with this meaningless reply to other replies. Hopefully the Janitors restore the original content.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://738178]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2014-07-29 00:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (211 votes), past polls