in reply to split a URL ?

The syntax error is because you need to escape the backslash like so
$b = split(/$domain\//,$a);
But as was suggested, the URI module may be more useful

Update I was just pointing out the syntax error, since the solution had already been covered.

                - Ant
                - Some of my best work - (1 2 3)

Replies are listed 'Best First'.
Re: Re: need some help
by Mr. Muskrat (Canon) on May 15, 2003 at 14:43 UTC

    I have to say that $a and $b should not be used! They are package global variables used by sort. Now that I have said that:

    I see a problem... split returns a list not a scalar. Use one of the following types of statements instead:
    @list = split(/$pattern/, $expr);
    $scalar = (split(/$pattern/, $expr))[0];
    ($scalar) = split(/$pattern/, $expr);

Re: Re: need some help
by CountZero (Bishop) on May 15, 2003 at 14:57 UTC

    From the docs:

    split

    Splits a string into a list of strings and returns that list. By default, empty leading fields are preserved, and empty trailing ones are deleted.

    In scalar context, returns the number of fields found and splits into the @_ array. Use of split in scalar context is deprecated, however, because it clobbers your subroutine arguments.

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Re: Re: need some help
by Anonymous Monk on May 15, 2003 at 14:26 UTC
    i tried what u showed me , first it didn't work, and second whay would we need to escape the //, i thought perl would understand that , maybe i am wrong , i don't get an error by doing what u said , the output on the screen says "2"